diff --git a/.infrastructure/ClusterIP.yml b/.infrastructure/ClusterIP.yml new file mode 100644 index 0000000..c5cb187 --- /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 diff --git a/.infrastructure/NodePort.yml b/.infrastructure/NodePort.yml new file mode 100644 index 0000000..a2be9d9 --- /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 diff --git a/.infrastructure/busybox.yml b/.infrastructure/busybox.yml index 5ff1aad..d1cce41 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 + - "1000" 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