Skip to content

Commit 44863a4

Browse files
committed
IntoTheDevOps: Add End-to-End Kubernetes content
Signed-off-by: NotHarshhaa <reddyharshhaa12@gmail.com>
1 parent 52e27c3 commit 44863a4

28 files changed

+4509
-0
lines changed

topics/kubernetes/CKA.md

Lines changed: 868 additions & 0 deletions
Large diffs are not rendered by default.

topics/kubernetes/README.md

Lines changed: 3157 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Kustomize - Common Labels
2+
3+
## Requirements
4+
5+
1. Running Kubernetes cluster
6+
2. Kubctl version 1.14 or above
7+
8+
## Objectives
9+
10+
In the current directory there is an app composed of a Deployment and Service.
11+
12+
1. Write a kustomization.yml file that will add to both the Service and Deployment the label "team-name: aces"
13+
2. Execute a kustomize command that will generate the customized k8s files with the label appended
14+
15+
## Solution
16+
17+
Click [here](solution.md) to view the solution
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Kustomize - Common Labels
2+
3+
## Requirements
4+
5+
1. Running Kubernetes cluster
6+
2. Kubctl version 1.14 or above
7+
8+
## Objectives
9+
10+
In the current directory there is an app composed of a Deployment and Service.
11+
12+
1. Write a kustomization.yml file that will add to both the Service and Deployment the label "team-name: aces"
13+
2. Execute a kustomize command that will generate the customized k8s files with the label appended
14+
15+
## Solution
16+
17+
1. Add the following to kustomization.yml in someApp directory:
18+
19+
```
20+
apiVersion: kustomize.config.k8s.io/v1beta1
21+
kind: Kustomization
22+
23+
commonLabels:
24+
team-name: aces
25+
26+
resources:
27+
- service.yml
28+
- deployment.yml
29+
```
30+
31+
2. Run `kubectl apply -k someApp`
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: nginx-deployment
5+
labels:
6+
app: nginx
7+
spec:
8+
replicas: 3
9+
selector:
10+
matchLabels:
11+
app: nginx
12+
template:
13+
metadata:
14+
labels:
15+
app: nginx
16+
spec:
17+
containers:
18+
- name: nginx
19+
image: nginx:1.14.2
20+
ports:
21+
- containerPort: 80
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: my-service
5+
spec:
6+
selector:
7+
app: nginx
8+
ports:
9+
- protocol: TCP
10+
port: 80
11+
targetPort: 9376
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Labels and Selectors 101
2+
3+
## Objectives
4+
5+
1. How to list all the Pods with the label "app=web"?
6+
2. How to list all objects labeled as "env=staging"?
7+
3. How to list all deployments from "env=prod" and "type=web"?
8+
9+
## Solution
10+
11+
Click [here](solution.md) to view the solution.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Labels and Selectors 101
2+
3+
## Objectives
4+
5+
1. How to list all the Pods with the label "app=web"?
6+
2. How to list all objects labeled as "env=staging"?
7+
3. How to list all deployments from "env=prod" and "type=web"?
8+
9+
## Solution
10+
11+
`k get po -l app=web`
12+
`k get all -l env=staging`
13+
`k get deploy -l env=prod,type=web`
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Node Selectors
2+
3+
## Objectives
4+
5+
1. Apply the label "hw=max" on one of the nodes in your cluster
6+
2. Create and run a Pod called `some-pod` with the image `redis` and configure it to use the selector `hw=max`
7+
3. Explain why node selectors might be limited
8+
9+
10+
## Solution
11+
12+
Click [here](solution.md) to view the solution
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Node Selectors
2+
3+
## Objectives
4+
5+
1. Apply the label "hw=max" on one of the nodes in your cluster
6+
2. Create and run a Pod called `some-pod` with the image `redis` and configure it to use the selector `hw=max`
7+
3. Explain why node selectors might be limited
8+
9+
10+
## Solution
11+
12+
Click [here](solution.md) to view the solution
13+
14+
1. `kubectl label nodes some-node hw=max`
15+
2.
16+
17+
```
18+
kubectl run some-pod --image=redis --dry-run=client -o yaml > pod.yaml
19+
20+
vi pod.yaml
21+
22+
spec:
23+
nodeSelector:
24+
hw: max
25+
26+
kubectl apply -f pod.yaml
27+
```
28+
29+
3. Assume you would like to run your Pod on all the nodes with with either `hw` set to max or to min, instead of just max. This is not possible with nodeSelectors which are quite simplified and this is where you might want to consider `node affinity`.

0 commit comments

Comments
 (0)