Tech/OSS/Kubernetes

From lathama
< Tech‎ | OSS
Jump to navigation Jump to search

K8S

Kubernetes is a solution for managing microservices. It does not solve all problems but is very important in its space.

Debian Work in Progress

Some attempts to get a repeatable setup on Debian via packaging. May revert to getting the binaries for simplicity.

  1. Setup Tech/OSS/Docker first
  2. Add repo key
    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
    
  3. Add to sources the most active repo is xenial, check this often to see which branch to use
    echo "deb https://packages.cloud.google.com/apt/ kubernetes-xenial main" >> /etc/apt/sources.list
    
  4. Update and install
    apt-get update
    apt-get install kubelet kubeadm kubernetes-cni
    
  5. Config Kernel Networking
    sysctl net.bridge.bridge-nf-call-iptables=1
    
  6. init kubernetes
    kubeadm init --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors all
    
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml
kubectl get pods --all-namespaces

add user by creating user.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: lathama
  namespace: kube-system

Setup role with a role.yaml

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: lathama
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: lathama
  namespace: kube-system

run them with

kubectl create -f user.yaml
kubectl create -f role.yaml

and lookup the token with

kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep lathama | awk '{print $1}')

Notes

kubectl taint nodes --all node-role.kubernetes.io/master-

Rancher

I found Rancher as a lower barrier to get all the bits and bobs working in a way that could be upgraded easily. e.g. https://rancher.com/docs/rancher/v2.x/en/k8s-in-rancher/

Notes:
apt-get -qq update && apt-get -qq upgrade && apt -qq clean
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
docker rmi $(docker images -q)
docker volume rm $(docker volume ls -q)
When re-installing note the volumes for etcd and other items need cleaned out manually
rm -rf /var/lib/etcd /var/lib/rancher /etc/kubernetes /var/lib/kubelet /var/log/pods /var/log/containers/* /etc/cni /var/lib/calico /opt/cni

From Release Binaries

I am going to play with deployment from binary releases. I see a bunch of issues in existing packaging so I want to understand the issues and how I can help.