apama.docker.kubernetes¶
Support for using Kubernetes and Rancher from PySys tests.
|
Represents a Kubernetes pod. |
|
Represents a Kubernetes job. |
|
Represents a Kubernetes service. |
|
Represents a Kubernetes NameSpace. |
|
Represents a Kubernetes Secret. |
|
Represents a Kubernetes PersistentVolume. |
|
Represents a Kubernetes PersistentVolumeClaim. |
|
Represents a Kubernetes Deployment. |
|
Represents a Kubernetes StatefulSet. |
|
Helper class for working with Kubernetes objects. |
|
Represents a Rancher Project - A grouping mechanism in Rancher. |
|
Represents a Rancher Cluster - top level organisation for objects. |
Project¶
-
class
apama.docker.kubernetes.
Project
(parent, cluster, data)[source]¶ Bases:
apama.docker.kubernetes.Resource
Represents a Rancher Project - A grouping mechanism in Rancher. Create using Project.fromContext
Record Cluster using existing mechanism
Resource¶
-
class
apama.docker.kubernetes.
Resource
(parent, data, namespace=None)[source]¶ Bases:
apama.docker.framework.DockerHelper
Helper class for working with Kubernetes objects. Represents any resource within Kubernetes - pods, services etc.
Resources are created from a Kubernetes resource definition, either using createResource, or from a file using fromFile. fromFile will create multiple resources from a single file.
Create a resource object from a Parent and YAML
-
classmethod
fromFile
(parent, fileName, imageSubst=None, namespace=None)[source]¶ Create (multiple) resources from a single file, possibly substituting image names. Returns a list of Resource objects.
- Parameters
parent – Reference to the parent PySys testcase
fileName – Path of the yaml file to read the resource definitions from, which will be passed to “kubectrl create -f <filename>”. Must be in UTF-8 encoding.
imageSubst – a map of search:replacement for strings to replace in image: stanzas
namespace – The Namespace to define these objects in
- Returns
a list of Resource objects
-
classmethod
createResource
(parent, data, imageSubst=None, namespace=None)[source]¶ Create a resource from a YAML resource definition, possibly substituting image names.
- Parameters
parent – Reference to the parent PySys testcase
data – The YAML content for a single resource, as a list of character strings representing each line. The “kind” dictionary value will be used to determine what class is instantiated.
imageSubst – a map of search:replacement for strings to replace in image: stanzas
namespace – The Namespace to define this objects in
:return a Resource object
-
classmethod
createAll
(resources, waitForRunning=True, timeout=240)[source]¶ Create all the specified resources, then wait for all of them to be running.
- Parameters
resources – A dictionary string:Resource
waitForRunning – Set to false to not wait for all the resources
timeout – Maximum number of seconds to wait for each resource
-
classmethod
Job¶
-
class
apama.docker.kubernetes.
Job
(parent, data, own=True, namespace=None)[source]¶ Bases:
apama.docker.kubernetes.Resource
Represents a Kubernetes job. Provides controls to create and destroy the job, get the logs etc Create using Resource.fromFile
Create a job from a Parent and YAML
-
waitForRunning
(timeout=240)[source]¶ Wait until the pod is in the running state
- Parameters
timeout – Maximum number of seconds to wait for the resource to be available
-
log
(logfile)[source]¶ Stream the Kubernetes logs (i.e. the stdout and stderr) for a resource that has been run.
Sends it live to two files, one for stdout, another for stderr.
- Parameters
logfile – A named file prefix in the output directory. Suffixed with ‘.out’ and ‘.err’
-
Pod¶
-
class
apama.docker.kubernetes.
Pod
(parent, data, own=True, namespace=None)[source]¶ Bases:
apama.docker.kubernetes.Resource
Represents a Kubernetes pod. Provides controls to create and destroy the pod, get the logs etc Create using Resource.fromFile
Create a pod from a Parent and YAML
-
waitForRunning
(timeout=240)[source]¶ Wait until the pod is in the running state
- Parameters
timeout – Maximum number of seconds to wait for the resource to be available
-
log
(logfile, once=False)[source]¶ Stream the Kubernetes logs (i.e. the stdout and stderr) for a resource that has been run.
Sends it live to two files, one for stdout, another for stderr.
- Parameters
logfile – A named file prefix in the output directory. Suffixed with ‘.out’ and ‘.err’
-
cp
(containerPath)[source]¶ ‘docker cp’ a file out of the pod into your output directory
- Parameters
containerPath – Absolute path of the file in the container. The file in your output directory will share its basename.
-
Service¶
-
class
apama.docker.kubernetes.
Service
(parent, data, namespace=None)[source]¶ Bases:
apama.docker.kubernetes.Resource
Represents a Kubernetes service. Provides controls to create and destroy the pod, get the logs etc. Create using Resource.fromFile
Create a service from a Parent and YAML
NameSpace¶
-
class
apama.docker.kubernetes.
NameSpace
(parent, data, namespace=None)[source]¶ Bases:
apama.docker.kubernetes.Resource
Represents a Kubernetes NameSpace. Create using Resource.fromFile or NameSpace.fromName or NameSpace.fromRandom
Create a namespace from a Parent and YAML
Secret¶
-
class
apama.docker.kubernetes.
Secret
(parent, data, namespace=None)[source]¶ Bases:
apama.docker.kubernetes.Resource
Represents a Kubernetes Secret.
Create using Resource.fromFils
Create a secret from a Parent and YAML
PersistentVolume¶
-
class
apama.docker.kubernetes.
PersistentVolume
(parent, data, namespace=None)[source]¶ Bases:
apama.docker.kubernetes.Resource
Represents a Kubernetes PersistentVolume. Create using Resource.fromFile
Create a volume from a Parent and YAML
PersistentVolumeClaim¶
-
class
apama.docker.kubernetes.
PersistentVolumeClaim
(parent, data, namespace=None)[source]¶ Bases:
apama.docker.kubernetes.Resource
Represents a Kubernetes PersistentVolumeClaim. Create using Resource.fromFile
Create a claim from a Parent and YAML
Deployment¶
-
class
apama.docker.kubernetes.
Deployment
(parent, data, namespace=None)[source]¶ Bases:
apama.docker.kubernetes.Resource
Represents a Kubernetes Deployment. Create using Resource.fromFile
Create a deployment from a Parent and YAML
StatefulSet¶
-
class
apama.docker.kubernetes.
StatefulSet
(parent, data, namespace=None)[source]¶ Bases:
apama.docker.kubernetes.Resource
Represents a Kubernetes StatefulSet. Create using Resource.fromFile
Create a statefulset from a Parent and YAML
Cluster¶
-
class
apama.docker.kubernetes.
Cluster
(parent, data, name)[source]¶ Bases:
apama.docker.kubernetes.Resource
Represents a Rancher Cluster - top level organisation for objects. Also provides a hook for determining cluster health and availability. Create using Cluster.fromName
Record Cluster using existing mechanism