Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: CKAD Updates for the 2024 exam #1

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 05-SERVICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Create it:
- `k aplly -f svc-definition.yml`

Expose a pod:
- `kubectl expose pod nginx --port=80 --name nginx-service --type=ClusterIP`
- `kubectl expose pod nginx --port=80 --name nginx-service`
- `--type=ClusterIP` is default, and `--target-port=` will the same as `--port=` is you don't set it

To see more details of the a POD:
- `k get po -o wide`
3 changes: 3 additions & 0 deletions 06-COMMANDS-ARGUMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Run POD with command and arguments:
- "5000"
```

Or just:
- `k run ubuntu --image=ubuntu --command sleep 5000`

Obs.:
- The tag `command` is will overwrite the tag `ENTRYPOINT` from Dockerfile.
- The tag `args` is will overwrite the tag `CMD` from Dockerfile.
Expand Down
9 changes: 4 additions & 5 deletions 09-SECURITY-CONTEXT.md → 09-SERVICE-ACCOUNT.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
How to create kubectl alias (optional):
- `alias k=kubectl`
## Service Account

Get all service accounts:
- Get all service accounts:
```
k get sa -A
```

Service Account for the POD:
- Service Account for the POD:
```
k create serviceaccount my-sa
```
To get the name of the token to see the value of the token:
- To get the name of the token to see the value of the token:
```
k describe serviceaccount my-sa
k describe secret my-sa-token-kbbdm
Expand Down
9 changes: 6 additions & 3 deletions 10-SERVICE-ACCOUNT.md → 10-SECURITY-CONTEXT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
How to create kubectl alias (optional):
- `alias k=kubectl`

Security Context for the POD:
```
Expand Down Expand Up @@ -52,4 +50,9 @@ Security Context for the Container with capabilities:
```

To see more details of the a POD:
- `k get po -o wide`
- `k get po -o wide`

---

Doc:
- <https://kubernetes.io/docs/tasks/configure-pod-container/security-context/>
2 changes: 0 additions & 2 deletions 11-RESOURCE-LIMITS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
How to create kubectl alias (optional):
- `alias k=kubectl`

Limite resorces for all the PODS in default NS:
```
Expand Down
2 changes: 0 additions & 2 deletions 12-TAINTS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
How to create kubectl alias (optional):
- `alias k=kubectl`

Create a taint
- `k taint nodes node-name key=value:taint-effect`
Expand Down
2 changes: 0 additions & 2 deletions 13-NODE-SELECTORS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
How to create kubectl alias (optional):
- `alias k=kubectl`

Create a label
- `k label nodes node1 app=ssd`
Expand Down
2 changes: 0 additions & 2 deletions 14-NODE-AFFINITY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
How to create kubectl alias (optional):
- `alias k=kubectl`

Show all labels on the nodes:
- `k get nodes --show-labels`
Expand Down
83 changes: 66 additions & 17 deletions 15-MILTI-CONTAINER-PODS.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,75 @@
How to create kubectl alias (optional):
- `alias k=kubectl`
#### Sidecar containers

- Here's an example of a Deployment with two containers, one of which is a sidecar:

```
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
labels:
app: myapp
spec:
replicas: 1
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: alpine:latest
command: ['sh', '-c', 'while true; do echo "logging" >> /opt/logs.txt; sleep 1; done']
volumeMounts:
- name: data
mountPath: /opt
initContainers:
- name: logshipper
image: alpine:latest
restartPolicy: Always
command: ['sh', '-c', 'tail -F /opt/logs.txt']
volumeMounts:
- name: data
mountPath: /opt
volumes:
- name: data
emptyDir: {}
```

- Two containers in a POD and sharing a volume, different mounthPaths but the same shared folder:

Add a Label on a POD:
```
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
name: two-containers
spec:

volumes:
- name: shared-data
emptyDir: {}

containers:
- image: nginx
name: nginx-container
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: app
operator: In
values:
- ssd

- name: nginx-container
image: nginx
volumeMounts:
- name: shared-data
mountPath: /usr/share/nginx/html

- name: debian-container
image: debian
volumeMounts:
- name: shared-data
mountPath: /pod-data
command: ["/bin/sh"]
args: ["-c", "echo Hello from the debian container > /pod-data/index.html"]
```

To see more details of the a POD:
- `k get po -o wide`
---

Doc:
- <https://kubernetes.io/docs/concepts/workloads/pods/>
2 changes: 0 additions & 2 deletions 16-READNESS-LIVENESS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
How to create kubectl alias (optional):
- `alias k=kubectl`

Add livenessProbe and readinessProbe on a POD:
```
Expand Down
2 changes: 0 additions & 2 deletions 17-LOGGING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
How to create kubectl alias (optional):
- `alias k=kubectl`

