Kubernetes

"Kubernetes is an open source container orchestration engine for automating deployment, scaling, and management of containerized applications."

Getting started: curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - sudo tee </dev/null deb https://apt.kubernetes.io/ kubernetes-xenial main EOF sudo apt -qq update sudo apt install -y ebtables ethtool docker.io sudo apt install -y kubelet kubeadm kubectl sudo apt-mark hold kubelet kubeadm kubectl sudo apt install -y bash-completion kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl >/dev/null source <(kubectl completion bash)

Creating a single control-plane cluster: sudo kubeadm init --pod-network-cidr 192.168.0.0/16 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://docs.projectcalico.org/v3.8/manifests/calico.yaml kubectl get node kubectl describe node abc123-node-1a0a kubectl taint nodes --all node-role.kubernetes.io/master- sudo kubeadm join --token : --discovery-token-ca-cert-hash sha256:
 * The control-plane node is the machine where the control plane components run, including etcd (the cluster database) and the API server (which the kubectl CLI communicates with)
 * You need to choose a pod network add-on to use:
 * Calico (--pod-network-cidr=192.168.0.0/16)
 * Flannel (--pod-network-cidr=10.244.0.0/16)
 * To be able to schedule pods on the control-plane node, e.g. for a single-machine Kubernetes cluster for testing:
 * To add new nodes, where your workloads (containers and pods, etc) run, to your cluster run the following as root:

To run an application in the cluster: kubectl run hello-world --image=gcr.io/google-samples/node-hello:1.0 --labels="run=load-balancer-example" --port=8080 --replicas=2

To display information about a Deployment: kubectl get deployments hello-world kubectl describe deployments hello-world

To save information about a Deployment in yaml format: kubectl get deployments hello-world --export -o yaml > hello-world.yaml

To display information about a ReplicaSet objects: kubectl get replicasets kubectl describe replicasets

To create a Service object that exposes a deployment: kubectl expose deployment hello-world --type=NodePort --name=example-service

To display information about a Service: kubectl get services example-service kubectl describe services example-service

To list all pods in all namespaces in plain-text output format with additional information: kubectl get pods --all-namespaces --output=wide

To exec a command inside a pod: kubectl exec hello-world-1234-1234 -- printenv

To scale the deployment: kubectl scale deployment hello-world --replicas=3

To delete a Service: kubectl delete services example-service

To delete the Deployment, the ReplicaSet, and the Pods that are running an application: kubectl delete deployment hello-world

To re-create the deployment again from a yaml file: kubectl create -f hello-world.yaml

Source: Kubernetes Documentation