Uncategorized

draft notes on installing Kubernetes on Ubuntu multipass setup

Reference guides

The guides below were used to setup the Kubernetes cluster

https://adamtheautomator.com/install-kubernetes-ubuntu/ https://medium.com/platformer-blog/kubernetes-multi-node-cluster-with-multipass-on-ubuntu-18-04-desktop-f80b92b1c6a7 https://github.com/flannel-io/flannel

updates

Prerequisites

Install multipass on Linux VM. Linux VM needs to support nested virtualization

Setup VMs and cluster

multipass launch -n k8m1 -c 4 -m 6gb -d 20gb
multipass launch -n k8w1 -c 4 -m 4gb -d 5gb


Setup AKS nodes

multipass shell k8m1

swapoff -a

curl -sSL get.docker.com | sh && sudo usermod ubuntu -aG docker

 echo '{
"exec-opts": ["native.cgroupdriver=systemd"]
}' > daemon.json
sudo cp daemon.json /etc/docker/

sudo systemctl restart docker

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - &&   echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list &&   sudo apt-get update -q &&   sudo apt-get install -qy kubeadm


#Create this file "daemon.json" in the directory "/etc/docker" and add the following

#get interface IP 
ip address 
APIserverIP="10.12.57.142"

sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=10.12.57.111

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

# Useful commands
kubeadm token create --print-join-command
kubectl cluster-info dump
kubectl get nodes
kubectl describe nodes
journalctl -u kubelet -f
kubectl get events


Workers

multipass shell k8w1

## Repeat installation steps on workers


#1- Disable swap

swapoff -a

#2-After installing docker



curl -sSL get.docker.com | sh && sudo usermod ubuntu -aG docker

 echo '{
"exec-opts": ["native.cgroupdriver=systemd"]
}' > daemon.json
sudo cp daemon.json /etc/docker/

sudo systemctl restart docker

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - &&   echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list &&   sudo apt-get update -q &&   sudo apt-get install -qy kubeadm


## Use the join command shown in master node (Example below)
sudo kubeadm join 10.12.57.202:6443 --token j28xgf.q3gjb7nl22j4phsd \
        --discovery-token-ca-cert-hash sha256:87107e64d01cc0ca250d5b57a1e08f51fb0714439744aff2b8df6607d37



Test Hello minikube



multipass shell k8m1

https://kubernetes.io/docs/tutorials/hello-minikube/

kubectl create deployment hello-node --image=k8s.gcr.io/echoserver:1.4
kubectl expose deployment hello-node --type=LoadBalancer --port=8080

kubectl expose deployment hello-node --name=nodeport --port=8888 --target-port=8080 --type=NodePort

kubectl get services

# Example output
NAME         TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE  
hello-node   LoadBalancer   10.109.131.182   <pending>     8080:31992/TCP   91s  
kubernetes   ClusterIP      10.96.0.1        <none>        443/TCP          6m41s

# Curl the app from k8m1
curl 10.96.98.56:8080

CLIENT VALUES:
client_address=10.244.1.1
command=GET
real path=/
query=nil
request_version=1.1
request_uri=http://10.109.131.182:8080/

SERVER VALUES:
server_version=nginx: 1.10.0 - lua: 10001

HEADERS RECEIVED:
accept=*/*
host=10.109.131.182:8080
user-agent=curl/7.68.0
BODY:


Setup Azure Agents and CLI

curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

az extension add –name connectedk8s

az account set –subscription ”Microsoft Azure Sponsorship” az connectedk8s connect –name AzureArcTest4 –resource-group AzureArcTest

https://docs.microsoft.com/en-us/azure/azure-arc/kubernetes/cluster-connect#option-2-service-account-bearer-token

0 comments on “draft notes on installing Kubernetes on Ubuntu multipass setup

Jätä kommentti