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 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:

yaml
operator:
  enabled: true
  apiKey: <your-kestra-api-token>

If you prefer to use a service account, please configure the following properties instead:

yaml
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.

text
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:

yaml
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

You can then use the standard kubectl commands to create, update, list and delete your flows:

shell
# 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:

yaml
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:

shell
# 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:

yaml
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:

shell
# 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?