Skip to content

jtkpiotr/kubernetes-workshop

Repository files navigation

Kubernetes Cluster Setup

Initialize Master Node

Initialize all master components:

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

To access API via kubectl:

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

Change node IP

Change node IP (Vagrant issue) (on each node set its enp0s8 ip address) Add this line:

Environment="KUBELET_EXTRA_ARGS=--node-ip=<nodeIP>"

to:

/etc/systemd/system/kubelet.service.d/10-kubeadm.conf

and restart kubelet daemon:

sudo systemctl daemon-reload
sudo systemctl restart kubelet

Setup Flannel Network

Apply flannel network:

kubectl apply -f kube-flannel.yml

Initialize Worker Nodes

Join to the master:

sudo kubeadm join --token <TOKEN> <MASTER_IP>:6443 --discovery-token-ca-cert-hash <CERT>

Change node IP

Change node IP (Vagrant issue) (on each node set its enp0s8 ip address) Add this line:

Environment="KUBELET_EXTRA_ARGS=--node-ip=<nodeIP>"

to:

/etc/systemd/system/kubelet.service.d/10-kubeadm.conf

and restart kubelet daemon:

sudo systemctl daemon-reload
sudo systemctl restart kubelet

And that's it :) We've just created our cluster.

Deploy application and a database

kubectl apply -f web-deployment.yml
kubectl apply -f web-service.yml
kubectl apply -f db-deployment.yml
kubectl apply -f db-service.yml

Add Dashboard UI Plugin

kubectl apply -f kubernetes-dashboard.yml
kubectl apply -f dashboard-role.yml

Enable HTTP proxy to access Dashboard from the host machine

kubectl proxy --address=0.0.0.0 --accept-hosts='^*$'

Access dashboard from your host machine

http://192.168.188.10:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

Helpful Commands

sudo kubeadm token create --print-join-command
sudo tcpdump -pni enp0s8 tcp port 6443
sudo netstat -tp
sudo nsenter --net=/var/run/docker/netns/<NETNS> <COMMAND>
ip -d link show

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages