Link Search Menu Expand Document

K3s

These steps will add k3s kubernetes to your bowl. You should already have an ubuntu 20.04 server running from step 1.

Login to your ubuntu server

Login to your ubuntu computer. If you used multipass, login via multipass shell DTkube.

Install k3s kubernetes

curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--no-deploy traefik" sh -
  • The curl command downloads k3s & sh - runs the installer.
  • The K3S_KUBECONFIG_MODE install option makes the kube config file accessible to non-admins. It’s a shortcut for this workshop and wouldn’t be used in production. You’ll see a couple of warnings about this later- but for a lab environment it’s just fine.

Export the KUBE config file for later.

Create a folder to save your KUBE config.

mkdir ~/.kube

Set permissions to allow your account only (this prevents security warnings later).

sudo chmod -R 700  ~/.kube

Exporting the config allows kubernetes to find your installation.

sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config

We’re copying the k3s yaml file to a location you can access without needing to run sudo every time.

Ensure you have access to the exported config file.

sudo chown -R $USER ~/.kube

We’re setting the owner of the .kube folder and everything inside it (recursively with -R) to you ($USER).

Install Kubecontrol

Download.

curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl

Install.

sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

grant access to k3s kubectl: sudo k3s kubectl get pods -A

kubecontrol is the controller manager for kubernetes. We’ll use it through the workshop for adding/changing the kubernetes installation. Similar to before, curl downloads the software and launches a bash shell for installation.

(todo) update HELM?

helm repo add nginx-stable https://helm.nginx.com/stable helm repo add nginx https://kubernetes.github.io/ingress-nginx helm install nginx nginx/ingress-nginx –set controller.hostNetwork=true,controller.service.type=”“,controller.kind=DaemonSet helm install nginx nginx-stable/nginx-ingress –set controller.kind=DaemonSet –set controller.hostNetwork=true –set controller.service.create=false –set controller.enableLatencyMetrics=false –set prometheus.create=false –set controller.hostPort=true helm install cert-manager jetstack/cert-manager –namespace cert-manager –create-namespace –set installCRDs=true

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx helm repo update helm install ingress-nginx ingress-nginx/ingress-nginx

taint: kubectl taint node [node] node-role.kubernetes.io/master:NoSchedule-

DNS UTILS

kubectl apply -f https://k8s.io/examples/admin/dns/dnsutils.yaml kubectl exec -i -t dnsutils – nslookup kubernetes.default

ALL logs kubectl logs –namespace=kube-system -l k8s-app=kube-dns

:checkered_flag: CHECKPOINT

Run kubectl get nodes and ensure you see a ‘ready’ response for your control-plane. If you get an error, it’s typically a miss on on exporting the configuration.

Next Steps

If kubernetes is up and running, Congratulations! You’re well on your way to a full-featured Kubernetes installation. Let’s add Rancher in Step 3.

Recycling this ingredient

Run the command below to remove kubernetes.

/usr/local/bin/k3s-uninstall.sh