CKAD own q&a's Flashcards

1
Q

Ingress vs egress ?

A

Ingress enables external traffic to reach containers, while egress enables containers to reach external resources. Ingress is typically used for exposing web applications and APIs to the outside world, while egress is used for accessing databases and other services outside of the cluster.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

why do i do need livenessprobe?

A

Caution: Liveness probes can be a powerful way to recover from application failures, but they should be used with caution. Liveness probes must be configured carefully to ensure that they truly indicate unrecoverable application failure, for example a deadlock.

ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

whats special when configured using goproxy?

A

it need to come with readinessProbe of its own cause its a 2-step rocket

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Difference in CKA vs CKAD exam allowed doc. sources?

A

CKA or CKAD: use the browser within the VM to access the following documentation:
https://kubernetes.io/docs/, https://kubernetes.io/blog/ and their subdomains. This includes all available language translations of these pages (e.g. https://kubernetes.io/zh/docs/)

CKAD only: https://helm.sh/docs

See here for all details: https://docs.linuxfoundation.org/tc-docs/certification/certification-resources-allowed#certified-kubernetes-administrator-cka-and-certified-kubernetes-application-developer-ckad

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

a tip how to search for multiple container pod yaml in the allowed documentation?

A

search two containers maybe? i found nginx and debian container in one pod yaml!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which of the following commands will run a command inside an active container?

A. kubectl exec
B. kubectl run
C. kubectl create
D. kubectl describe

A

kubectl exec -i -t my-pod –container main-app – /bin/bash.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what does nodeSelector can be good for?

A

The nodeSelector: entry in the podspec could use this label to cause a pod to be deployed on a particular node with an entry such as:

P.s. Poor mans affinity option from what i understood later.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can you name some built-in object labels?

A

There are several built-in object labels. For example nodes have labels such as the arch, hostname, and os, which could be used for assigning pods to a particular node, or type of node.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

whats an ambassador in kubernetes?

A

It is “an open source, Kubernetes-native API gateway for microservices built on Envoy”.

It allows for access to the outside world without having to implement a service or another entry in an ingress controller: proxy local connection, reverse proxy, limits HTTP requests, re-route from the main container to the outside world.​

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Whats an initContainer?

A

The use of an initContainer allows one or more containers to run only if one or more previous containers run and exit successfully. For example, you could have a checksum verification scan container and a security scan container check the intended containers. Only if both containers pass the checks would the following group of containers be attempted. You can see a simple example below:

spec:
containers:
- name: intended
image: workload
initContainers:
- name: scanner
image: scanapp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Can k8s deployments be described in other terms?

A

This controller, or operator, is an agent to create and manage one or more instances of a specific stateful application. We have worked with built-in controllers such for Deployments and other resources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The addition of a Custom Resource Definition can be handled through exactly what?

A

The addition of a Custom Resource Definition will be added to the cluster API path, currently under apiextensions.k8s.io/v1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does An option spec field is .spec.concurrencyPolicy used for?

A

An option spec field is .spec.concurrencyPolicy which determines how to handle existing jobs, should the time segment expire. If set to Allow, the default, another concurrent job will be run, and twice as many pods would be running. If set to Forbid, the current job continues and the new job is skipped. A value of Replace cancels the current job and the controlled pods, and starts a new job in its place.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Q. lab 4.1????: Verify your nodes are using a CNI plugin. Read through the startup process of CNI. Each message begins with a type ofmessage and a time stamp, followed by the details of the message. UseTABto complete for your node name. Examineboth the controller and one of your proxy pods

A

Those are the messages, dont see any type of message in the begining: I1212 11:23:19.028798 1 replica_set.go:205] Starting replicationcontroller controller
I1212 11:23:19.028813 1 shared_informer.go:252] Waiting for caches to sync for ReplicationC
ontroller

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

how many layers are there in the context of k8s CNI and what are their names?

A

1) physical is not talked about according to chatgpt
2) Layer 2 - Data Link Layer: This layer is responsible for node-to-node data transfer and handles things like MAC addressing, Ethernet framing, VLAN tagging, and error detection. CNI plugins operating at this layer manage how data is transferred within the same network segment or VLAN.

Layer 3 - Network Layer: This layer deals with IP addressing and routing. It is responsible for moving packets across network boundaries. CNI plugins operating at this layer are involved in routing and IP address assignment for pods.

Layer 4 - Transport Layer: While not directly managed by CNI plugins, this layer, which handles protocols like TCP and UDP, is relevant in the overall Kubernetes networking picture, particularly in services, ingress, and egress operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

how is OSI organised?

A

Layer 1 - Physical Layer: This is the most fundamental layer, dealing with the transmission of raw bits over a physical medium. It includes things like cable types, electrical signals, and data rates. It’s the foundation upon which all higher layers are built.

