Skip to content

Commit

Permalink
My answers to chapter 03 lab
Browse files Browse the repository at this point in the history
  • Loading branch information
serra committed Jan 3, 2024
1 parent b22cd74 commit 961f289
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
30 changes: 29 additions & 1 deletion ch03/lab/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
kubectl apply -f deployments.yaml
# Lab Assignment

## Goal

Deploy services for updated version of numbers app.

## Tests

```bash
kubectl apply -f deployments.yaml
kubectl get pods
```

> There are two versions of the web app
Expand All @@ -13,3 +22,22 @@ kubectl apply -f solution/services.yaml
> http://localhost:8088
![](./solution/numbers-web-v2.png)


## Steps

1. deploy the applications from the application manifest
2. inspect what pods are running
1. what services are already running?
1. only the k8s clusterip
2. what pods are already running?
1. three pods (api, web, web-v2)
3. if needed configure services in a separate file
1. configure a local service for the api
2. configure a load balancer, first select web v1

## Learnings

When reapplying a manifest, k8s knows what to patch or create.

Selectors in services differ from pod templates in deployment; the `matchLabel:` is not needed in services.
2 changes: 1 addition & 1 deletion ch03/lab/deployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ spec:
spec:
containers:
- name: web
image: kiamol/ch03-numbers-web:v2
image: kiamol/ch03-numbers-web:v2
24 changes: 24 additions & 0 deletions ch03/lab/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v1
kind: Service
metadata:
name: numbers-api
spec:
ports:
- port: 80
selector:
app: lab-numbers-api
version: v1
type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
name: numbers-web
spec:
ports:
- port: 8080
targetPort: 80
selector:
app: lab-numbers-web
version: v2
type: LoadBalancer

0 comments on commit 961f289

Please sign in to comment.