From 8b735cc717e1d3491e3da62d7f9d0aac285c28e9 Mon Sep 17 00:00:00 2001 From: Vicheslav Der Date: Sun, 13 Oct 2024 23:45:02 +0300 Subject: [PATCH 1/2] solution --- .infrastructure/busybox.yml | 2 +- .infrastructure/lcasterIp.yml | 13 +++++++++++++ .infrastructure/node-port.yml | 15 +++++++++++++++ .infrastructure/todoapp-pod.yml | 28 +++++++++++++++++++++++++++- README.md | 28 ++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 .infrastructure/lcasterIp.yml create mode 100644 .infrastructure/node-port.yml diff --git a/.infrastructure/busybox.yml b/.infrastructure/busybox.yml index 4d1c7fa..dda4f47 100644 --- a/.infrastructure/busybox.yml +++ b/.infrastructure/busybox.yml @@ -6,7 +6,7 @@ metadata: spec: containers: - name: busybox - image: ikulyk404/busyboxplus:curl + image: efirshey/busyboxplus:latest args: - sleep - "1000" diff --git a/.infrastructure/lcasterIp.yml b/.infrastructure/lcasterIp.yml new file mode 100644 index 0000000..cfc5d1c --- /dev/null +++ b/.infrastructure/lcasterIp.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: todoapp-clusterip + namespace: todoapp +spec: + selector: + app: todolist + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + type: ClusterIP diff --git a/.infrastructure/node-port.yml b/.infrastructure/node-port.yml new file mode 100644 index 0000000..2c071c7 --- /dev/null +++ b/.infrastructure/node-port.yml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: todoapp-nodeport + namespace: todoapp +spec: + selector: + app: todolist + type: NodePort + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + nodePort: 30007 + \ No newline at end of file diff --git a/.infrastructure/todoapp-pod.yml b/.infrastructure/todoapp-pod.yml index b1e4f8b..b57c3af 100644 --- a/.infrastructure/todoapp-pod.yml +++ b/.infrastructure/todoapp-pod.yml @@ -6,7 +6,33 @@ metadata: spec: containers: - name: todoapp - image: ikulyk404/todoapp:3.0.0 + image: efirshey/todoapp:3.0.0 + ports: + - containerPort: 8080 + 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 + namespace: todoapp +spec: + containers: + - name: todoapp-1 + image: efirshey/todoapp:3.0.0 ports: - containerPort: 8080 livenessProbe: diff --git a/README.md b/README.md index 981fe53..b0eb2cc 100644 --- a/README.md +++ b/README.md @@ -41,3 +41,31 @@ 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. + + + +## Test + +1. Connect to the busybox: + +``` +kubectl -n todoapp exec -it busybox -- sh +``` + +2. Run curl: + +``` +curl http://todoapp-clusterip.todoapp.svc.cluster.local +``` + +3. Check using port-forwarding: + +``` +kubectl port-forward service/todoapp-clusterip 8081:80 -n todoapp +``` + +4. Check app using NodePort, following the link below: + +``` +http://localhost:30007 +``` \ No newline at end of file From 20849a90b54f96dcd0ae253071e2127bdba8e2b2 Mon Sep 17 00:00:00 2001 From: Vicheslav Der Date: Sun, 13 Oct 2024 23:46:54 +0300 Subject: [PATCH 2/2] eof --- .infrastructure/node-port.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.infrastructure/node-port.yml b/.infrastructure/node-port.yml index 2c071c7..0e519d6 100644 --- a/.infrastructure/node-port.yml +++ b/.infrastructure/node-port.yml @@ -12,4 +12,3 @@ spec: port: 80 targetPort: 8080 nodePort: 30007 - \ No newline at end of file