Layer 2 - Data Link Layer: This layer is responsible for node-to-node data transfer and operates on frames. It handles things like physical addressing (MAC addresses), error detection and correction, and defines the protocol to establish and terminate a connection between two physically connected devices.

Layer 3 - Network Layer: The Network Layer is concerned with the routing of packets across different networks. It deals with logical addressing (IP addresses) and determines how data is sent to its destination through routing.

Layer 4 - Transport Layer: This layer provides end-to-end communication services for applications. It ensures complete data transfer and is responsible for error recovery and flow control. Protocols like TCP and UDP operate at this layer.

Layer 5 - Session Layer: This layer manages sessions between applications. It establishes, manages, and terminates connections between applications.

Layer 6 - Presentation Layer: It translates data between the application layer and the network. It’s responsible for data encryption, decryption, compression, and conversion.

Layer 7 - Application Layer: The highest layer of the OSI model, it provides services directly to user applications. It deals with network services that support applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Come up with questions about support of these features in k8s CNI projects: about support for vxlands, which layer is supported, network policies support, support for encryption of tcp and udp trafic and more? Here is what chatgpt 4 said:

A

Enhanced Kubernetes CNI Providers Comparison
Calico

Network Layer Support: Layer 3.
VXLAN Support: Yes, offers both VXLAN and IP-in-IP encapsulation.
Network Policies: Advanced network policy enforcement.
Encryption Support: Supports WireGuard for encrypting traffic.
Use Cases: High-performance, security-focused environments; advanced policy management.
Calico with Canal

Network Layer Support: Combines Layer 2 (Flannel) and Layer 3 (Calico).
VXLAN Support: Inherits VXLAN support from both Calico and Flannel.
Network Policies: Advanced, from Calico.
Encryption Support: Supports encryption via Calico (WireGuard).
Use Cases: Environments needing both simple setup (Flannel) and advanced policy control (Calico).
Flannel

Network Layer Support: Primarily Layer 2.
VXLAN Support: Yes, focuses on simplicity in VXLAN implementation.
Network Policies: Basic support, not as advanced as Calico.
Encryption Support: Does not natively support encryption of traffic.
Use Cases: Smaller, simpler Kubernetes setups; focus on ease of deployment.
Cilium

Network Layer Support: Layer 3, with eBPF-based networking.
VXLAN Support: Yes, along with other encapsulation formats.
Network Policies: Highly advanced, with eBPF-powered security features.
Encryption Support: Strong support for encryption, including transparent encryption of traffic.
Use Cases: Security-centric deployments; environments requiring detailed network visibility and control.
Kube-router

Network Layer Support: Layer 3 focused.
VXLAN Support: Limited or no native support for VXLAN.
Network Policies: Basic to moderate policy support.
Encryption Support: No native support for traffic encryption.
Use Cases: Balances performance and simplicity; suitable for medium-scale environments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What are some ways containers can communicate within the same pod?

A

IPC, loopback or shared filesystem access

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Tips for the exam!

A

second: k should already be an alias, otherwise; alias k=kubectl
third: dont ever click on links not allowed or u will get disqualified. for that exit maximum window and see what are the links before clicking
fourth: Use :set paste or even better vim ~./.vimrc and put these there:

syntax on
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What does those options stand for? autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab

A

autocmd FileType yaml: This part tells Vim to automatically execute the following commands whenever a file of the ‘yaml’ file type is opened. Vim detects the file type based on the file extension or sometimes the file content.

setlocal: This command sets options locally for the current buffer. It ensures that the changes made apply only to the YAML file you’re working on, not globally across all open files in Vim.

ts=2: This sets the ‘tabstop’ (ts) option to 2. The ‘tabstop’ option specifies the number of spaces that a tab in the file counts for. In this case, each tab character will be displayed as two spaces.

sts=2: This sets the ‘softtabstop’ (sts) option to 2. When you’re entering text, the ‘softtabstop’ setting makes Vim behave as though the tab character is 2 spaces wide. It affects how text is inserted and how the Tab and Backspace keys work.

sw=2: This sets the ‘shiftwidth’ (sw) option to 2. The ‘shiftwidth’ setting determines the number of spaces to use for each step of (auto)indent. It controls how many spaces are inserted for indentation.

expandtab: This option, when enabled, makes Vim insert spaces instead of tabs when the Tab key is pressed. Combined with the settings above, it means that each time you press Tab, it will insert two spaces.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Name possible memory settings in the pod yaml

A

Requests is what Kubernetes guarantees as available for the container.
Limits is the maximum amount of memory the container is allowed to use.
Args (“–vm-bytes”, “250M”) is specific to the stress tool used inside the container for testing and is not a Kubernetes resource allocation setting.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How do you aproach this on the exam? you need to know cron, its the linux 5 places cron thats used and which place is which:

A

