Skip to content

Commit e41db34

Browse files
committed
learn k8s
1 parent 246a215 commit e41db34

File tree

30 files changed

+147
-101
lines changed

30 files changed

+147
-101
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
XXXX
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
XXXX

03-installation-and-setup/kind-bind-mount-2/test2.xx

Whitespace-only changes.

04-built-in-resource-types/Deployment/Deployment.nginx-minimal.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ spec:
1414
spec:
1515
containers:
1616
- name: nginx
17-
image: nginx:1.26.0
17+
# Change image tag then ReplicaSet will create new Pods
18+
image: nginx:1.25.0

04-built-in-resource-types/Deployment/Taskfile.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ tasks:
2828
desc: "Roll the pods in one of the deployments"
2929
cmds:
3030
- kubectl rollout restart deployment nginx-better
31+
# Switch to previous ReplicaSet
32+
3133
- watch "kubectl get pods"
3234

35+
# kubectl rollout undo deployment nginx-better
36+
3337
05-delete-namespace:
3438
desc: "Delete the namespace to clean up"
3539
cmds:

04-built-in-resource-types/Ingress/Ingress.minimal-nginx.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ spec:
1515
pathType: ImplementationSpecific
1616
backend:
1717
service:
18-
name: nginx-clusterip
18+
name: nginx-nodeport
1919
port:
2020
number: 80
21+
# kubectl run curl-pod -it --rm --image=curlimages/curl --command -- sh
22+
# curl -H "Host: ingress-example-nginx.com" <node_ip>:<node_port>
23+
# -H to specify the host header
24+
# <node_ip>: is the IP of the node where the Ingress controller is running
25+
# <node_port>: is the NodePort of the Ingress controller

04-built-in-resource-types/Service/Taskfile.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,18 @@ tasks:
4242
- cmd: gum style "🚨 Deleting the namespace recursively deletes the resources inside of it! 🚨 "
4343
silent: true
4444
- kubectl delete -f Namespace.yaml
45+
# Debug shell on a node => It create a debug pod on the node
46+
# kubectl debug node/kind-worker2 -it --image=ubuntu
47+
48+
# Debug shell on a pod => It create a debug pod on the same node
49+
# kubectl run curl-pod -it --rm --image=curlimages/curl --command -- sh
50+
# curl <pod_ip>:<pod_port>
51+
# curl <service_ip or service_name>:<service_port>
52+
# eg: curl nginx-clusterip
53+
# node_port defined in the service
54+
# eg: curl <node_ip>:<node_port>
55+
56+
# kubectl run curl-pod -it --rm -n default --image=curlimages/curl --command -- sh
57+
# outside namespace
58+
# curl <service_name>.<namespace>.svc.cluster.local
59+
# eg: curl nginx-clusterip.04--service.svc.cluster.local

05-helm/postgresql/Taskfile.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ tasks:
3434
silent: true
3535
- helm registry login registry-1.docker.io
3636
desc: Login to OCI registry
37+
# sonthh98/<docker-hub_password>
3738

3839
05-list-registry:
3940
cmds:

06-demo-application/api-golang/Taskfile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3"
22

33
vars:
44
DATABASE_URL: "postgres://postgres:foobarbaz@localhost:5432/postgres"
5-
IMAGE_REPO: sidpalas/devops-directive-docker-course-api-golang
5+
IMAGE_REPO: sonthh98/devops-directive-docker-course-api-golang
66
IMAGE_TAG: foobarbaz
77

88
tasks:

06-demo-application/api-node/Taskfile.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ version: "3"
22

33
vars:
44
DATABASE_URL: "postgres://postgres:foobarbaz@localhost:5432/postgres"
5-
IMAGE_REPO: sidpalas/devops-directive-docker-course-api-node
5+
IMAGE_REPO: sonthh98/devops-directive-docker-course-api-node
66
IMAGE_TAG: foobarbaz
77

88
tasks:
99
build-container-image:
1010
desc: Build container image
1111
cmds:
12-
- docker build -t {{.IMAGE_REPO}}{{.IMAGE_TAG}} .
12+
- docker build -t {{.IMAGE_REPO}}:{{.IMAGE_TAG}} .
1313

1414
build-container-image-multi-arch:
1515
desc: Build multi-arch container image

06-demo-application/client-react/Taskfile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: "3"
22

33
vars:
4-
IMAGE_REPO: sidpalas/devops-directive-docker-course-client-react-nginx
4+
IMAGE_REPO: sonthh98/devops-directive-docker-course-client-react-nginx
55
IMAGE_TAG: foobarbaz
66

77
tasks:

06-demo-application/load-generator-python/Taskfile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: "3"
22

33
vars:
4-
IMAGE_REPO: sidpalas/devops-directive-kubernetes-course-load-generator-python
4+
IMAGE_REPO: sonthh98/devops-directive-kubernetes-course-load-generator-python
55
IMAGE_TAG: foobarbaz
66

77
tasks:

06-demo-application/postgresql/Taskfile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: "3"
22

33
vars:
4-
IMAGE_REPO: sidpalas/devops-directive-kubernetes-course-db-migrator
4+
IMAGE_REPO: sonthh98/devops-directive-kubernetes-course-db-migrator
55
IMAGE_TAG: foobarbaz
66

77
tasks:

07-deploying-demo-application/api-golang/Deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
spec:
1818
containers:
1919
- name: api-golang
20-
image: sidpalas/devops-directive-docker-course-api-golang:foobarbaz
20+
image: sonthh98/devops-directive-docker-course-api-golang:foobarbaz
2121
env:
2222
- name: PORT
2323
value: "8000"
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
apiVersion: traefik.containo.us/v1alpha1
2-
kind: IngressRoute
3-
metadata:
4-
name: api-golang
5-
namespace: demo-app
6-
spec:
7-
entryPoints:
8-
- web
9-
routes:
10-
- kind: Rule
11-
match: Host(`kubernetes-course.devopsdirective.com`) && PathPrefix(`/api/golang`)
12-
middlewares:
13-
- name: strip-api-prefixes
14-
services:
15-
- kind: Service
16-
name: api-golang
17-
port: 8000
18-
scheme: http
1+
# apiVersion: traefik.containo.us/v1alpha1
2+
# kind: IngressRoute
3+
# metadata:
4+
# name: api-golang
5+
# namespace: demo-app
6+
# spec:
7+
# entryPoints:
8+
# - web
9+
# routes:
10+
# - kind: Rule
11+
# match: Host(`kubernetes-course.devopsdirective.com`) && PathPrefix(`/api/golang`)
12+
# middlewares:
13+
# - name: strip-api-prefixes
14+
# services:
15+
# - kind: Service
16+
# name: api-golang
17+
# port: 8000
18+
# scheme: http

07-deploying-demo-application/api-golang/Secret.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ metadata:
66
name: api-golang-database-url
77
namespace: demo-app
88
stringData:
9-
DATABASE_URL: postgres://postgres:foobarbaz@postgres-postgresql.postgres.svc.cluster.local:5432/postgres
9+
DATABASE_URL: postgres://postgres:foobarbaz@postgres-postgresql.postgresx.svc.cluster.local:5432/postgres

07-deploying-demo-application/api-node/Deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
spec:
1818
containers:
1919
- name: api-node
20-
image: sidpalas/devops-directive-docker-course-api-node:foobarbaz
20+
image: sonthh98/devops-directive-docker-course-api-node:foobarbaz
2121
env:
2222
- name: PORT
2323
value: "3000"
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
apiVersion: traefik.containo.us/v1alpha1
2-
kind: IngressRoute
3-
metadata:
4-
name: api-node
5-
namespace: demo-app
6-
spec:
7-
entryPoints:
8-
- web
9-
routes:
10-
- kind: Rule
11-
match: Host(`kubernetes-course.devopsdirective.com`) && PathPrefix(`/api/node`)
12-
middlewares:
13-
- name: strip-api-prefixes
14-
services:
15-
- kind: Service
16-
name: api-node
17-
port: 3000
18-
scheme: http
1+
# apiVersion: traefik.containo.us/v1alpha1
2+
# kind: IngressRoute
3+
# metadata:
4+
# name: api-node
5+
# namespace: demo-app
6+
# spec:
7+
# entryPoints:
8+
# - web
9+
# routes:
10+
# - kind: Rule
11+
# match: Host(`kubernetes-course.devopsdirective.com`) && PathPrefix(`/api/node`)
12+
# middlewares:
13+
# - name: strip-api-prefixes
14+
# services:
15+
# - kind: Service
16+
# name: api-node
17+
# port: 3000
18+
# scheme: http

