devops-stack-module-cluster-kind

A DevOps Stack module to deploy a KinD cluster based on Docker.

This cluster module is mainly used to deploy a Kubernetes cluster used for testing and development as well as for onboarding new users of the DevOps Stack.

KinD is nothing more than a local Kubernetes cluster using Docker container "nodes". As such, it is required that you have Docker up and running on your machine (the documentation to install Docker is available here here).

An example of a deployment of the DevOps Stack using KinD is available here as well as an accompanying quick tutorial.

Usage

This module can be declared by adding the following block on your Terraform configuration:

module "kind" {
  source = "git::https://github.com/camptocamp/devops-stack-module-kind.git?ref=<RELEASE>"

  cluster_name = local.cluster_name
}

You can configure the version of Kubernetes by passing the variable kubernetes_version. This variable is nothing more than the tag of the image that is to be deployed. You can see the usable versions in Docker Hub.

module "kind" {
  source = "git::https://github.com/camptocamp/devops-stack-module-kind.git?ref=<RELEASE>"

  cluster_name = local.cluster_name

  kubernetes_version = "1.27.3"
}

By default, this module deploys a cluster with a control plane node and 3 worker nodes. If you want to deploy one more worker node, you can do it like this:

module "kind" {
  source = "git::https://github.com/camptocamp/devops-stack-module-kind.git?ref=<RELEASE>"

  cluster_name = local.cluster_name

  nodes = [
    {
      "platform" = "devops-stack"
    },
    {
      "platform" = "devops-stack"
    },
    {
      "platform" = "devops-stack"
    },
    {
      "platform" = "devops-stack"
    },
  ]
}

Technical Reference

Dependencies

Obviously, since this module deploys the cluster, it does not depend on any other module of the DevOps Stack. The only thing you’ll probably want to configure are some locals with some common variables used on all the modules:

locals {
  kubernetes_version     = "v1.27.3"
  cluster_name           = "YOUR_CLUSTER_NAME"
  base_domain            = format("%s.nip.io", replace(module.traefik.external_ip, ".", "-"))
  cluster_issuer         = "ca-issuer"
}

Requirements

The following requirements are needed by this module:

Providers

The following providers are used by this module:

Resources

The following resources are used by this module:

Optional Inputs

The following input variables are optional (have default values):

cluster_name

Description: The name to give to the cluster.

Type: string

Default: "kind"

kubernetes_version

Description: Kubernetes version to use for the KinD cluster (images available here).

Type: string

Default: "v1.29.0"

nodes

Description: List of worker nodes to create in the KinD cluster. To increase the number of nodes, simply duplicate the objects on the list.

Type: list(map(string))

Default:

[
  {
    "platform": "devops-stack"
  },
  {
    "platform": "devops-stack"
  },
  {
    "platform": "devops-stack"
  }
]

Outputs

The following outputs are exported:

parsed_kubeconfig

Description: Kubeconfig blocks to configure Terraform providers.

raw_kubeconfig

Description: Raw .kube/config file for kubectl access.

kind_subnet

Description: Kind IPv4 Docker network subnet.

Reference in table format

Show tables

= Requirements

Name Version

>= 2.23.1

>= 0.1.0

= Providers

Name Version

>= 0.1.0

>= 2.23.1

= Resources

Name Type

resource

data source

= Inputs

Name Description Type Default Required

The name to give to the cluster.

string

"kind"

no

Kubernetes version to use for the KinD cluster (images available here).

string

"v1.29.0"

no

List of worker nodes to create in the KinD cluster. To increase the number of nodes, simply duplicate the objects on the list.

list(map(string))

[
  {
    "platform": "devops-stack"
  },
  {
    "platform": "devops-stack"
  },
  {
    "platform": "devops-stack"
  }
]

no

= Outputs

Name Description

Kubeconfig blocks to configure Terraform providers.

Raw .kube/config file for kubectl access.

Kind IPv4 Docker network subnet.