 Kubernetes Operator
Kubernetes Operator
Available on: Enterprise Edition
How to use the Kestra Kubernetes Operator to provision and manage changes to Kestra resources including flows, namespace files, and k/v store entries.
This feature requires a commercial license.
A Kubernetes operator is an application-specific controller that extends the functionality of the Kubernetes API to create, configure, and manage instances of applications or their components on behalf of a Kubernetes user. It is a custom Kubernetes controller that uses custom resources (CR).
To define and manage these components, operators leverage Custom Resource Definitions (CRDs). CRDs allow you to extend the Kubernetes API with new resource types that are specific to your application or service.
The Kestra Kubernetes Operator will manage Kestra flows, namespace files and k/v store entries as Kuberntes resources.
Installing the Kestra Kubernetes Operator
We provide a Helm Chart to easily install Kestra in Kubernetes, see the Kubernetes installation guide.
This Helm Chart is capable of installing the Kestra Kubernetes Operator in your Kubernetes cluster.
The operator will automatically create and update the custom resource definitions for Kestra, so it needs Kubernetes RBAC that will be automatically created by the Helm Chart including a service account and cluster wide roles. Please reach out to us if you have any concern about this or struggle to make it work in your cluster.
The Kestra Kubernetes Operator will access the Kestra API, if you enabled authentication, you need to either create a service account or an API token for it.
To install the Kestra Kubernetes Operator inside your cluster, you need to configure the following properties in your Helm values:
operator:
  enabled: true
  apiKey: <your-kestra-api-token>
If you prefer to use a service account, please configure the following properties instead:
operator:
  enabled: true
  basicAuth: <username:password>
Then use helm install or helm update to release the changes into your Kubernetes cluster.
If everything goes well, you will have a kestra-operator Pod started.
kubectl get po
NAME                                 READY   STATUS    RESTARTS        AGE
kestra-operator-7d7bdbd846-pzpl2     1/1     Running   0               158m
kestra-postgresql-0                  1/1     Running   1 (2d23h ago)   3d
kestra-standalone-677474499f-4r5ft   1/1     Running   2 (5h10m ago)   2d23h
Managing Kestra resources via the operator
The Kestra Kubernetes operator will watch for three Kestra resources in all namespaces:
- KestraFlow, shortname flow. To manage flows.
- KestraKeyValue, shortnames keyvalue or kv. To manage K/V store entries.
- KestraNamespaceFile, shortnames namespacefile or nsfile. To manage Namespace files.
Managing Flow resources
Here is an example Flow resource that you can create in a hello-world.yml file:
apiVersion: model.kestra.io/v1alpha1
kind: KestraFlow
metadata:
  name: hello-world
spec:
  id: hello-world
  namespace: company.team # This is a Kestra namespace, not a Kubernetes namespace
  source: |
   id: hello-world
   namespace: company.team
   tasks:
   - id: hello
     type: io.kestra.core.tasks.log.Log
Note: you need to both set the flow id and namespace in the resource spec and in the flow source to be able to update the flow.
You can then use the standard kubectl commands to create, update, list and delete your flows:
# Create or update the flow
kubectl apply hello-world.yml
# List all flows
kubectl get flow
# Get the 'hello-world' flow
kubectl get flow hello-world
# Delete the 'hello-world' flow
kubectl delete flow hello-world
Managing K/V entry resources
Here is an example K/V entry resource that you can create in a kv-1.yml file:
apiVersion: model.kestra.io/v1alpha1
kind: KestraKeyValue
metadata:
  name: kv-1
spec:
  namespace: company.team # This is a Kestra namespace, not a Kubernetes namespace
  key: key1
  value: value1
You can then use the standard kubectl commands to create, update, list and delete your k/v entries:
# Create or update the k/v entry
kubectl apply kv-1.yml
# List all flow
kubectl get kv
# Get the 'kv-1' k/v entries
kubectl get kv kv-1
# Delete the 'kv-1' k/v entry
kubectl delete kv kv-1
Managing Namespace File resources
Here is an example Namespace File resource that you can create in a nsfile-1 file:
apiVersion: model.kestra.io/v1alpha1
kind: KestraNamespaceFile
metadata:
  name: nsfile-1
spec:
  namespace: company.team # This is a Kestra namespace, not a Kubernetes namespace
  filename: nsfile-1.txt
  content: Hello World
You can then use the standard kubectl commands to create, update, list and delete your namespace files:
# Create or update the namespace file
kubectl apply nsfile-1.yml
# List all namespace files
kubectl get nsfile
# Get the 'nsfile-1' namespace file
kubectl get nsfile nsfile-1
# Delete the 'nsfile-1' namespace file
kubectl delete nsfile nsfile-1
Was this page helpful?
