diff --git a/.infrastructure/clusterip.yml b/.infrastructure/clusterip.yml new file mode 100644 index 0000000..ef0a86e --- /dev/null +++ b/.infrastructure/clusterip.yml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: todolist-clusterip +spec: + selector: + app: todolist + 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..52ed24d --- /dev/null +++ b/.infrastructure/nodeport.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: todolist-nodeport +spec: + selector: + app: todolist + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + nodePort: 30007 + type: NodePort diff --git a/.infrastructure/todoapp-pod.yml b/.infrastructure/todoapp-pod.yml index b1e4f8b..4be5cb4 100644 --- a/.infrastructure/todoapp-pod.yml +++ b/.infrastructure/todoapp-pod.yml @@ -6,7 +6,7 @@ metadata: spec: containers: - name: todoapp - image: ikulyk404/todoapp:3.0.0 + image: guver2004/todoapp:3.0.0 ports: - containerPort: 8080 livenessProbe: @@ -21,3 +21,28 @@ spec: port: 8080 initialDelaySeconds: 5 periodSeconds: 5 + +--- +apiVersion: v1 +kind: Pod +metadata: + name: todoapp + namespace: todoapp +spec: + containers: + - name: todoapp + image: guver2004/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 diff --git a/README.md b/README.md index 981fe53..1d7d790 100644 --- a/README.md +++ b/README.md @@ -41,3 +41,33 @@ 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. + +# How to run: +1. create namespace + ```kubectl apply -f .infrastructure/namespace.yml``` + +2. start pods + ```kubectl apply -f .infrastructure/todoapp-pod.yml``` + +3. start busybox pod + ```kubectl apply -f .infrastructure/busybox.yml``` + +4. start cluster ip +```kubectl apply -f .infrastructure/clusterip.yml``` + +5. start node port + ```kubectl apply -f .infrastructure/nodeport.yml``` + +6. enter busybox container + ```kubectl -n todoapp exec -it busybox -- sh``` + +7. to check connection using port forwarding run + ``` + kubectl port-forward service/todoapp-clusterip 8081:80 -n todoapp + curl http://todoapp-cluster.todoapp.svc.cluster.local + ``` + +8. to check access from nodeport use link http://localhost:30007/ + +9. to do the cleanup run + ```kubectl delete namespace todoapp cleanup```