From 75c71f82e25dcfb4cf8df1a5b3564a8ddae524a8 Mon Sep 17 00:00:00 2001 From: Serveladus Date: Fri, 26 Jul 2024 17:19:50 +0300 Subject: [PATCH 1/3] Solution --- .infrastructure/busybox.yml | 2 +- .infrastructure/todoapp-pod.yml | 38 ++++++++++++++++++++++++++++++++- README.md | 14 ++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/.infrastructure/busybox.yml b/.infrastructure/busybox.yml index 5ff1aad..e243314 100644 --- a/.infrastructure/busybox.yml +++ b/.infrastructure/busybox.yml @@ -6,7 +6,7 @@ metadata: spec: containers: - name: busybox - image: radial/busyboxplus:curl + image: busybox:stable args: - sleep - "1000" \ No newline at end of file diff --git a/.infrastructure/todoapp-pod.yml b/.infrastructure/todoapp-pod.yml index b1e4f8b..3da5957 100644 --- a/.infrastructure/todoapp-pod.yml +++ b/.infrastructure/todoapp-pod.yml @@ -3,12 +3,48 @@ kind: Pod metadata: name: todoapp namespace: todoapp + labels: + app: todoapp spec: containers: - name: todoapp - image: ikulyk404/todoapp:3.0.0 + image: XtheCutter/todoapp:3.0.0 ports: - containerPort: 8080 + env: + - name: PYTHONUNBUFFERED + value: "1" + livenessProbe: + httpGet: + path: api/health + port: 8080 + initialDelaySeconds: 60 + periodSeconds: 5 + readinessProbe: + httpGet: + path: api/ready + port: 8080 + initialDelaySeconds: 5 + periodSeconds: 5 + +--- + +apiVersion: v1 +kind: Pod +metadata: + name: todoapp-2 + namespace: todoapp + labels: + app: todoapp +spec: + containers: + - name: todoapp + image: XtheCutter/todoapp:3.0.0 + ports: + - containerPort: 8080 + env: + - name: PYTHONUNBUFFERED + value: "1" livenessProbe: httpGet: path: api/health diff --git a/README.md b/README.md index 981fe53..8116aae 100644 --- a/README.md +++ b/README.md @@ -41,3 +41,17 @@ Create a kubernetes manifest for a pod which will containa ToDo app container: 1. `README.md` file should contain instructions on how to test ToDo application using the service `port-forward` command 1. `README.md` should contain instruction on how to access an app using a NodePort Service 1. Create PR with your changes and attach it for validation on a platform. + +kubectl apply -f clusterIp.yml +kubectl apply -f nodeport.yml + +kubectl get services -o wide +kubectl port-forward service/todoapp-clusterip-service 8081:80 -n todoapp + +Check: http://localhost:8081 + +Test: +kubectl -n todoapp exec -it busybox -- sh +curl http://todoapp-clusterip-service.todoapp.svc.cluster.local + +http://localhost:30007 From 343417c813c6dd6b97cca8c19001c6d3e757e081 Mon Sep 17 00:00:00 2001 From: Serveladus Date: Fri, 26 Jul 2024 17:20:48 +0300 Subject: [PATCH 2/3] Solution2 --- .infrastructure/ClusterIP.yml | 13 +++++++++++++ .infrastructure/NodePort.yml | 14 ++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .infrastructure/ClusterIP.yml create mode 100644 .infrastructure/NodePort.yml diff --git a/.infrastructure/ClusterIP.yml b/.infrastructure/ClusterIP.yml new file mode 100644 index 0000000..412f74a --- /dev/null +++ b/.infrastructure/ClusterIP.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: todoapp-clusterip-service + namespace: todoapp +spec: + selector: + app: todoapp + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + type: ClusterIP \ No newline at end of file diff --git a/.infrastructure/NodePort.yml b/.infrastructure/NodePort.yml new file mode 100644 index 0000000..a3b819e --- /dev/null +++ b/.infrastructure/NodePort.yml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: todoapp-nodeport-service + namespace: todoapp +spec: + type: NodePort + selector: + app: todoapp + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + nodePort: 30007 \ No newline at end of file From 82cfc84a7b5cacca1b87917e192732fc12667eb3 Mon Sep 17 00:00:00 2001 From: Serveladus Date: Sat, 27 Jul 2024 15:09:38 +0300 Subject: [PATCH 3/3] Solution3 --- .infrastructure/ClusterIP.yml | 2 +- .infrastructure/NodePort.yml | 2 +- .infrastructure/busybox.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.infrastructure/ClusterIP.yml b/.infrastructure/ClusterIP.yml index 412f74a..c5cb187 100644 --- a/.infrastructure/ClusterIP.yml +++ b/.infrastructure/ClusterIP.yml @@ -10,4 +10,4 @@ spec: - protocol: TCP port: 80 targetPort: 8080 - type: ClusterIP \ No newline at end of file + type: ClusterIP diff --git a/.infrastructure/NodePort.yml b/.infrastructure/NodePort.yml index a3b819e..a2be9d9 100644 --- a/.infrastructure/NodePort.yml +++ b/.infrastructure/NodePort.yml @@ -11,4 +11,4 @@ spec: - protocol: TCP port: 80 targetPort: 8080 - nodePort: 30007 \ No newline at end of file + nodePort: 30007 diff --git a/.infrastructure/busybox.yml b/.infrastructure/busybox.yml index e243314..d1cce41 100644 --- a/.infrastructure/busybox.yml +++ b/.infrastructure/busybox.yml @@ -9,4 +9,4 @@ spec: image: busybox:stable args: - sleep - - "1000" \ No newline at end of file + - "1000"