Create a new cronjob which runs busybox and the sleep 30 command. Have the cronjob run every three minutes. View the job status to check your work. Change the settings so the pod runs 10 minutes from the current time, every week. For example, if the current time was 2:14PM, I would configure the job to run at 2:24PM, every Monday.

Obs! remember its 5parts cron and they are MHDMDofweek

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is the ambassador in Kubernetes?

A

Ambassador is a Kubernetes-native API Gateway built on Envoy Proxy. Managed entirely via Kubernetes Custom Resource Definitions, Ambassador provides powerful capabilities for traffic management, authentication, and observability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Which of the following are helper container types? Choose all answers that apply: Ambassador, Adapter,ProbeHelper,Sidecar

A

All except Probehelper. can u give example of those?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

If a Pod uses more CPU than allowed, it will be evicted. True or False?

A

False! But its true for memory and disk!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

howdo you find port of your local registry?

A

You just need to list your k8s services: kubectl get svc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Write the list of all DbBackup objects into /root/db-backups .

A

kubectl get db-backups -A

k get crd to get a list of all, and then take the part before the first dot.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What does this 3 term mean? Helm Chart, Helm Release, Helm Values ?

A

Helm Chart: Kubernetes YAML template-files combined into a single package, Values allow customisation

Helm Release: Installed instance of a Chart

Helm Values: Allow to customise the YAML template-files in a Chart when creating a Release

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Write the list of all Helm releases in the cluster into /root/releases .

A

helm ls -A > /root/releases

Obs. helm list -h helps!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

How to get to know Api Group of k8s Deployments ?

A

The answer is “Apps”. Two ways to find out:
1) kubectl api-resources| grep -i deploy
deployments deploy apps/v1 true Deployment
2) k explain deploy
GROUP: apps
KIND: Deployment
VERSION: v1

P.s. Remember, group is like groupid in maven: [groupId]:[artifactId]:[type]:[version]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

your best way to know the actual version of some api thing?

A

kubectl api-resources| grep -i

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

1) What is the official doc reference link for all the special annotations? 2) what is it for namespaces?

A
  1. https://kubernetes.io/docs/reference/labels-annotations-taints/. 2. kubernetes.io/metadata.name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Whats inside a basic Dockerfile that just ping a website?

A

FROM bash
CMD [“ping”, “killercoda.com”]

Obs! remember command parts separated with comma. Also lower/uppercase in FROM matters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

Howto build and list a simple docker/podman image?

A

podman build -t pinger .

podman image ls

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

howto run a simple docker/podman image?

A

podman run –name my-ping pinger

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

This is the 4 ingredients of Dockerfile. What 2 would i use to create an image that pings a webside:

FROM ubuntu:22.04
COPY . /app
RUN make /app
CMD python /app/app.py

A

FROM bash
CMD [“ping”, “killercoda.com”]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

What was the biggest surprise when i did killerkoda ingress task?

A

ingressClass! P.s. seems i can see it here kubectl get ingress test-ingress

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q
  1. What is a command to create a container just by a command? 2. Where in official doc do i find that info
A
  1. kubectl run nginx –image=nginx 2. reference > kubectl > generated > kubectl_run
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

Howto get kubectl events sorted by time?

A

kubectl get events –sort-by=’.lastTimestamp’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

What are 4 servicetypes?

A

Service type
For some parts of your application (for example, frontends) you may want to expose a Service onto an external IP address, one that’s accessible from outside of your cluster.

Kubernetes Service types allow you to specify what kind of Service you want.

The available type values and their behaviors are:

ClusterIP
Exposes the Service on a cluster-internal IP. Choosing this value makes the Service only reachable from within the cluster. This is the default that is used if you don’t explicitly specify a type for a Service. You can expose the Service to the public internet using an Ingress or a Gateway.
NodePort
Exposes the Service on each Node’s IP at a static port (the NodePort). To make the node port available, Kubernetes sets up a cluster IP address, the same as if you had requested a Service of type: ClusterIP.
LoadBalancer
Exposes the Service externally using an external load balancer. Kubernetes does not directly offer a load balancing component; you must provide one, or you can integrate your Kubernetes cluster with a cloud provider.
ExternalName
Maps the Service to the contents of the externalName field (for example, to the hostname api.foo.bar.example). The mapping configures your cluster’s DNS server to return a CNAME record with that external hostname value. No proxying of any kind is set up.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

How do you expose deployment using service?

A

kubectl expose deployment/kubernetes-bootcamp –type=”NodePort” –port 8080

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

How am i supposed to find info about exposing a deployment?

A

Searching for “service expose deployment” gave 2 main type of results that are useful: 1) tutorial pages that are still under kubernetes.io 2) under tasks/access-application-cluster/service-access-application-cluster/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

howto create secret from command with 3 data strings?

