{"id":807,"date":"2025-08-29T12:59:48","date_gmt":"2025-08-29T10:59:48","guid":{"rendered":"https:\/\/blog.chloesoe.ch\/?p=807"},"modified":"2025-08-29T13:01:02","modified_gmt":"2025-08-29T11:01:02","slug":"cka-notes","status":"publish","type":"post","link":"https:\/\/blog.chloesoe.ch\/?p=807","title":{"rendered":"CKA Notes"},"content":{"rendered":"<h2>General<\/h2>\n<p>Usage of documentation is allowed<\/p>\n<p>Cheat sheet. <a href=\"https:\/\/kubernetes.io\/docs\/reference\/kubectl\/cheatsheet\/\">https:\/\/kubernetes.io\/docs\/reference\/kubectl\/cheatsheet\/<\/a><\/p>\n<h2>Commands<\/h2>\n<pre><code># get persistent volumes (sorted by capacity)\nkubectl get pv\nkubectl get pv -o yaml\nkubectl get pv --sort-by=.spec.capacity.storage\n\n# get services\nkubectl get service --all-namespaces\n\n# run a command inside a pod\n# use exec, `--` needed because without it is deprecated\nkubectl -n beebox-mobile exec quark -- cat \/etc\/key\/key.txt\n\n# apply a deployment\nkubectl apply -f deployment.yml\n\n# get all deployments\nkubectl get deployments --all-namespaces<\/code><\/pre>\n<h2>kubectl tips<\/h2>\n<p><a href=\"https:\/\/kubernetes.io\/docs\/concepts\/overview\/working-with-objects\/object-management\/\">https:\/\/kubernetes.io\/docs\/concepts\/overview\/working-with-objects\/object-management\/<\/a><\/p>\n<p>Declarative vs Imperative<\/p>\n<pre><code># declarative, apply a yaml or json\nkubectl apply -f deployment.yml \n\n# imparative\nkubectl create deployment my-deployment --image=nginx\n\n# with a dry run you can save create a yaml file:\nkubectl create deployment my-deployment --image=nginx --dry-run -o yaml\n\n# imperative command to create a secret from a file:\nkubectl create secret generic nginx-htpasswd --from-file .htpasswd<\/code><\/pre>\n<pre><code>kubectl scale deployment my-deployment --replicas=5\n\n# recording\nkubectl scale deployment my-deployment --replicas=5 --record\n# you will see the changes in annotations in describe\nkubectl describe deployment my deployment<\/code><\/pre>\n<h2>RBAC<\/h2>\n<p><a href=\"https:\/\/kubernetes.io\/docs\/reference\/access-authn-authz\/rbac\/\">https:\/\/kubernetes.io\/docs\/reference\/access-authn-authz\/rbac\/<\/a><\/p>\n<pre><code># apply role based access\nkubectl apply -f rbac.yaml\n\nkubectl auth reconcile -f rbac.yaml --dry-run=client\nkubectl auth reconcile -f rbac.yaml\n\n# bind user to role, see https:\/\/kubernetes.io\/docs\/reference\/access-authn-authz\/rbac\/#rolebinding-example, run also with `auth reconcile`<\/code><\/pre>\n<h2>Network Plugin<\/h2>\n<p>Installing isn't well described in the current documentation. Could be difficult do find the correct URL to install calico.yaml during CKA exam.<\/p>\n<p>Installation is described at v1.17 docs <a href=\"https:\/\/v1-17.docs.kubernetes.io\/docs\/setup\/production-environment\/tools\/kubeadm\/create-cluster-kubeadm\/\">https:\/\/v1-17.docs.kubernetes.io\/docs\/setup\/production-environment\/tools\/kubeadm\/create-cluster-kubeadm\/<\/a>. From the course we have this command:<\/p>\n<pre><code class=\"language-bash\">kubectl apply -f https:\/\/docs.projectcalico.org\/v3.15\/manifests\/calico.yaml<\/code><\/pre>\n<p>Troubleshooting network issues: Image nicolaka\/netshoot<\/p>\n<h2>Metrics<\/h2>\n<p>First we have to install metrics server as addon.<\/p>\n<pre><code># install the file provided by the CKA course\nkubectl create -f https:\/\/raw.githubusercontent.com\/ACloudGuru-Resources\/content-cka-resources\/master\/metrics-server-components.yaml\n\n# check if metrics server is running\nkubectl get --raw \/apis\/metrics.k8s.io\/\n\n# use top\nkubectl top pod\nkubectl top pod -n my-namespace --selector app=xyz --sort-by=cpu<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>General Usage of documentation is allowed Cheat sheet. https:\/\/kubernetes.io\/docs\/reference\/kubectl\/cheatsheet\/ Commands # get persistent volumes (sorted by capacity) kubectl get pv kubectl get pv -o yaml kubectl get pv &#8211;sort-by=.spec.capacity.storage # get services kubectl get service &#8211;all-namespaces # run a command inside a pod # use exec, `&#8211;` needed because without it is deprecated kubectl -n&#8230; <a href=\"https:\/\/blog.chloesoe.ch\/?p=807\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">CKA Notes<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[32,33],"class_list":["post-807","post","type-post","status-publish","format-standard","hentry","category-k8s","tag-cka","tag-cks"],"_links":{"self":[{"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=\/wp\/v2\/posts\/807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=807"}],"version-history":[{"count":4,"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=\/wp\/v2\/posts\/807\/revisions"}],"predecessor-version":[{"id":811,"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=\/wp\/v2\/posts\/807\/revisions\/811"}],"wp:attachment":[{"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.chloesoe.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}