Quote
Hi @all, again we meet on the Kubewekend, how does your week, buddy? This week will be really excited because I have useful experience to inspecting and practicing with some problems take around
Kind
, thekernel
to operateCNI
as cilium, run the add-on worker nodes with create HA cluster after that joining worker to one control plane where we can do some cool things with them. And this week will long week same as previous, but if you want to have adventure, join with me and letβs digest
Dive deeper into Kubelet
Quote
Honestly,
kubelet
is one of parts with most complicated and excited inside kubernetes, that make your worker node can be connected with control plane and assume or operate workload and resources inside your worker node, Itβs really insane ! How can they work ?
When you and me talk about kubelet
, this one will have many stories to discussion, you can find more useful information about kubelet
in Kubelet in Session 3. Because in any cluster and Kubewekend not exceptional, kubelet
usually run as service in system not run as workload in kubernetes
, therefore if you want to see how kubelet
service status, you can see via systemd
inside machine
Info
If you can see you can see anything about
kubelet
, likeID
Memory
Command
CGroup
and many things will help you debug the problems, when you want to understand and hardcore usejournalctl
to figure out all of thread inside π₯Ά
When you dive into kubelet
as command this one run, you can see where configuration to perform kubelet
because kubelet
is binary for execution
Info
If you want to figure out why we can create service, please give time take the look another blog of mine at Setup Cadvisor
Back to kubelet
, this one have some characteristic to concern about
-
As least one worker node will run inside control plane if you not define another one, that why we have
kubelet
insidecontrol-plane
image -
Use bootstrap
kubeconfig
at/etc/kubernetes/bootstrap-kubelet.conf
- Will be empty because we donβt use any bootstrap to build up -
Use
kubeconfig
at/etc/kubernetes/kubelet.conf
- Define about context of cluster like certificate and address of cluster to connect -
Check about config at
/var/lib/kubelet/config.yaml
- Same as configuration if you have look on session via API -
Container runtime inside
image
use viacontainerd.sock
- socket container likedockerd
but lightweight, usually use both of them, it better together. Read more at: containerd vs. Docker: Understanding Their Relationship and How They Work Together
Question
If you want to understand
Container Runtime
withcontainerd
, it plays role as interface stand between for helping your container interact with operation system, anddockerd
is the higher level which provide more feature for developer. Thatβs it π, usually inside container just havecontainerd
for optimize resources and reduce the complexity
- Next we see that provide
node-ip
, really same as the network which provide forkind
container - Use pod-infra-container-image as
pause:3.9
- Β a container which holds the network namespace for the pod. Kubernetes creates pause containers to acquire the respective podβs IP address and set up the network namespace for all other containers that join that pod. Read more at: What is the use of a pause image in Kubernetes? - Obviously use
kind
control-plane because that worker will associate viakind
- And lastly, runtime-cgroups to help
kubelet
can know about how much resource provide and permit to use viacontainerd
Quote
Those characteristics are a lots, I know about that but you need to understand to see what happen on next part, tough job but sound cool.
If you have understand kubelet
and know about what is kubelet
process run inside kubewekend
, that is enough to moving next part, and problems will come up
Dynamic add nodes to kind cluster
Question
The purpose of created HA is help us on split the workload inside Kubernetes, and run in multiple machine or VM. With that idea, this will not cause any damage when worker node have problems, such as upgrade
kubernetes
and keep no downtime for your services, and add-on we can have more things to practical, actually about write customize scheduler π
Before start this part, we will research about HA or High Availability concept, one of best practice in Infrastructure
Info
High Availability (HA)?
The ability of a system to operate continuously for a designated period of time even if components within the system fail.
The highest mission of HA is keep your system always alive, and itβs all. Therefore, to prevention downtime, you add more cluster into your control plane and when any workload become failure that will have target to exchange traffic and not cause any downtime, enough reason to create kind
cluster with feature and more efficiency for my community, for my reader πππ
When think about create HA with kind
, I think that impossible and now I understand more about how to create that and be brave to contribute for our community, thankful and appreciate him - Steve Sklar to help me know what actually need to do and have way to continue diving to it π
. Read more about that at How to dynamically add nodes to a kind cluster
Not mount kernel
to worker node
Now, we are starting, and first of all is create worker via using Docker
command to create node with kind
as container, but in the first time, you will stand between two situation down below
- Succeed run
kubelet
- Failure run
kubelet
Question
What is different between of them ? Answer: Not mount the volume where define your
host
kernel
You need to mount your kernel configuration to be ensure kubelet
can connect with your machine to running the node and operation pod inside via -v /lib/modules:/lib/modules:ro
Actually if you want to know about kubelet
techniques stand behind, check out
- driver of container runtime in
cgroup
andsystemd
part that components to control all process, resources inside the machine - Explaining what is
systemd
andcgroup
in Linux via article Medium - Systemd and cgroup
Quote
Take a notes for this reason, we will discuss more about problems about
cgroup
on the next part
Now when you run docker
container in successful, and now we have worker node but that stand loneliness, so you need join that container to control plane. Currently, Kubewekend cluster is using kind
to operate control plane
via kubeadm
, Read more principle and concept of kind
at kind Principles.
Info
If you know you know,
kubeadm
is first concept to help you create control plane and bootstrapkubernetes
, you can check via Creating a cluster with kubeadm
Following the step to create and join node in documentation, you can reproduce them inside kind
via some steps
- Create token
Info
Create a token which managed via control plane, and provide suitable command with token to help you in joining worker or another control plane to clusters
- Join to control plane
Bug
When you donβt use param
--skip-phases=preflight
, your command join will fail for 100%, becausekubeadm
will run and yourkernel
in machine not existconfigs
file to load full information about yourkernel
, see down below
Info
Parameter
--skip-phases=preflight
, this step will help you bypasspreflight
ofkubeadm
step, reach you init and others stories will work great
After you perform two step above, you actually join your worker
node into clusters, retrieve that via command
Story will become complex and pleasant on next part, another problems come up and you need actually to control your kernel
and understand why it canβt start your CNI and connect that with CNI
and make your worker node become Not Ready
state.
Canβt not install cilium CNI
inside worker node
Now we have problem not run CNI
on worker node, you know kubernetes
used auto discovery when have new node join to cluster, control plane will schedule to provide daemonset
workload to inside worker node via kubelet
and kube-apiserver
, including
- kube-proxy β
- CSI - not have this feature currently β
- CNI - Cilium and actually problems in currently β
In the step to initialization the cilium
and kube-proxy
, kube-proxy
work perfectly but CNI not run at all with multiple error number, sometime announce 2
or 137
Check status of kubelet
service inside new worker node
When check it that announce about cilium
- our CNI was be killed by PostStartHook
event and cause FailedPostStartHook
inside Kubewekend cluster, we need to figure out why was that
First I try to stop kubelet
service by systemd of k8s-worker
, use
Next, try to run kubelet
with command inside kubelet
service with in refer in Dive deeper into Kubelet in previous part and force add node-ip
because i think that cause problems
But not the actually issue is really come up when I try to overview the error with huge information through what we got in running kubelet
command.
And yup I detect about error make container crash in step run cilium-agent
, see down-below
Something wrong inside the cgroups
and cannot to giving pods cilium
to create process and add them to group management. Try to search and access some issue in github
- more information but useful 100%, and find out something can help as
- (arm64) OCI runtime exec failed: exec failed: unable to start container process: error adding pid 791507 to cgroups
- Kubernetes postStart lifecycle hook blocks CNI
From the idea of BenTheElder in the first issue link - whose maintain kind
so he talk about Older version of kernel machine when you kind version
. So letβs think
- We have newest
kind
version - 0.23.0 β
- We install the cluster in node version 1.28.9, still update and not deprecated, so it not come up from cluster image β
Question
Can I perform install
kind
in currently Ubuntu version ? Does it have any different ?
And yup it does, when i try figure out, there are different between my host and my vagrant machine on the kernel
version, I dunno but in some warning they mark me about cgroupns not enabled! Please use cgroup v2, or cgroup v1 with cgroupns enabled.
Therefore, I try self-hosted kind
on my machine in Ubuntu 22.04, with kernel
version 6.5.0-44-generic
and in vagrant
machine with Ubuntu 20.04, with kernel
version 5.4.0-189-generic
. And It work when try to install cilium
inside my Ubuntu with kernel
version 6.5.0-44-generic
and not work with vagrant
. Really suspicious, LOL π
Question
Another question, does cilium have any requirements in latest version ?
And yup it really have π , therefore try to figure out problem and check about requirement cilium
Cilium need me install Linux kernelΒ >= 4.19.57 or equivalent (e.g., 4.18 on RHEL8) and luckily vagrant
get to used it and one more, Ubuntu 20.04 is good enough with requirement on higher version 18.04.3
Donβt no why so, try back to kind
configuration and try to setup add-on worker into control plane when start, and try to self-hosted customize CNI with cilium
against, letβs try
And yup we actually run cilium
succeed, donβt know why dude, LOL π. It means that problems can be via cilium
be installed via auto-discovery and dunno why it execution the error like that LOL.
If you can see, cgroup v1
in-use with node pre-provisioning via kind-config
and rasise any warning about cgroupns not enabled! Please use cgroup v2, or cgroup v1 with cgroupns enabled
BTW we can validate that not come from kernel
version, or at least I donβt know in this time and we know that have enough condition to run cilium
inside worker node
Warning
Actually, Error log make me confuse because another error level 137
One time again, I try to add more node and the error actually occur in step run cilium-agent
, dunno why but i have see error: 137
Bug
Error 137 means this pods cannot run because do not have enough memory to consume for pods and
systemd
killed, and in another waykubelet
will keep reserve memory to make your node became stableI donβt know about different between
aks
andkind
because when I useaks
that problems come up andkind
maybe same because when i run on host not in VM, cilium actually can start
Question
This reason further strengthens the work to be considering upgrade more resource in host, we actually need to do
First of all, back to Vagrantfile
inside Kubewekend Session 1 to change some configuration in master-machine
And done of change, to keep your machine not destroy just need to reload
feature to applied new change
Try one more again about add worker node, and not yet expand resources doesnβt help currently, actually problems occur on cgroups
and FailedPreStopHook
, anything make sense they have connection, you need to provide
-
Enough resource around 100-200 cilium-client, need to be little bit well off to prevent the resources are occupied by
kubelet
-
Problem donβt occur any when we use default
CNI
ofkind
iskind-net
Todo
Yup back to issue we will concern about update
kernel
and you have two optional
- Risk: Install new kernel inside your
vagrant
host, need to make sure you know are you doing- Safe: Update a new version Ubuntu for
vagrant
host to receive a compatible version ofkernel
So following the safe option, I choose upgrade Ubuntu to new version 20.04 β 22.04 and received new version kernel from 5.4.0-189-generic
to 5.15.0-116-generic
. Read more at Update Ubuntu new version
Success
And actually that resolve any problem you meet, so i think if you want to operate
cilium
at version1.5
with old kernel you need downgrade your version ofcilium
, and do not use latest because of congestion inside the kernel
As you can see, you need to use kernel
over 5.10 version to valid run the cilium
maybe on latest version, so that why we need upgrade kernel
Info
Follow the Update Ubuntu new version, to understand technique to upgrade your kernel version and
kubewekend
cluster on Ubuntu 20.04
Quote
It can be upgrade to kernel
5.15.0-116-generic
with not need to update the version to Ubuntu 22.04, but for sure you can test both of methodologies.In my perspective, update version of Ubuntu to new version and get the kernel support is better than force update your old version to new kernel version because that can cause some damage and hard to resolve if you meet, but well done we resolve anything else and now we can understand how can make HA for our cluster you multiple machine
Letβs practice to handle create that on multiple machine because i just do this stuff on the same machine to testing it actually work, and meet any problems LOL π
When redeploy and check log of worker
node, as you can see it move on to using cgroup v2
You can relate this feature on cluster architecture on cgroup v2
at Kubernetes Documentation - About cgroup v2
If you want explore more feature cgroup v2
better than cgroup v1
, please relate to CNCF Blog - Embracing Cgroup V2: Best Practices for Migrating Kubernetes Clusters to AlmaLinux to see what it got, super cool
Use vmbox
to join worker node into master node
I know about there are more alternative out there which cut off the effort when self-hosted and join worker via kubeadm
like
- kubespray - Deploy a Production Ready Kubernetes Cluster
- K3s - Lightweight Kubernetes. Easy to install, half the memory, all in a binary of less than 100 MB
But hand on with kubewekend
can be harder than use template like above, actually kind
is good enough to create and practice local kubernetes, hangover I want to create little bit challenge for myself, but donβt worry in this part will explain at all
Use vagrant
again to create add one worker machine like we doing on session 1, if you are done with this step, reach to next π
After done bring up worker
machine, we need make master
and worker
can interact with each others via same network
Attach your machine with Nat Network
And if you can see currently, our machines is using NAT
and it will not connect with others, so we need use alternative plan for networking, such as Bridged
and NAT Network
but recommend you use NAT Network
with purpose learning and flexible than Bridged
First, I have practice with scripting for help you automation all step when hand on creating network and give machine interact, but many issue let me not image why πΏ
Vagrant
make me so annoy when change new network configuration for adapter, worker node will lost all information SSH of host π- When applied network, It causes your host stuck in boot state when you try shutdown and update new interface. Not actually methodology to check machine boot succeed or not
You can approach that via script down below, but you can meet the trouble for sure, not easily BTW π€
Therefore, to not waste your time, you can use UI
for instead, not cover much but we can use both UI and CLI during progress
-
First of all create networks for whole VM in cluster follow step Choose
Tools
βNetwork
β ChooseNAT Networks
Tab β Click Create Button β Change information in General Options -
Choose
network
in configuration of VM, such ask8s-master-machine
![[Pasted image 20240725151934.png]]
-
On the network, in part
attached to
change fromNAT
βNAT Network
and select your network which you create![[Pasted image 20240726092754.png]]
-
Approve and recheck inside the machine with provide new IP Address via DHCP, but at currently you can access host via
vagrant
, useVMBoxManage
to retrieve info of machine. DocumentationOr you can use Log Viewer (Ctrl + L) of virtualbox to access and view log your target machine
-
But before recheck, use need to port forward again for port to ssh inside that machine as
Tools
βNAT Networks
β Choose name of NAT network β ChoosePort Forwarding
in the bottom β Click add rule β Provide information for rule β Apply -
Access again with
vagrant ssh
and now you are connecting tok8s-master-machine
viaNAT Networking
, but withk8s-worker-machine-x
have some different to connect, you need usessh
instead because yourssh-config
with vagrant is changing via host configuration
![[Pasted image 20240725154459.png]]
![[Pasted image 20240728004200.png]]
Validate your connect between master
and worker
with ping command
Now our host is connected, moving on to update kernel on two host to 5.15.0-116-generic
and reaching self-hosted kubewekend
cluster
Do some step with configuration cgroup
And now we will try run kind
and worker
node with docker in the second part of session Dynamic add nodes to kind cluster and poorly we need to update your cluster to new one version because of 20.04
will change your kernel but cgroup v1
is still alive and do not use cgroup v2
and it makes our host canβt be run cilium cni
if not actually configuration
Master Machine
In the individual in upgrading kernel
, It will not actually upgrade your cgroup
to new version but your machine can be use cgroup v2
but need to configuration, therefore you have two optional
- Upgrade to new version, It means you can re-provisioning your machine with
Ubuntu jammy 22.04
or use command to update. Vagrant Ubuntu 22.04 - Change daemon to enable
cgroupns
, and help your docker daemon can execute and understand what state of it
Quote
I know that will tough option which you need to choose, follow me if you donβt want to cause any trouble you should choose option 1, but if you want to explore more about
cgroup
andsystemd
maybe options 2 can be best choiceAs I can say, I will try hard path in this session, if you want to make option 1, please follow Part 2 of session to figure out how to upgrade OS π
If you choose optional 2, you are brave men buddy. We will have two option in optional 2 and I can guide you at all and can be applied one of them if you want
- Continuous use
cgroupv1
but enablecgroupns
, and it can make sure your can be better to - Applied
cgroup v2
to try upgrade some configuration ofsystemd
With continuing use cgroupv1
and enable cgroupns
, you can explore at: Systemd fails to run in a docker container when using cgroupv2 (βcgroupns=private), It will require you add more flag inside command to give your docker-daemon can enable cgroupns
feature with flag
--cgroup-parent=docker.slice
: Specify custom cgroups, It means you can choose what cgroup running insidedocker
--cgroupns
:cgroup
namespace to use (host|private), and you need to change toprivate
if you run own privatecgroup
namespace
Now your container is running both cgroup v1
and cgroupns
inside worker
container, so how about cgroupv2
is actually work, answer is yes when you update new kernel for your machine you have cgroupv2
in the system but currently your host is not to use cgroupv2
as default, we will learn how to do that via update-grub
and try to set worker
node use cgroupv2
When you validate your host support cgroupv2
, use grep
and find at /proc/mounts
Or you can use grep
with /proc/filesystems
, explore at How do I check cgroup v2 is installed on my machine?
If machine only support cgroupv1
you will not see any line cgroup2
and how you can adapt your machine into cgroupv2
, you can modify grub
and boot your host
with level 2, It means disable cgroupv1
as default and only use cgroupv2
Following discussion Error: The image used by this instance requires a CGroupV1 host system when using clustering, in the line GRUB_CMDLINE_LINUX
, try to add systemd.unified_cgroup_hierarchy=1
and try update grub again
And now try to run worker
node and see what is going on
Your host is currently use cgroupv2
and awesome π, follow this article to know more buddy cgroup v2
Connect your worker to master via kubeadm
If you catch up workflow, the part will last perform in this session, and we need to make sure your connection between master and worker machine
Warning
Because
kind
is not create to purpose when you can use between machine, we enforcekind
to do it so that cause annoy when you failure, I know about that tough andvagrant
host is not easily when change toNAT
βNAT Network
Therefore, just practice in this session because HA is not good with kind
, maybe you use alternative tools can be better but kind
is target and our competition in this series that why we need to pleasure with that one.
You need alternative Vagrantfile
to prevent much annoy when you canβt connect to VM when change new network
As you can see about cannot connect
πΏ, not do anything, we must be upgrade Vagrantfile
like this
Change your network
adapter of worker node to NAT
and run vagrant reload
to reconfiguration again
After running reload
, you change again to natnetworks
and check ssh-config
, the surprise your ssh
is keep not like as when you build your worker
node in the loop and turn on autocorrect: true
network
Try ssh
command
If you have problem, please destroy β up your machine again to applied new network adapter. When you run ssh
succeed into your host, run worker
node but you need add more host to worker
container because we need that can interact with machine because that give network can interact and connect via host at /etc/hosts
. Read more at Add entries to container hosts file (βadd-host)
Now you run succeed container and you need to exec some command inside to check your host can interact with master
node
In you master
machine, host simple webserver with python to see they can interact with others inside worker
container
Your worker
can interact with master
node via container to host, and now you need to validate it can be interact between container and container. Try step in Part 2 of this session
And applied command inside worker
container but change ip address and port because we forward port inside apiserver
to 6996 β 6443 like this
And yup nothing execute π
So I try to add -v=5
to debug my command
And now problem will show for us
The evident proves your cert
trust only 0.0.0.0
and localhost
network, and it mean you need to configuration kubeadm
in master
node to make that actually generate cert
for eth ip.
Therefore, I do research and find the solution at How can I add an additional IP / hostname to my Kubernetes certificate? which guide me to add on new IP in kubeadm
and letβs that generate valid token and cert, for apiserver
can approve IP of host
First of all, try connect to your master
container
Now find your kubeadm
configuration and try to add your host
to make your node can interact with master
IP
As you can see only 0.0.0.0
and localhost
as we discussion, so you nano
try add your host IP below list in certSANs
Now move the old certificates to another folder, otherwise kubeadm will not recreate new ones
UseΒ kubeadm
Β to generate new apiserver
certificates
After that you kubernetes
will apply change after you update your new certificate for cluster, now you can check status of kube-apiserver
It restart like I expectation, and now try to generate token to see your worker node can connect to your master
node
And boom
Continue error π, not easily now we need to continuous modify because I see this warning
Again your kube-apiserver
cannot interact you need to configuration how to permit and help your worker
node connect kube-apiserver
, try again in kubeadm.yaml
Change the control plane address to host because worker
node can interact with kube-apiserver
via host IP address, that reason why I config like this and now trying again, donβt forget delete pod kube-apiserver
or use can use kill -9
to delete process
After try update new configuration to configmap
And the result is continue failure π
I think about we donβt have Coredns to resolve and reason why it not bring up because not install CNI for currently master node π
It can be accept all route and try connect to endpoint 10.0.96.15:6996
in mode global, not ensure but make a test but before we will install cilium use Installl Cilium to your host
Quote
And I realize i make big mistake, misconfiguration between
10.0.96.15:6996
and10.0.69.15:6996
and that really stupid π to make me waste time to debug
And so try again and continue error again, but retrieve cluster-info
is pass and that proven we are right path to configuration
Now the we met on the configuration for kubeadm-config
, and actually that have issue can be resolve via article kubeadm join failed: unable to fetch the kubeadm-config ConfigMap
Issue ask me about to reconfiguration both kubeadm.yaml
(Done) but configmap of cluster-info
is not upgrade, so we need to update that, but first retrieve that with command
Currently server is not configuration to IP so we need to edit that we can use kubectl edit
to update configmap
After save and update, we reload kube-apiserver
and kubelet
of master node if needed but first try with kube-apiserver
as kill container
Check again inside worker
node before reload kubelet
because that can cause some damage and your cluster can be interrupted and I donβt want this situation π
And finally we can connect addition worker
host into master
, that is huge progress to get this result, cry for that πππ
And when use get nodes, you have some problems take around CNI
again
And It comes up with error about not found apiserver
because it configuration cluster network and our kubewekend
cluster you use MachineIP + Port
And issue be resolved via some issue and documentation, help us reconfiguration CNI
with Cilium
So we will uninstall CNI and try to install again with right configuration
And after applied we have ready node as we expected
Conclusion
Success
Sorry to take you much to join with adventure with me, but hope you find well information during the session, figure out what thing need to control and management when create new host, networking, security, container runtime, kernel and moreover like
cgroup
andsystemd
kubelet
. Therefore, I love muchkubernetes
because we need to learn and keep update when try to self-hosted and managekubernetes
problems, really tough but supper fun and cool
Quote
Thanks all support from community to help me create
kubewekend
as expected, I know it hard to hand-on in automation, I will try but not this week. Happy to practice and learn a lots of things inside kubernetes, help me upgrade skill when try with linux and I thinks that I cool stuff I do from writing series. Therefore, thankful for my reader who read to end, appreciate your patience, and one time again stay safe, learning and I will see you on the next weekend. Bye bye π€π€π€