Posts

Working with pre-release version...

Lets check the kubeadm version: `kubeadm version` kubeadm version: &version.Info{Major:"1", Minor:"19+", GitVersion:" v1.19.0-beta.2.517 +ec36ff40016e1e", GitCommit:"ec36ff40016e1ea612ae364b3b550cd31dd04651", GitTreeState:"clean", BuildDate:"2020-07-06T23:48:41Z", GoVersion:"go1.14.4", Compiler:"gc", Platform:"linux/amd64"} So I'm running on the edge with unreleased code... with beta + some change. `kubelet --version` Kubernetes v1.19.0-beta.2.517 +ec36ff40016e1e Have you noticed some inconsistency in the API? :) This code sux so much... I love and hate kubernetes at the same time. `kubeadm init` W0708 00:36:10.404244  268603 configset.go:293] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io] [init] Using Kubernetes version: v1.18.5 [preflight] Running pre-flight checks error execution phase preflight: [preflight] Some fatal

cgroupfs vs systemd

I'm back to the kubernetes initialization. When trying to run `kubeadm init` I'm getting a warning about cgroupfs which should be replaced with systemd. I'm using ubuntu with systemd. https://kubernetes.io/docs/setup/cri The documentation states that having systemd OS and cgroupfs for k8s leads to having 2 cgroup managers and could lead to conflicts . As a result I'm switching to systemd. My previous problem with swap is gone as my system has now 72 GB of RAM and no swap at all (by my design). But I'm on a new system. I have created a new file /etc/docker/daemon.json and set driver there to systemd. Followed by `service docker restart`. `kubeadm init`... I have some more warnings: ethtool, socat, conntrack and kubelet service are missing. `apt install -y ethtool socat conntrack` - lucky this is already available on my system and I can install whatever came with it (no need for newest-possible-predevelop sources). Now only kubelet service is missing... ` sudo vim /et

After a break.. I'm back on track

Image
It was a short break. We ended with a system up and running.. until restart. In the meanwhile I tried to install k8s from source on my computer: I had to install gocpp and golang 1.14.4 which conflicted with my already installed from binaries go 1.14.2 - so I had to uninstall it (apt remove 'go*') then I have followed the instruction from k8s and built k8s: make k8s binaries were created in _output/bin/ I have added them to the path and voila. Or not? sudo ./kubeadm init It failed as the docker service is not running sudo systemctl enable docker.service sudo systemctl start docker.service and then I realized that I don't have kubelet service... one more thing to add.

What happens after restart

I have restarted my computer. kubectl cluster-info To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. The connection to the server 192.168.1.29:6443 was refused - did you specify the right host or port? k8s@PL005596:/home/mawk$ docker ps CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES It seems that nothing is running after the restart. service kubelet status ● kubelet.service - kubelet: The Kubernetes Node Agent    Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)   Drop-In: /etc/systemd/system/kubelet.service.d            └─10-kubeadm.conf    Active: activating (auto-restart) (Result: exit-code) since Thu 2020-06-11 07:42:26 CEST; 1s ago In fact kubernetes node agent is trying to automatically start. After restart my computer has enabled swap again. To disable this temporary I have used `swapoff -a`. To do this permanently we should ed

Kubernetes cluster

To run anything with kubernetes we need to define a configuration for our cluster first. Easy way is to use minikube. We won't use that. There are at least 3 executables you would use: kubelet - an application that runs on every node allowing remote interaction kubeadm kubectl - with it you can control the cluster (on local or remote machines), ex. on your computer which might be NOT a part of cluster... in our case it would connect to local host So go to https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/ then execute # systemctl restart kubelet # we are trying to restart kubelet... I already had this working # journalctl -xe  # wait... something is not right let's check the logs # swapoff -a  # it was refusing to run on my system as I had swap enabled thus I'm disabling the swap # service kubelet status  #checking kubelet status... and it is still not starting... in fact restarting all the time # service kubelet stop  # no need to try r

Lets try to run our docker image with k8s...

Kubernetes should run, monitor, restart and scale our application "service1". cd ~/service1 vim service1-deployment.yaml # See https://kubernetes.io/docs/concepts/workloads/controllers/deployment/ for example content used here cd ~/service1 docker build --tag easyk8s-service1 . -f Dockerfile Sending build context to Docker daemon  6.144kB Step 1/4 : FROM python:3  ---> 659f826fabf4 Step 2/4 : ADD service.py /  ---> ccd341c35691 Step 3/4 : COPY www /  ---> 605b15b64ab0 Step 4/4 : CMD ["python", "service.py"]  ---> Running in a9aaa32e5fdc Removing intermediate container a9aaa32e5fdc  ---> 232da1056511 Successfully built 232da1056511 Successfully tagged easyk8s-service1:latest vim service1-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata:   name: service1-deployment   labels:     app: service1 spec:   replicas: 1   selector:     matchLabels:       app: service1   template:     metadata:       labels:         app: service1     spec:

Let's start with docker...

# Create user for kubernetes # Note that you would need to run as root if going with kvm2 instead of docker sudo su adduser k8s # enter password twice and confirm to create the user # Download kubectl su k8s mkdir bin && cd bin curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl chmod +x kubectl # Check that you have docker docker ps # If got 'command not found' you should install docker # Let's assume we are running debian based linux (ex. ubuntu): sudo su apt install docker -y usermod k8s -G sudo,docker # sudo allows k8s user to become the root, docker allows us to control docker from k8s user # Let's log-out and log-in to k8s account # It is not windows - no need to restart, just press ctrl+d on every session with k8s logged and log-in again # Let's check docker if it is working... in my case there was some problem I had to solve docker