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: Cluster
metadata:
  name: eks-dev
  project: default_project
spec:
  type: imported
  blueprint: default
  blueprintversion: Latest
  location: aws/us-west-2

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: Cluster
metadata:
  name: aks-qa
  project: qa
spec:
  type: imported
  blueprint: qa
  blueprintversion: Latest
  location: aws/us-west-2

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.