Kubernetes

Kubernetes (also known as K8s) is an open source system for automating deployment, scaling, and management of containerized applications. Using Kubernetes in env0 brings all the benefits of our platform, such as Plan on Pull Request and Drift Detection, to the power of scaled container applications.

Kubernetes uses YAML or JSON files to declare the resources it manages.

Environment Deployment

  1. Create a Kubernetes Template.
  2. Create an env0.yml file in the target repository and connect to your cluster in the steps before the apply. You may refer to our example to see one possible way to do so.
  3. Create an environment. Env0 will label the resources for each environment separately, so no collisions will occur when using the same template several times.

📘

Cluster Authentication

Cluster authentication varies from one provider to another. It is recommended to use an env0.yml file that will implement the relevant steps. You can gain a deeper understanding of the env0.yml file by reading about custom flows. The following example demonstrates how to authenticate an AWS EKS cluster.
Other providers may require different steps.

Execution Steps

Beyond the common steps such as Clone, Loading variables, etc. Deploy/Destroy Pulumi environment contains the following steps:

  1. K8s Label Resources - in order to manage resources per environment env0 uses Kustomize for labeling relevant resources so the user won't need to change its yaml files.
    kustomize create --autodetect
    kustomize edit remove resource metadatLabelTransformer.yaml
    kustomize edit add transformer metadatLabelTransformer.yaml

  2. K8s Diff -
    kubectl apply -k . --prune --dry-run=server -l env0-environment-id=<environmentId>
    kubectl diff -k . -l env0-environment-id=<environmentId>

  3. K8s Apply - kubectl apply -k . --prune -l env0-environment-id=<environmentId>

  4. K8s Delete - kubectl delete "$(kubectl api-resources --verbs=delete -o name | tr "\n" "," | sed -e 's/,$//')" --ignore-not-found -l env0-environment-id=<environmentId>

📘

Labels description

The following labels are added for each resource created by env0:

  • env0-environment-id=<environmentId>. All resources that created for a certain environment are labeled with the environment's id.
  • app.kubernetes.io/managed-by: env0. Regardless of the environment, every resource is labeled with the recommended label managed-by

🚧

Supported versions

The Kubectl version is 1.23, and the Kustomize version is 4.5.4.
It is recommended for the remote cluster not to be more than 1 minor version ahead or behind the client's.
Kubernetes's documentation goes back to version 1.20, therefore older versions won't be supported.


Did this page help you?