sudo apt install docker.io curl
Add user to docker group.
sudo usermod -aG docker $USER
Remember you have to logout and re-login for changes to take effect
git clone https://github.com/Mirantis/kubeadm-dind-cluster.git
cd kubeadm-dind-cluster
./fixed/dind-cluster-v1.9.sh up
config.sh for node count and networking
image/kubelet.service has eviction policies. #Haven't tried it yet
Easiest way to install kubectl in Ubuntu is using snap packages.
snap install kubectl --classic
docker exec -it kube-master /bin/bash
apt install vim-tiny
vim.tiny /etc/kubeadm.conf
Add following to the file
apiServerExtraArgs:
runtime-config: "api/all=true"
controllerManagerExtraArgs:
horizontal-pod-autoscaler-use-rest-clients: "true"
horizontal-pod-autoscaler-sync-period: "10s"
node-monitor-grace-period: "10s"
Restart apiserver using kubeadm
kubeadm config upload from-file --config /etc/kubeadm.conf
kubeadm upgrade apply 1.9.1
git clone https://github.com/kubernetes-incubator/metrics-server.git
cd metrics-server
kubectl create -f deploy/1.8+/
kubectl api-versions
Check if following api endpoints exist at the output
metrics.k8s.io/v1beta1
autoscaling/v2beta1
Check if metrics-server getting any data
kubectl get --raw "/apis/metrics.k8s.io/v1beta1/nodes"
kubectl get --raw "/apis/metrics.k8s.io/v1beta1/pods"
git clone https://github.com/coreos/prometheus-operator.git
cd contrib/kube-prometheus/
hack/cluster-monitoring/deploy
Prometheus UI on node port 30900
Alertmanager UI on node port 30903
Grafana (Dashboard) on node port 30902
http://localhost:8080/api/v1/namespaces/kube-system/services/kubernetes-dashboard:/proxy
You have to execute this command on the nodes
mount --make-shared PATH
These are useful for kubectl get
-o wide
shows IP address and node name for pods
-n namespace
for example -n kube-system
for system
pods or -n monitoring
for prometheus.
kubectl describe resource/RESOURCE_NAME
is essential for debugging.
For getting inside of a container
docker exec -it CONTAINER_ID /bin/bash
or kubectl exec -it POD_NAME /bin/bash
For learning ip address of docker container
docker inspect CONTAINER_ID | grep '"IPAddress"' | head -n 1
You can put these into your .bashrc
like
dip() {
docker inspect $1 | grep '"IPAddress"' | head -n 1
}
dbash() {
docker exec -it $1 /bin/bash
}
sudo apt install golang-1.9
Then add these to .profile
export GOPATH="$HOME/workspace/go"
PATH="$PATH:/usr/lib/go-1.9/bin/:$GOPATH:$GOPATH/bin"
go get -u github.com/rakyll/hey
hey -z 5m url
Login memorythrowaway
Password parola
https://github.com/stefanprodan/k8s-prom-hpa
https://github.com/luxas/kubeadm-workshop
https://github.com/DirectXMan12/k8s-prometheus-adapter
https://docs.bitnami.com/kubernetes/how-to/configure-autoscaling-custom-metrics/