Kubernetes for the Absolute Beginners - Hands-on Tutorial
Introduction
Introduction
According to the Linux Foundation's 10th Annual Open Source Jobs Report, 77% of organizations are expanding their use of cloud and container technologies. Furthermore, the Udemy for Business Workspace Learning Trends Report highlighted an 842% surge in Kubernetes demand—a growth rate more than double that of any other IT operational skill over the past five years.
My name is Mumshad Mannambeth, and in this article, I will guide you through your first steps into Kubernetes, the leading platform for hosting production-grade applications. With an increasing demand for Kubernetes-skilled engineers, this is the ideal time to explore the technology.
For many beginners, Kubernetes appears complex due to a lack of foundational knowledge and the absence of a proper learning infrastructure. This guide addresses those challenges by starting with the basics:
We begin by covering container fundamentals before gradually introducing core Kubernetes concepts. Throughout this guide, you will find clear illustrations, engaging analogies, and step-by-step demos designed to simplify complex topics.
Beyond theory, our interactive labs provide live Kubernetes environments directly in your browser. You will complete coding exercises that mirror real-world Kubernetes challenges. For example, you may review detailed pod status outputs like the following:
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
default-token-f5ntk:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-f5ntk
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- ------
Normal Scheduled 46s default-scheduler Successfully assigned default/nginx
Normal Pulling 45s kubelet, minikube Pulling image "nginx"
Normal Pulled 44s kubelet, minikube Successfully pulled image "nginx"
Normal Created 44s kubelet, minikube Created container nginx
Normal Started 44s kubelet, minikube Started container nginx
Note
Our labs require no high-end hardware or external cloud platforms, so you can experiment on older systems or locally without worrying about cloud costs.
In another scenario, you might encounter errors that need troubleshooting. Consider this example:
Last State: Terminated
Reason: ContainerCannotRun
Message: OCI runtime create failed: container_linux.go:367: starting container process caused
exec: "kube-schedulerrrr": executable file not found in $PATH: unknown
Exit Code: 127
Started: Fri, 22 Apr 2022 22:17:39 +0000
Finished: Fri, 22 Apr 2022 22:17:39 +0000
Ready: False
Restart Count: 6
Requests:
cpu: 100m
Liveness: http-get https://127.0.0.1:10259/healthz delay=0s timeout=1s period=10s failure=8
Startup: http-get https://127.0.0.1:10259/healthz delay=0s timeout=1s period=10s failure=24
Environment: <none>
Mounts:
/etc/kubernetes/scheduler.conf from kubeconfig (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
kubeconfig:
Type: HostPath (bare host directory volume)
Path: /etc/kubernetes/scheduler.conf
HostPathType: FileOrCreate
QoS Class: Burstable
Node-Selectors: <none>
Tolerations: :NoExecute op=Exists
Events:
Type Reason Age From Message
Normal Pulled 5m15s (x5 over 6m47s) kubelet Container image "kube-scheduler:v1.20.0" already present on machine
Normal Created 5m15s (x5 over 6m47s) kubelet Created container kube-scheduler
Warning Failed 5m15s (x5 over 6m47s) kubelet Error: failed to start container "kube-scheduler": E
Each lab is uniquely designed with tools tailored to the lesson at hand. Instead of a generic copy-and-paste environment, every lab is curated to emphasize the topic you have just studied. For example, you might explore deployments using commands like these:
root@controlplane:~# kubectl get pods
NAME READY STATUS RESTARTS AGE
app-586dbdbc54-hc779 1/1 Running 0 10m
root@controlplane:~# kubectl describe deploy app
Name: app
Namespace: default
CreationTimestamp: Fri, 22 Apr 2022 22:11:45 +0000
Labels: app=app
Annotations: deployment.kubernetes.io/revision=1
Selector: app=app
Replicas: 2 desired | 1 updated | 1 total
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: app=app
Containers:
nginx:
Image: nginx:alpine
Port: <none>
Host Port: <none>
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
-------- ------ -------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
New ReplicaSet: app-586dbdbc54 (1/1 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 10m deployment-controller Scale up replica set app-586dbdbc54 to 1
For a more advanced demonstration, consider the following YAML configuration for creating a Pod that runs the kube-controller-manager:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
component: kube-controller-manager
tier: control-plane
name: kube-controller-manager
namespace: kube-system
spec:
containers:
- command:
- kube-controller-manager
- --allocate-node-cids=true
- --authentication-kubeconfig=/etc/kubernetes/conf
- --authorization-kubeconfig=/etc/kubernetes/conf
- --bind-address=127.0.0.1
- --client-ca-file=/etc/kubernetes/pki/ca.crt
- --cluster-cidr=10.244.0.0/16
- --cluster-name=kubernetes
- --cluster-signing-cert-file=/etc/kubernetes/pki/ca.crt
- --cluster-signing-key-file=/etc/kubernetes/pki/ca.key
- --controllers=*,bootstrapsigner,token cleaner
- --kubeconfig=/etc/kubernetes/controller-manager.conf
- --leader-elect=true
- --port=0
- --requestheader-client-ca-file=/etc/kubernetes/pki/ca.crt
- --root-ca-file=/etc/kubernetes/pki/ca.crt
- --service-account-private-key-file=/etc/kubernetes/pki/sa.key
- --service-cluster-ip-range=10.96.0.0/12
- --service-account-credentials=true
image: k8s.gcr.io/kube-controller-manager:v1.20.0
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 8
httpGet:
host: 127.0.0.1
path: /healthz
Rather than presenting pre-filled environments, each lab challenges you to actively solve problems, analyze logs, and adjust configurations. For instance, you might troubleshoot a CrashLoopBackOff status with the following session:
kube-controller-manager-controlplane 0/1 CrashLoopBackOff 5 3m31s
kube-flannel-ds-b85q5 1/1 Running 0 36m
kube-proxy-pthlt 1/1 Running 0 36m
kube-scheduler-controlplane 1/1 Running 0 11m
root@controlplane:~# k logs kube-controller-manager-controlplane
Flag --port has been deprecated, see --secure-port instead.
10422 22:31:03.31107 1 serving.go:331] Generated plugin "kubelet" unable to load client CA file "/etc/kubernetes/pki/ca.crt"
root@controlplane:~# ls /etc/kubernetes/pki/ca.crt
/etc/kubernetes/pki/ca.crt
root@controlplane:~# cat /etc/kubernetes/pki/ca.crt
-----BEGIN CERTIFICATE-----
MIICtSZCACgGAVABIGABADBgkhkIG9wBAsQFAWNMRWEQYDVQ
cm5ldGxvM2JBdIY0M2dIY0M1XQ0M1OY0M1FJY0M3FJY0M0
AxMkA3V1XZLCZCdVODJYJJo2vHBAEBQDA0wGg0DAI0YQzA0
QxgrxLkGxzNZBzQkMXByKLh1GJ5ZQGUJ1U5AhfdQGmxZ4bYp
jI4CuqmZ5NGrIEZmC5Ykj+n6KwWxeWb0+eySb5BslAw8RzQ0
6c0lctImFg0JDgx4ZcgXeb3W4CAW6ASaYj4sFvkvIjvx5FQV
QyCq8NdD+GuTSNQ2bzUsFZHqjoxK7ej4TLybsTIULVJ1H6XZ
BOSSbmvOQWTDugejWc16bMimc00GAAZREZEMCM+hOHGSi9q
-----END CERTIFICATE-----
root@controlplane:~# vi /etc/kubernetes/mal
Warning
When troubleshooting errors such as a CrashLoopBackOff status, carefully review your log outputs and configuration files. Adjust settings incrementally to isolate the issue.
You will also be challenged with tasks that require analyzing logs, modifying configurations, and performing other hands-on exercises. If you need assistance, hints and solutions are available, along with access to an exclusive Slack community channel:
[bob@student-node ~]$ ip a | grep eth1
2926: eth1@if2927: <BROADCAST,MULTICAST>
inet 172.25.0.6/24 brd 172.25.0.255
[bob@student-node ~]$
In addition to our robust lab environments, we are proud to be a CNCF certified Kubernetes training partner. This certification confirms that our training and course content meet industry standards.
We are confident that you will benefit immensely from this course. To ensure your satisfaction, we offer a 30-day money-back guarantee. There is nothing to lose—enroll today and embark on your Kubernetes journey with confidence. I'll see you in class!
Watch Video
Watch video content