A
  1. either base64 each parameter and put in in yaml or 2. kubectl create secret generic db-secret-xxdf –from-literal=DB_Host=sql01 –from-literal=DB_User=root –from-literal=DB_Password=password123
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

howto label deployment?

A

kubectl label deployment my-deployment unhealthy=true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

what do u do if u need to configure pod to run as root user?

A

root is the default user, no action needed!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

how do u restart a pod?

A

A pod is the smallest unit in Kubernetes (K8S). They should run until they are replaced by a new deployment. Because of this, there is no way to restart a pod, instead, it should be replaced.

There is no kubectl restart [podname] command for use with K8S (with Docker you can use docker restart [container_id] ), so there are a few different ways to achieve a pod ‘restart’ with kubectl

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

Are you familiar with all of these shortcuts?
rs,deploy,svc,ns,netpol,pvc,sa

A

netpol = network policy, sa = service account

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q
  1. how do u replace multiple lines in VIM? how do u indent multiple lines?
A
  1. kom ihåg procent tecken :%s/foo/bar/g
  2. 5jj (5 för antal rader , j och sen j igen tror jag)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

difference readinessprobe and livenessProbe? example how it look like?

A

livenessProbe:
exec:
command:
- cat
- /tmp/healthy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

Read all the k8s doc pages i opened fully

A

so i get my mental model over all the parts i can type!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

TODO Kilkoda exam 2 q9

TODO: maybe do CKA test exam in addition to CKAD exam just to have a variation of tasks with quick answers!

A

q9: PV custom-volume has the correct host path?
q9 desc: Create a PersistentVolume called custom-volume with size: 50MiB reclaim policy:retain, Access Modes: ReadWriteMany and hostPath: /opt/data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

how do you permanently save the namespace for all subsequent kubectl commands in that context?

A

kubectl config set-context –current –namespace=ggckad-s2

53
Q

How do you quickly see if a pod have some volumemounts?

A

k exec pod1 – ls /etc/birke

54
Q

When the exam say to create container from dockerfile, do they mean k8s or docker/podman container?

A

apparently they mean a docker container!

55
Q

Howto Tag the Docker/Podman image, which is currently tagged as pinger , also as local-registry:5000/pinger?
Howto also then push the image into the local registry?

A

podman tag pinger local-registry:5000/pinger

podman image ls

podman push local-registry:5000/pinger

56
Q

What does maxSurge mean in the context of deployments? and how can it be measured?

A

maxSurge: The number of pods that can be created above the desired amount of pods during an update. This can be an absolute number or percentage of the replicas count. The default is 25%.

57
Q

What did i forget when trying to use your own CRD?

A

1) You create yaml by yourself, not template generator!
2) The mandatory first 5 lines start according to abbreviation “AKMnS”
3) !!! Most important cause i made it wrong!! The first A which is apiversion comes from CRD groupid/version, that is “apiVersion: beta.killercoda.com/v1” with or without citation!!!

58
Q

Whats interesting about this?

controlplane $ k get shopping-items
NAME AGE
bananas 8m26s
shopping-items.beta.killercoda.com 10m
controlplane $ k delete bananas
error: the server doesn’t have a resource type “bananas”
controlplane $ k delete crd bananas
Error from server (NotFound): customresourcedefinitions.apiextensions.k8s.io “bananas” not found
controlplane $ k delete crd shopping-items.beta.killercoda.com
customresourcedefinition.apiextensions.k8s.io “shopping-items.beta.killercoda.com” deleted

A

Strange that i could not remove banas here!? Also it seems when i remove CRD, i remove the instance of it too!

59
Q

if i need to search for helm chart “nginx-stable/nginx-ingress”, where can i search and where did i actually find it?

A

helm search hub - search for charts in the Artifact Hub or your own hub instance
helm search repo - search repositories for a keyword in charts

i found it in the repo! P.s. luckily i did not have to care about that when i just tried to install it by: helm install devserver nginx-stable/nginx-ingress -n team-yellow

60
Q

Whats The key difference between Blue-Green and Canary rollouts in Kubernetes ?

A

The key difference between Blue-Green and Canary rollouts in Kubernetes lies in their approach to releasing new versions:

Blue-Green Rollout: This involves two identical environments: Blue (current production) and Green (new version). Once the Green environment is ready and tested, traffic is switched from Blue to Green. If issues arise, you can switch back to Blue. It’s a more straightforward approach with less risk and easier rollback, but requires double the resources.

Canary Rollout: This is a more gradual process where the new version (Canary) is slowly rolled out to a small subset of users. The new version’s performance and stability are monitored, and if no issues are detected, the rollout continues gradually until the canary version replaces the old version completely. This method allows for more detailed monitoring and reduces risk but can be more complex to manage.

61
Q

