This commit is contained in:
2024-02-20 17:15:27 +08:00
committed by huty
parent 6706e1a633
commit 34158042ad
1529 changed files with 177765 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
# Ch09 lab
Run v1 of the app:
```
kubectl apply -f lab/v1/
```
Get the URL and browse:
```
kubectl get svc vweb -o jsonpath='http://{.status.loadBalancer.ingress[0].*}:8090'
```
> v1 is the blue deployment
## Sample Solution
My [v2 Deployment](solution/vweb-v2.yaml) runs four Pods from the v2 image. It's a new Deployment object, not an update to the existing v1 Deployment.
My [Service update](solution/vweb-service-v2.yaml) changes the label selector in the existing service to point to the Pods in the v2 Deployment.
```
kubectl apply -f lab/solution/
```
> v2 is the green deployment
You can flip between blue and green by updating just the Service:
```
# for v1
kubectl apply -f lab/v1/vweb-service-v1.yaml
```
```
# for v2
kubectl apply -f lab/solution/vweb-service-v2.yaml
```
> Your browser may cache the response, so be sure to do a full refresh (usually Ctrl-F5 on Windows and Cmd+Shift+R on Mac)
## Teardown
Delete the lab resources by their labels:
```
kubectl delete all -l kiamol=ch09-lab
```

View File

@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: vweb
labels:
kiamol: ch09-lab
spec:
ports:
- port: 8090
targetPort: http
selector:
app: vweb
version: v2
type: LoadBalancer

View File

@@ -0,0 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: vweb-v2
labels:
kiamol: ch09-lab
app: vweb
spec:
replicas: 4
selector:
matchLabels:
app: vweb
version: v2
template:
metadata:
labels:
app: vweb
version: v2
spec:
containers:
- name: web
image: kiamol/ch09-vweb:v2
ports:
- name: http
containerPort: 80

View File

@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: vweb
labels:
kiamol: ch09-lab
spec:
ports:
- port: 8090
targetPort: http
selector:
app: vweb
version: v1
type: LoadBalancer

View File

@@ -0,0 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: vweb-v1
labels:
kiamol: ch09-lab
app: vweb
spec:
replicas: 4
selector:
matchLabels:
app: vweb
version: v1
template:
metadata:
labels:
app: vweb
version: v1
spec:
containers:
- name: web
image: kiamol/ch09-vweb:v1
ports:
- name: http
containerPort: 80