{"id":16474925,"url":"https://github.com/walidshaari/vmug-cka","last_synced_at":"2026-03-18T19:55:04.682Z","repository":{"id":88308424,"uuid":"404549880","full_name":"walidshaari/vmug-cka","owner":"walidshaari","description":null,"archived":false,"fork":false,"pushed_at":"2021-09-29T17:40:11.000Z","size":484,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-27T15:59:43.493Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/walidshaari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-09T01:42:15.000Z","updated_at":"2023-03-20T17:10:40.000Z","dependencies_parsed_at":"2023-04-27T21:32:29.603Z","dependency_job_id":null,"html_url":"https://github.com/walidshaari/vmug-cka","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/walidshaari/vmug-cka","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walidshaari%2Fvmug-cka","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walidshaari%2Fvmug-cka/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walidshaari%2Fvmug-cka/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walidshaari%2Fvmug-cka/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/walidshaari","download_url":"https://codeload.github.com/walidshaari/vmug-cka/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walidshaari%2Fvmug-cka/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29997213,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T01:47:34.672Z","status":"online","status_checked_at":"2026-03-02T02:00:07.342Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T12:34:56.907Z","updated_at":"2026-03-02T09:34:16.015Z","avatar_url":"https://github.com/walidshaari.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License: CC BY-SA 4.0](https://licensebuttons.net/l/by-sa/4.0/80x15.png)](https://creativecommons.org/licenses/by-sa/4.0/)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"300\" src=\"./pics/cka-logo.png\"\u003e\n\u003c/p\u003e\n\n\n### Workloads \u0026 Scheduling – 15%\n1. [Understand deployments and how to perform rolling update and rollbacks](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/)\n\n    install metrics server from \n    \n    kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml\n    try to explore the deployment and service\n    \n    Q-  Which namespace was it installed on? can you change this during installation?\n    \n    Q-  What is the status of the replica-set created by the deployment?\n    \n    Q-  Explore and relate the pods to the replicaset to the deployment\n    \n    Q-  What is wrong with the deployment? can you fix it?\n    \n    Q-  how many replicasets are associated now with the deployment?\n    \n    Q- can you tell from the rollout history why? how can you improve on it?\n    \n    \n    \n    \n3. Use [ConfigMaps](https://kubernetes.io/docs/concepts/configuration/configmap/) and [Secrets](https://kubernetes.io/docs/concepts/configuration/secret/) to configure applications\n  - [configure a pod with a configmap](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/)\n  - [configure a pod with a secret](https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/)\n4. Know how to [scale applications](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#scaling-a-deployment)\n  - [scaling a statefulset](https://kubernetes.io/docs/tasks/run-application/scale-stateful-set/)\n  - [scaling a replicaset](https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/#scaling-a-replicaset)\n5. Understand the primitives used to create robust, self-healing, application deployments\n - [Replicaset](https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/)\n - [Deployments](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/)\n - [Statefulsets](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/)\n - [Daemonset](https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/)\n6. Understand [how resource limits can affect Pod scheduling](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#how-pods-with-resource-requests-are-scheduled)\n7. Awareness of manifest management and common templating tools\n  * [Kustomize](https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/)\n    - [Kustomize Blog](https://kubernetes.io/blog/2018/05/29/introducing-kustomize-template-free-configuration-customization-for-kubernetes/)\n  * [manage kubernetes objects](https://kubernetes.io/docs/tasks/manage-kubernetes-objects/)\n  * [Install service catalog using helm](https://kubernetes.io/docs/tasks/service-catalog/install-service-catalog-using-helm/)\n    - Non-k8s.io resource: CNCF Kubecon video: [An introduction to Helm - Bridget Kromhout, Microsoft \u0026 Marc Khouzam, City of Montreal](https://youtu.be/x2w6T0sE50w?list=PLj6h78yzYM2O1wlsM-Ma-RYhfT5LKq0XC)\n   - Non-k8s.io resource: External resource: [templating-yaml-with-code](https://learnk8s.io/templating-yaml-with-code)\n\n\n### Tips\n\n- Always remember your Cluster context and namespace **in the exam**.\n\n```\nwal@Bei:~/code/gitrepos/vmug-cka$ kubectl config get-contexts\nCURRENT   NAME            CLUSTER         AUTHINFO        NAMESPACE\n          default         default         default         \n*         kind-vmug-cka   kind-vmug-cka   kind-vmug-cka   \n\n ###* I can set namespace, and practice it so I do not forget during exam, or practice using -n namespace in commands *###\n\nwal@Bei:~/code/gitrepos/vmug-cka$ kubectl config set-context --current --cluster=kind-vmug-cka --namespace=vmug-cka\nContext \"kind-vmug-cka\" modified.\nwal@Bei:~/code/gitrepos/vmug-cka$ kubectl config get-contexts\nCURRENT   NAME            CLUSTER         AUTHINFO        NAMESPACE\n          default         default         default         \n*         kind-vmug-cka   kind-vmug-cka   kind-vmug-cka   vmug-cka\nwal@Bei:~/code/gitrepos/vmug-cka$ kubectl get pods\nNAME       READY   STATUS    RESTARTS   AGE\nenv-pod    1/1     Running   3          3h53m\nnginx      1/1     Running   0          3h58m\ntest-pod   1/1     Running   4          4h30m\n\n```\n- [Use autocompletion](https://kubernetes.io/docs/tasks/tools/included/optional-kubectl-configs-bash-linux/)\n  ```\n  echo 'source \u003c(kubectl completion bash)' \u003e\u003e~/.bashrc\n  echo 'alias k=kubectl' \u003e\u003e~/.bashrc\n  echo 'complete -F __start_kubectl k' \u003e\u003e~/.bashrc\n  exec $SHELL    #for bashrc to get executed with the new mods\n  ```\n  \n  You might need to source the profile shell script `source  /etc/profile.d/bash_completion.sh`\n  \n  ```\n  k get pods\n  NAME       READY   STATUS    RESTARTS   AGE\n  test-pod   1/1     Running   0          2m18s\n  ```\n- Familiarize yourself with Kuberentios.io docuemntaion\n  - Cheatsheet  https://kubernetes.io/docs/reference/kubectl/cheatsheet/\n    - Familiarize yourelf how to generate or format outputs:  https://kubernetes.io/docs/reference/kubectl/cheatsheet/#formatting-output \n    - Free YAML and jsonpath course from kodekloud https://legacy.kodekloud.com/p/json-path-quiz\n  - Tasks  https://kubernetes.io/docs/tasks/\n  - Concepts https://kubernetes.io/docs/concepts/\n  - Familiarize yourself with `kubectl explain \u003capi-resource\u003e --recursive`\n\n\n## Practice cluster using KinD\n\n```\n$ cat kind/two-nodes.yaml \nkind: Cluster\napiVersion: kind.x-k8s.io/v1alpha4\nname: vmug-cka\nnodes:\n- role: control-plane\n  image: kindest/node:v1.21.2 \n- role: worker\n  image:  kindest/node:v1.21.2\n  \n# create a two worker nodes cluster from the above config file\n$kind create cluster --config kind/two-nodes.yaml\n```\n\nEnsure cluster and kubectl are same version required in the exam, as per exam FAQ it is 1.21 for CKA as of yesterday\n```\n $ curl -LO https://dl.k8s.io/release/v1.21.2/bin/linux/amd64/kubectl\n  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n100   154  100   154    0     0    175      0 --:--:-- --:--:-- --:--:--   174\n100 44.2M  100 44.2M    0     0  4528k      0  0:00:10  0:00:10 --:--:-- 5515k\n$ chmod +x kubectl \n$ sudo mv kubectl  /usr/local/bin/\n[sudo] password for wal: \n\nwal@Bei:~/code/gitrepos/vmug-cka$ kubectl  version\nClient Version: version.Info{Major:\"1\", Minor:\"21\", GitVersion:\"v1.21.2\", GitCommit:\"092fbfbf53427de67cac1e9fa54aaa09a28371d7\", GitTreeState:\"clean\", BuildDate:\"2021-06-16T12:59:11Z\", GoVersion:\"go1.16.5\", Compiler:\"gc\", Platform:\"linux/amd64\"}\nServer Version: version.Info{Major:\"1\", Minor:\"21\", GitVersion:\"v1.21.2\", GitCommit:\"092fbfbf53427de67cac1e9fa54aaa09a28371d7\", GitTreeState:\"clean\", BuildDate:\"2021-07-12T20:40:20Z\", GoVersion:\"go1.16.5\", Compiler:\"gc\", Platform:\"linux/amd64\"}\n\n```\n##  scope:\n\nYou need to be familiar with **Deployments**, **ConfigMaps \u0026 Secrets**, and defining **resource limits and requestes** needed by the containers running the application. When creating a new Pod, the Kubernetes scheduler places the object on an available node. Scheduling rules like **node affinity and taints/tolerations** control and fine-tunes the behavior.\n\n\n## Data requirements:\n\n- decoupling across environments (e.g public, private, dev, qa, prod)\n- scalable sharing of configuration\n- Enables immutable images\n- Security ( sharing of images, constraining data to specific accounts, keeping secrets out)\n\n![Kelesy Hightower](pics/donot-hardocode.png)\nhttps://twitter.com/kelseyhightower/status/932644210997465089\n\n\n### passing data directly to command arguments\n\n\u003cdetails\u003e\u003csummary\u003e Q1: create a pod named test-pod running in vmug-cka namespace using image busybox configued with the sleep command to run for an hour     \u003c/summary\u003e\n   \n ```  \n\n $ export DO='-o yaml --dry-run=client'\n \n $ kubectl -n vmug-cka run $DO test-pod --image busybox -- sleep 1h|tee test-pod.yaml\n apiVersion: v1\n kind: Pod\n metadata:\n   creationTimestamp: null\n   labels:\n     run: test-pod\n   name: test-pod\n   namespace: vmug-cka\n spec:\n   containers:\n   - args:\n     - sleep\n     - 1h\n     image: busybox\n     name: test-pod\n     resources: {}\n   dnsPolicy: ClusterFirst\n   restartPolicy: Always\n status: {}\n  \n $ kubectl create  -f test-pod.yaml \n pod/test-pod created\n $ k get pods -n vmug-cka\n NAME       READY   STATUS    RESTARTS   AGE\n test-pod   1/1     Running   0          11s\n```\n   \n \u003c/details\u003e\n\n### Environment variables\n\n\u003cdetails\u003e\u003csummary\u003e Q2: create a pod named env-pod running in vmug-cka namespace using image busybox configued with the sleep command to run for an hour, and sets the following environment variables SERVER=vcsa.home.local, USER=admin@vsphere.local, PASS=N1N5ecur3   \u003c/summary\u003e\n         \n```\n\n\t$ kubectl -n vmug-cka run $DO env-pod --image busybox --env SERVER=vcsa.home.local --env USER=admin@vsphere.local --env PASS=N0N5ecur3 -- sleep 1h|tee test-pod.yaml\n\tapiVersion: v1\n\tkind: Pod\n\tmetadata:\n\t  creationTimestamp: null\n\t  labels:\n\t    run: env-pod\n\t  name: env-pod\n\t  namespace: vmug-cka\n\tspec:\n\t  containers:\n\t  - args:\n\t    - sleep\n\t    - 1h\n\t    env:\n\t    - name: SERVER\n\t      value: vcsa.home.local\n\t    - name: USER\n\t      value: admin@vsphere.local\n\t    - name: PASS\n\t      value: N0N5ecur3\n\t    image: busybox\n\t    name: env-pod\n\t    resources: {}\n\t  dnsPolicy: ClusterFirst\n\t  restartPolicy: Always\n\tstatus: {}\n\n   ```\n \n   \u003c/details\u003e\n\n  \u003cdetails\u003e\n  \u003csummary\u003e\n   Q3: list the user set enviornment variables only; if that was an exam question they might direct you to store them in a file\n  \u003c/summary\u003e\n\n\n  ```\n\n  $ kubectl set env pod/env-pod  -n vmug-cka --list\n  # Pod env-pod, container env-pod\n  SERVER=vcsa.home.local\n  USER=admin@vsphere.local\n  PASS=N0N5ecur3\n\n  ```\n\n  \u003c/details\u003e\n\n\n### Configmaps\n\n### secrets\n\n\n\n\n\n## Configurations\n\nkubectl apply manifests/pod-envfrom-cm.yaml\n\n```\n\n### try as much as possible what could go wrong\n\nwal@Bei:~/code/gitrepos/cert-magic$ kubectl get pods\nNAME             READY   STATUS                       RESTARTS   AGE\nconfigured-pod   0/1     CreateContainerConfigError   0          89s\n\n### use events and describe pod to investiage errors\n\nwal@Bei:~/code/gitrepos/cert-magic$ kubectl get events|grep  Warning\n0s          Warning   Failed                    pod/configured-pod   Error: configmap \"backend-config\" not found\n\n\n\n...\n...\nEvents:\n  Type     Reason     Age                   From               Message\n  ----     ------     ----                  ----               -------\n  Normal   Scheduled  4m6s                  default-scheduler  Successfully assigned default/configured-pod to localhost\n  Warning  Failed     113s (x12 over 4m7s)  kubelet            Error: configmap \"backend-config\" not found\n  Normal   Pulled     98s (x13 over 4m7s)   kubelet            Container image \"nginx:1.19.0\" already present on machine\n\n\n\n```\n\nthe fix?\n\n```\nwal@Bei:~/code/gitrepos/cert-magic$ kubectl apply -f manifests/backend-cm.yaml \nconfigmap/backend-config configured\n\nwal@Bei:~/code/gitrepos/cert-magic$ kubectl exec  -it configured-pod -- env|grep data\ndatabase_url=jdbc:postgresql://localhost/test\ndatabase_user=saiyam\ndatabase_env=staging\n\n```\n\n\n## Secrets\n![kh on secrets](pics/kh-secrets.png)\nhttps://twitter.com/kelseyhightower/status/1324483384551239681\n- []()\n\n\u003cdetails\u003e\n\u003csummary\u003e  Q1: Create a secret to hold the following govc credential, the secret name is called govc-creds, in name space vmug-cka, the secret should hold the following key value pairs:  server = vcsa.home.local, user =' administrator@vsphere.local', password = 'Admin!23', port = 443, insecure-flag = 1\n\t\n\u003c/summary\u003e\n\t\n```\nkubectl -n vmug-cka create secret generic govc-creds --from-literal=server=vcsa.home.local --from-literal=user='administrator@vsphere.local' --from-literal=password='Admin!23' --from-literal=port=443 --from-literal=insecure-flag=1 $DO\n```\n```\t\napiVersion: v1\ndata:\n  insecure-flag: MQ==\n  password: QWRtaW4hMjM=\n  port: NDQz\n  server: dmNzYS5ob21lLmxvY2Fs\n  user: YWRtaW5pc3RyYXRvckB2c3BoZXJlLmxvY2Fs\nkind: Secret\nmetadata:\n  creationTimestamp: null\n  name: govc-creds\n  namespace: vmug-cka\n\n```\n\t\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e  Q2:\n\tuse the kubectl --template option to print out the above secret govc-cred password key decoded in clear-text\n\u003c/summary\u003e\n\t\n```\necho `kubectl get  secret govc-creds -n vmug-cka --template={{.data.password}}|base64 -d`\n```\n```\t\nAdmin!23\n```\n\t\n```\t\n###*  the template argument was built based on the secret schema as you can see below if we use describe *###\nkubectl describe -n vmug-cka secret govc-creds\nName:         govc-creds\nNamespace:    vmug-cka\nLabels:       \u003cnone\u003e\nAnnotations:  \u003cnone\u003e\n\nType:  Opaque\n\nData\n====\nuser:           27 bytes\ninsecure-flag:  1 bytes\npassword:       8 bytes\nport:           3 bytes\nserver:         15 bytes\n\n\n```\n\t\n\u003c/details\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e  Q:\n\t\n\u003c/summary\u003e\n\t\n```\n\n```\n```\t\n\n\n```\n\t\n\u003c/details\u003e\n\n\n\n### kubectl set   env --help\n```\nExamples:\n  # Update deployment 'registry' with a new environment variable\n  kubectl set env deployment/registry STORAGE_DIR=/local\n  \n  # List the environment variables defined on a deployments 'sample-build'\n  kubectl set env deployment/sample-build --list\n  \n  # List the environment variables defined on all pods\n  kubectl set env pods --all --list\n  \n  # Output modified deployment in YAML, and does not alter the object on the server\n  kubectl set env deployment/sample-build STORAGE_DIR=/data -o yaml\n  \n  # Update all containers in all replication controllers in the project to have ENV=prod\n  kubectl set env rc --all ENV=prod\n  \n  # Import environment from a secret\n  kubectl set env --from=secret/mysecret deployment/myapp\n  \n  # Import environment from a config map with a prefix\n  kubectl set env --from=configmap/myconfigmap --prefix=MYSQL_ deployment/myapp\n  \n  # Import specific keys from a config map\n  kubectl set env --keys=my-example-key --from=configmap/myconfigmap deployment/myapp\n  \n  # Remove the environment variable ENV from container 'c1' in all deployment configs\n  kubectl set env deployments --all --containers=\"c1\" ENV-\n  \n  # Remove the environment variable ENV from a deployment definition on disk and\n  # update the deployment config on the server\n  kubectl set env -f deploy.json ENV-\n  \n  # Set some of the local shell environment into a deployment config on the server\n  env | grep RAILS_ | kubectl set env -e - deployment/registry\n```\n\n### kubectl set   env --help\n\t\n## Scheduling\n\n### resource limits and requests\n\t\nhttps://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/#specify-a-cpu-request-and-a-cpu-limit\n\n** Create a deployment of two replicas of nginx called prod01, enforcing container limits and request as follow max memory used by a container: 256Mi\n    while max cpu 1/2 vcpu, minimal specs to run the nginx container as follow: memory: 100Mi and 100m cpu\n    ensure that this runs on a node **vmug-cka-worker2**\n**\n\t\n### Node affinity\n\n- Why control plane node does not have many pods as worker nodes?\n  \n  can you describe it and check for effective taints?\n\t\n  can you run a daemonset across all nodes including control plane node?\n  create a busybox sleep 1 hour daemonset across all nodes\n\t\n\t\n** Add a label *env=prod* to one node and create nginx deployment called *prod* with 2 replicas and node Affinity rule to place the pods onto the labeled node.**\n\n    \u003cdetails\u003e\u003csummary\u003eshow\u003c/summary\u003e\u003cp\u003e\n\n    [Affinity and anti-affinity documentation](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity)\n\n        kubectl label node \u003cnode-name\u003e env=prod\t\n\n    Generate your own yaml or use this one. There is something wrong with it(indentation or something is missing).\n\n    ```YAML\n    apiVersion: apps/v1\n    kind: Deployment\n    metadata:\n      name: blue\n    spec:\n      replicas: 5\n      selector:\n        matchLabels:\n          run: nginx\n    template:\n        metadata:\n          labels:\n            run: nginx\n        spec:\n          containers:\n          - image: nginx\n            imagePullPolicy: Always\n            name: nginx\n          affinity:\n            requiredDuringSchedulingIgnoredDuringExecution:\n                nodeSelectorTerms:\n                - matchExpressions:\n                  - key: env\n                    operator: In\n                    values:\n                    - prod\n    ```\n\n    Check that all pods are scheduled onto the labeled node.\n\n    **Take-away**: Node affinity is a set of rules used by the scheduler to determine where a pod can be placed.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalidshaari%2Fvmug-cka","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwalidshaari%2Fvmug-cka","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalidshaari%2Fvmug-cka/lists"}