When the questiono ask “Write the Api Group of Deployments into /root/group “ what do they mean? individual deploy property or a high level logical group for deploy?

A

The later! So the answer is “apps” , here is how u get it:
k explain deploy

This will show VERSION: apps/v1 .
The version is displayed as VERSION: {group}/{version}.

echo apps > /root/group

Obs! Dont make a mistake and look at individual deploys!

62
Q

If the task is: “There is a FlowSchema file at /apps/flowschema.yaml which uses a deprecated Api version.

Update the file to use the non deprecated one.” How would u find out what to use?

A

Try to apply it and see kubectl say its not the latest one. Obs! It will suggest the latest one!!!

63
Q

2 selfcheck questions for an exam question which goes: “Write all Admission Controller Plugins, which are enabled in the kube-apiserver manifest, into /root/admission-plugins .” 1) how to do it ? 2)what is it verifying actually

A

1) cat /etc/kubernetes/manifests/kube-apiserver.yaml | grep admission-plugins 2) It verifies that i know they are mounted locally for me to use. Obs! ps aux | grep kube-apiserver shows it too.

obs! Dont get excited when you find this in documentation “kube-apiserver -h | grep enable-admission-plugins” because it gets u “admission plugins that SHOULD BE enabled in addition to default enabled ones”

64
Q

how do you view all logs using a certain label?

A

kubectl logs -l app=elasticsearch

65
Q

how do u spec a netpol so it allows port on a certain trafic? block, allow or just port spec?

A

just port spec:

egress:
- ports:
- port: 53
protocol: TCP
- port: 53
protocol: UDP

66
Q

How do u verify that u blocked access to a certain host?

A

These should work
k -n space1 exec app1-0 – nslookup killercoda.com

these should not work
k -n space1 exec app1-0 – curl -m 1 tester.default.svc.cluster.local
k -n space1 exec app1-0 – curl -m 1 killercoda.com

67
Q

how do u use namespace selector by name? not labels but name!!!

A
  • namespaceSelector:
    matchLabels:
    kubernetes.io/metadata.name: space2
68
Q

There was one qn ask was to creating cpu limit not beyond the NS QUOTA. but when I can’t find any quota on namespace

A

The q was in a comment under https://www.youtube.com/watch?v=h9-6K8v3wHM`

obs! chatgpt said no automatic way to make ns limits are not exceeeded by all pods, needs to be checked manually!

69
Q

What is CPU resource units, the quantity expression 0.1 is equivalent to when expressed differently?

A

For CPU resource units, the quantity expression 0.1 is equivalent to the expression 100m, which can be read as “one hundred millicpu”.

70
Q

how to canary deploy?

A

No magic! just 2 keys:
1) labels is the key which tie together old deploy, new deploy and service. just dont forget that in a deploy spec same label name is mentioned 3 times!
2) second is just to have right spec.replicas that correspond to the task, 2 (new) and 8(old) for 20/80 with max 10 replicas!

71
Q

how to see labels attached to a namespace?

A

k get ns -A –show-labels

72
Q

how to quickly see in which context you are?

A

k config get-contexts (look for star *)
or
k config current-context

73
Q

What objects does not belong to namespace but entire thing?

A

PVs, StorageClass, CRD, clusterrole and clusterrolebinding, namespace and componentstatus are not bound to any ns.

74
Q

whats the easiest way to get kubectl within namespace and context to do anything?

A

kubectl –context=<other-context-name> -n <other-namespace> <command></command></other-namespace></other-context-name>

75
Q

when creating new deployment to fulfill canary deployment 80/20 of total 10 replicas, how many elements of deploy have label app: wonderful?

A

3: metadata.label, spec.selector.matchLabels, spec.template.metadata

p.s. for seamless transition between green and blue deployment you can use labels. And service allows seamless transitions when applied. Thats what chatgpt says:

Apply the updated Service configuration using kubectl apply -f <service-file>.yaml. Kubernetes Services are designed to provide a seamless transition of traffic from one set of Pods to another when the selector labels are updated, allowing for zero downtime.</service-file>

76
Q

When setting the context, i need to have 4 params of which 2 are probably the same as in other contexts and 2 are probably new. what are they?

A

kubectl config set-context dev –namespace=development \
–cluster=lithe-cocoa-92103_kubernetes \
–user=lithe-cocoa-92103_kubernetes

obs! ingen förkortning på namespace!!!

And then kubectl config use-context dev

77
Q

where are manifest files located?

A

/etc/kubernetes/manifests/. Remember E.K.M like ekg but M in the end.

78
Q

whats a container hostname from within the cluster?

A

podName.nsName.svc.cluster.local

79
Q

What are PV mount options?

A

Retain - meaning the PV, until deleted, is kept alive.
Recycle - meaning the data can be restored later after getting scrubbed.
Delete - associated storage assets (such as AWS EBS, GCE PD, Azure Disk, and OpenStack Cinder volumes) are deleted.

