Skip to content

Instantly share code, notes, and snippets.

@sqerison
Last active September 16, 2021 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sqerison/3a45a7e9eb1f3600fe12032d3d7efd41 to your computer and use it in GitHub Desktop.
Save sqerison/3a45a7e9eb1f3600fe12032d3d7efd41 to your computer and use it in GitHub Desktop.
Example of Argo Rollouts Canary deployment
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
spec:
args:
- name: service-name
metrics:
- name: success-rate
interval: 5m
# NOTE: prometheus queries return results in the form of a vector.
# So it is common to access the index 0 of the returned array to obtain the value
successCondition: result[0] >= 0.95
failureLimit: 3
provider:
prometheus:
address: http://prometheus.example.com:9090
query: |
sum(irate(
istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}",response_code!~"5.*"}[5m]
)) /
sum(irate(
istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}"}[5m]
))
apiVersion: argoproj.io/v1alpha1 # Create a rollout resource
kind: Rollout
metadata:
name: rollout-ref-deployment
spec:
replicas: 5
workloadRef: # Reference an existing Deployment using workloadRef field
apiVersion: apps/v1
kind: Deployment
name: rollout-ref-deployment
strategy:
# --- Everything above this comment are the same as a deployment ---
canary: # A new field for configurable Canary options
steps:
- setWeight: 10
analysis:
templates:
- templateName: success-rate
- setWeight: 50
- pause: {duration: 10m}
apiVersion: argoproj.io/v1alpha1 # Changed from apps/v1
kind: Rollout # Changed from Deployment
metadata:
name: rollout
spec:
replicas: 10
selector:
matchLabels:
app: nginx
template: # --- Everything inside template section is the same as a deployment
# --- Deployment specs
minReadySeconds: 30
revisionHistoryLimit: 3
strategy:
# --- Everything above this comment are the same as a deployment ---
canary: # A new field for configurable Canary options
steps:
- setWeight: 10
analysis:
templates:
- templateName: success-rate
- setWeight: 50
- pause: {duration: 10m}
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
namespace: default
name: deny-from-other-namespaces
spec:
podSelector:
matchLabels:
ingress:
- from:
- podSelector: {}
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: api-allow-5000
spec:
podSelector:
matchLabels:
app: apiserver
ingress:
- ports:
- port: 5000
from:
- podSelector:
matchLabels:
role: monitoring
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: web-allow-prod
spec:
podSelector:
matchLabels:
app: web
ingress:
- from:
- namespaceSelector:
matchLabels:
purpose: production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment