<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>CKA on Deep Blue</title>
    <link>https://blog.dustbreak.com/tags/cka/</link>
    <description>Recent content in CKA on Deep Blue</description>
    <generator>Hugo -- gohugo.io</generator>
    <lastBuildDate>Sun, 03 Oct 2021 23:05:47 +0800</lastBuildDate><atom:link href="https://blog.dustbreak.com/tags/cka/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>CKA Learning path 22</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_22/</link>
      <pubDate>Sun, 03 Oct 2021 23:05:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_22/</guid>
      <description>Certified Kubernetes Administrator (CKA) Practice Exam: Part 1 Introduction This lab provides practice scenarios to help prepare you for the Certified Kubernetes Administrator (CKA) exam. You will be presented with tasks to complete as well as server(s) and/or an existing Kubernetes cluster to complete them in. You will need to use your knowledge of Kubernetes to successfully complete the provided tasks, much like you would on the real CKA exam. Good luck!</description>
      <content:encoded><![CDATA[<h1 id="certified-kubernetes-administrator-cka-practice-exam-part-1">Certified Kubernetes Administrator (CKA) Practice Exam: Part 1</h1>
<h2 id="introduction">Introduction</h2>
<p>This lab provides practice scenarios to help prepare you for the Certified Kubernetes Administrator (CKA) exam. You will be presented with tasks to complete as well as server(s) and/or an existing Kubernetes cluster to complete them in. You will need to use your knowledge of Kubernetes to successfully complete the provided tasks, much like you would on the real CKA exam. Good luck!</p>
<h2 id="solution">Solution</h2>
<p>Log in to the server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="count-the-number-of-nodes-that-are-ready-to-run-normal-workloads">Count the Number of Nodes That Are Ready to Run Normal Workloads</h3>
<ol>
<li>
<p>Switch to the appropriate context with <code>kubectl</code>:</p>
<pre tabindex="0"><code>kubectl config use-context acgk8s
</code></pre></li>
<li>
<p>Count the number of nodes ready to run a normal workload:</p>
<pre tabindex="0"><code>kubectl get nodes
</code></pre></li>
<li>
<p>Check that the worker nodes can run normal workloads:</p>
<pre tabindex="0"><code>kubectl describe node  acgk8s-worker1
</code></pre></li>
<li>
<p>Scroll to the top of the output and check the list of taints. You should see none.</p>
</li>
<li>
<p>Repeat the steps above for <code>acgk8s-worker2</code>. You should see no taints on that node either.</p>
</li>
<li>
<p>Save this number to the file <code>/k8s/0001/count.txt</code>:</p>
<pre tabindex="0"><code>echo 2 &gt; /k8s/0001/count.txt
</code></pre></li>
</ol>
<h3 id="retrieve-error-messages-from-a-container-log">Retrieve Error Messages from a Container Log</h3>
<ol>
<li>
<p>Obtain error messages from a container&rsquo;s log:</p>
<pre tabindex="0"><code>kubectl logs -n backend data-handler -c proc
</code></pre></li>
<li>
<p>Return only the error messages:</p>
<pre tabindex="0"><code>kubectl logs -n backend data-handler -c proc | grep ERROR
</code></pre></li>
<li>
<p>Save this output to the file <code>/k8s/0002/errors.txt</code>:</p>
<pre tabindex="0"><code>kubectl logs -n backend data-handler -c proc | grep ERROR &gt; /k8s/0002/errors.txt
</code></pre></li>
</ol>
<h3 id="find-the-pod-that-is-utilizing-the-most-cpu-within-a-namespace">Find the Pod That Is Utilizing the Most CPU within a Namespace</h3>
<ol>
<li>
<p>Locate which Pod in the <code>web</code> namespace with the label <code>app=auth</code> is using the most CPU (In some cases, other pods may show as consuming more cpu):</p>
<pre tabindex="0"><code>kubectl top pod -n web --sort-by cpu --selector app=auth
</code></pre></li>
<li>
<p>Save the name of this Pod to <code>/k8s/0003/cpu-pod.txt</code>:</p>
<pre tabindex="0"><code>echo auth-web &gt; /k8s/0003/cpu-pod.txt
</code></pre></li>
</ol>
<h1 id="certified-kubernetes-administrator-cka-practice-exam-part-2">Certified Kubernetes Administrator (CKA) Practice Exam: Part 2</h1>
<h2 id="introduction-1">Introduction</h2>
<p>This lab provides practice scenarios to help prepare you for the Certified Kubernetes Administrator (CKA) exam. You will be presented with tasks to complete as well as server(s) and/or an existing Kubernetes cluster to complete them in. You will need to use your knowledge of Kubernetes to successfully complete the provided tasks, much like you would on the real CKA exam. Good luck!</p>
<h2 id="solution-1">Solution</h2>
<p>Log in to the server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="edit-the-web-frontend-deployment-to-expose-the-http-port">Edit the <code>web-frontend</code> Deployment to Expose the HTTP Port</h3>
<ol>
<li>
<p>Switch to the appropriate context with <code>kubectl</code>:</p>
<pre tabindex="0"><code>kubectl config use-context acgk8s
</code></pre></li>
<li>
<p>Edit the <code>web-frontend</code> deployment in the <code>web</code> namespace:</p>
<pre tabindex="0"><code>kubectl edit deployment -n web web-frontend
</code></pre></li>
<li>
<p>Change the Pod template to expose port 80 on our NGINX containers:</p>
<pre tabindex="0"><code>spec:
  containers:
  - image: nginx:1.14.2
    ports:
    - containerPort: 80
</code></pre></li>
<li>
<p>Press <strong>Esc</strong> and enter <code>:wq</code> to save and exit.</p>
</li>
</ol>
<h3 id="create-a-service-to-expose-the-web-frontend-deployments-pods-externally">Create a Service to Expose the <code>web-frontend</code> Deployment&rsquo;s Pods Externally</h3>
<ol>
<li>
<p>Open a <code>web-frontend</code> service file:</p>
<pre tabindex="0"><code>vi web-frontend-svc.yml
</code></pre></li>
<li>
<p>Define the service in the YAML document:</p>
<pre tabindex="0"><code>apiVersion: v1
kind: Service
metadata:
  name: web-frontend-svc
  namespace: web
spec:
  type: NodePort
  selector:
    app: web-frontend
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
    nodePort: 30080
</code></pre></li>
<li>
<p>Press <strong>Esc</strong> and enter <code>:wq</code> to save and exit.</p>
</li>
<li>
<p>Create the service:</p>
<pre tabindex="0"><code>kubectl create -f web-frontend-svc.yml
</code></pre></li>
</ol>
<h3 id="scale-up-the-web-frontend-deployment">Scale Up the Web Frontend Deployment</h3>
<ol>
<li>
<p>Scale up the deployment:</p>
<pre tabindex="0"><code>kubectl scale deployment web-frontend -n web --replicas=5
</code></pre></li>
</ol>
<h3 id="create-an-ingress-that-maps-to-the-new-service">Create an Ingress That Maps to the New Service</h3>
<ol>
<li>
<p>Create a <code>web-frontend-ingress</code> file:</p>
<pre tabindex="0"><code>vi web-frontend-ingress.yml
</code></pre></li>
<li>
<p>Define an Ingress in the YAML document:</p>
<pre tabindex="0"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web-frontend-ingress
  namespace: web
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: web-frontend-svc
            port:
              number: 80
</code></pre></li>
<li>
<p>Press <strong>Esc</strong> and enter <code>:wq</code> to save and exit.</p>
</li>
<li>
<p>Create the Ingress:</p>
<pre tabindex="0"><code>kubectl create -f web-frontend-ingress.yml
</code></pre></li>
</ol>
<h1 id="certified-kubernetes-administrator-cka---practice-exam-part-3">Certified Kubernetes Administrator (CKA) - Practice Exam Part 3</h1>
<h2 id="introduction-2">Introduction</h2>
<p>This lab provides practice scenarios to help prepare you for the Certified Kubernetes Administrator (CKA) exam. You will be presented with tasks to complete as well as server(s) and/or an existing Kubernetes cluster to complete them in. You will need to use your knowledge of Kubernetes to successfully complete the provided tasks, much like you would on the real CKA exam. Good luck!</p>
<h2 id="solution-2">Solution</h2>
<p>Log in to the server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="create-a-service-account">Create a Service Account</h3>
<ol>
<li>
<p>Switch to the appropriate context with <code>kubectl</code>:</p>
<pre tabindex="0"><code>kubectl config use-context acgk8s
</code></pre></li>
<li>
<p>Create a service account:</p>
<pre tabindex="0"><code>kubectl create sa webautomation -n web
</code></pre></li>
</ol>
<h3 id="create-a-clusterrole-that-provides-read-access-to-pods">Create a ClusterRole That Provides Read Access to Pods</h3>
<ol>
<li>
<p>Create a <code>pod-reader.yml</code> file:</p>
<pre tabindex="0"><code>vi pod-reader.yml
</code></pre></li>
<li>
<p>Define the ClusterRole:</p>
<pre tabindex="0"><code>apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: pod-reader
rules:
- apiGroups: [&#34;&#34;]
  resources: [&#34;pods&#34;]
  verbs: [&#34;get&#34;, &#34;watch&#34;, &#34;list&#34;]
</code></pre></li>
<li>
<p>Press <strong>Esc</strong> and enter<code>:wq</code> to save and exit.</p>
</li>
<li>
<p>Creat the ClusterRole:</p>
<pre tabindex="0"><code>kubectl create -f pod-reader.yml
</code></pre></li>
</ol>
<h3 id="bind-the-clusterrole-to-the-service-account-to-only-read-pods-in-the-web-namespace">Bind the ClusterRole to the Service Account to Only Read Pods in the <code>web</code> Namespace</h3>
<ol>
<li>
<p>Create the <code>rb-pod-reader.yml</code> file:</p>
<pre tabindex="0"><code>vi rb-pod-reader.yml
</code></pre></li>
<li>
<p>Define the RoleBinding:</p>
<pre tabindex="0"><code>apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: rb-pod-reader
  namespace: web
subjects:
- kind: ServiceAccount
  name: webautomation
roleRef:
  kind: ClusterRole
  name: pod-reader
  apiGroup: rbac.authorization.k8s.io
</code></pre></li>
<li>
<p>Press <strong>Esc</strong> and enter<code>:wq</code> to save and exit.</p>
</li>
<li>
<p>Create the RoleBinding:</p>
<pre tabindex="0"><code>kubectl create -f rb-pod-reader.yml
</code></pre></li>
<li>
<p>Verify the RoleBinding works:</p>
<pre tabindex="0"><code>kubectl get pods -n web --as=system:serviceaccount:web:webautomation
</code></pre></li>
</ol>
<h1 id="certified-kubernetes-administrator-cka---practice-exam-part-4">Certified Kubernetes Administrator (CKA) - Practice Exam Part 4</h1>
<h2 id="introduction-3">Introduction</h2>
<p>This lab provides practice scenarios to help prepare you for the Certified Kubernetes Administrator (CKA) exam. You will be presented with tasks to complete as well as server(s) and/or an existing Kubernetes cluster to complete them in. You will need to use your knowledge of Kubernetes to successfully complete the provided tasks, much like you would on the real CKA exam. Good luck!</p>
<h2 id="solution-3">Solution</h2>
<p>Log in to the server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="back-up-the-etcd-data">Back Up the etcd Data</h3>
<ol>
<li>
<p>From the terminal, log in to the etcd server:</p>
<pre tabindex="0"><code>ssh etcd1
</code></pre></li>
<li>
<p>Back up the etcd data:</p>
<pre tabindex="0"><code>ETCDCTL_API=3 etcdctl snapshot save /home/cloud_user/etcd_backup.db \
--endpoints=https://etcd1:2379 \
--cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
--cert=/home/cloud_user/etcd-certs/etcd-server.crt \
--key=/home/cloud_user/etcd-certs/etcd-server.key
</code></pre></li>
</ol>
<h3 id="restore-the-etcd-data-from-the-backup">Restore the etcd Data from the Backup</h3>
<ol>
<li>
<p>Stop etcd:</p>
<pre tabindex="0"><code>sudo systemctl stop etcd
</code></pre></li>
<li>
<p>Delete the existing etcd data:</p>
<pre tabindex="0"><code>sudo rm -rf /var/lib/etcd
</code></pre></li>
<li>
<p>Restore etcd data from a backup:</p>
<pre tabindex="0"><code>sudo ETCDCTL_API=3 etcdctl snapshot restore /home/cloud_user/etcd_backup.db \
--initial-cluster etcd-restore=https://etcd1:2380 \
--initial-advertise-peer-urls https://etcd1:2380 \
--name etcd-restore \
--data-dir /var/lib/etcd
</code></pre></li>
<li>
<p>Set database ownership:</p>
<pre tabindex="0"><code>sudo chown -R etcd:etcd /var/lib/etcd
</code></pre></li>
<li>
<p>Start etcd:</p>
<pre tabindex="0"><code>sudo systemctl start etcd
</code></pre></li>
<li>
<p>Verify the system is working:</p>
<pre tabindex="0"><code>ETCDCTL_API=3 etcdctl get cluster.name \
--endpoints=https://etcd1:2379 \
--cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
--cert=/home/cloud_user/etcd-certs/etcd-server.crt \
--key=/home/cloud_user/etcd-certs/etcd-server.key
</code></pre></li>
</ol>
<h1 id="cka-practice-exam---part-5">CKA Practice Exam - Part 5</h1>
<h2 id="introduction-4">Introduction</h2>
<p>This lab provides practice scenarios to help prepare you for the Certified Kubernetes Administrator (CKA) exam. You will be presented with tasks to complete as well as server(s) and/or an existing Kubernetes cluster to complete them in. You will need to use your knowledge of Kubernetes to successfully complete the provided tasks, much like you would on the real CKA exam. Good luck!</p>
<h2 id="solution-4">Solution</h2>
<p>Log in to the server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="upgrade-all-kubernetes-components-on-the-control-plane-node">Upgrade All Kubernetes Components on the Control Plane Node</h3>
<ol>
<li>
<p>Switch to the appropriate context with <code>kubectl</code>:</p>
<pre tabindex="0"><code>kubectl config use-context acgk8s
</code></pre></li>
<li>
<p>Upgrade kubeadm:</p>
<pre tabindex="0"><code>sudo apt-get update &amp;&amp; \
sudo apt-get install -y --allow-change-held-packages kubeadm=1.21.1-00
</code></pre></li>
<li>
<p>Drain the control plane node:</p>
<pre tabindex="0"><code>kubectl drain acgk8s-control --ignore-daemonsets
</code></pre></li>
<li>
<p>Check whether the components are upgradeable to v1.21.1:</p>
<pre tabindex="0"><code>sudo kubeadm upgrade plan v1.21.1
</code></pre></li>
<li>
<p>Apply the upgrade:</p>
<pre tabindex="0"><code>sudo kubeadm upgrade apply v1.21.1
</code></pre></li>
<li>
<p>Upgrade kubelet and kubectl:</p>
<pre tabindex="0"><code>sudo apt-get update &amp;&amp; \
sudo apt-get install -y --allow-change-held-packages kubelet=1.21.1-00 kubectl=1.21.1-00
</code></pre></li>
<li>
<p>Reload:</p>
<pre tabindex="0"><code>sudo systemctl daemon-reload
</code></pre></li>
<li>
<p>Restart kubelet:</p>
<pre tabindex="0"><code>sudo systemctl restart kubelet
</code></pre></li>
<li>
<p>Uncordon the control plane node:</p>
<pre tabindex="0"><code>kubectl uncordon acgk8s-control
</code></pre></li>
</ol>
<h3 id="upgrade-all-kubernetes-components-on-the-worker-node">Upgrade All Kubernetes Components on the Worker Node</h3>
<ol>
<li>
<p>Drain the <code>worker1</code> node:</p>
<pre tabindex="0"><code>kubectl drain acgk8s-worker1 --ignore-daemonsets --force
</code></pre></li>
<li>
<p>SSH into the node:</p>
<pre tabindex="0"><code>ssh acgk8s-worker1
</code></pre></li>
<li>
<p>Install a new version of kubeadm:</p>
<pre tabindex="0"><code>sudo apt-get update &amp;&amp; \
sudo apt-get install -y --allow-change-held-packages kubeadm=1.21.1-00
</code></pre></li>
<li>
<p>Upgrade the node:</p>
<pre tabindex="0"><code>sudo kubeadm upgrade node
</code></pre></li>
<li>
<p>Upgrade kubelet and kubectl:</p>
<pre tabindex="0"><code>sudo apt-get update &amp;&amp; \
sudo apt-get install -y --allow-change-held-packages kubelet=1.21.1-00 kubectl=1.21.1-00
</code></pre></li>
<li>
<p>Reload:</p>
<pre tabindex="0"><code>sudo systemctl daemon-reload
</code></pre></li>
<li>
<p>Restart kubelet:</p>
<pre tabindex="0"><code>sudo systemctl restart kubelet
</code></pre></li>
<li>
<p>Type <code>exit</code> to exit the node.</p>
</li>
<li>
<p>Uncordon the node:</p>
<pre tabindex="0"><code>kubectl uncordon acgk8s-worker1
</code></pre></li>
<li>
<p>Repeat the process above for <code>acgk8s-worker2</code> to upgrade the other worker node.</p>
</li>
</ol>
<h1 id="certified-kubernetes-administrator-cka-practice-exam-part-6">Certified Kubernetes Administrator (CKA): Practice Exam: Part 6</h1>
<h2 id="introduction-5">Introduction</h2>
<p>This lab provides practice scenarios to help prepare you for the Certified Kubernetes Administrator (CKA) Exam. You will be presented with tasks to complete, as well as server(s) and/or an existing Kubernetes cluster to complete them in. You will need to use your knowledge of Kubernetes to successfully complete the provided tasks, much like you would on the real CKA exam. Good luck!</p>
<h2 id="solution-5">Solution</h2>
<p>Log in to the server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="drain-the-worker1-node">Drain the <code>Worker1</code> Node</h3>
<ol>
<li>
<p>Switch to the <code>acgk8s</code></p>
<pre tabindex="0"><code>kubectl config use-context acgk8s
</code></pre></li>
<li>
<p>Attempt to drain the</p>
<pre tabindex="0"><code></code></pre></li>
</ol>
<p>worker1</p>
<pre tabindex="0"><code></code></pre><p>kubectl drain acgk8s-worker1</p>
<pre tabindex="0"><code>
3. Does the node drain successfully?

4. Override the errors and drain the node:
</code></pre><p>kubectl drain acgk8s-worker1 &ndash;delete-local-data &ndash;ignore-daemonsets &ndash;force</p>
<pre tabindex="0"><code>
5. Check the status of the exam objectives:
</code></pre><p>./verify.sh</p>
<pre tabindex="0"><code>
### Create a Pod That Will Only Be Scheduled on Nodes with a Specific Label

1. Add the
</code></pre><p>disk=fast</p>
<pre tabindex="0"><code>
label to the
</code></pre><p>worker2</p>
<pre tabindex="0"><code>
node:
</code></pre><p>kubectl label nodes acgk8s-worker2 disk=fast</p>
<pre tabindex="0"><code>
2. Create a YAML file named
</code></pre><p>fast-nginx.yml</p>
<pre tabindex="0"><code></code></pre><p>vim fast-nginx.yml</p>
<pre tabindex="0"><code>
3. In the file, paste the following:
</code></pre><p>apiVersion: v1
kind: Pod
metadata:
name: fast-nginx
namespace: dev
spec:
nodeSelector:
disk: fast
containers:
- name: nginx
image: nginx</p>
<pre tabindex="0"><code>
4. Save the file:
</code></pre><p>ESC
:wq</p>
<pre tabindex="0"><code>
5. Create the
</code></pre><p>fast-nginx</p>
<pre tabindex="0"><code>
pod:
</code></pre><p>kubectl create -f fast-nginx.yml</p>
<pre tabindex="0"><code>
6. Check the status of the pod:
</code></pre><p>kubectl get pod fast-nginx -n dev -o wide</p>
<pre tabindex="0"><code>
7. Check the status of the exam objectives:
</code></pre><p>./verify.sh</p>
<pre tabindex="0"><code>
# Certified Kubernetes Administrator (CKA): Practice Exam: Part 7

## Introduction

This lab provides practice scenarios to help prepare you for the Certified Kubernetes Administrator (CKA) Exam. You will be presented with tasks to complete, as well as server(s) and/or an existing Kubernetes cluster to complete them in. You will need to use your knowledge of Kubernetes to successfully complete the provided tasks, much like you would on the real CKA exam. Good luck!

## Solution

Log in to the server using the credentials provided:
</code></pre><p>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;</p>
<pre tabindex="0"><code>
&gt; **Note:** *When copying and pasting code into Vim from the lab guide, first enter `:set paste` (and then `i` to enter insert mode) to avoid adding unnecessary spaces and hashes. To save and quit the file, press **Escape** followed by `:wq`. To exit the file* without *saving, press **Escape** followed by `:q!`.*

### Create a PersistentVolume

1. Switch to the
</code></pre><p>acgk8s</p>
<pre tabindex="0"><code>
context:
</code></pre><p>kubectl config use-context acgk8s</p>
<pre tabindex="0"><code>
2. Create a YAML file named
</code></pre><p>localdisk.yml</p>
<pre tabindex="0"><code></code></pre><p>vim localdisk.yml</p>
<pre tabindex="0"><code>
3. In the file, paste the following:
</code></pre><p>apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: localdisk
provisioner: kubernetes.io/no-provisioner
allowVolumeExpansion: true</p>
<pre tabindex="0"><code>
4. Save the file:
</code></pre><p>ESC
:wq</p>
<pre tabindex="0"><code>
5. Create a storage class using the YAML file:
</code></pre><p>kubectl create -f localdisk.yml</p>
<pre tabindex="0"><code>
6. Create a YAML file named
</code></pre><p>host-storage-pv.yml</p>
<pre tabindex="0"><code></code></pre><p>vim host-storage-pv.yml</p>
<pre tabindex="0"><code>
7. In the file, paste the following:
</code></pre><p>apiVersion: v1
kind: PersistentVolume
metadata:
name: host-storage-pv
spec:
storageClassName: localdisk
persistentVolumeReclaimPolicy: Recycle
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /etc/data</p>
<pre tabindex="0"><code>
8. Save the file:
</code></pre><p>ESC
:wq</p>
<pre tabindex="0"><code>
9. Create the PersistentVolume:
</code></pre><p>kubectl create -f host-storage-pv.yml</p>
<pre tabindex="0"><code>
10. Check the status of the volume:

 ```
 kubectl get pv host-storage-pv
 ```

11. Check the status of the exam objectives:

 ```
 ./verify.sh
 ```

### Create a Pod That Uses the PersistentVolume for Storage

1. Create a YAML file named
</code></pre><p>host-storage-pvc.yml</p>
<pre tabindex="0"><code></code></pre><p>vim host-storage-pvc.yml</p>
<pre tabindex="0"><code>
2. In the file, paste the following:
</code></pre><p>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: host-storage-pvc
namespace: auth
spec:
storageClassName: localdisk
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi</p>
<pre tabindex="0"><code>
3. Save the file:
</code></pre><p>ESC
:wq</p>
<pre tabindex="0"><code>
4. Create the PersistentVolumeClaim:
</code></pre><p>kubectl create -f host-storage-pvc.yml</p>
<pre tabindex="0"><code>
5. Check the status of the PersistentVolumeClaim:
</code></pre><p>kubectl get pv</p>
<pre tabindex="0"><code>
6. Verify that the claim is bound to the volume:
</code></pre><p>kubectl get pvc -n auth</p>
<pre tabindex="0"><code>
7. Create a YAML file named
</code></pre><p>pv-pod.yml</p>
<pre tabindex="0"><code></code></pre><p>vim pv-pod.yml</p>
<pre tabindex="0"><code>
8. In the file, paste the following:
</code></pre><p>apiVersion: v1
kind: Pod
metadata:
name: pv-pod
namespace: auth
spec:
containers:
- name: busybox
image: busybox
command: [&lsquo;sh&rsquo;, &lsquo;-c&rsquo;, &lsquo;while true; do echo success &gt; /output/output.log; sleep 5; done&rsquo;]
volumeMounts:
- name: pv-storage
mountPath: /output
volumes:
- name: pv-storage
persistentVolumeClaim:
claimName: host-storage-pvc</p>
<pre tabindex="0"><code>
9. Save the file:
</code></pre><p>ESC
:wq</p>
<pre tabindex="0"><code>
10. Create the pod:

 ```
 kubectl create -f pv-pod.yml
 ```

11. Check the status of the exam objectives:

 ```
 ./verify.sh
 ```

### Expand the PersistentVolumeClaim

1. Edit
</code></pre><p>host-storage-pvc</p>
<pre tabindex="0"><code></code></pre><p>kubectl edit pvc host-storage-pvc -n auth</p>
<pre tabindex="0"><code>
2. Under `spec`, change the `storage` value to **200Mi**.

3. Save the file:
</code></pre><p>ESC
:wq</p>
<pre tabindex="0"><code>
4. Check the status of the exam objectives:
</code></pre><p>./verify.sh</p>
<pre tabindex="0"><code>
# Certified Kubernetes Administrator (CKA): Practice Exam: Part 8

## Introduction

This lab provides practice scenarios to help prepare you for the Certified Kubernetes Administrator (CKA) Exam. You will be presented with tasks to complete, as well as server(s) and/or an existing Kubernetes cluster to complete them in. You will need to use your knowledge of Kubernetes to successfully complete the provided tasks, much like you would on the real CKA exam. Good luck!

## Solution

Log in to the server using the credentials provided:
</code></pre><p>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;</p>
<pre tabindex="0"><code>
### Create a Networkpolicy That Denies All Access to the Maintenance Pod

1. Switch to the
</code></pre><p>acgk8s</p>
<pre tabindex="0"><code>
context:
</code></pre><p>kubectl config use-context acgk8s</p>
<pre tabindex="0"><code>
2. Check the
</code></pre><p>foo</p>
<pre tabindex="0"><code>
namespace:
</code></pre><p>kubectl get pods -n foo</p>
<pre tabindex="0"><code>
3. Check the
</code></pre><p>maintenance</p>
<pre tabindex="0"><code>
pod&#39;s labels:
</code></pre><p>kubectl describe pod maintenance -n foo</p>
<pre tabindex="0"><code>
4. Create a new YAML file named
</code></pre><p>np-maintenance.yml</p>
<pre tabindex="0"><code></code></pre><p>vim np-maintenance.yml</p>
<pre tabindex="0"><code>
5. In the file, paste the following:
</code></pre><p>apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: np-maintenance
namespace: foo
spec:
podSelector:
matchLabels:
app: maintenance
policyTypes:
- Ingress
- Egress</p>
<pre tabindex="0"><code>
6. Save the file:
</code></pre><p>ESC
:wq</p>
<pre tabindex="0"><code>
7. Create the
</code></pre><p>NetworkPolicy</p>
<pre tabindex="0"><code></code></pre><p>kubectl create -f np-maintenance.yml</p>
<pre tabindex="0"><code>
8. Check the status of the exam objectives:
</code></pre><p>./verify.sh</p>
<pre tabindex="0"><code>
### Create a Networkpolicy That Allows All Pods in the `users-backend` Namespace to Communicate with Each Other Only on a Specific Port

1. Label the
</code></pre><p>users-backend</p>
<pre tabindex="0"><code>
namespace:
</code></pre><p>kubectl label namespace users-backend app=users-backend</p>
<pre tabindex="0"><code>
2. Create a YAML file named
</code></pre><p>np-users-backend-80.yml</p>
<pre tabindex="0"><code></code></pre><p>vim np-users-backend-80.yml</p>
<pre tabindex="0"><code>
3. In the file, paste the following:
</code></pre><p>apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: np-users-backend-80
namespace: users-backend
spec:
podSelector: {}
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
app: users-backend
ports:
- protocol: TCP
port: 80</p>
<pre tabindex="0"><code>
4. Save the file:
</code></pre><p>ESC
:wq</p>
<pre tabindex="0"><code>
5. Create the NetworkPolicy:
</code></pre><p>kubectl create -f np-users-backend-80.yml</p>
<pre tabindex="0"><code>
6. Check the status of the exam objectives:
</code></pre><p>./verify.sh</p>
<pre tabindex="0"><code>
# Certified Kubernetes Administrator (CKA): Practice Exam: Part 7

## Introduction

This lab provides practice scenarios to help prepare you for the Certified Kubernetes Administrator (CKA) Exam. You will be presented with tasks to complete, as well as server(s) and/or an existing Kubernetes cluster to complete them in. You will need to use your knowledge of Kubernetes, to successfully complete the provided tasks, much like you would on the real CKA exam. Good luck!

## Solution

Log in to the server using the credentials provided:
</code></pre><p>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;</p>
<pre tabindex="0"><code>
### Create a Multi-Container Pod

1. Switch to the
</code></pre><p>acgk8s</p>
<pre tabindex="0"><code>
context:
</code></pre><p>kubectl config use-context acgk8s</p>
<pre tabindex="0"><code>
2. Create a YAML file named
</code></pre><p>multi.yml</p>
<pre tabindex="0"><code></code></pre><p>apiVersion: v1
kind: Pod
metadata:
name: multi
namespace: baz
spec:
containers:
- name: nginx
image: nginx
- name: redis
image: redis</p>
<pre tabindex="0"><code>
3. Save the file:
</code></pre><p>ESC
:wq</p>
<pre tabindex="0"><code>
4. Create the multi-container pod:
</code></pre><p>kubectl create -f multi.yml</p>
<pre tabindex="0"><code>
5. Check the status of the pod:
</code></pre><p>kubectl get pods -n baz</p>
<pre tabindex="0"><code>
6. Check the status of the exam objectives:
</code></pre><p>./verify.sh</p>
<pre tabindex="0"><code>
### Create a Pod Which Uses a Sidecar to Expose the Main Container&#39;s Log File to Stdout

1. Create a YAML file named logging-sidecar.yml:
</code></pre><p>vim logging-sidecar.yml</p>
<pre tabindex="0"><code>
2. In the file, paste the following:
</code></pre><p>apiVersion: v1
kind: Pod
metadata:
name: logging-sidecar
namespace: baz
spec:
containers:
- name: busybox1
image: busybox
command: [&lsquo;sh&rsquo;, &lsquo;-c&rsquo;, &lsquo;while true; do echo Logging data &gt; /output/output.log; sleep 5; done&rsquo;]
volumeMounts:
- name: sharedvol
mountPath: /output
- name: sidecar
image: busybox
command: [&lsquo;sh&rsquo;, &lsquo;-c&rsquo;, &rsquo;tail -f /input/output.log&rsquo;]
volumeMounts:
- name: sharedvol
mountPath: /input
volumes:
- name: sharedvol
emptyDir: {}</p>
<pre tabindex="0"><code>
3. Save the file:
</code></pre><p>ESC
:wq</p>
<pre tabindex="0"><code>
4. Create the
</code></pre><p>logging-sidecar</p>
<pre tabindex="0"><code>
pod:
</code></pre><p>kubectl create -f logging-sidecar.yml</p>
<pre tabindex="0"><code>
5. Check the status of the pod:
</code></pre><p>kubectl get pods -n baz</p>
<pre tabindex="0"><code>
6. Check the
</code></pre><p>logging-sidecar</p>
<pre tabindex="0"><code>
logs:
</code></pre><p>kubectl logs logging-sidecar -n baz -c sidecar</p>
<pre tabindex="0"><code>
7. Check the status of the exam objectives:
</code></pre><p>./verify.sh</p>
<pre tabindex="0"><code>
# Certified Kubernetes Administrator (CKA): Practice Exam: Part 10

## Introduction

This lab provides practice scenarios to help prepare you for the Certified Kubernetes Administrator (CKA) Exam. You will be presented with tasks to complete, as well as server(s) and/or an existing Kubernetes cluster to complete them in. You will need to use your knowledge of Kubernetes, to successfully complete the provided tasks, much like you would on the real CKA exam. Good luck!

## Solution

Log in to the server using the credentials provided:
</code></pre><p>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;</p>
<pre tabindex="0"><code>
### Determine What Is Wrong with the Broken Node

1. Switch to the
</code></pre><p>acgk8s</p>
<pre tabindex="0"><code>
context:
</code></pre><p>kubectl config use-context acgk8s</p>
<pre tabindex="0"><code>
2. Check the current status of the nodes:
</code></pre><p>kubectl get nodes</p>
<pre tabindex="0"><code>
3. Identify the broken node and save the name to a file named
</code></pre><p>broken-node.txt</p>
<pre tabindex="0"><code></code></pre><p>echo acgk8s-worker2 &gt; /k8s/0004/broken-node.txt</p>
<pre tabindex="0"><code>
4. Attempt to determine the cause of the issue:
</code></pre><p>kubectl describe node acgk8s-worker2</p>
<pre tabindex="0"><code>
### Fix the Problem

1. Access the node using
</code></pre><p>ssh acgk8s-worker2</p>
<pre tabindex="0"><code>
2. Check the
</code></pre><p>kubelet</p>
<pre tabindex="0"><code>
log:
</code></pre><p>sudo journalctl -u kubelet</p>
<pre tabindex="0"><code>
3. Check the last entry in the log.

4. Check the
</code></pre><p>kubelet</p>
<pre tabindex="0"><code>
status:
</code></pre><p>sudo systemctl status kubelet</p>
<pre tabindex="0"><code>
5. Enable
</code></pre><p>kubelet</p>
<pre tabindex="0"><code></code></pre><p>sudo systemctl enable kubelet</p>
<pre tabindex="0"><code>
6. Start
</code></pre><p>kubelet</p>
<pre tabindex="0"><code></code></pre><p>sudo systemctl start kubelet</p>
<pre tabindex="0"><code>
7. Verify that
</code></pre><p>kubelet</p>
<pre tabindex="0"><code>
started successfully:
</code></pre><p>sudo systemctl status kubelet</p>
<pre tabindex="0"><code>
8. Return to the control plane node:
</code></pre><p>exit</p>
<pre tabindex="0"><code>
9. Check the status of the nodes:
</code></pre><p>kubectl get nodes</p>
<pre tabindex="0"><code>
10. Check the status of the exam objectives:

 ```
 ./verify.sh
 ```
</code></pre>]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 21</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_21/</link>
      <pubDate>Sun, 03 Oct 2021 17:39:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_21/</guid>
      <description>Troubleshooting a Broken Kubernetes Cluster Introduction Every Kubernetes administrator will likely need to deal with a broken cluster at some point, whether a single node or the entire cluster is down. In this lab, you will be able to practice your troubleshooting skills. You will be presented with a broken Kubernetes cluster and asked to use your investigative skills to identify the problem and fix it.
Solution Log in to the control plane node server using the credentials provided:</description>
      <content:encoded><![CDATA[<h1 id="troubleshooting-a-broken-kubernetes-cluster">Troubleshooting a Broken Kubernetes Cluster</h1>
<h2 id="introduction">Introduction</h2>
<p>Every Kubernetes administrator will likely need to deal with a broken cluster at some point, whether a single node or the entire cluster is down. In this lab, you will be able to practice your troubleshooting skills. You will be presented with a broken Kubernetes cluster and asked to use your investigative skills to identify the problem and fix it.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the control plane node server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="determine-what-is-wrong-with-the-cluster">Determine What is Wrong with the Cluster</h3>
<ol>
<li>
<p>Find out which node is having a problem by using <code>kubectl get nodes</code>. Identify if a node is in the <em>NotReady</em> state.</p>
</li>
<li>
<p>Get more information on the node by using <code>kubectl describe node &lt;NODE_NAME&gt;.</code></p>
</li>
<li>
<p>Look for the <em>Conditions</em> section of the <em>Node Information</em> and find out what is affecting the node&rsquo;s status, causing it to fail.</p>
</li>
<li>
<p>Log in to the worker 2 node server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre></li>
<li>
<p>Look at the kubelet logs of the worker 2 node by using <code>sudo journalctl -u kubelet</code>.</p>
</li>
<li>
<p>Go to the end of the log by pressing <code>Shift + G</code> and see the error messages stating that kubelet has stopped.</p>
</li>
<li>
<p>Look at the status of the kubelet status by using <code>sudo systemctl status kubelet</code>, and note whether the kubelet service is running or not.</p>
</li>
</ol>
<h3 id="fix-the-problem">Fix the Problem</h3>
<ol>
<li>In order to fix the problem, we need to not only start the server but also enable kubelet to ensure that it continues to work if the server restarts in the future. Use <code>clear</code> to clear the service status, and then start and enable kubelet by using <code>sudo systemctl enable kubelet</code>, followed by <code>sudo systemctl start kubelet</code>.</li>
<li>Check if kubelet is active by using <code>sudo systemctl status kubelet</code>, and note if the service is listed as <em>active (running)</em>.</li>
<li>Return to the control plane node.</li>
<li>Check if all nodes are now in a <em>Ready</em> status by using <code>kubectl get nodes</code>. You may have to wait and try the command a few times before all nodes appear as <em>Ready</em>.</li>
</ol>
<h1 id="troubleshooting-a-broken-kubernetes-application">Troubleshooting a Broken Kubernetes Application</h1>
<h2 id="introduction-1">Introduction</h2>
<p>Kubernetes administrators need to be able to fix issues with applications running in a cluster. This lab will allow you to test your skills when it comes to fixing broken Kubernetes applications. You will be presented with a cluster running a broken application and asked to identify and correct the problem.</p>
<h2 id="solution-1">Solution</h2>
<p>Log in to the server by using the credentials provided: <code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;</code>.</p>
<h3 id="identify-what-is-wrong-with-the-application">Identify What is Wrong with the Application</h3>
<ol>
<li>Examine the <code>web-consumer</code> deployment, which resides in the <code>web</code> namespace, and its Pods by using <code>kubectl get deployment -n web web-consumer</code>.</li>
<li>Get more information by using <code>kubectl describe deployment -n web web-consumer</code>, including container specifications and labels that the Pods are using.</li>
<li>Look more closely at the Pods by using <code>kubectl get pods -n web</code> to see if both Pods are up and running.</li>
<li>Get more information about the Pods by using <code>kubectl describe pod -n web &lt;POD_NAME&gt;</code>, and evaluate any warning messages that may come up.</li>
<li>Look at the logs associated with the container <code>busybox</code> by using <code>kubectl logs -n web &lt;POD_NAME&gt; -c busybox</code>.</li>
<li>Determine what may be going wrong by reading the output from the container logs.</li>
<li>Take a closer look at the pod itself by using <code>kubectl get pod -n web &lt;POD_NAME&gt; -o yaml</code> to get the data in the yaml format.</li>
<li>Determine which command is causing the errors (in this case, the <code>while true; do curl auth-db; sleep 5; done</code> command).</li>
</ol>
<h3 id="fix-the-problem-1">Fix the Problem</h3>
<ol>
<li>Take a closer look at the service by using <code>kubectl get svc -n web auth-db</code>.</li>
<li>Locate where the service is by using <code>kubectl get namespaces</code> and finding the one other non-default namespace called <code>data</code>.</li>
<li>Check <code>kubectl get svc -n data</code> and find the <code>auth-db</code> service in this namespace, rather than the <code>web</code> namespace.</li>
<li>Start resolving the issue by using <code>kubectl edit deployment -n web web-consumer</code>.</li>
<li>In the <code>spec</code> section, scroll down to find the pod template and locate the <code>while true; do curl auth-db; sleep 5; done</code> command.</li>
<li>Change the command to <code>while true; do curl auth-db.data.svc.cluster.local; sleep 5; done</code> to give the fully qualified domain name of that service. This will allow the <code>web-consumer</code> deployment&rsquo;s Pods to communicate with the service successfully.</li>
<li>Save the file and exit by pressing the ESC key and using <code>:wq</code>.</li>
<li>Check <code>kubectl get pods -n web</code> to ensure that the old pods have terminated and the new pods are running successfully.</li>
<li>Check the log of one of the new pods by using <code>kubectl logs -n web &lt;POD-NAME&gt; -c busybox</code>. This time the pod should be able to communicate successfully with the service.</li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 20</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_20/</link>
      <pubDate>Sun, 03 Oct 2021 16:56:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_20/</guid>
      <description>Using PersistentVolumes in Kubernetes Introduction PersistentVolumes provide a way to treat storage as a dynamic resource in Kubernetes. This lab will allow you to demonstrate your knowledge of PersistentVolumes. You will mount some persistent storage to a container using a PersistentVolume and a PersistentVolumeClaim.
Solution Log in to the server using the credentials provided:
ssh cloud_user@&amp;lt;PUBLIC_IP_ADDRESS&amp;gt; Create a PersistentVolume That Allows Claim Expansion Create a custom Storage Class by using ```vi localdisk.</description>
      <content:encoded><![CDATA[<h1 id="using-persistentvolumes-in-kubernetes">Using PersistentVolumes in Kubernetes</h1>
<h2 id="introduction">Introduction</h2>
<p>PersistentVolumes provide a way to treat storage as a dynamic resource in Kubernetes. This lab will allow you to demonstrate your knowledge of PersistentVolumes. You will mount some persistent storage to a container using a PersistentVolume and a PersistentVolumeClaim.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="create-a-persistentvolume-that-allows-claim-expansion">Create a PersistentVolume That Allows Claim Expansion</h3>
<ol>
<li>
<p>Create a custom Storage Class by using ```vi localdisk.yml`.</p>
</li>
<li>
<p>Define the Storage Class by using:</p>
<pre tabindex="0"><code>apiVersion: storage.k8s.io/v1 
kind: StorageClass 
metadata: 
  name: localdisk 
provisioner: kubernetes.io/no-provisioner
allowVolumeExpansion: true
</code></pre></li>
<li>
<p>Save and exit the file by hitting the ESC key and using <code>:wq</code>.</p>
</li>
<li>
<p>Finish creating the Storage Class by using <code>kubectl create -f localdisk.yml</code>.</p>
</li>
<li>
<p>Create the PersistentVolume by using <code>vi host-pv.yml</code>.</p>
</li>
<li>
<p>Define the PersistentVolume with a size of 1Gi by using:</p>
<pre tabindex="0"><code>kind: PersistentVolume 
apiVersion: v1 
metadata: 
   name: host-pv 
spec: 
   storageClassName: localdisk
   persistentVolumeReclaimPolicy: Recycle 
   capacity: 
      storage: 1Gi 
   accessModes: 
      - ReadWriteOnce 
   hostPath: 
      path: /var/output
</code></pre></li>
<li>
<p>Save and exit the file by hitting the ESC key and using <code>:wq</code>.</p>
</li>
<li>
<p>Finish creating the PersistentVolume by using <code>kubectl create -f host-pv.yml</code>.</p>
</li>
<li>
<p>Check the status of the PersistenVolume by using <code>kubectl get pv</code>.</p>
</li>
</ol>
<h3 id="create-a-persistentvolumeclaim">Create a PersistentVolumeClaim</h3>
<ol>
<li>
<p>Start creating a PersistentVolumeClaim for the PersistentVolume to bind to by using <code>vi host-pvc.yml</code>.</p>
</li>
<li>
<p>Define the PersistentVolumeClaim with a size of 100Mi by using:</p>
<pre tabindex="0"><code>apiVersion: v1 
kind: PersistentVolumeClaim 
metadata: 
   name: host-pvc 
spec: 
   storageClassName: localdisk 
   accessModes: 
      - ReadWriteOnce 
   resources: 
      requests: 
         storage: 100Mi
</code></pre></li>
<li>
<p>Save and exit the file by hitting the ESC key and using <code>:wq</code>.</p>
</li>
<li>
<p>Finish creating the PersistentVolumeClaim by using <code>kubectl create -f host-pvc.yml</code>.</p>
</li>
<li>
<p>Check the status of the PersistentVolume and PersistentVolumeClaim to verify that they have been bound:</p>
<pre tabindex="0"><code>kubectl get pv
kubectl get pvc
</code></pre></li>
</ol>
<h3 id="create-a-pod-that-uses-a-persistentvolume-for-storage">Create a Pod That Uses a PersistentVolume for Storage</h3>
<ol>
<li>
<p>Create a Pod that uses the PersistentVolumeClaim by using <code>vi pv-pod.yml</code>.</p>
</li>
<li>
<p>Define the Pod by using:</p>
<pre tabindex="0"><code>apiVersion: v1 
kind: Pod 
metadata: 
   name: pv-pod 
spec: 
   containers: 
      - name: busybox 
        image: busybox 
        command: [&#39;sh&#39;, &#39;-c&#39;, &#39;while true; do echo Success! &gt; /output/success.txt; sleep 5; done&#39;] 
</code></pre></li>
<li>
<p>Mount the PersistentVolume to the /output location by adding the following, which should be level with the <code>containers</code> spec in terms of indentation:</p>
<pre tabindex="0"><code>volumes: 
 - name: pv-storage 
   persistentVolumeClaim: 
      claimName: host-pvc
</code></pre></li>
<li>
<p>In the <code>containers</code> spec, below the <code>command</code>, set the list of volume mounts by using:</p>
<pre tabindex="0"><code>volumeMounts: 
- name: pv-storage 
  mountPath: /output 
</code></pre></li>
<li>
<p>Save and exit the file by hitting the ESC key and using <code>:wq</code>.</p>
</li>
<li>
<p>Finish creating the Pod by using <code>kubectl create -f pv-pod.yml</code>.</p>
</li>
<li>
<p>Check that the Pod is up and running by using <code>kubectl get pods</code>.</p>
</li>
<li>
<p>If you wish, you can log in to the worker node and verify the output data by using <code>cat /var/output/success.txt</code>.</p>
</li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 19</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_19/</link>
      <pubDate>Sun, 03 Oct 2021 16:51:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_19/</guid>
      <description>Managing Container Storage with Kubernetes Volumes Introduction Kubernetes volumes offer a simple way to mount external storage to containers. This lab will test your knowledge of volumes as you provide storage to some containers according to a provided specification. This will allow you to practice what you know about using Kubernetes volumes.
Solution Log in to the control plane server using the credentials provided:
ssh cloud_user@&amp;lt;PUBLIC_IP_ADDRESS&amp;gt; Create a Pod That Outputs Data to the Host Using a Volume Create a Pod that will interact with the host file system by using vi maintenance-pod.</description>
      <content:encoded><![CDATA[<h1 id="managing-container-storage-with-kubernetes-volumes">Managing Container Storage with Kubernetes Volumes</h1>
<h2 id="introduction">Introduction</h2>
<p>Kubernetes volumes offer a simple way to mount external storage to containers. This lab will test your knowledge of volumes as you provide storage to some containers according to a provided specification. This will allow you to practice what you know about using Kubernetes volumes.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the control plane server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="create-a-pod-that-outputs-data-to-the-host-using-a-volume">Create a Pod That Outputs Data to the Host Using a Volume</h3>
<ol>
<li>
<p>Create a Pod that will interact with the host file system by using <code>vi maintenance-pod.yml</code>.</p>
</li>
<li>
<p>Enter in the first part of the basic YAML for a simple busybox Pod that outputs some data every 5 seconds to the host&rsquo;s disk:</p>
<pre tabindex="0"><code>apiVersion: v1
kind: Pod
metadata:
    name: maintenance-pod
spec:
    containers:
    - name: busybox
      image: busybox
      command: [&#39;sh&#39;, &#39;-c&#39;, &#39;while true; do echo Success! &gt;&gt; /output/output.txt; sleep 5; done&#39;]
</code></pre></li>
<li>
<p>Under the basic YAML, begin creating volumes, which should be level with the <em>containers</em> spec:</p>
<pre tabindex="0"><code>volumes:
- name: output-vol
  hostPath:
      path: /var/data
</code></pre></li>
<li>
<p>In the <em>containers</em> spec of the basic YAML, add a line for volume mounts:</p>
<pre tabindex="0"><code>volumeMounts:
- name: output-vol
  mountPath: /output
</code></pre></li>
<li>
<p>Save the file and exit by pressing the <code>ESC</code> key and using <code>:wq</code>.</p>
</li>
<li>
<p>Finish creating the Pod by using <code>kubectl create -f maintenance-pod.yml</code>.</p>
</li>
<li>
<p>Make sure the Pod is up and running by using <code>kubectl get pods</code> and check that <code>maintenance-pod</code> is running, so it should be outputting data to the host system.</p>
</li>
<li>
<p>Log into the worker node server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre></li>
<li>
<p>Look at the output by using <code>cat /var/data/output.txt</code> to see whether the Pod setup was successful.</p>
</li>
</ol>
<h3 id="create-a-multi-container-pod-that-shares-data-between-containers-using-a-volume">Create a Multi-Container Pod That Shares Data Between Containers Using a Volume</h3>
<ol>
<li>
<p>Return to the control plane server.</p>
</li>
<li>
<p>Create another YAML file for a shared-data multi-container Pod by using <code>vi shared-data-pod.yml</code>.</p>
</li>
<li>
<p>Start with the basic Pod definition and add multiple containers, where the first container will write the <code>output.txt</code> file and the second container will read the <code>output.txt</code> file:</p>
<pre tabindex="0"><code>apiVersion: v1
kind: Pod
metadata:
    name: shared-data-pod
spec:
    containers:
    - name: busybox1
      image: busybox
      command: [&#39;sh&#39;, &#39;-c&#39;, &#39;while true; do echo Success! &gt;&gt; /output/output.txt; sleep 5; done&#39;]
    - name: busybox2
      image: busybox
      command: [&#39;sh&#39;, &#39;-c&#39;, &#39;while true; do cat /input/output.txt; sleep 5; done&#39;]
</code></pre></li>
<li>
<p>Set up the volumes, again at the same level as <em>containers</em> with an <code>emptyDir</code> volume that only exists to share data between two containers in a simple way:</p>
<pre tabindex="0"><code>volumes:
- name: shared-vol
  emptyDir: {}
</code></pre></li>
<li>
<p>Mount that volume between the two containers by adding the following lines under <em>command</em> for the <em>busybox1</em> container:</p>
<pre tabindex="0"><code>volumeMounts:
- name: shared-vol
  mountPath: /output
</code></pre></li>
<li>
<p>For the <em>busybox2</em> container, add the following lines to mount the same volume under <em>command</em> to complete creating the shared file:</p>
<pre tabindex="0"><code>volumeMounts:
- name: shared-vol
  mountPath: /input
</code></pre></li>
<li>
<p>Save the file and exit by pressing the <code>ESC</code> key and using <code>:wq</code>.</p>
</li>
<li>
<p>Finish creating the multi-container Pod using <code>kubectl create -f shared-data-pod.yml</code>.</p>
</li>
<li>
<p>Make sure the Pod is up and running by using <code>kubectl get pods</code> and check if both containers are running and ready.</p>
</li>
<li>
<p>To make sure the Pod is working, check the logs for <code>shared-data-pod.yml</code> and specify the second container that is reading the data and printing it to the console, using <code>kubectl logs shared-data-pod -c busybox2</code>.</p>
</li>
<li>
<p>If you see the series of &ldquo;Success!&rdquo; messages, you have successfully created both containers, one of which is using a host path volume to write some data to the host disk and the other of which is using an emptyDir volume to share a volume between two containers in the same Pod.</p>
</li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 18</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_18/</link>
      <pubDate>Wed, 29 Sep 2021 22:37:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_18/</guid>
      <description>Using Kubernetes Ingress Introduction Kubernetes Ingress allows you to customize how external entities can interact with your Kubernetes applications via the network. This lab will allow you to exercise your knowledge of Kubernetes Ingress. You will use Ingress to open access from an existing service to an external server.
Solution Log in to the server using the credentials provided:
ssh cloud_user@&amp;lt;PUBLIC_IP_ADDRESS&amp;gt; Create a Service to Expose the web-auth Deployment Check out the deployment:</description>
      <content:encoded><![CDATA[<h1 id="using-kubernetes-ingress">Using Kubernetes Ingress</h1>
<h2 id="introduction">Introduction</h2>
<p>Kubernetes Ingress allows you to customize how external entities can interact with your Kubernetes applications via the network. This lab will allow you to exercise your knowledge of Kubernetes Ingress. You will use Ingress to open access from an existing service to an external server.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="create-a-service-to-expose-the-web-auth-deployment">Create a Service to Expose the web-auth Deployment</h3>
<ol>
<li>
<p>Check out the deployment:</p>
<pre tabindex="0"><code>kubectl get deployment web-auth -o yaml
</code></pre><p>Note the <code>web-auth</code> label on our Pods. We&rsquo;ll use this label to select these Pods using our Service.</p>
</li>
<li>
<p>Create a <code>web-auth-svc.yml</code> file:</p>
<pre tabindex="0"><code>vi web-auth-svc.yml
</code></pre></li>
<li>
<p>Paste the following YAML definitions:</p>
<blockquote>
<p><strong>Note:</strong> To paste YAML directly into the Vi/Vim editor, first enter the command <code>:set paste</code>.</p>
</blockquote>
<pre tabindex="0"><code>apiVersion: v1
kind: Service
metadata:
  name: web-auth-svc
spec:
  type: ClusterIP
  selector:
    app: web-auth
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 80
</code></pre></li>
<li>
<p>Press <strong>Esc</strong> and enter <code>:wq</code> to save and exit.</p>
</li>
<li>
<p>Create the Service:</p>
<pre tabindex="0"><code>kubectl create -f web-auth-svc.yml
</code></pre></li>
</ol>
<h3 id="create-an-ingress-that-maps-to-the-new-service">Create an Ingress That Maps to the New Service</h3>
<ol>
<li>
<p>Create a <code>web-auth-ingress.yml</code> file:</p>
<pre tabindex="0"><code>vi web-auth-ingress.yml
</code></pre></li>
<li>
<p>Add the following YAML definitions:</p>
<blockquote>
<p><strong>Note:</strong> To paste YAML directly into the Vi/Vim editor, first enter the command <code>:set paste</code>.</p>
</blockquote>
<pre tabindex="0"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web-auth-ingress
spec:
  rules:
  - http:
      paths:
      - path: /auth
        pathType: Prefix
        backend:
          service:
            name: web-auth-svc
            port:
              number: 80
</code></pre></li>
<li>
<p>Press <strong>Esc</strong> and enter <code>:wq</code> to save and exit.</p>
</li>
<li>
<p>Create the Ingress:</p>
<pre tabindex="0"><code>kubectl create -f web-auth-ingress.yml
</code></pre></li>
<li>
<p>Check the status of the Ingress:</p>
<pre tabindex="0"><code>kubectl describe ingress web-auth-ingress
</code></pre><p>Note the service endpoints in the Backends section of the output. You have successfully created an Ingress that maps to the backend Service.</p>
</li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 17</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_17/</link>
      <pubDate>Wed, 29 Sep 2021 21:33:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_17/</guid>
      <description>Using Kubernetes Services with DNS Introduction Kubernetes Services can be located with the Kubernetes DNS just like Pods can. In this lab, you will work with the Kubernetes DNS to discover Services from within a Pod. This will test your knowledge of how to interact with Services using DNS.
Solution Log in to the control plane server using the credentials provided:
ssh cloud_user@&amp;lt;PUBLIC_IP_ADDRESS&amp;gt; Perform an Nslookup for a Service in the Same Namespace Start using the busybox Pod in the web namespace to perform an nslookup on the web-frontend Service by entering:</description>
      <content:encoded><![CDATA[<h1 id="using-kubernetes-services-with-dns">Using Kubernetes Services with DNS</h1>
<h2 id="introduction">Introduction</h2>
<p>Kubernetes Services can be located with the Kubernetes DNS just like Pods can. In this lab, you will work with the Kubernetes DNS to discover Services from within a Pod. This will test your knowledge of how to interact with Services using DNS.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the control plane server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="perform-an-nslookup-for-a-service-in-the-same-namespace">Perform an Nslookup for a Service in the Same Namespace</h3>
<ol>
<li>
<p>Start using the <code>busybox</code> Pod in the <code>web</code> namespace to perform an nslookup on the <code>web-frontend</code> Service by entering:</p>
<pre tabindex="0"><code>kubectl exec -n web busybox -- nslookup web-frontend
</code></pre></li>
<li>
<p>Redirect the output to save the results in a text file by using:</p>
<pre tabindex="0"><code>kubectl exec -n web busybox -- nslookup web-frontend &gt;&gt; ~/dns_same_namespace_results.txt
</code></pre></li>
<li>
<p>Look up the same Service using the fully qualified domain name by entering:</p>
<pre tabindex="0"><code>kubectl exec -n web busybox -- nslookup web-frontend.web.svc.cluster.local
</code></pre></li>
<li>
<p>Redirect the output to save the results of the second nslookup in a text file by using:</p>
<pre tabindex="0"><code>kubectl exec -n web busybox -- nslookup web-frontend.web.svc.cluster.local &gt;&gt; ~/dns_same_namespace_results.txt
</code></pre></li>
<li>
<p>Check that everything looks okay in the text file by using:</p>
<pre tabindex="0"><code>cat ~/dns_same_namespace_results.txt
</code></pre></li>
<li>
<p>Use <code>clear</code> to clear the text file output.</p>
</li>
</ol>
<h3 id="perform-an-nslookup-for-a-service-in-a-different-namespace">Perform an Nslookup For a Service in a Different Namespace</h3>
<ol>
<li>
<p>Use the <code>busybox</code> Pod in the <code>web</code> namespace to perform an nslookup on the <code>user-db</code> Service in the <code>data</code> namespace, while only utilizing the short Service name, by entering:</p>
<pre tabindex="0"><code>kubectl exec -n web busybox -- nslookup user-db
</code></pre><p>This first request is supposed to result in an error message, so don&rsquo;t be alarmed if you see that we can&rsquo;t resolve <code>user-db</code>.</p>
</li>
<li>
<p>Save the results of this nslookup in a text file by using:</p>
<pre tabindex="0"><code>kubectl exec -n web busybox -- nslookup user-db &gt;&gt; ~/dns_different_namespace_results.txt
</code></pre></li>
<li>
<p>Perform the same lookup using the fully qualified domain name by entering:</p>
<pre tabindex="0"><code>kubectl exec -n web busybox -- nslookup user-db.data.svc.cluster.local
</code></pre></li>
<li>
<p>Save the results in a text file by using:</p>
<pre tabindex="0"><code>kubectl exec -n web busybox -- nslookup user-db.data.svc.cluster.local &gt;&gt; ~/dns_different_namespace_results.txt
</code></pre></li>
<li>
<p>Check the output in the text file by using:</p>
<pre tabindex="0"><code>cat ~/dns_different_namespace_results.txt
</code></pre></li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 16</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_16/</link>
      <pubDate>Wed, 29 Sep 2021 21:03:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_16/</guid>
      <description>Exposing Kubernetes Pods Using Services Introduction Kubernetes Services are a great way to combine Kubernetes networking with the dynamic and often automated nature of Kubernetes applications. In this lab, you will use Services to expose existing Kubernetes Pods. This will allow you to practice your skills with Kubernetes Services.
Solution Log in to the server using the credentials provided:
ssh cloud_user@&amp;lt;PUBLIC_IP_ADDRESS&amp;gt; Expose the Pods from the User-db Deployment as an Internal Service Examine the properties of the user-db deployment by using kubectl get deployment user-db -o yaml.</description>
      <content:encoded><![CDATA[<h1 id="exposing-kubernetes-pods-using-services">Exposing Kubernetes Pods Using Services</h1>
<h2 id="introduction">Introduction</h2>
<p>Kubernetes Services are a great way to combine Kubernetes networking with the dynamic and often automated nature of Kubernetes applications. In this lab, you will use Services to expose existing Kubernetes Pods. This will allow you to practice your skills with Kubernetes Services.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="expose-the-pods-from-the-user-db-deployment-as-an-internal-service">Expose the Pods from the User-db Deployment as an Internal Service</h3>
<ol>
<li>
<p>Examine the properties of the <code>user-db</code> deployment by using <code>kubectl get deployment user-db -o yaml</code>.</p>
</li>
<li>
<p>In the deployment properties, find the spec and look for the Pod template, paying particular attention to the labels, especially the label <code>app: user-db</code>.</p>
</li>
<li>
<p>Take note of which port(s) are exposed.</p>
</li>
<li>
<p>Start creating a Service that will expose its Pods to other components within the cluster by using <code>vi user-db-svc.yml</code>.</p>
</li>
<li>
<p>Define the Service by using:</p>
<pre tabindex="0"><code>apiVersion: v1 
kind: Service 
metadata: 
  name: user-db-svc 
spec: 
  type: ClusterIP 
  selector: 
    app: user-db 
  ports: 
  - protocol: TCP 
    port: 80 
    targetPort: 80
</code></pre></li>
<li>
<p>Save and exit the file by hitting the ESC key and using <code>:wq</code>.</p>
</li>
<li>
<p>Finish creating the Service by using <code>kubectl create -f user-db-svc.yml</code>.</p>
</li>
<li>
<p>Test the Service to make sure it works by using <code>kubectl exec busybox -- curl user-db-svc</code>. It may not work right away, so you may need to wait a few minutes and try again, but you should be able to see the Nginx welcome page.</p>
</li>
</ol>
<h3 id="expose-the-pods-from-the-web-frontend-deployment-as-an-external-service">Expose the Pods from the Web-frontend Deployment as an External Service</h3>
<ol>
<li>
<p>Now, examine the properties of the frontend deployment by using <code>kubectl get deployment web-frontend -o yaml</code>.</p>
</li>
<li>
<p>Check the labels applied to the Pod template. You should see the label <code>app=web-frontend</code>.</p>
</li>
<li>
<p>Take note of which port(s) are exposed.</p>
</li>
<li>
<p>Start creating a Service that will expose its Pods on port 30080 of each cluster node by using <code>vi web-frontend-svc.yml</code>.</p>
</li>
<li>
<p>Define the Service by using:</p>
<pre tabindex="0"><code>apiVersion: v1 
kind: Service 
metadata: 
  name: web-frontend-svc 
spec: 
  type: NodePort 
  selector: 
    app: web-frontend 
  ports: 
  - protocol: TCP 
    port: 80 
    targetPort: 80 
    nodePort: 30080
</code></pre></li>
<li>
<ol>
<li>Save and exit the file by hitting the ESC key and using <code>:wq</code>.</li>
</ol>
</li>
<li>
<p>Finish creating the Service by using <code>kubectl create -f web-frontend-svc.yml</code>.</p>
</li>
<li>
<p>Test the Service from outside the cluster (such as in a browser) by navigating to <code>http://&lt;PUBLIC_IP_ADDRESS&gt;:30080</code>.</p>
</li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 15</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_15/</link>
      <pubDate>Wed, 29 Sep 2021 16:02:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_15/</guid>
      <description>Exploring Kubernetes Networking Introduction Kubernetes networking is a deep and varied subject. In this lab, you will test your knowledge of Kubernetes networking by implementing a networking solution. You will also verify two pods can communicate with one another via your virtual container network.
Solution Log in to the lab server using the credentials provided:
ssh cloud_user@&amp;lt;PUBLIC_IP_ADDRESS&amp;gt; Fix the Issue Causing Pods Not to Start Up List the pods to check their status:</description>
      <content:encoded><![CDATA[<h1 id="exploring-kubernetes-networking">Exploring Kubernetes Networking</h1>
<h2 id="introduction">Introduction</h2>
<p>Kubernetes networking is a deep and varied subject. In this lab, you will test your knowledge of Kubernetes networking by implementing a networking solution. You will also verify two pods can communicate with one another via your virtual container network.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the lab server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="fix-the-issue-causing-pods-not-to-start-up">Fix the Issue Causing Pods Not to Start Up</h3>
<ol>
<li>
<p>List the pods to check their status:</p>
<pre tabindex="0"><code>kubectl get pods
</code></pre></li>
<li>
<p>Check the node status:</p>
<pre tabindex="0"><code>kubectl get nodes
</code></pre><p>It looks like the nodes are <code>NotReady</code>.</p>
</li>
<li>
<p>Describe a node to see if you can get more info:</p>
<pre tabindex="0"><code>kubectl describe node k8s-worker1
</code></pre><p>It looks like <code>kube-proxy</code>, a component that handles networking-related tasks, is stuck starting up.</p>
</li>
<li>
<p>Check the status of the networking plugin pods:</p>
<pre tabindex="0"><code>kubectl get pods -n kube-system
</code></pre><p>The networking pods seem to be missing. Most likely, a networking plugin was never installed.</p>
</li>
<li>
<p>Install the Calico networking plugin:</p>
<pre tabindex="0"><code>kubectl apply -f https://docs.projectcalico.org/v3.14/manifests/calico.yaml
</code></pre></li>
<li>
<p>Check the status of the Nodes and Pods again:</p>
<pre tabindex="0"><code>kubectl get nodes
</code></pre><p>They should both be <code>Ready</code> after about a minute.</p>
<pre tabindex="0"><code>kubectl get pods
</code></pre></li>
</ol>
<h3 id="verify-you-can-communicate-between-pods-using-the-cluster-network">Verify You Can Communicate between Pods Using the Cluster Network</h3>
<ol>
<li>
<p>Verify the two pods can communicate over the network:</p>
<pre tabindex="0"><code>kubectl get pods -o wide
</code></pre></li>
<li>
<p>Run <code>curl</code> on the IP address of the <code>cyberdyne-frontend</code> Pod (which will be listed in the output from the previous command):</p>
<pre tabindex="0"><code>kubectl exec testclient -- curl &lt;cyberdyne-frontend_POD_IP&gt;
</code></pre><p>The result should be HTML of an Nginx page, meaning the Pods are able to communicate.</p>
</li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 14</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_14/</link>
      <pubDate>Wed, 29 Sep 2021 15:32:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_14/</guid>
      <description>Managing Kubernetes Applications with Deployments Introduction Deployments offer a wide range of features for automating application management. In this lab, you will put your knowledge of deployments to the test. You will use an existing deployment to scale an application, as well as perform a rolling update.
Solution Log in to the Control Plane Node server using the credentials provided:
ssh cloud_user@&amp;lt;PUBLIC_IP_ADDRESS&amp;gt; Update the App to a New Version of the Code Edit the beebox-web deployment:</description>
      <content:encoded><![CDATA[<h1 id="managing-kubernetes-applications-with-deployments">Managing Kubernetes Applications with Deployments</h1>
<h2 id="introduction">Introduction</h2>
<p>Deployments offer a wide range of features for automating application management. In this lab, you will put your knowledge of deployments to the test. You will use an existing deployment to scale an application, as well as perform a rolling update.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the Control Plane Node server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="update-the-app-to-a-new-version-of-the-code">Update the App to a New Version of the Code</h3>
<ol>
<li>
<p>Edit the <code>beebox-web</code> deployment:</p>
<pre tabindex="0"><code>kubectl edit deployment beebox-web
</code></pre></li>
<li>
<p>Locate the Pod&rsquo;s container specification, and change the <code>1.0.1</code> image version tag to <code>1.0.2</code>:</p>
<pre tabindex="0"><code>...

spec:
  containers:
  - image: acgorg/beebox-web:1.0.2
    imagePullPolicy: IfNotPresent
    name: web-server

...
</code></pre></li>
<li>
<p>Save and exit the file by pressing <strong>Escape</strong> followed by <code>:wq</code>.</p>
</li>
<li>
<p>Check the status of your deployment to watch the rolling update occur:</p>
<pre tabindex="0"><code>kubectl rollout status deployment.v1.apps/beebox-web
</code></pre></li>
</ol>
<h3 id="scale-the-app-to-a-larger-number-of-replicas">Scale the App to a Larger Number of Replicas</h3>
<ol>
<li>
<p>Scale the deployment to <code>5</code> replicas:</p>
<pre tabindex="0"><code>kubectl scale deployment.v1.apps/beebox-web --replicas=5
</code></pre></li>
<li>
<p>View the deployment to watch it scale up:</p>
<pre tabindex="0"><code>kubectl get deployment beebox-web
</code></pre></li>
<li>
<p>View the Pods:</p>
<pre tabindex="0"><code>kubectl get pods
</code></pre></li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 13</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_13/</link>
      <pubDate>Tue, 28 Sep 2021 23:05:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_13/</guid>
      <description>Using Static Pods in Kubernetes Introduction Static pods are a great way to run a pod on a single node without the involvement of the Kubernetes control plane. In this lab, you will have a chance to exercise your knowledge of static pods by creating them in an existing cluster.
Create a Manifest for a Static Pod Log in to the Worker Node 1 server:
ssh cloud_user@&amp;lt;PUBLIC_IP_ADDRESS&amp;gt; Create a static pod manifest file:</description>
      <content:encoded><![CDATA[<h1 id="using-static-pods-in-kubernetes">Using Static Pods in Kubernetes</h1>
<h2 id="introduction">Introduction</h2>
<p>Static pods are a great way to run a pod on a single node without the involvement of the Kubernetes control plane. In this lab, you will have a chance to exercise your knowledge of static pods by creating them in an existing cluster.</p>
<h3 id="create-a-manifest-for-a-static-pod">Create a Manifest for a Static Pod</h3>
<ol>
<li>
<p>Log in to the <code>Worker Node 1</code> server:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre></li>
<li>
<p>Create a static pod manifest file:</p>
<pre tabindex="0"><code>[cloud_user@k8s-worker1]$ sudo vi /etc/kubernetes/manifests/beebox-diagnostic.yml
</code></pre></li>
<li>
<p>Add the following into the file:</p>
<pre tabindex="0"><code>apiVersion: v1
kind: Pod
metadata:
  name: beebox-diagnostic
spec:
  containers:
  - name: beebox-diagnostic
    image: acgorg/beebox-diagnostic:1
    ports:
    - containerPort: 80
</code></pre></li>
<li>
<p>Save and exit the file by pressing <strong>Escape</strong> followed by <code>:wq</code>.</p>
</li>
</ol>
<h3 id="start-up-the-static-pod">Start Up the Static Pod</h3>
<ol>
<li>
<p>Restart kubelet to start the static pod:</p>
<pre tabindex="0"><code>[cloud_user@k8s-worker1]$ sudo systemctl restart kubelet
</code></pre></li>
<li>
<p>In a new terminal session, log in to the <code>Control Plane Node</code> server:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre></li>
<li>
<p>Check the status of your static Pod:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]]$ kubectl get pods
</code></pre></li>
<li>
<p>Attempt to delete the static Pod using the k8s API:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]]$ kubectl delete pod beebox-diagnostic-k8s-worker1
</code></pre></li>
<li>
<p>Check the status of the Pod:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]]$ kubectl get pods
</code></pre><p>We&rsquo;ll see the Pod was immediately re-created, since it is only a mirror Pod created by the worker kubelet to represent the static Pod.</p>
</li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 12</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_12/</link>
      <pubDate>Tue, 28 Sep 2021 22:45:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_12/</guid>
      <description>Using DaemonSets in Kubernetes Introduction DaemonSets are a great way to ensure a pod replica runs dynamically on each node. They even automatically handle the creation and removal of such pods when nodes join or leave the cluster. In this lab, you will have the opportunity to practice your skills with DaemonSets by using them to run pods on all nodes in an existing cluster.
Solution Log in to the lab server using the credentials provided:</description>
      <content:encoded><![CDATA[<h1 id="using-daemonsets-in-kubernetes">Using DaemonSets in Kubernetes</h1>
<h2 id="introduction">Introduction</h2>
<p>DaemonSets are a great way to ensure a pod replica runs dynamically on each node. They even automatically handle the creation and removal of such pods when nodes join or leave the cluster. In this lab, you will have the opportunity to practice your skills with DaemonSets by using them to run pods on all nodes in an existing cluster.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the lab server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="create-a-daemonset-specification-yaml-file">Create a DaemonSet Specification YAML File</h3>
<ol>
<li>
<p>Create a DaemonSet descriptor:</p>
<pre tabindex="0"><code>vi daemonset.yml
</code></pre></li>
<li>
<p>Add the following to the file:</p>
<pre tabindex="0"><code>apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: beebox-cleanup
spec:
  selector:
    matchLabels:
      app: beebox-cleanup
  template:
    metadata:
      labels:
        app: beebox-cleanup
    spec:
      containers:
      - name: busybox
        image: busybox:1.27
        command: [&#39;sh&#39;, &#39;-c&#39;, &#39;while true; do rm -rf /beebox-temp/*; sleep 60; done&#39;]
        volumeMounts:
        - name: beebox-tmp
          mountPath: /beebox-temp
      volumes:
      - name: beebox-tmp
        hostPath:
          path: /etc/beebox/tmp
</code></pre></li>
<li>
<p>Save and exit the file by pressing <strong>Escape</strong> followed by <code>:wq</code>.</p>
</li>
</ol>
<h3 id="create-the-daemonset-in-the-cluster">Create the DaemonSet in the Cluster</h3>
<ol>
<li>
<p>Create the DaemonSet in the cluster:</p>
<pre tabindex="0"><code>kubectl apply -f daemonset.yml
</code></pre></li>
<li>
<p>Get a list of pods, and verify a DaemonSet pod is running on each worker node:</p>
<pre tabindex="0"><code>kubectl get pods -o wide
</code></pre></li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 11</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_11/</link>
      <pubDate>Tue, 28 Sep 2021 22:27:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_11/</guid>
      <description>Assigning a Kubernetes Pod to a Specific Node Introduction Kubernetes scheduling usually doesn&amp;rsquo;t need much help in order to determine which node to run a pod on. However, you may occasionally wish to have a little more control. In this lab, you will be able to practice the process of ensuring a pod runs on a specific node.
Solution Log in to the lab server using the credentials provided:
ssh cloud_user@&amp;lt;PUBLIC_IP_ADDRESS&amp;gt; Configure the auth-gateway Pod to Only Run on k8s-worker2 Attach a label to k8s-worker2.</description>
      <content:encoded><![CDATA[<h1 id="assigning-a-kubernetes-pod-to-a-specific-node">Assigning a Kubernetes Pod to a Specific Node</h1>
<h2 id="introduction">Introduction</h2>
<p>Kubernetes scheduling usually doesn&rsquo;t need much help in order to determine which node to run a pod on. However, you may occasionally wish to have a little more control. In this lab, you will be able to practice the process of ensuring a pod runs on a specific node.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the lab server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="configure-the-auth-gateway-pod-to-only-run-on-k8s-worker2">Configure the <code>auth-gateway</code> Pod to Only Run on <code>k8s-worker2</code></h3>
<ol>
<li>
<p>Attach a label to <code>k8s-worker2</code>.</p>
<pre tabindex="0"><code>kubectl label nodes k8s-worker2 external-auth-services=true
</code></pre></li>
<li>
<p>Open <code>auth-gateway.yml</code>:</p>
<pre tabindex="0"><code>vi auth-gateway.yml
</code></pre></li>
<li>
<p>Add a <code>nodeSelector</code> to the <code>auth-gateway</code> pod descriptor:</p>
<pre tabindex="0"><code>...

spec:
  nodeSelector:
    external-auth-services: &#34;true&#34;

  ...
</code></pre></li>
<li>
<p>Save and exit the file by pressing <strong>Escape</strong> followed by <code>:wq</code>.</p>
</li>
<li>
<p>Delete and re-create the pod:</p>
<pre tabindex="0"><code>kubectl delete pod auth-gateway -n beebox-auth
</code></pre><pre tabindex="0"><code>kubectl create -f auth-gateway.yml
</code></pre></li>
<li>
<p>Verify the pod is scheduled on the <code>k8s-worker2</code> node:</p>
<pre tabindex="0"><code>kubectl get pod auth-gateway -n beebox-auth -o wide
</code></pre></li>
</ol>
<h3 id="configure-the-auth-data-deployments-replica-pods-to-only-run-on-k8s-worker2">Configure the <code>auth-data</code> Deployment&rsquo;s Replica Pods to Only Run on <code>k8s-worker2</code></h3>
<ol>
<li>
<p>Open <code>auth-data.yml</code>:</p>
<pre tabindex="0"><code>vi auth-data.yml
</code></pre></li>
<li>
<p>Add a nodeSelector to the pod template in the deployment spec (it will be the second <code>spec</code> in the file):</p>
<pre tabindex="0"><code>...

spec:

  ...

  template:

    ...

    spec:
      nodeSelector:
        external-auth-services: &#34;true&#34;

      ...
</code></pre></li>
<li>
<p>Save and exit the file by pressing <strong>Escape</strong> followed by <code>:wq</code>.</p>
</li>
<li>
<p>Update the deployment:</p>
<pre tabindex="0"><code>kubectl apply -f auth-data.yml
</code></pre></li>
<li>
<p>Verify the deployment&rsquo;s replicas are all running on <code>k8s-worker2</code>:</p>
<pre tabindex="0"><code>kubectl get pods -n beebox-auth -o wide
</code></pre></li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 10</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_10/</link>
      <pubDate>Tue, 28 Sep 2021 21:09:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_10/</guid>
      <description>Using Init Containers in Kubernetes Introduction Init containers are a great way to customize container startup. This lab will allow you to test your knowledge of init containers by using them to solve problems in an existing Kubernetes cluster.
Solution Log in to the provided lab server using the credentials provided:
ssh cloud_user@&amp;lt;PUBLIC_IP_ADDRESS&amp;gt; Create a Sample Pod That Uses an Init Container to Delay Startup Open the pod descriptor file:</description>
      <content:encoded><![CDATA[<h1 id="using-init-containers-in-kubernetes">Using Init Containers in Kubernetes</h1>
<h2 id="introduction">Introduction</h2>
<p>Init containers are a great way to customize container startup. This lab will allow you to test your knowledge of init containers by using them to solve problems in an existing Kubernetes cluster.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the provided lab server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="create-a-sample-pod-that-uses-an-init-container-to-delay-startup">Create a Sample Pod That Uses an Init Container to Delay Startup</h3>
<ol>
<li>
<p>Open the pod descriptor file:</p>
<pre tabindex="0"><code>vi pod.yml
</code></pre></li>
<li>
<p>Add an init container (at the same level as <code>containers</code> in the file) to delay startup until the <code>shipping-svc</code> service is available:</p>
<pre tabindex="0"><code>spec:
  ...
  initContainers:
  - name: shipping-svc-check
    image: busybox:1.27
    command: [&#39;sh&#39;, &#39;-c&#39;, &#39;until nslookup shipping-svc; do echo waiting for shipping-svc; sleep 2; done&#39;]
</code></pre></li>
<li>
<p>Save and exit the file by pressing <strong>Escape</strong> followed by <code>:wq</code>.</p>
</li>
<li>
<p>Create the pod:</p>
<pre tabindex="0"><code>kubectl create -f pod.yml
</code></pre></li>
<li>
<p>Check the status of the pod:</p>
<pre tabindex="0"><code>kubectl get pods
</code></pre><p>It should remain in the <code>Init</code> status.</p>
</li>
</ol>
<h3 id="test-your-setup-by-creating-the-service-and-verifying-the-pod-starts-up">Test Your Setup by Creating the Service and Verifying the Pod Starts Up</h3>
<ol>
<li>
<p>Create the service from the <code>shipping-svc.yml</code> file:</p>
<pre tabindex="0"><code>kubectl create -f shipping-svc.yml
</code></pre></li>
<li>
<p>Check the status of your pod again:</p>
<pre tabindex="0"><code>kubectl get pods
</code></pre><p>It should enter the <code>Running</code> status after about a minute.</p>
</li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 9</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_9/</link>
      <pubDate>Tue, 28 Sep 2021 17:21:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_9/</guid>
      <description>Building Self-Healing Containers in Kubernetes Introduction Kubernetes offers several features that can be used together to create self-healing applications in a variety of scenarios. In this lab, you will be able to practice your skills at using features such as probes and restart policies to create a container application that is automatically healed when it stops working.
Solution Log in to the provided lab server using the credentials provided:
ssh cloud_user@&amp;lt;PUBLIC_IP_ADDRESS&amp;gt; Set a Restart Policy to Restart the Container When It Is Down Find the pod that needs to be modified:</description>
      <content:encoded><![CDATA[<h1 id="building-self-healing-containers-in-kubernetes">Building Self-Healing Containers in Kubernetes</h1>
<h2 id="introduction">Introduction</h2>
<p>Kubernetes offers several features that can be used together to create self-healing applications in a variety of scenarios. In this lab, you will be able to practice your skills at using features such as probes and restart policies to create a container application that is automatically healed when it stops working.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the provided lab server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="set-a-restart-policy-to-restart-the-container-when-it-is-down">Set a Restart Policy to Restart the Container When It Is Down</h3>
<ol>
<li>
<p>Find the pod that needs to be modified:</p>
<pre tabindex="0"><code>kubectl get pods -o wide
</code></pre></li>
<li>
<p>Take note of the <code>beebox-shipping-data</code> pod&rsquo;s IP address.</p>
</li>
<li>
<p>Use the <code>busybox</code> pod to make a request to the pod to see if it is working:</p>
<pre tabindex="0"><code>kubectl exec busybox -- curl &lt;beebox-shipping-data_ IP&gt;:8080
</code></pre><p>We will likely get an error message.</p>
</li>
<li>
<p>Get the pod&rsquo;s YAML descriptor:</p>
<pre tabindex="0"><code>  kubectl get pod beebox-shipping-data -o yaml &gt; beebox-shipping-data.yml
</code></pre></li>
<li>
<p>Open the file:</p>
<pre tabindex="0"><code>vi beebox-shipping-data.yml
</code></pre></li>
<li>
<p>Set the <code>restartPolicy</code> to <code>Always</code>:</p>
<pre tabindex="0"><code>spec:
  ...
  restartPolicy: Always
  ...
</code></pre></li>
</ol>
<h3 id="create-a-liveness-probe-to-detect-when-the-application-has-crashed">Create a Liveness Probe to Detect When the Application Has Crashed</h3>
<ol>
<li>
<p>Add a liveness probe:</p>
<pre tabindex="0"><code>spec:
  containers:
  - ...
    name: shipping-data
    livenessProbe:
      httpGet:
        path: /
        port: 8080
      initialDelaySeconds: 5
      periodSeconds: 5
    ...
</code></pre></li>
<li>
<p>Save and exit the file by pressing <strong>Escape</strong> followed by <code>:wq</code>.</p>
</li>
<li>
<p>Delete the pod:</p>
<pre tabindex="0"><code>kubectl delete pod beebox-shipping-data
</code></pre></li>
<li>
<p>Re-create the pod to apply the changes:</p>
<pre tabindex="0"><code>kubectl apply -f beebox-shipping-data.yml
</code></pre></li>
<li>
<p>Check the pod status</p>
<pre tabindex="0"><code>kubectl get pods -o wide
</code></pre></li>
<li>
<p>If you wait a minute or so and check again, you should see the pod is being restarted whenever the application crashes.</p>
</li>
<li>
<p>Check the http response from the pod again (it will have a new IP address since we re-created it):</p>
<pre tabindex="0"><code>kubectl exec busybox -- curl &lt;beebox-shipping-data_IP&gt;:8080
</code></pre><p>If you wish, you can explore and see what happens as the application crashes and the pod is restarted automatically.</p>
</li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 8</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_8/</link>
      <pubDate>Mon, 13 Sep 2021 22:42:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_8/</guid>
      <description>Passing Configuration Data to a Kubernetes Container Introduction Kubernetes has multiple options for storing and managing configuration data. This lab will focus on the process of passing that configuration data to your containers in order to configure applications. You will have the opportunity to work with application configuration in Kubernetes hands-on by passing some existing configuration data stored in Secrets and ConfigMaps to a container.
Solution Log in to the provided lab server using the credentials provided:</description>
      <content:encoded><![CDATA[<h1 id="passing-configuration-data-to-a-kubernetes-container">Passing Configuration Data to a Kubernetes Container</h1>
<h2 id="introduction">Introduction</h2>
<p>Kubernetes has multiple options for storing and managing configuration data. This lab will focus on the process of passing that configuration data to your containers in order to configure applications. You will have the opportunity to work with application configuration in Kubernetes hands-on by passing some existing configuration data stored in Secrets and ConfigMaps to a container.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the provided lab server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="generate-an-htpasswd-file-and-store-it-as-a-secret">Generate an <code>htpasswd</code> File and Store It as a Secret</h3>
<ol>
<li>
<p>Generate an <code>htpasswd</code> file:</p>
<pre tabindex="0"><code>htpasswd -c .htpasswd user
</code></pre></li>
<li>
<p>Create a password you can easily remember (we&rsquo;ll need it again later).</p>
</li>
<li>
<p>View the file&rsquo;s contents:</p>
<pre tabindex="0"><code>cat .htpasswd
</code></pre></li>
<li>
<p>Create a Secret containing the <code>htpasswd</code> data:</p>
<pre tabindex="0"><code>kubectl create secret generic nginx-htpasswd --from-file .htpasswd
</code></pre></li>
<li>
<p>Delete the <code>.htpasswd</code> file:</p>
<pre tabindex="0"><code>rm .htpasswd
</code></pre></li>
</ol>
<h3 id="create-the-nginx-pod">Create the Nginx Pod</h3>
<ol>
<li>
<p>Create <code>pod.yml</code>:</p>
<pre tabindex="0"><code>vi pod.yml
</code></pre></li>
<li>
<p>Set vi to &lsquo;paste&rsquo; mode by hitting <code>:</code>, and then typing <code>set paste</code> (ENTER). Then switch back to INSERT mode by hitting <code>i</code>.</p>
</li>
<li>
<p>Enter the following to create the pod and mount the Nginx config and <code>htpasswd</code> Secret data:</p>
<pre tabindex="0"><code>apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.19.1
    ports:
    - containerPort: 80
    volumeMounts:
    - name: config-volume
      mountPath: /etc/nginx
    - name: htpasswd-volume
      mountPath: /etc/nginx/conf
  volumes:
  - name: config-volume
    configMap:
      name: nginx-config
  - name: htpasswd-volume
    secret:
      secretName: nginx-htpasswd
</code></pre></li>
<li>
<p>Save and exit the file by pressing <strong>Escape</strong> followed by <code>:wq</code>.</p>
</li>
<li>
<p>View the existing ConfigMap:</p>
<pre tabindex="0"><code>kubectl get cm
</code></pre></li>
<li>
<p>Get more info about <code>nginx-config</code>:</p>
<pre tabindex="0"><code>kubectl describe cm nginx-config
</code></pre></li>
<li>
<p>Create the pod:</p>
<pre tabindex="0"><code>kubectl apply -f pod.yml
</code></pre></li>
<li>
<p>Check the status of your pod and get its IP address:</p>
<pre tabindex="0"><code>kubectl get pods -o wide
</code></pre><p>Its IP address will be listed once it has a <code>Running</code> status. We&rsquo;ll use this in the final two commands.</p>
</li>
<li>
<p>Within the existing <code>busybox</code> pod, without using credentials, verify everything is working:</p>
<pre tabindex="0"><code>kubectl exec busybox -- curl &lt;NGINX_POD_IP&gt;
</code></pre><p>We&rsquo;ll see HTML for the <code>401 Authorization Required</code> page — but this is a good thing, as it means our setup is working as expected.</p>
</li>
<li>
<p>Run the same command again using credentials (including the password you created at the beginning of the lab) to verify everything is working:</p>
<pre tabindex="0"><code>kubectl exec busybox -- curl -u user:&lt;PASSWORD&gt; &lt;NGINX_POD_IP&gt;
</code></pre><p>This time, we&rsquo;ll see the <code>Welcome to nginx!</code> page HTML.</p>
</li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 7</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_7/</link>
      <pubDate>Mon, 13 Sep 2021 21:54:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_7/</guid>
      <description>Discovering Pod Resource Usage with Kubernetes Metrics Introduction Kubernetes metrics allow you to gain insight into a wide variety of data about your Kubernetes applications. You can use these metrics to gain insight into how your compute resources are being used. In this lab, you will have the opportunity to hone your skills by investigating existing pods running in a Kubernetes cluster to determine which ones are using the most CPU.</description>
      <content:encoded><![CDATA[<h1 id="discovering-pod-resource-usage-with-kubernetes-metrics">Discovering Pod Resource Usage with Kubernetes Metrics</h1>
<h2 id="introduction">Introduction</h2>
<p>Kubernetes metrics allow you to gain insight into a wide variety of data about your Kubernetes applications. You can use these metrics to gain insight into how your compute resources are being used. In this lab, you will have the opportunity to hone your skills by investigating existing pods running in a Kubernetes cluster to determine which ones are using the most CPU.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the lab server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="install-kubernetes-metrics-server">Install Kubernetes Metrics Server</h3>
<ol>
<li>
<p>Install Kubernetes Metrics Server:</p>
<pre tabindex="0"><code>kubectl apply -f https://raw.githubusercontent.com/linuxacademy/content-cka-resources/master/metrics-server-components.yaml
</code></pre></li>
<li>
<p>Verify Metrics Server is responsive:</p>
<pre tabindex="0"><code>kubectl get --raw /apis/metrics.k8s.io/
</code></pre><p>It may take a few minutes for Metrics Server to become responsive to requests.</p>
</li>
</ol>
<h3 id="locate-the-cpu-using-pod-and-write-its-name-to-a-file">Locate the CPU-Using Pod and Write Its Name to a File</h3>
<ol>
<li>
<p>In the <code>beebox-mobile</code> namespace, determine which pod with the label <code>app=auth</code> is using the most CPU:</p>
<pre tabindex="0"><code>kubectl top pod -n beebox-mobile --sort-by cpu --selector app=auth
</code></pre><p>If you get an error message saying metrics are not available, wait a few minutes and then run the command again.</p>
</li>
<li>
<p>Write the name of the pod to a file:</p>
<pre tabindex="0"><code>echo auth-proc &gt; /home/cloud_user/cpu-pod-name.txt
</code></pre></li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 6</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_6/</link>
      <pubDate>Mon, 30 Aug 2021 12:34:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_6/</guid>
      <description>Controlling Access in Kubernetes with RBAC Introduction Role-based access control is an important component when it comes to managing a Kubernetes cluster securely. The more users and automated processes there are that need to interface with the Kubernetes API, the more important controlling access becomes. In this lab, you will have the opportunity to practice your skills with the Kubernetes RBAC system by implementing your own RBAC permissions to appropriately limit user access.</description>
      <content:encoded><![CDATA[<h1 id="controlling-access-in-kubernetes-with-rbac">Controlling Access in Kubernetes with RBAC</h1>
<h2 id="introduction">Introduction</h2>
<p>Role-based access control is an important component when it comes to managing a Kubernetes cluster securely. The more users and automated processes there are that need to interface with the Kubernetes API, the more important controlling access becomes. In this lab, you will have the opportunity to practice your skills with the Kubernetes RBAC system by implementing your own RBAC permissions to appropriately limit user access.</p>
<h2 id="solution">Solution</h2>
<ol start="4">
<li>
<p>Log in to the lab server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><p><strong>Note:</strong> <em>When copying and pasting code into Vim from the lab guide, first enter <code>:set paste</code> (and then <code>i</code> to enter insert mode) to avoid adding unnecessary spaces and hashes.</em></p>
</li>
</ol>
<h3 id="create-a-role-for-the-dev-user">Create a Role for the <code>dev</code> User</h3>
<ol>
<li>
<p>Test access by attempting to list pods as the <code>dev</code> user:</p>
<pre tabindex="0"><code>kubectl get pods -n beebox-mobile --kubeconfig dev-k8s-config
</code></pre><p>We&rsquo;ll get an error message.</p>
</li>
<li>
<p>Create a role spec file:</p>
<pre tabindex="0"><code>vi pod-reader-role.yml
</code></pre></li>
<li>
<p>Add the following to the file:</p>
<pre tabindex="0"><code>apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: beebox-mobile
  name: pod-reader
rules:
- apiGroups: [&#34;&#34;]
  resources: [&#34;pods&#34;, &#34;pods/log&#34;]
  verbs: [&#34;get&#34;, &#34;watch&#34;, &#34;list&#34;]
</code></pre></li>
<li>
<p>Save and exit the file by pressing <strong>Escape</strong> followed by <code>:wq</code>.</p>
</li>
<li>
<p>Create the role:</p>
<pre tabindex="0"><code>kubectl apply -f pod-reader-role.yml
</code></pre></li>
</ol>
<h3 id="bind-the-role-to-the-dev-user-and-verify-your-setup-works">Bind the Role to the <code>dev</code> User and Verify Your Setup Works</h3>
<ol>
<li>
<p>Create the RoleBinding spec file:</p>
<pre tabindex="0"><code>vi pod-reader-rolebinding.yml
</code></pre></li>
<li>
<p>Add the following to the file:</p>
<pre tabindex="0"><code>apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: pod-reader
  namespace: beebox-mobile
subjects:
- kind: User
  name: dev
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: pod-reader
  apiGroup: rbac.authorization.k8s.io
</code></pre></li>
<li>
<p>Save and exit the file by pressing <strong>Escape</strong> followed by <code>:wq</code>.</p>
</li>
<li>
<p>Create the RoleBinding:</p>
<pre tabindex="0"><code>kubectl apply -f pod-reader-rolebinding.yml
</code></pre></li>
<li>
<p>Test access again to verify you can successfully list pods:</p>
<pre tabindex="0"><code>kubectl get pods -n beebox-mobile --kubeconfig dev-k8s-config
</code></pre><p>This time, we should see a list of pods (there&rsquo;s just one).</p>
</li>
<li>
<p>Verify the <code>dev</code> user can read pod logs:</p>
<pre tabindex="0"><code>kubectl logs beebox-auth -n beebox-mobile --kubeconfig dev-k8s-config
</code></pre><p>We&rsquo;ll get an <code>Auth processing...</code> message.</p>
</li>
<li>
<p>Verify the <code>dev</code> user cannot make changes by attempting to delete a pod:</p>
<pre tabindex="0"><code>kubectl delete pod beebox-auth -n beebox-mobile --kubeconfig dev-k8s-config
</code></pre><p>We&rsquo;ll get an error, which is what we want.</p>
</li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 5</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_5/</link>
      <pubDate>Sat, 28 Aug 2021 21:42:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_5/</guid>
      <description>Backing up and Restoring Kubernetes Data in etcd Introduction Backups are an important part of any resilient system. Kubernetes is no exception. In this lab, you will have the opportunity to practice your skills by backing up and restoring a Kubernetes cluster state stored in etcd. This will help you get comfortable with the steps involved in backing up Kubernetes data.
Solution Log in to the provided lab server using the credentials provided:</description>
      <content:encoded><![CDATA[<h1 id="backing-up-and-restoring-kubernetes-data-in-etcd">Backing up and Restoring Kubernetes Data in etcd</h1>
<h2 id="introduction">Introduction</h2>
<p>Backups are an important part of any resilient system. Kubernetes is no exception. In this lab, you will have the opportunity to practice your skills by backing up and restoring a Kubernetes cluster state stored in etcd. This will help you get comfortable with the steps involved in backing up Kubernetes data.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the provided lab server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="back-up-the-etcd-data">Back Up the etcd Data</h3>
<ol>
<li>
<p>Look up the value for the key <code>cluster.name</code> in the etcd cluster:</p>
<pre tabindex="0"><code>ETCDCTL_API=3 etcdctl get cluster.name \
  --endpoints=https://10.0.1.101:2379 \
  --cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
  --cert=/home/cloud_user/etcd-certs/etcd-server.crt \
  --key=/home/cloud_user/etcd-certs/etcd-server.key
</code></pre><p>The returned value should be <code>beebox</code>.</p>
</li>
<li>
<p>Back up etcd using etcdctl and the provided etcd certificates:</p>
<pre tabindex="0"><code>ETCDCTL_API=3 etcdctl snapshot save /home/cloud_user/etcd_backup.db \
  --endpoints=https://10.0.1.101:2379 \
  --cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
  --cert=/home/cloud_user/etcd-certs/etcd-server.crt \
  --key=/home/cloud_user/etcd-certs/etcd-server.key
</code></pre></li>
<li>
<p>Reset etcd by removing all existing etcd data:</p>
<pre tabindex="0"><code>sudo systemctl stop etcd
</code></pre><pre tabindex="0"><code>sudo rm -rf /var/lib/etcd
</code></pre></li>
</ol>
<h3 id="restore-the-etcd-data-from-the-backup">Restore the etcd Data from the Backup</h3>
<ol>
<li>
<p>Restore the etcd data from the backup (this command spins up a temporary etcd cluster, saving the data from the backup file to a new data directory in the same location where the previous data directory was):</p>
<pre tabindex="0"><code>sudo ETCDCTL_API=3 etcdctl snapshot restore /home/cloud_user/etcd_backup.db \
  --initial-cluster etcd-restore=https://10.0.1.101:2380 \
  --initial-advertise-peer-urls https://10.0.1.101:2380 \
  --name etcd-restore \
  --data-dir /var/lib/etcd
</code></pre></li>
<li>
<p>Set ownership on the new data directory:</p>
<pre tabindex="0"><code>sudo chown -R etcd:etcd /var/lib/etcd
</code></pre></li>
<li>
<p>Start etcd:</p>
<pre tabindex="0"><code>sudo systemctl start etcd
</code></pre></li>
<li>
<p>Verify the restored data is present by looking up the value for the key <code>cluster.name</code> again:</p>
<pre tabindex="0"><code>ETCDCTL_API=3 etcdctl get cluster.name \
  --endpoints=https://10.0.1.101:2379 \
  --cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
  --cert=/home/cloud_user/etcd-certs/etcd-server.crt \
  --key=/home/cloud_user/etcd-certs/etcd-server.key
</code></pre><p>The returned value should be <code>beebox</code>.</p>
</li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 4</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_4/</link>
      <pubDate>Thu, 05 Aug 2021 09:05:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_4/</guid>
      <description>Performing a Kubernetes Upgrade with kubeadm Introduction When you are managing Kubernetes in the real world, it is essential that you are able to keep your cluster up to date. This lab will allow you to practice the process of upgrading a Kubernetes cluster to a newer Kubernetes version using kubeadm. This will ensure you are comfortable with the upgrade process and ready to manage real-world Kubernetes clusters.
Solution Log in to the control plane server using the credentials provided:</description>
      <content:encoded><![CDATA[<h1 id="performing-a-kubernetes-upgrade-with-kubeadm">Performing a Kubernetes Upgrade with kubeadm</h1>
<h2 id="introduction">Introduction</h2>
<p>When you are managing Kubernetes in the real world, it is essential that you are able to keep your cluster up to date. This lab will allow you to practice the process of upgrading a Kubernetes cluster to a newer Kubernetes version using kubeadm. This will ensure you are comfortable with the upgrade process and ready to manage real-world Kubernetes clusters.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the control plane server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;CONTROL_PLANE_SERVER_PUBLIC_IP_ADDRESS&gt;
</code></pre><blockquote>
<p><strong>Note:</strong> We&rsquo;ll be switching between nodes throughout the lab, so be sure to check the Bash prompt for which node to run the commands on.</p>
</blockquote>
<h3 id="upgrade-the-control-plane">Upgrade the Control Plane</h3>
<ol>
<li>
<p>Upgrade kubeadm:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]$ sudo apt-get update &amp;&amp; \
sudo apt-get install -y --allow-change-held-packages kubeadm=1.21.1-00
</code></pre></li>
<li>
<p>Make sure it upgraded correctly:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]$ kubeadm version
</code></pre></li>
<li>
<p>Drain the control plane node:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]$ kubectl drain k8s-control --ignore-daemonsets
</code></pre></li>
<li>
<p>Plan the upgrade:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]$ sudo kubeadm upgrade plan v1.21.1
</code></pre></li>
<li>
<p>Upgrade the control plane components:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]$ sudo kubeadm upgrade apply v1.21.1
</code></pre></li>
<li>
<p>Upgrade kubelet and kubectl on the control plane node:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]$ sudo apt-get update &amp;&amp; \
sudo apt-get install -y --allow-change-held-packages kubelet=1.21.1-00 kubectl=1.21.1-00
</code></pre></li>
<li>
<p>Restart kubelet:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]$ sudo systemctl daemon-reload
</code></pre><pre tabindex="0"><code>[cloud_user@k8s-control]$ sudo systemctl restart kubelet
</code></pre></li>
<li>
<p>Uncordon the control plane node:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]$ kubectl uncordon k8s-control
</code></pre></li>
<li>
<p>Verify the control plane is working:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]$ kubectl get nodes
</code></pre><p>If it shows a <code>NotReady</code> status, run the command again after a minute or so. It should become <code>Ready</code>.</p>
</li>
</ol>
<h3 id="upgrade-the-worker-nodes">Upgrade the Worker Nodes</h3>
<blockquote>
<p><strong>Note:</strong> In a real-world scenario, you should not perform upgrades on all worker nodes at the same time. Make sure enough nodes are available at any given time to provide uninterrupted service.</p>
</blockquote>
<h4 id="worker-node-1">Worker Node 1</h4>
<ol>
<li>
<p>Run the following on the <em>control plane node</em> to drain worker node 1:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]$ kubectl drain k8s-worker1 --ignore-daemonsets --force
</code></pre><p>You may get an error message that certain pods couldn&rsquo;t be deleted, which is fine.</p>
</li>
<li>
<p>In a new terminal window, log in to worker node 1:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;WORKER_1_PUBLIC_IP_ADDRESS&gt;
</code></pre></li>
<li>
<p>Upgrade kubeadm on worker node 1:</p>
<pre tabindex="0"><code>[cloud_user@k8s-worker1]$ sudo apt-get update &amp;&amp; \
sudo apt-get install -y --allow-change-held-packages kubeadm=1.21.1-00
</code></pre><pre tabindex="0"><code>[cloud_user@k8s-worker1]$ kubeadm version
</code></pre></li>
<li>
<p>Back on <em>worker node 1</em>, upgrade the kubelet configuration on the worker node:</p>
<pre tabindex="0"><code>[cloud_user@k8s-worker1]$ sudo kubeadm upgrade node
</code></pre></li>
<li>
<p>Upgrade kubelet and kubectl on worker node 1:</p>
<pre tabindex="0"><code>[cloud_user@k8s-worker1]$ sudo apt-get update &amp;&amp; \
sudo apt-get install -y --allow-change-held-packages kubelet=1.21.1-00 kubectl=1.21.1-00
</code></pre></li>
<li>
<p>Restart kubelet:</p>
<pre tabindex="0"><code>[cloud_user@k8s-worker1]$ sudo systemctl daemon-reload
</code></pre><pre tabindex="0"><code>[cloud_user@k8s-worker1]$ sudo systemctl restart kubelet
</code></pre></li>
<li>
<p>From the <em>control plane node</em>, uncordon worker node 1:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]$ kubectl uncordon k8s-worker1
</code></pre></li>
</ol>
<h4 id="worker-node-2">Worker Node 2</h4>
<ol>
<li>
<p>From the <em>control plane node</em>, drain worker node 2:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]$ kubectl drain k8s-worker2 --ignore-daemonsets --force
</code></pre></li>
<li>
<p>In a new terminal window, log in to worker node 2:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;WORKER_2_PUBLIC_IP_ADDRESS&gt;
</code></pre></li>
<li>
<p>Upgrade kubeadm:</p>
<pre tabindex="0"><code>[cloud_user@k8s-worker2]$ sudo apt-get update &amp;&amp; \
sudo apt-get install -y --allow-change-held-packages kubeadm=1.21.1-00
</code></pre><pre tabindex="0"><code>[cloud_user@k8s-worker2]$ kubeadm version
</code></pre></li>
<li>
<p>Back on <em>worker node 2</em>, perform the upgrade:</p>
<pre tabindex="0"><code>[cloud_user@k8s-worker2]$ sudo kubeadm upgrade node
</code></pre><pre tabindex="0"><code>[cloud_user@k8s-worker2]$ sudo apt-get update &amp;&amp; \
sudo apt-get install -y --allow-change-held-packages kubelet=1.21.1-00 kubectl=1.21.1-00
</code></pre><pre tabindex="0"><code>[cloud_user@k8s-worker2]$ sudo systemctl daemon-reload
</code></pre><pre tabindex="0"><code>[cloud_user@k8s-worker2]$ sudo systemctl restart kubelet
</code></pre></li>
<li>
<p>From the <em>control plane node</em>, uncordon worker node 2:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]$ kubectl uncordon k8s-worker2
</code></pre></li>
<li>
<p>Still in the <em>control plane node</em>, verify the cluster is upgraded and working:</p>
<pre tabindex="0"><code>[cloud_user@k8s-control]$ kubectl get nodes
</code></pre><p>If they show a <code>NotReady</code> status, run the command again after a minute or so. They should become <code>Ready</code>.</p>
</li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 3</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_3/</link>
      <pubDate>Wed, 04 Aug 2021 21:47:47 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_3/</guid>
      <description>Building a Kubernetes 1.21 Cluster with Kubeadm Introduction This lab will allow you to practice the process of building a new Kubernetes cluster. You will be given a set of Linux servers, and you will have the opportunity to turn these servers into a functioning Kubernetes cluster. This will help you build the skills necessary to create your own Kubernetes clusters in the real world.
Solution Log in to the lab server using the credentials provided:</description>
      <content:encoded><![CDATA[<h1 id="building-a-kubernetes-121-cluster-with-kubeadm">Building a Kubernetes 1.21 Cluster with Kubeadm</h1>
<h2 id="introduction">Introduction</h2>
<p>This lab will allow you to practice the process of building a new Kubernetes cluster. You will be given a set of Linux servers, and you will have the opportunity to turn these servers into a functioning Kubernetes cluster. This will help you build the skills necessary to create your own Kubernetes clusters in the real world.</p>
<h2 id="solution">Solution</h2>
<p>Log in to the lab server using the credentials provided:</p>
<pre tabindex="0"><code>ssh cloud_user@&lt;PUBLIC_IP_ADDRESS&gt;
</code></pre><h3 id="install-packages">Install Packages</h3>
<ol>
<li>
<p>Log into the Control Plane Node <em>(Note: The following steps must be performed on all three nodes.).</em></p>
</li>
<li>
<p>Create configuration file for containerd:</p>
<pre tabindex="0"><code>cat &lt;&lt;EOF | sudo tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
EOF
</code></pre></li>
<li>
<p>Load modules:</p>
<pre tabindex="0"><code>sudo modprobe overlay
sudo modprobe br_netfilter
</code></pre></li>
<li>
<p>Set system configurations for Kubernetes networking:</p>
<pre tabindex="0"><code>cat &lt;&lt;EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
</code></pre></li>
<li>
<p>Apply new settings:</p>
<pre tabindex="0"><code>sudo sysctl --system
</code></pre></li>
<li>
<p>Install containerd:</p>
<pre tabindex="0"><code>sudo apt-get update &amp;&amp; sudo apt-get install -y containerd
</code></pre></li>
<li>
<p>Create default configuration file for containerd:</p>
<pre tabindex="0"><code>sudo mkdir -p /etc/containerd
</code></pre></li>
<li>
<p>Generate default containerd configuration and save to the newly created default file:</p>
<pre tabindex="0"><code>sudo containerd config default | sudo tee /etc/containerd/config.toml
</code></pre></li>
<li>
<p>Restart containerd to ensure new configuration file usage:</p>
<pre tabindex="0"><code>sudo systemctl restart containerd
</code></pre></li>
<li>
<p>Verify that containerd is running.</p>
<pre tabindex="0"><code>sudo systemctl status containerd
</code></pre></li>
<li>
<p>Disable swap:</p>
<pre tabindex="0"><code>sudo swapoff -a
</code></pre></li>
<li>
<p>Disable swap on startup in:</p>
<pre tabindex="0"><code>/etc/fstab
</code></pre><pre tabindex="0"><code>sudo sed -i &#39;/ swap / s/^\(.*\)$/#\1/g&#39; /etc/fstab
</code></pre></li>
<li>
<p>Install dependency packages:</p>
<pre tabindex="0"><code>sudo apt-get update &amp;&amp; sudo apt-get install -y apt-transport-https curl
</code></pre></li>
<li>
<p>Download and add GPG key:</p>
<pre tabindex="0"><code>curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
</code></pre></li>
<li>
<p>Add Kubernetes to repository list:</p>
<pre tabindex="0"><code>cat &lt;&lt;EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
</code></pre></li>
<li>
<p>Update package listings:</p>
<pre tabindex="0"><code>sudo apt-get update
</code></pre></li>
<li>
<p>Install Kubernetes packages (Note: If you get a dpkg lock message, just wait a minute or two before trying the command again):</p>
<pre tabindex="0"><code>sudo apt-get install -y kubelet=1.21.0-00 kubeadm=1.21.0-00 kubectl=1.21.0-00
</code></pre></li>
<li>
<p>Turn off automatic updates:</p>
<pre tabindex="0"><code>sudo apt-mark hold kubelet kubeadm kubectl
</code></pre></li>
<li>
<p>Log into both Worker Nodes to perform previous steps.</p>
</li>
</ol>
<h3 id="initialize-the-cluster">Initialize the Cluster</h3>
<ol>
<li>
<p>Initialize the Kubernetes cluster on the control plane node using kubeadm</p>
<p>(Note: This is only performed on the Control Plane Node):</p>
<pre tabindex="0"><code>sudo kubeadm init --pod-network-cidr 192.168.0.0/16 --kubernetes-version 1.21.0
</code></pre></li>
<li>
<p>Set kubectl access:</p>
<pre tabindex="0"><code>mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
</code></pre></li>
<li>
<p>Test access to cluster:</p>
<pre tabindex="0"><code>kubectl get nodes
</code></pre></li>
</ol>
<h3 id="install-the-calico-network-add-on">Install the Calico Network Add-On</h3>
<ol>
<li>
<p>On the Control Plane Node, install Calico Networking:</p>
<pre tabindex="0"><code>kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
</code></pre></li>
<li>
<p>Check status of the control plane node:</p>
<pre tabindex="0"><code>kubectl get nodes
</code></pre></li>
</ol>
<h3 id="join-the-worker-nodes-to-the-cluster">Join the Worker Nodes to the Cluster</h3>
<ol>
<li>
<p>In the Control Plane Node, create the token and copy the kubeadm join command</p>
<p>(NOTE:The join command can also be found in the output from <code>kubeadm init</code> command):</p>
<pre tabindex="0"><code>kubeadm token create --print-join-command
</code></pre></li>
<li>
<p>In both Worker Nodes, paste the kubeadm join command to join the cluster. Use sudo to run it as root:</p>
<pre tabindex="0"><code>sudo kubeadm join ...
</code></pre></li>
<li>
<p>In the Control Plane Node, view cluster status (Note: You may have to wait a few moments to allow all nodes to become ready):</p>
<pre tabindex="0"><code>kubectl get nodes
</code></pre></li>
</ol>
]]></content:encoded>
    </item>
    
    <item>
      <title>CKA Learning path 2</title>
      <link>https://blog.dustbreak.com/posts/cka_learning_2/</link>
      <pubDate>Sun, 11 Apr 2021 16:22:41 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/cka_learning_2/</guid>
      <description>1. Control Plane The control plane is a collection of multiple components responsible for managing the cluster itself globally. Essentially, the control plane controls the cluster.
Individual control plane components can run on any machine in the cluster, but usually are run on dedicated controller machines.</description>
      <content:encoded><![CDATA[<h2 id="1-control-plane">1. Control Plane</h2>
<p>The control plane is a collection of multiple components responsible for managing the cluster itself globally. Essentially, the control plane controls the cluster.</p>
<p>Individual control plane components can run on any machine in the cluster, but usually are run on dedicated controller machines.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>1 - K8S Component tools</title>
      <link>https://blog.dustbreak.com/posts/1-k8s-component-tools/</link>
      <pubDate>Sun, 11 Apr 2021 12:15:41 +0800</pubDate>
      
      <guid>https://blog.dustbreak.com/posts/1-k8s-component-tools/</guid>
      <description>Component tools
1. Etcd A distributed, reliable key-value store for the most critical data of a distributed system
etcd
default port: 2379
./etcdctl set key1 value1 ./etcdctl get key1 Every information you see when you run the kubectl get command is from the Etcd Server.
To list all keys stored by Kubernetes, run the command like this. Run inside the etcd-master POD.
kubectl exec etcd-master -n kube-system etcdctl get / --prefix -keys-only 2.</description>
      <content:encoded><![CDATA[<p>Component tools</p>
<h2 id="1-etcd">1. Etcd</h2>
<p>A distributed, reliable key-value store for the most critical data of a distributed system</p>
<p><a href="https://etcd.io/">etcd</a></p>
<p>default port: 2379</p>
<pre tabindex="0"><code>./etcdctl set key1 value1
./etcdctl get key1
</code></pre><p>Every information you see when you run the <code>kubectl get</code> command is from the <strong>Etcd</strong> Server.</p>
<p>To list all keys stored by Kubernetes, run the command like this. Run inside the etcd-master POD.</p>
<pre tabindex="0"><code>kubectl exec etcd-master -n kube-system etcdctl get / --prefix -keys-only
</code></pre><h2 id="2-kube-apiserver">2. kube-apiserver</h2>
<p>Kube-apiserver is the primary management component in kubernetes. When you run a kubectl command, the kubectl utility is in fact reaching to the kube-apiserver. The kube-apiserver first authenticates the request and validates it. It then retrieves the data from the etcd cluster and reponds back with the requested information.</p>
<p>POST request is available as well.</p>
<pre tabindex="0"><code>curl -X POST /api/v1/namespaces/default/pods ...[other]
</code></pre><p>enable verbose for your command</p>
<pre tabindex="0"><code>kubectl get pods -A -v 8
</code></pre><pre tabindex="0"><code>I0209 16:48:43.713733   29886 loader.go:374] Config loaded from file:  /Users/~/.kube/config
I0209 16:48:43.714375   29886 loader.go:374] Config loaded from file:  /Users/~/.kubeconfig_pro
I0209 16:48:43.724834   29886 round_trippers.go:463] GET https://127.0.0.1:6443/api/v1/pods?limit=500
I0209 16:48:43.724856   29886 round_trippers.go:469] Request Headers:
I0209 16:48:43.724870   29886 round_trippers.go:473]     Accept: application/json;as=Table;v=v1;g=meta.k8s.io,application/json;as=Table;v=v1beta1;g=meta.k8s.io,application/json
I0209 16:48:43.724879   29886 round_trippers.go:473]     User-Agent: kubectl/v1.25.0 (darwin/amd64) kubernetes/a866cbe
I0209 16:48:43.744984   29886 round_trippers.go:574] Response Status: 200 OK in 20 milliseconds
</code></pre><p><a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/">kube-apiserver</a></p>
<p>kube-apiserver is the <strong>only</strong> component that interacts directly with the etcd datastrore.</p>
<h2 id="3-kube-controller-manager">3. kube-controller-manager</h2>
<p>kube-controller-manager manages various controllers in kubernetes. A controller is like an office or department within the master ship that have their own set of responsibilities.</p>
<p>These offices are:</p>
<p>​	<em>No 1. Continuously on the lookout for the status of the ships</em></p>
<p>​	<em>No 2. Take necessary actions to remediate the situation</em></p>
<p><a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/">kube-controller-manager</a></p>
<p>Node Monitor Period = 5s</p>
<p>Node Monitor Grace Period = 40s</p>
<p>POD Eviction Timeout = 5m</p>
<h2 id="4-kube-scheduler">4. kube-scheduler</h2>
<p>kube-scheduler is responsible for scheduling pods on nodes. It is only reponsible for deciding which pod goes on which node. It doesn&rsquo;t actually place the pod on the nodes.</p>
<p><a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-scheduler/">kube-scheduler</a></p>
<p>The scheduler decides which nodes the pods are placed on depending on certain criteria. You may have pods with different resource requirements. You can have nodes in the cluster dedicated to certain applications.</p>
<pre><code>1. Filter Nodes
2. Rank Nodes - calculates the amount of resources that would be free on the nodes after placing the pod on them
</code></pre>
<h2 id="5-kubelet">5. kubelet</h2>
<p>The kubelet is like the captain on the ship. They lead all activities on a ship. They&rsquo;re the ones responsible for doing all the paperwork necessary to become part of the cluster. They&rsquo;re the sole point of contact from the master ship. They load or unload containers on the ship as instructed by the scheduler on the master. The kubelet in the kubernetes worker node, registers the node with the kubernetes cluster. When it receives instructions to load a container or a pod on the node, it requests the container runtime engine, which maybe Docker, to pull the required image and run an instance. The kubelet then continues to monitor the state of the pod and the containers in it and reports to the kube-apiserver on a timely basis.</p>
<p><a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/">kubelet</a></p>
<h2 id="6-kube-proxy">6. kube-proxy</h2>
<p>kube-proxy is a process that runs on each node in the kubernetes cluster. Its job is to look for new services and every time a new service is created it creates the appropriate rules on each node to forward traffic to those services to the backend pods. One way it does this is using IPTABLES rules.</p>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