80
Q

Name one way to troubleshoot fluentd logging?

A

Check the queued log messages
You can check the buffer directory if Fluent Bit is configured to buffer queued log messages to disk instead of in memory. (You can configure it through the InputTail fluentbit config, by setting the storage.type field to filesystem.)

kubectl exec -it logging-demo-fluentbit-9dpzg ls /buffers

Ref: https://kube-logging.dev/docs/operation/troubleshooting/fluentbit/

81
Q

What does it mean if, in deployment spec, under spec: i have the following:

  tolerations:
  - effect: NoSchedule
    operator: Exists
A

it seems like it means no schedule unless there is a matching toleration!

82
Q

howto get the name of the serviceaccount your pod is using?

A

kubectl get pods/<podname> -o yaml
In the output, you see a field spec.serviceAccountName. Kubernetes automatically sets that value if you don't specify it when you create a Pod.
Obs! This is about how an application running inside a Pod can access the Kubernetes API!</podname>

83
Q

What does it mean if a task require “Set the security context for a Pod”

A

It seems its this part:
securityContext:
runAsUser: 1000
runAsGroup: 3000
fsGroup: 2000

Obs! it can be set both on pod and container level!

84
Q

What are all the bookmarks pointing to?

A

“kubectl commands” generated, tasks, reference, concepts, tutorials, helm.sh

85
Q

how do i found out if a node have taints?

A

k get nodes controlplane -o json| grep -i10 taints

86
Q

why would a pod be scheduled on a node despite the taint?

A

A pod might be scheduled on a node with a taint for several reasons, despite the general expectation that taints should prevent pods from being scheduled unless they tolerate the taint. Here are some common scenarios:

Tolerations: The most likely reason is that the pod has a toleration that matches the taint on node01. Tolerations allow pods to schedule onto nodes with matching taints. If a pod’s toleration key, value, and effect match those of a taint on a node, the scheduler allows the pod to be placed on that node.

Taint Effect: The effect of the taint on the node may allow the scheduling of the pod under certain conditions. For example, a taint with the PreferNoSchedule effect might not strictly prevent all pods from being scheduled on the node; instead, it will try to avoid placing pods on the node but isn’t guaranteed to prevent it.

DaemonSets: Pods created by DaemonSets are scheduled on all nodes that match the DaemonSet’s node selector, ignoring most taints by default. This is because DaemonSets often represent system-level functions that need to run on all nodes.

Critical System Pods: Some critical system pods might be scheduled on any node regardless of taints to ensure the stability and functionality of the cluster. These could include pods related to Kubernetes system components like networking or DNS.

Changes to Taints or Tolerations: The taint on node01 might have been added after the pod was already scheduled and running on the node. Similarly, the tolerations for the pod might have been added or modified after the pod was created, allowing it to be scheduled on a tainted node.

Administrative Override: A cluster administrator can manually schedule a pod on a node regardless of taints, using specific commands or configurations that bypass the usual scheduling constraints.

If you are encountering a situation where pods are being scheduled on a node with a taint and it’s not clear why it’s important to review the pod’s tolerations, the taints on the node, and any administrative actions that might have affected scheduling decisions.

87
Q

whatsup with removing taint ?

A

its the same as adding, just a minus in the end

kubectl taint nodes controlplane node-role.kubernetes.io/control-plane:NoSchedule-

88
Q

Can you label both pod and node? and if so how?

A

k label node node01 color=blue

89
Q

how to find out what node consumes most cpu or mem?

A

k top node! P.s. similar as for pod k top pod.

90
Q

how do you see the status of init container using describe pod command?

A

Its under init-containers/state! Its ABSOLUTELY NOT in the bottom where its says running and started even though those rows are about init container.

91
Q

if a pod have a init container with these command, what does it say about the pods availability?
Command:
sh
-c
sleep 600

A

That the pod will be available after 10min: 60sek * 10

92
Q

it does not make sense that if node taint condition match pod toleration with condition NoSchedule, its something positive?

A

Its because NoSchedule is basically abbreviation for NoScheduleUnlessTheAboveRuleMatch!

93
Q

how to know if i should use podaffinity with labelSelector vs nodeAffinity with nodeSelectorTerms?

A

For starters the example actually specified NodeAffinity!

94
Q

Whats the differences between node affinity and pod affinity?

A

Node Affinity ensures that pods are hosted on particular nodes. Pod Affinity ensures two pods to be co-located in a single node.

95
Q

how to get explanation for any structure?

A

kubectl explain deployment.spec.template.spec.affinityexplain deployment.spec.template.spec.affinity

96
Q

whats topologyKey ?

A

topologyKey is the key of node labels. If two Nodes are labelled with this key and have identical values for that label, the scheduler treats both Nodes as being in the same topology. The scheduler tries to place a balanced number of Pods into each topology domain.

