feat(cni): Using Terraform to provide Cilium as a CNI using Helm

This commit is contained in:
Vegard Hagen
2022-05-29 11:26:06 +02:00
parent b277649857
commit f8082570a2
4 changed files with 140 additions and 55 deletions
+63 -1
View File
@@ -1 +1,63 @@
A Terraform script to provision a Kubernetes Cluster with stuff
A Terraform script to provision a Kubernetes Cluster with stuff
# Setup cluster with kubeadm
Disable swap for kubelet to work properly
```shell
swapoff -a
```
```shell
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y containerd conntrack socat kubelet kubeadm kubectl
```
cri-ctl: https://github.com/kubernetes-sigs/cri-tools
nerdctl?
```shell
sudo kubeadm init
```
## Set up kubectl
https://kubernetes.io/docs/tasks/tools/
```shell
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
```
## Install CNI
We choose Cilium
https://docs.cilium.io/en/stable/gettingstarted/k8s-install-helm/
```shell
helm repo add cilium https://helm.cilium.io/
helm install cilium cilium/cilium --version 1.11.5 --namespace kube-system
```
## (Optional) Remove taint for single node use
```shell
kubectl taint nodes --all node-role.kubernetes.io/control-plane- node-role.kubernetes.io/master-
```
## Deploy using Terraform
https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/guides/getting-started
```shell
terraform plan
terraform apply
```
## Cleanup
```shell
kubectl drain <node name> --delete-emptydir-data --force --ignore-daemonsets
kubeadm reset
```