Show the POD logs:
- `k logs pod-name`
Expand Down
4 changes: 1 addition & 3 deletions 18-MONITORING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
How to create kubectl alias (optional):
- `alias k=kubectl`

Go to github and install metrics-server:
Go to github and install metrics-server(If needed):
- `https://github.com/kubernetes-sigs/metrics-server`

Get Nodes metrics:
Expand Down
12 changes: 7 additions & 5 deletions 19-POD-LABELS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
How to create kubectl alias (optional):
- `alias k=kubectl`

Documentation:
- https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
#### Labels

Add two labels on a POD:
```
Expand All @@ -23,3 +19,9 @@ Add two labels on a POD:

Get Pods by labels:
- `k get pods -l environment=production,tier=frontend`


---

Doc:
- https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
2 changes: 0 additions & 2 deletions 20-LABELS-SELECTORS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
How to create kubectl alias (optional):
- `alias k=kubectl`

Get Nodes metrics:
- `k get pods --selector app=app1`
Expand Down
2 changes: 0 additions & 2 deletions 21-ROLLING-UPDATES-AND-ROLLBACKS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
How to create kubectl alias (optional):
- `alias k=kubectl`

Deployment Strategys:
- Recreate
Expand Down
3 changes: 1 addition & 2 deletions 22-JOBS-CRONJOBS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
How to create kubectl alias (optional):
- `alias k=kubectl`
#### CronJob - Jobs

Add a JOB:
```
Expand Down
3 changes: 1 addition & 2 deletions 23-SERVICES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
How to create kubectl alias (optional):
- `alias k=kubectl`
#### Service

Service NodePort:
```
Expand Down
6 changes: 2 additions & 4 deletions 24-INGRESS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
How to create kubectl alias (optional):
- `alias k=kubectl`
- `alias kdr='kubectl -o yaml --dry-run=client'`

#### Ingress

Install Nginx Ingress Controller Steps:
- ConfigMap
- `kdr create configmap nginx-configuration -n ingress-space > configmap.yml`
Expand Down
13 changes: 7 additions & 6 deletions 25-NETWORK-POLICIES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
How to create kubectl alias (optional):
- `alias k=kubectl`

Documentation:
- https://kubernetes.io/docs/concepts/services-networking/network-policies/
#### Network Policy

NetworkPolicy example:
```
Expand Down Expand Up @@ -37,4 +33,9 @@ Create it:


Obs.: ***Flannel*** does not support NetwotkPolicies.
But ***Kube-router, Calico, Romana, Weave-net*** does.
But ***Kube-router, Calico, Cilium...*** does support.

---

Doc:
- <https://kubernetes.io/docs/concepts/services-networking/network-policies/>
17 changes: 5 additions & 12 deletions 26-VOLUMES-PV-PVC.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
How to create kubectl alias (optional):
- `alias k=kubectl`

Documentation:
- https://kubernetes.io/docs/concepts/storage/volumes/
- https://kubernetes.io/docs/concepts/storage/persistent-volumes/
#### Persistent Volumes and PV. Claims

Persistent Volumes:
```
Expand Down Expand Up @@ -60,10 +55,8 @@ POD:
claimName: my-pvc
```

---


volumes:
- name: default-token-qq6ns
secret:
defaultMode: 420
secretName: default-token-qq6ns
Doc:
- <https://kubernetes.io/docs/concepts/storage/volumes/>
- <https://kubernetes.io/docs/concepts/storage/persistent-volumes/>
43 changes: 43 additions & 0 deletions 27 - HELM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## Helm

#### Install

Go to <https://helm.sh/docs/intro/install/>

#### Some commands

- `helm search hub` searches the Artifact Hub, which lists helm charts from dozens of different repositories.
- `helm search repo` searches the repositories that you have added to your local helm
```
helm search repo wordpress
helm search hub wordpress
```

- Add a Repo:
```
helm repo add bitname https://charts.bitnami.com/bitnami
helm repo update
```

- Search for a repo:
`helm search repo joomla`

- List repositories:
`helm repo ls`

- Env prints out all the environment info in use by Helm
`helm env`

- Install App:
- `helm install <name> <chart>`
- Ex.: `helm install my-nginx stable/nginx-ingress`
- Uninstall App:
- `helm uninstall <name>`
- Ex.: `helm uninstall my-nginx`
- You can pass `--namespace my-namespace` as well

- Pull and download:
- `helm pull <chart> --untar=true`

Some Cheats:
<https://helm.sh/docs/intro/cheatsheet/>
Loading