Browse Source

add canary

dotbalo 6 years ago
parent
commit
d274fbd5d7

+ 58 - 0
canary/canary-deployment-v1.yaml

@@ -0,0 +1,58 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  annotations:
+    deployment.kubernetes.io/revision: "1"
+  generation: 1
+  labels:
+    app: canary-v1
+  name: canary-v1
+  namespace: canary-production
+  resourceVersion: "486797"
+spec:
+  progressDeadlineSeconds: 2147483647
+  replicas: 1
+  revisionHistoryLimit: 10
+  selector:
+    matchLabels:
+      app: canary-v1
+  strategy:
+    rollingUpdate:
+      maxSurge: 1
+      maxUnavailable: 1
+    type: RollingUpdate
+  template:
+    metadata:
+      creationTimestamp: null
+      labels:
+        app: canary-v1
+    spec:
+      containers:
+      - image: dotbalo/canary:v1
+        imagePullPolicy: Always
+        name: canary-v1
+        ports:
+        - containerPort: 8080
+          protocol: TCP
+        terminationMessagePath: /dev/termination-log
+        terminationMessagePolicy: File
+      dnsPolicy: ClusterFirst
+      restartPolicy: Always
+      schedulerName: default-scheduler
+      securityContext: {}
+      terminationGracePeriodSeconds: 30
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: canary-v1
+  namespace: canary-production
+spec:
+  ports:
+  - port: 8080
+    protocol: TCP
+    targetPort: 8080
+  selector:
+    app: canary-v1
+  sessionAffinity: None
+  type: ClusterIP

+ 58 - 0
canary/canary-deployment-v2.yaml

@@ -0,0 +1,58 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  annotations:
+    deployment.kubernetes.io/revision: "1"
+  generation: 1
+  labels:
+    app: canary-v2
+  name: canary-v2
+  namespace: canary-production-canary
+  resourceVersion: "486797"
+spec:
+  progressDeadlineSeconds: 2147483647
+  replicas: 1
+  revisionHistoryLimit: 10
+  selector:
+    matchLabels:
+      app: canary-v2
+  strategy:
+    rollingUpdate:
+      maxSurge: 1
+      maxUnavailable: 1
+    type: RollingUpdate
+  template:
+    metadata:
+      creationTimestamp: null
+      labels:
+        app: canary-v2
+    spec:
+      containers:
+      - image: dotbalo/canary:v2
+        imagePullPolicy: Always
+        name: canary-v2
+        ports:
+        - containerPort: 8080
+          protocol: TCP
+        terminationMessagePath: /dev/termination-log
+        terminationMessagePolicy: File
+      dnsPolicy: ClusterFirst
+      restartPolicy: Always
+      schedulerName: default-scheduler
+      securityContext: {}
+      terminationGracePeriodSeconds: 30
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: canary-v2
+  namespace: canary-production-canary
+spec:
+  ports:
+  - port: 8080
+    protocol: TCP
+    targetPort: 8080
+  selector:
+    app: canary-v2
+  sessionAffinity: None
+  type: ClusterIP

+ 15 - 0
canary/canary-ingress-v1.yaml

@@ -0,0 +1,15 @@
+apiVersion: extensions/v1beta1
+kind: Ingress
+metadata:
+  name: canary-v1
+  namespace: canary-production
+  annotations:
+    kubernetes.io/ingress.class: nginx
+spec:
+  rules:
+  - host: canary.com
+    http:
+      paths:
+      - backend:
+          serviceName: canary-v1
+          servicePort: 8080

+ 17 - 0
canary/canary-ingress-v2.yaml

@@ -0,0 +1,17 @@
+apiVersion: extensions/v1beta1
+kind: Ingress
+metadata:
+  name: canary-v2
+  namespace: canary-production-canary
+  annotations:
+    kubernetes.io/ingress.class: nginx
+    nginx.ingress.kubernetes.io/canary: "true"
+    nginx.ingress.kubernetes.io/canary-weight: "10"
+spec:
+  rules:
+  - host: canary.com
+    http:
+      paths:
+      - backend:
+          serviceName: canary-v2
+          servicePort: 8080

+ 8 - 0
canary/count.rb

@@ -0,0 +1,8 @@
+counts = Hash.new(0)
+
+100.times do
+  output = `curl -s canary.com | grep 'Canary' | awk '{print $2}' | awk -F"<" '{print $1}'`
+  counts[output.strip.split.last] += 1
+end
+
+puts counts