diff --git a/.infrastructure/clusterip.yml b/.infrastructure/clusterip.yml new file mode 100644 index 0000000..a864eaf --- /dev/null +++ b/.infrastructure/clusterip.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/nodeport.yml b/.infrastructure/nodeport.yml new file mode 100644 index 0000000..2c074d3 --- /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: todolist + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + nodePort: 30007 diff --git a/.infrastructure/todoapp-pod.yml b/.infrastructure/todoapp-pod.yml index b1e4f8b..5f4b1ff 100644 --- a/.infrastructure/todoapp-pod.yml +++ b/.infrastructure/todoapp-pod.yml @@ -3,6 +3,34 @@ kind: Pod metadata: name: todoapp namespace: todoapp + labels: + app: todolist +spec: + containers: + - name: todoapp + image: ikulyk404/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-1 + namespace: todoapp + labels: + app: todolist spec: containers: - name: todoapp diff --git a/README.md b/README.md index 981fe53..c4d93e3 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. + +# ---------------------------------------- + +# Let's create a new service: + +kubectl apply -f ./infrastructure/busybox.yml +kubectl apply -f ./infrastructure/namespace.yml +kubectl apply -f ./infrastructure/clusterip.yml +kubectl apply -f ./infrastructure/nodeport.yml +kubectl apply -f ./infrastructure/ttodoapp-pod.yml + +# Connect to the container busybox: + +kubectl -n todoapp exec -it busybox -- sh + +# Inside the container, query the DNS name of the ClusterIP service using curl: + +curl http://todoapp-clusteri.todoapp.svc.cluster.local + +# Forward a local port to the ClusterIP service: + +kubectl port-forward service/todoapp-clusterip 8080:80 -n todoapp + +# Open browser: + +http://localhost:8080 +or +http://localhost:3007