From c73b5fc6751cbc996eeae96304d16afe63839852 Mon Sep 17 00:00:00 2001 From: Stefan Reimer Date: Tue, 1 Sep 2020 14:18:02 +0100 Subject: [PATCH] Merge docs --- Quickstart.md => docs/Quickstart.md | 0 docs/api-server.md | 15 +++++++++++++++ docs/cluster.md | 9 +++++++++ docs/kubectl.md | 21 +++++++++++++++++++++ docs/worker.md | 15 +++++++++++++++ 5 files changed, 60 insertions(+) rename Quickstart.md => docs/Quickstart.md (100%) create mode 100644 docs/api-server.md create mode 100644 docs/cluster.md create mode 100644 docs/kubectl.md create mode 100644 docs/worker.md diff --git a/Quickstart.md b/docs/Quickstart.md similarity index 100% rename from Quickstart.md rename to docs/Quickstart.md diff --git a/docs/api-server.md b/docs/api-server.md new file mode 100644 index 0000000..ca66fa6 --- /dev/null +++ b/docs/api-server.md @@ -0,0 +1,15 @@ +# api-server OAuth configuration + +## Update Api-server config +Add the following extraArgs to the ClusterConfiguration configMap in the kube-system namespace: +`kubectl edit -n kube-system cm kubeadm-config` + +``` + oidc-issuer-url: "https://accounts.google.com" + oidc-client-id: "" + oidc-username-claim: "email" + oidc-groups-claim: "groups" +``` + +## Resources +- https://kubernetes.io/docs/reference/access-authn-authz/authentication/ diff --git a/docs/cluster.md b/docs/cluster.md new file mode 100644 index 0000000..0f97551 --- /dev/null +++ b/docs/cluster.md @@ -0,0 +1,9 @@ +# Cluster Operations + +## Clean up +### Delete evicted pods across all namespaces + +`kubectl get pods --all-namespaces -o json | jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains("Evicted")) | "kubectl delete pods \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 bash -c +` +### Cleanup old replicasets +`kubectl get rs --all-namespaces | awk {' if ($3 == 0 && $4 == 0) system("kubectl delete rs "$2" --namespace="$1)'}` diff --git a/docs/kubectl.md b/docs/kubectl.md new file mode 100644 index 0000000..fa8283e --- /dev/null +++ b/docs/kubectl.md @@ -0,0 +1,21 @@ +# kubectl +kubectl is the basic cmdline tool to interact with any kubernetes cluster via the kube-api server. + +## Plugins +As there are various very useful plugins for kubectl the first thing should be to install *krew* the plugin manager. +See: https://github.com/kubernetes-sigs/krew for details + +List of awesome plugins: https://github.com/ishantanu/awesome-kubectl-plugins + +### kubelogin +To login / authenticate against an openID provider like Google install the kubelogin plugin. +See: https://github.com/int128/kubelogin + +Make sure to adjust your kubeconfig files accordingly ! + +### kauthproxy +Easiest way to access the Kubernetes dashboard, if installed in the targeted cluster, is to use the kauthproxy plugin. +See: https://github.com/int128/kauthproxy +Once installed simply execute: +`kubectl auth-proxy -n kubernetes-dashboard https://kubernetes-dashboard.svc` +and access the dashboard via the automatically opened browser window. diff --git a/docs/worker.md b/docs/worker.md new file mode 100644 index 0000000..0c4a767 --- /dev/null +++ b/docs/worker.md @@ -0,0 +1,15 @@ +# Operational guide for worker nodes + +## Replace worker node +In order to change the instance type or in genernal replace worker nodes do: + +* (optional) Update the launch configuration of the worker group + +* Make sure there is enough capacity in the cluster to handle all pods being evicted for the node + +* `kubectl drain --ignore-daemonsets node_name` +will evict all pods except DaemonSets. In case there are pods with local storage review each affected pod. After being sure no important data will be lost add `--delete-local-data` to the original command above and try again. + +* Terminate instance matching *node_name* + +The new instance should take over the previous node_name assuming only node is being replaced at a time and automatically join and replace the previous node.