97
Q

Whats the difference of applying nodeAffinity/podAffinity/podAntiAffinity on a pod vs deployment?

A

For pod its spec.affinity.nodeAffinity.reuiredDuring.. structure and for deployment its spec.template.spec.affinity.nodeAffinity.requiredDuring… structure

98
Q

How do i find out How many DIFFERENT OBJECTS are in the prod environment including PODs, ReplicaSets and any other objects?

A

k get all –selector env=prod

p.s. selelctor seems like equal of label: -l env=prod

99
Q

how do i Identify the POD which is part of the prod environment, the finance BU and of frontend tier?

A

i comma-separate the labels rather than putting -l in front of each one as in: k get pod -o wide -l tier=frontend,env=prod,bu=finance

100
Q

whats the Relationship Between spec.selector.matchLabels and spec.template.metadata.labels ?

A

The labels defined in spec.template.metadata.labels must match the selector defined in spec.selector.matchLabels. This is how Kubernetes knows which Pods are managed by which Deployment (or other workload resources).
When a Deployment creates new Pods, it adds the labels from spec.template.metadata.labels to those Pods. The Deployment’s selector (spec.selector.matchLabels) must be able to match these labels, or else the Deployment will not recognize the Pods as its own.
This relationship ensures that the Deployment only manages the Pods that it’s supposed to manage, according to the labels and selectors you define.

Same goes for Replicaset, E.g.:

apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: replicaset-1
spec:
replicas: 2
selector:
matchLabels:
tier: front-end
template:
metadata:
labels:
tier: front-end
spec:
containers:
- name: nginx
image: nginx

101
Q

can you please explain why the these command produce errors when trying to apply generated yaml: k create job throw-dice-job –image=kodekloud/throw-dice –dry-run=server -o yaml > q2of9.yaml

A

Its due to the usage of –dry-run=server

Chatgpt: The errors you’re encountering when applying the YAML generated with –dry-run=server for a Kubernetes Job are related to the spec.selector and spec.template.metadata.labels fields. When you generate YAML with –dry-run=server, the Kubernetes server populates certain fields that are usually auto-generated during the actual creation of a resource. These fields include unique identifiers and selectors that are intended to be managed by Kubernetes itself and not specified manually.

102
Q

what parameter do i need to mind on a JOB so it does not quit before it succede?

A

its spec.backoffLimit of a job yaml!

This is the indicator:
describe job | grep -i Succeeded
Pods Statuses: 0 Active (0 Ready) / 1 Succeeded / 0 Failed

103
Q

What would you put in the JOB spec so it completes 3 times successfully out of randomly many required attempts?

A

spec:
completions: 3
backoffLimit: 25 # This is so the job does not quit before it succeeds.

104
Q

How do you know how many endpoints exist for a given system

A

? i answered 1 because there were no Subsets and it was correct!

Obs! The exam tip: Run the command: kubectl describe service and look at the Endpoints

Endpoints is a collection of endpoints that implement the actual service. Example:

Name: “mysvc”,
Subsets: [
{
Addresses: [{“ip”: “10.10.1.1”}, {“ip”: “10.10.2.2”}],
Ports: [{“name”: “a”, “port”: 8675}, {“name”: “b”, “port”: 309}]
},
{
Addresses: [{“ip”: “10.10.3.3”}],
Ports: [{“name”: “a”, “port”: 93}, {“name”: “b”, “port”: 76}]
},
]

105
Q

how do you know which type of traffic is the netpol affecting?

A

k describe netpol payroll-policy. There is a type there!

106
Q

how do you create entirely different Egress rules for different pods?

A

You have multiple “- to” blocks. E.g.:

egress:
- to:
- podSelector:
matchLabels:
name: mysql
ports:
- protocol: TCP
port: 3306

  • to:

Obs! ports under “-to” part is described by same explain as just “to” without leading dash!

107
Q

how would you know which namespace is the Ingress Controller deployed in?

A

Actually, its not trivial. The answer was the namepace of the service deployment.apps/ingress-nginx-controller and not the namespace i see in when i run these: k get ingress -A

108
Q

whats service port vs. targetport?

A

The primary distinction between port and targetPort is that port specifies the Service‘s listening port for incoming traffic. The targetPort field specifies the port number for routing traffic to the Service‘s pods.

109
Q

when do i use rewrite-target in a new ingress instead of just adding mapping to an existing ingress?

A

It could be appropriate in several scenarios, particularly when you need to manage how URLs are rewritten and directed to your backend services in a way that’s distinct from the existing mappings. Here’s an example use case:

