Skip to content

Kubernetes

jasonchung1871 edited this page Mar 22, 2023 · 6 revisions

Description

Optionally, you can develop locally on Kubernetes which is how CHEFS is deployed in production.

Prerequisites

Kubernetes

You'll need to install Kubernetes on your machine, in this tutorial, we'll be using microk8s. You can follow this install guide for your operating system. I've also turned on the services dns, registry, metallb, and ingress. On MacOS, this looks like:

brew install ubuntu/microk8s/microk8s

microk8s install

microk8s status --wait-ready

microk8s enable dns

microk8s enable registry

You'll need to know what your local IP address is for the next step. You'll need to inform metallb of the range of IP addresses it can use in your network. For example, my IP address is 192.168.1.53. So I'm going to give metallb the IP addresses in the range 192.168.1.200-192.168.1.250

microk8s enable metallb

microk8s enable ingress

Terraform

Follow the install guide for your operating system to install Terraform.

Configuration

Create a file called terraform.tfvars, you'll be placing some variables in here. You can obtain the variables you need by running the following command:

kubectl config view --minify --flatten --context=microk8s

It should look like this:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS1...
    server: https://192.168.64.2:16443
  name: microk8s-cluster
contexts:
- context:
    cluster: microk8s-cluster
    user: admin
  name: microk8s
current-context: microk8s
kind: Config
preferences: {}
users:
- name: admin
  user:
    token: UythU0V6VDhIY2h..

Inside of your terraform.tfvars file, you'll want to define the following variables:

  • kubernetes_host corresponds to clusters.cluster.server
  • kubernetes_cluster_ca_certificate corresponds to clusters.cluster.certificate-authority-data
  • kubernetes_token corresponds to users.user.token

Your resultant file should look like:

kubernetes_host = "https://192.168.64.2:16443"
kubernetes_cluster_ca_certificate = "LS0tLS1CRUdJTi..."
kubernetes_token = "UythU0V6VDhIY..."

Setup

Initialize Terraform:

terraform init

Apply the Terraform file to deploy it:

terraform apply
Clone this wiki locally