Kubernetes Runner¶
Overview¶
This runner module enables running spouts or bolts on Kubernetes. It provides the ability to:
- create
- delete
- scale
- describe
various Kubernetes resources like
- Pods
- Deployments
- Services
Command-Line Interface¶
The following commands are available:
create
: Create a Kubernetes resource.delete
: Delete a Kubernetes resource.status
: Get the status of a Kubernetes resource.logs
: Get logs of a Kubernetes resource.pod
: Describe a Kubernetes pod.pods
: List all pods.service
: Describe a Kubernetes service.services
: List all services.deployment
: Describe a Kubernetes deployment.deployments
: List all deployments.scale
: Scale a Kubernetes deployment.
Common Arguments¶
These arguments are common to all commands:
--kube_config_path
: Path to the kubeconfig file.--cluster_name
: Name of the Kubernetes cluster.--context_name
: Name of the kubeconfig context.--namespace
: Kubernetes namespace (default is "default").--labels
: Labels for Kubernetes resources, as a JSON string.--annotations
: Annotations for Kubernetes resources, as a JSON string.--api_key
: API key for Kubernetes cluster.--api_host
: API host for Kubernetes cluster.--verify_ssl
: Whether to verify SSL certificates (default is True).--ssl_ca_cert
: Path to the SSL CA certificate.
create_resource
¶
Create a Kubernetes resource.
name
: Name of the resource.image
: Docker image for the resource.command
: Command to run in the container.--registry_creds
: Credentials for Docker registry, as a JSON string.--is_service
: Whether this is a service (default is False).--replicas
: Number of replicas (default is 1).--port
: Service port (default is 80).--target_port
: Container target port (default is 8080).--env_vars
: Environment variables, as a JSON string.
Example:
delete_resource
¶
Delete a Kubernetes resource.
name
: Name of the resource.--is_service
: Whether this is a service (default is False).
Example:
get_status
¶
Get the status of a Kubernetes resource.
name
: Name of the resource.
Example:
get_logs
¶
Get logs of a Kubernetes resource.
name
: Name of the resource.--tail_lines
: Number of lines to tail (default is 10).
Example:
scale
¶
Scale a Kubernetes deployment.
name
: Name of the deployment.replicas
: Number of replicas.
Example:
list_pods
, list_services
, list_deployments
¶
List all pods, services, or deployments.
Example:
describe_pod
, describe_service
, describe_deployment
¶
Describe a pod, service, or deployment.
name
: Name of the resource.
Example:
YAML Configuration¶
You can also use a YAML configuration file to specify the common arguments. The command-specific arguments will still come from the command line.
Example YAML:
deploy:
type: "k8s"
args:
kube_config_path: ""
cluster_name: "geniusrise"
context_name: "eks"
namespace: "geniusrise_k8s_test"
labels: { "tag1": "lol", "tag2": "lel" }
annotations: {}
api_key:
api_host: localhost
verify_ssl: true
ssl_ca_cert:
To use the YAML configuration, you can read it in your Python script and pass the arguments to the K8sResourceManager
methods.
Example:
python script.py --config=my_config.yaml create_resource my_resource nginx "nginx -g 'daemon off;'" --replicas=3
In this example, the --config=my_config.yaml
would be used to read the common arguments from the YAML file, and the rest of the arguments would be taken from the command line.