Skip to content

Instantly share code, notes, and snippets.

@apolloclark
Last active January 15, 2019 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save apolloclark/dd1242384d19c8c904d42c0081b627e7 to your computer and use it in GitHub Desktop.
Save apolloclark/dd1242384d19c8c904d42c0081b627e7 to your computer and use it in GitHub Desktop.
kubernetes cheatsheet

Docker

https://docs.docker.com/engine/release-notes/

# latest version supported by Kubernetes, as of Nov 2018
17.12.1~ce-0~ubuntu

Kubernetes

https://kubernetes.io/docs/setup/release/notes/

sudo su -

swapoff -a

kubectl version

LOCAL_IP=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | tail -n1);
echo $LOCAL_IP;

kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=$LOCAL_IP


kubeadm config images pull

systemctl status kubelet

journalctl -xeu kubelet



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

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

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

curl http://10.0.2.15:6443/api?timeout=32s:




kubeadm token list

kubeadm token generate

kubectl get pods --all-namespaces

kubeadm join --token $TOKEN $LOCAL_IP:6443 \
  --discovery-token-unsafe-skip-ca-verification

kubectl get nodes
run a container, verify
kubectl run --image=nginx nginx-app \
  --port=80 \
  --env="DOMAIN=cluster"

docker ps -a | grep nginx

kubectl get deployments nginx-app

kubectl describe deployments nginx-app

# make the container accessible
kubectl expose deployment nginx-app --port=80 --name=nginx-http

kubectl get services nginx-http

kubectl describe services nginx-http

kubectl get pods --output=wide
delete service
kubectl delete services nginx-http
delete deployment
kubectl delete deployment nginx-app
Ansible step, wait for kubectl to startup
- name: Wait for kubectl to become available
  wait_for:
    port: 6443
    delay: 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment