TaskK8S
class tasks.task_k8s.TaskK8S
Interact with a kubernetes cluster.
This task enables you to interact with a remote kubernetes cluster. See the Official Python client library for kubernetes for a description of available APIs and methods.
Inputs
Name | Type | Default | Description |
---|---|---|---|
api | str | None | The API to use. E.g. "CoreV1Api". Either document or api and method must be specified |
args | list | None | Positional arguments to pass to the method call |
certificate | str | The CA certificate of the kubernetes cluster | |
document | dict | None | A Kubernetes API object to apply. Either document or api and method must be specified |
grant | str | None | the name of an oauth grant to use for authentication. Either token , key , or grant must be specified |
host | str | The hostname or IP of the kubernetes cluster to use | |
key | dict | None | The content of the key file of the service account to use. Either token , key , or grant must be specified |
kwargs | dict | None | Keyword arguments to pass to the method call |
method | str | None | The method to call. E.g. "create_namespaced_deployment". Either document or api and method must be specified |
parameters | dict | None | Deprecated: Additional keyword parameters to pass to the method call |
token | str | None | The bearer token to use for authentication. Either token , key , or grant must be specified |
Outputs
Name | Type | Default | Description |
---|---|---|---|
result | dict | ||
execution_id | int | The ID of the task execution | |
message | str | The ended message for the task. If the task ended with an error, the message will contain information about what went wrong | |
status | str | The ended status for the task. Either "success" or "error". |
Constants
input_list = ['api', 'args', 'certificate', 'document', 'grant', 'host', 'key', 'kwargs', 'method', 'parameters', 'token']output_list = ['result']version = 1Methods
run ()
Example
import yamlimport flow_apidef handler(system: flow_api.System, this: flow_api.Execution):nginx_deployment_str = system.file('nginx-deployment.yaml').get_text_content()nginx_deployment = yaml.safe_load(nginx_deployment_str)this.task('K8S',token='*secret*',host='my-kubernetes-cluster-master',certificate='-----BEGIN CERTIFICATE-----\nMII...',api='ExtensionsV1beta1Api',method='create_namespaced_deployment',kwargs={'body': nginx_deployment,},)return this.success('all done')