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

solved #43

Open
wants to merge 1 commit 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
8 changes: 3 additions & 5 deletions .infrastructure/busybox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
namespace: todoapp
spec:
containers:
- name: busybox
image: ikulyk404/busyboxplus:curl
args:
- sleep
- "1000"
- name: busybox
image: niklafinskiy/alpine-curl:1.0.0
command: ["/bin/sh", "-c", "apk update && apk add coreutils && sleep infinity"]
13 changes: 13 additions & 0 deletions .infrastructure/clusterIpService.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: cluster-ip-service
namespace: todoapp
spec:
type: ClusterIP
selector:
app: todolist
ports:
- protocol: TCP
port: 80
targetPort: 8080
14 changes: 14 additions & 0 deletions .infrastructure/nodePortService.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: node-port-service
namespace: todoapp
spec:
type: NodePort
selector:
app: todolist
ports:
- protocol: TCP
port: 80
targetPort: 8080
nodePort: 30007
36 changes: 36 additions & 0 deletions .infrastructure/todoapp-pod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ kind: Pod
metadata:
name: todoapp
namespace: todoapp
labels:
app: todolist
spec:
containers:
- name: todoapp
image: ikulyk404/todoapp:3.0.0
env:
- name: PYTHONUNBUFFERED
value: "1"
ports:
- containerPort: 8080
livenessProbe:
Expand All @@ -21,3 +26,34 @@ spec:
port: 8080
initialDelaySeconds: 5
periodSeconds: 5

---

apiVersion: v1
kind: Pod
metadata:
name: todoapp-2
namespace: todoapp
labels:
app: todolist
spec:
containers:
- name: todoapp
image: ikulyk404/todoapp:3.0.0
env:
- name: PYTHONUNBUFFERED
value: "1"
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
24 changes: 24 additions & 0 deletions INSTRUCTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
In order to set up the cluster services and pods:
kubectl apply -f .infrastructure/namespace.yml
kubectl apply -f .infrastructure/nodePortService.yml
kubectl apply -f .infrastructure/clusterIpService.yml
kubectl apply -f .infrastructure/todoapp-pod.yml
kubectl apply -f .infrastructure/busybox.yml

Optionally set the current namespace to the namespace that was created:
kubectl config set-context --current --namespace todoapp

In order to access the todoapp server using the busybox container:
1. First get the name of the service:
kubectl get svc
2. Next sh into the busy box container and perform a request to the service:
kubectl exec -it busybox -- /bin/sh
curl -v http://cluster-ip-service.todoapp.cluster.local

In order to access the todoapp server from the browser:
kubectl port-forward service/cluster-ip-service 8080:80

In order to access the todoapp server using the node-port service:
1. Get the IP address of one of the nodes:
minikube ip
2. Make a request to the service from the browser by using the IP address of the node and the nodePort (30007)