One of these applications, let’s call it AppX, is designed to handle requests under a specific path, say /appx/*. However, AppX is developed to expect requests that do not include the /appx prefix in the URI path.

Another reason maybe security, need for ssl termination.

110
Q

Guess why this ingress i constructed myself from official doc did not work?

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: minimal-ingress
namespace: critical-space
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx-example
rules:
- http:
paths:
- path: /pay
pathType: Prefix
backend:
service:
name: pay-service
port:
number: 8282

A

IngressClassName should not be there at all! P.s. i guess in that case default one is used.

p.s. wrong namespace was the thirst error.

111
Q

how do you delete label from service?

A

The same minus in the end!:
kubectl label service my-service app-

112
Q

what comes to mind when creating ingress for existing two servicec on the exam?

A

Ingress resource comes under the namespace scoped, so don’t forget to create the ingress in the same namespace as the services this is applied to!

p.s. ports of the services is not what you see on the surface by: get svc - o wide but inside the decription

113
Q

what can be done instead of deleting a pod when you added a volume but forgot to add it under container?

A

i can use the force flag.

p.s. replace instead of apply and then –force flag, but apply actually also worked but only with –force flag

114
Q

Sometimes its not straightforward to find example definitions for some objects, e.g. pvc. Whats a more straighforward way to search for it?

A

“kind: PersistentVolumeClaim”

115
Q

why was the pvc not bound but pending in kodecloud lab?

A

its because the access mode was a mismatch with the pv.

p.s. i created PV first and PVC second

116
Q

Whats interesting about capacity when the PV was just claimed and bound and PV was 100Mi and PVC was 50Mi ?

A

Checking capactiy under k get pvc showed 100!!!

117
Q

Det finns 2 fel med CronJob i lightning-lab-2-2/

A

1) completions,backoffLimit,activeDeadlineSeconds skulle sitta på spec.jobTemplate.spec och inte på spec 2) restartPolicy: Never

118
Q

when you want to expose a deployment as a service, how do you do that when the deployment is in different namespace?

A

k -n yourNS expose deploy europe –port 80

Obs! k expose deploy -h does not saying anything about namespace, so its important to remember its kubectl itself that have that parameter!

119
Q

What do you derive out of a CKAD saying following:

There are two existing Deployments in Namespace world which should be made accessible via an Ingress.

First: create ClusterIP Services for both Deployments for port 80 . The Services should have the same name as the Deployments.

A
  1. you should run expose command
  2. ingress does not exist and dont even need to exist?????
  3. BOTTOMLINE: you should run the following for each:
    k -n world expose deploy europe –port 80

see first exercise here: https://killercoda.com/nginx-ingress/scenario/ingress-create

120
Q

what would be one thing i can easily mess up when creating ingress? Based on excercise nr 2 here https://killercoda.com/nginx-ingress/scenario/ingress-create

A

These part:

spec:
ingressClassName: nginx
rules:
- host: “world.universe.mine”

Tips1: ingress class name can be looked up like: get ingressclasses
Tips2: hos comes w/o port and in these case reflected in /etc/hosts

121
Q

Nämn alla ställen att kolla på vid api server crash enligt https://killercoda.com/killer-shell-cka/scenario/apiserver-crash

A

/var/log/pods
/var/log/containers
crictl ps + crictl logs
docker ps + docker logs (in case when Docker is used)
kubelet logs: /var/log/syslog or journalctl

122
Q

kubernetes manifest location

A

/etc/kubernetes/manifests

123
Q

how to check logs for all containers in the same deployment?

A

kubectl logs –all-containers deploy/collect-data

124
Q

are these equivalent? is these configs separated by — not equivalent?
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: space2

egress:
- to:
- namespaceSelector:
matchExpressions:
- key: namespace
operator: In
values: [“space2”]

A
125
Q

howto find answer to that error :

k apply -f /apps/flowschema.yaml –dry-run=client
error: resource mapping not found for name: “health-for-strangers” namespace: “” from “/apps/flowschema.yaml”: no matches for kind “FlowSchema” in version “flowcontrol.apiserver.k8s.io/v1beta2”

A

kubectl api-versions | grep flow

126
Q

how do i find admission control plugin names?

A

cat /etc/kubernetes/manifests/kube-apiserver.yaml OR ELSE ps aux | grep kube-apiserver

127
Q

1.how do i disable an admission controller plugin? 2. and why would i do that?

A

1.Although it does not exist per default i add it in the same /etc/kubernetes/manifests/kube-apiserver.yaml
2. I do it because i am crazy and want to delete default namespace

128
Q

whats tricky for my mind in these way to select namespace?:

namespaceSelector:
matchExpressions:
- key: namespace
operator: In
values: [“space2”]

A

i assume its about name of the namespace while, according to chatgpt, it matches namespaces where the LABEL NAMESPACE exists and its value is space2. !!! What???

Facit alt1: that key would have worked: kubernetes.io/metadata.name
Facit alt2: - namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: space2