This commit is contained in:
Pamir Erdem
2018-09-13 19:45:25 +03:00
parent 53e8b81a05
commit 23da749101
4 changed files with 123 additions and 1 deletions

View File

@@ -7,4 +7,6 @@
kubectl apply -f app-v2.yaml
kubectl get pods -n bluegreen
kubectl patch service my-app -n bluegreen -p '{"spec":{"selector":{"version":"v2.0.0"}}}'
kubectl delete ns bluegreen
kubectl delete pod nettools

View File

@@ -0,0 +1,16 @@
kubectl create ns canary
kubectl apply -f app-v1.yaml
kubectl run --restart=Never --image=raesene/alpine-nettools nettools
kubectl exec -it nettools -- /bin/sh
while true; do curl http://my-app.canary; done
kubectl apply -f app-v2.yaml
kubectl scale deployment my-app-v2 -n canary --replicas=10
kubectl scale deployment my-app-v1 -n canary --replicas=0
kubectl get pods -n canary
kubectl delete ns canary

View File

@@ -0,0 +1,60 @@
apiVersion: v1
kind: Service
metadata:
name: my-app
namespace: canary
labels:
app: my-app
spec:
type: NodePort
ports:
- name: http
port: 80
targetPort: http
selector:
app: my-app
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app-v1
namespace: canary
labels:
app: my-app
spec:
replicas: 10
selector:
matchLabels:
app: my-app
version: v1.0.0
template:
metadata:
labels:
app: my-app
version: v1.0.0
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9101"
spec:
containers:
- name: my-app
image: containersol/k8s-deployment-strategies
ports:
- name: http
containerPort: 8080
- name: probe
containerPort: 8086
env:
- name: VERSION
value: v1.0.0
livenessProbe:
httpGet:
path: /live
port: probe
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe:
httpGet:
path: /ready
port: probe
periodSeconds: 5

View File

@@ -0,0 +1,44 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app-v2
namespace: canary
labels:
app: my-app
spec:
replicas: 1
selector:
matchLabels:
app: my-app
version: v2.0.0
template:
metadata:
labels:
app: my-app
version: v2.0.0
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9101"
spec:
containers:
- name: my-app
image: containersol/k8s-deployment-strategies
ports:
- name: http
containerPort: 8080
- name: probe
containerPort: 8086
env:
- name: VERSION
value: v2.0.0
livenessProbe:
httpGet:
path: /live
port: probe
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe:
httpGet:
path: /ready
port: probe
periodSeconds: 5