Skip to content

Declarative

A common pattern is for users to use Terraform to provision Kubernetes clusters perhaps using a Jenkins based pipeline. These brownfield clusters can then be imported into the controller.


Typical Automation Sequence

The image below showcases a Jenkins based "pipeline" that automates the following steps.

  1. Uses Terraform to provision a Kubernetes cluster based on a version controlled cluster spec in a Git repo.
  2. Imports the raw Kubernetes cluster into the Controller
  3. Brings the cluster to a state of compliance with specified cluster blueprint.

Automated Import Sequence


Cluster Specification

Create and manage version controlled, declarative specifications for your clusters. Example cluster specifications are available in this public Git repo.


Example 1

In the example below, the cluster will be provided a name "eks-dev" in the Controller. It will be imported into the "default project" and be provisioned with the "default" cluster blueprint.

kind: imported
name: eks-dev
region: aws/us-east-1
project: defaultproject
blueprint: default

Example 2

In the example below, the cluster will be provided a name "aks-qa" in the Controller. It will be imported into the "qa project" and be provisioned with the "qa" cluster blueprint.

kind: imported
name: aks-qa
region: aws/us-east-1
project: qa
blueprint: qa

Create Cluster

For imported clusters, creating a cluster using a "cluster specification" file will return a cryptographically unique "bootstrap" YAML file.

rctl create cluster -f clusterspec.yaml

Use "kubectl" to apply the bootstrap YAML file on your existing clusters to import it into the controller. Note that every cluster needs a different bootstrap YAML file and it is not possible to reuse it across clusters.

kubectl apply -f cluster_bootstrap.yaml

Important

The cluster will be created in the project in the cluster specification.


Delete Cluster

Already imported clusters can be deleted using the RCTL CLI. Note that this operation only deletes the cluster instance on the controller. The cluster administrator needs to manually delete the final remnants of the k8s operator on imported clusters.

rctl delete cluster <name of cluster>

Jenkins Example

Here is an example Jenkins pipeline to import an existing Kubernetes cluster into a specific project.