Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #41

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .infrastructure/clusterIp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: todoapp-service
namespace: todoapp
spec:
selector:
app: todolist

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The selector label app: todolist must match the labels of the pods you want this service to target. Ensure that the pods in the todoapp namespace have the label app: todolist. If the pods have a different label, update this selector accordingly.

ports:
- protocol: TCP
port: 80
targetPort: 8080
type: ClusterIP
14 changes: 14 additions & 0 deletions .infrastructure/nodeport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: todoapp-nodeport-service
namespace: todoapp
spec:
type: NodePort
selector:
app: todolist

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The selector label app: todolist must match the labels of the pods you want this service to target. Ensure that the pods in the todoapp namespace have the label app: todolist. If the pods have a different label, update this selector accordingly.

ports:
- protocol: TCP
port: 80
targetPort: 8080
nodePort: 30007
34 changes: 34 additions & 0 deletions .infrastructure/todoapp-pod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,40 @@ kind: Pod
metadata:
name: todoapp
namespace: todoapp
labels:
app: todolist
spec:
containers:
- name: todoapp
image: ikulyk404/todoapp:3.0.0
imagePullPolicy: Always
env:
- name: APP_ENV
value: "develop"
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
Expand Down
37 changes: 37 additions & 0 deletions INSTRUCTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## How to apply all manifests

To apply manifests, open project folder in terminal and execute following commands:

```
cd .\infrastructure\
kubectl apply -f namespace.yml
kubectl apply -f todoapp-pod.yml
kubectl apply -f busybox.yml
kubectl apply -f clusterIp.yml
kubectl apply -f nodeport.yml
cd ..
```

## How to test by calling a ClusterIP service
``
kubectl -n todoapp exec -it busybox -- sh
``

After succesfuly exec into the busybox pod, execute next command in shell

``
curl http://todoapp-service:80
``

## How to test ToDo application using the service port-forward command

``
kubectl -n todoapp port-forward service/todoapp-service 8080:80
``
Once the port forward is set up, you can access the service running on the pod visiting `http://localhost:8080`

## How to access an app using a NodePort Service

``
http://localhost:30007
``