07-deploying-demo-application/api-node/Secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ metadata:
66
name: api-node-database-url
77
namespace: demo-app
88
stringData:
9-
DATABASE_URL: postgres://postgres:foobarbaz@postgres-postgresql.postgres.svc.cluster.local:5432/postgres
9+
DATABASE_URL: postgres://postgres:foobarbaz@postgres-postgresql.postgresx.svc.cluster.local:5432/postgres

07-deploying-demo-application/client-react/ConfigMap.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,24 @@ data:
1313
add_header 'Content-Type' 'text/plain';
1414
return 200 "pong";
1515
}
16-
16+
location /api/golang/ {
17+
proxy_set_header X-Forwarded-Host $host;
18+
proxy_set_header X-Forwarded-Server $host;
19+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
20+
proxy_http_version 1.1;
21+
22+
rewrite ^/api-golang/(.*) /$1 break;
23+
proxy_pass http://api-golang:8000/;
24+
}
25+
location /api/node/ {
26+
proxy_set_header X-Forwarded-Host $host;
27+
proxy_set_header X-Forwarded-Server $host;
28+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
29+
proxy_http_version 1.1;
30+
31+
rewrite ^/api/node/(.*) /$1 break;
32+
proxy_pass http://api-node:3000/;
33+
}
1734
location / {
1835
root /usr/share/nginx/html;
1936
index index.html index.htm;

07-deploying-demo-application/client-react/Deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spec:
1616
app: client-react-nginx
1717
spec:
1818
containers:
19-
- image: sidpalas/devops-directive-docker-course-client-react-nginx:foobarbaz
19+
- image: sonthh98/devops-directive-docker-course-client-react-nginx:foobarbaz
2020
name: client-react-nginx
2121
ports:
2222
- containerPort: 8080
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
apiVersion: traefik.containo.us/v1alpha1
2-
kind: IngressRoute
3-
metadata:
4-
name: client-react-nginx
5-
namespace: demo-app
6-
spec:
7-
entryPoints:
8-
- web
9-
routes:
10-
- kind: Rule
11-
match: Host(`kubernetes-course.devopsdirective.com`)
12-
services:
13-
- kind: Service
14-
name: client-react-nginx
15-
port: 8080
16-
scheme: http
1+
# apiVersion: traefik.containo.us/v1alpha1
2+
# kind: IngressRoute
3+
# metadata:
4+
# name: client-react-nginx
5+
# namespace: demo-app
6+
# spec:
7+
# entryPoints:
8+
# - web
9+
# routes:
10+
# - kind: Rule
11+
# match: Host(`kubernetes-course.devopsdirective.com`)
12+
# services:
13+
# - kind: Service
14+
# name: client-react-nginx
15+
# port: 8080
16+
# scheme: http
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
apiVersion: traefik.containo.us/v1alpha1
2-
kind: Middleware
3-
metadata:
4-
name: strip-api-prefixes
5-
namespace: demo-app
6-
spec:
7-
stripPrefix:
8-
forceSlash: false
9-
prefixes:
10-
- /api/node
11-
- /api/golang
1+
# apiVersion: traefik.containo.us/v1alpha1
2+
# kind: Middleware
3+
# metadata:
4+
# name: strip-api-prefixes
5+
# namespace: demo-app
6+
# spec:
7+
# stripPrefix:
8+
# forceSlash: false
9+
# prefixes:
10+
# - /api/node
11+
# - /api/golang

07-deploying-demo-application/common/Taskfile.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ tasks:
77
- kubectl apply -f Namespace.yaml
88
- kubens demo-app
99

10-
deploy-traefik:
11-
desc: "Deploy Traefik using Helm"
12-
cmds:
13-
- helm repo add traefik https://traefik.github.io/charts
14-
- helm upgrade --install -n traefik --create-namespace traefik traefik/traefik --version 20.8.0
10+
# deploy-traefik:
11+
# desc: "Deploy Traefik using Helm"
12+
# cmds:
13+
# - helm repo add traefik https://traefik.github.io/charts
14+
# - helm upgrade --install -n traefik --create-namespace traefik traefik/traefik --version 20.8.0
1515

16-
apply-traefik-middleware:
17-
desc: "Deploy Traefik middleware"
18-
cmds:
19-
- "kubectl apply -f Middleware.yaml"
16+
# apply-traefik-middleware:
17+
# desc: "Deploy Traefik middleware"
18+
# cmds:
19+
# - "kubectl apply -f Middleware.yaml"

07-deploying-demo-application/load-generator-python/ConfigMap.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ metadata:
66
name: load-generator-config
77
namespace: demo-app
88
data:
9-
API_URL: http://api-node.demo-app.svc.cluster.local:3000
10-
# API_URL: http://api-golang.demo-app.svc.cluster.local:8080
9+
# API_URL: http://api-node.demo-app.svc.cluster.local:3000
10+
API_URL: http://api-golang.demo-app.svc.cluster.local:8080
1111
DELAY_MS: "100"

07-deploying-demo-application/load-generator-python/Deployment.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ spec:
1717
spec:
1818
containers:
1919
- name: load-generator
20-
image: sidpalas/devops-directive-kubernetes-course-load-generator-python:foobarbaz
20+
image: sonthh98/devops-directive-kubernetes-course-load-generator-python:foobarbaz
2121
imagePullPolicy: Always
22-
env:
23-
- name: API_URL
24-
value: http://api-node.demo-app.svc.cluster.local:3000
25-
- name: DELAY_MS
26-
value: "500"
22+
# env:
23+
# - name: API_URL
24+
# value: http://api-node.demo-app.svc.cluster.local:3000
25+
# - name: DELAY_MS
26+
# value: "500"
2727
# Could alternatively move these to a configmap
28-
# envFrom:
29-
# - configMapRef:
30-
# name: load-generator-config
28+
envFrom:
29+
- configMapRef:
30+
name: load-generator-config
3131
resources:
3232
limits:
3333
memory: "50Mi"

07-deploying-demo-application/postgresql/Job.db-migrator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ spec:
88
spec:
99
containers:
1010
- name: migrate
11-
image: sidpalas/devops-directive-kubernetes-course-db-migrator:foobarbaz
11+
image: sonthh98/devops-directive-kubernetes-course-db-migrator:foobarbaz
1212
args:
1313
- -path=/app/migrations
1414
- -database=$(DATABASE_URL)?sslmode=disable

07-deploying-demo-application/postgresql/Secret.db-password.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ metadata:
66
namespace: demo-app
77
type: Opaque
88
stringData:
9-
DATABASE_URL: postgres://postgres:[email protected]:5432/postgres
9+
DATABASE_URL: postgres://postgres:[email protected]:5432/postgres
10+
# cat /etc/resolv.conf in Postgres pod to get the cluster DNS suffix

07-deploying-demo-application/postgresql/Taskfile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ tasks:
77
- helm repo add bitnami https://charts.bitnami.com/bitnami
88
- |
99
helm upgrade --install \
10-
-n postgres \
10+
-n postgresx \
1111
postgres bitnami/postgresql \
1212
--set auth.postgresPassword=foobarbaz \
1313
--version 15.3.2 \

0 commit comments

Comments
 (0)