diff --git a/Makefile b/Makefile index 6ccac1be..109302aa 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ run: run-appmesh: go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=appmesh \ - -metrics-server=http://ab3325177465c11e9a94c02c4171f346-2027522465.us-west-2.elb.amazonaws.com:9090 \ + -metrics-server=http://acfc235624ca911e9a94c02c4171f346-1585187926.us-west-2.elb.amazonaws.com:9090 \ -slack-url=https://hooks.slack.com/services/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 \ -slack-channel="devops-alerts" diff --git a/artifacts/appmesh/canary.yaml b/artifacts/appmesh/canary.yaml new file mode 100644 index 00000000..d2b00e03 --- /dev/null +++ b/artifacts/appmesh/canary.yaml @@ -0,0 +1,50 @@ +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: podinfo + namespace: test +spec: + # deployment reference + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: podinfo + # the maximum time in seconds for the canary deployment + # to make progress before it is rollback (default 600s) + progressDeadlineSeconds: 60 + # HPA reference (optional) + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: podinfo + service: + # container port + port: 9898 + # App Mesh reference + meshName: global.appmesh-system + # define the canary analysis timing and KPIs + canaryAnalysis: + # schedule interval (default 60s) + interval: 10s + # max number of failed metric checks before rollback + threshold: 10 + # max traffic percentage routed to canary + # percentage (0-100) + maxWeight: 50 + # canary increment step + # percentage (0-100) + stepWeight: 5 + # App Mesh Prometheus checks + metrics: + - name: envoy_cluster_upstream_rq + # minimum req success rate (non 5xx responses) + # percentage (0-100) + threshold: 99 + interval: 1m + # external checks (optional) + webhooks: + - name: load-test + url: http://flagger-loadtester.test/ + timeout: 5s + metadata: + cmd: "hey -z 1m -q 10 -c 2 http://podinfo.test:9898/" diff --git a/artifacts/appmesh/deployment.yaml b/artifacts/appmesh/deployment.yaml new file mode 100644 index 00000000..beeae326 --- /dev/null +++ b/artifacts/appmesh/deployment.yaml @@ -0,0 +1,65 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: podinfo + namespace: test + labels: + app: podinfo +spec: + minReadySeconds: 5 + revisionHistoryLimit: 5 + progressDeadlineSeconds: 60 + strategy: + rollingUpdate: + maxUnavailable: 0 + type: RollingUpdate + selector: + matchLabels: + app: podinfo + template: + metadata: + annotations: + prometheus.io/scrape: "true" + labels: + app: podinfo + spec: + containers: + - name: podinfod + image: quay.io/stefanprodan/podinfo:1.4.0 + imagePullPolicy: IfNotPresent + ports: + - containerPort: 9898 + name: http + protocol: TCP + command: + - ./podinfo + - --port=9898 + - --level=info + env: + - name: PODINFO_UI_COLOR + value: blue + livenessProbe: + exec: + command: + - podcli + - check + - http + - localhost:9898/healthz + initialDelaySeconds: 5 + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - podcli + - check + - http + - localhost:9898/readyz + initialDelaySeconds: 5 + timeoutSeconds: 5 + resources: + limits: + cpu: 2000m + memory: 512Mi + requests: + cpu: 100m + memory: 64Mi diff --git a/artifacts/appmesh/global-mesh.yaml b/artifacts/appmesh/global-mesh.yaml new file mode 100644 index 00000000..d03c06db --- /dev/null +++ b/artifacts/appmesh/global-mesh.yaml @@ -0,0 +1,7 @@ +apiVersion: appmesh.k8s.aws/v1alpha1 +kind: Mesh +metadata: + name: global + namespace: appmesh-system +spec: + serviceDiscoveryType: dns diff --git a/artifacts/appmesh/hpa.yaml b/artifacts/appmesh/hpa.yaml new file mode 100644 index 00000000..fa2b5a6f --- /dev/null +++ b/artifacts/appmesh/hpa.yaml @@ -0,0 +1,19 @@ +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: podinfo + namespace: test +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: podinfo + minReplicas: 2 + maxReplicas: 4 + metrics: + - type: Resource + resource: + name: cpu + # scale up if usage is above + # 99% of the requested CPU (100m) + targetAverageUtilization: 99 diff --git a/artifacts/appmesh/ingress.yaml b/artifacts/appmesh/ingress.yaml new file mode 100644 index 00000000..cf5bc694 --- /dev/null +++ b/artifacts/appmesh/ingress.yaml @@ -0,0 +1,177 @@ +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: ingress-config + namespace: test + labels: + app: ingress +data: + envoy.yaml: | + static_resources: + listeners: + - address: + socket_address: + address: 0.0.0.0 + port_value: 80 + filter_chains: + - filters: + - name: envoy.http_connection_manager + config: + access_log: + - name: envoy.file_access_log + config: + path: /dev/stdout + codec_type: auto + stat_prefix: ingress_http + http_filters: + - name: envoy.router + config: {} + route_config: + name: local_route + virtual_hosts: + - name: local_service + domains: ["*"] + routes: + - match: + prefix: "/" + route: + cluster: podinfo + host_rewrite: podinfo.test + timeout: 15s + retry_policy: + retry_on: "gateway-error,connect-failure,refused-stream" + num_retries: 10 + per_try_timeout: 5s + clusters: + - name: podinfo + connect_timeout: 0.30s + type: strict_dns + lb_policy: round_robin + http2_protocol_options: {} + hosts: + - socket_address: + address: podinfo.test + port_value: 9898 + admin: + access_log_path: /dev/null + address: + socket_address: + address: 0.0.0.0 + port_value: 9999 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ingress + namespace: test + labels: + app: ingress +spec: + replicas: 1 + selector: + matchLabels: + app: ingress + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 0 + template: + metadata: + labels: + app: ingress + annotations: + prometheus.io/path: "/stats/prometheus" + prometheus.io/port: "9999" + prometheus.io/scrape: "true" + # dummy port to exclude ingress from mesh traffic + # only egress should go over the mesh + appmesh.k8s.aws/ports: "444" + spec: + terminationGracePeriodSeconds: 30 + containers: + - name: ingress + image: "envoyproxy/envoy-alpine:d920944aed67425f91fc203774aebce9609e5d9a" + securityContext: + capabilities: + drop: + - ALL + add: + - NET_BIND_SERVICE + command: + - /usr/bin/dumb-init + - -- + args: + - /usr/local/bin/envoy + - --base-id 30 + - --v2-config-only + - -l + - $loglevel + - -c + - /config/envoy.yaml + ports: + - name: admin + containerPort: 9999 + protocol: TCP + - name: http + containerPort: 80 + protocol: TCP + - name: https + containerPort: 443 + protocol: TCP + livenessProbe: + initialDelaySeconds: 5 + tcpSocket: + port: admin + readinessProbe: + initialDelaySeconds: 5 + tcpSocket: + port: admin + resources: + requests: + cpu: 100m + memory: 64Mi + volumeMounts: + - name: config + mountPath: /config + volumes: + - name: config + configMap: + name: ingress-config +--- +kind: Service +apiVersion: v1 +metadata: + name: ingress + namespace: test +spec: + selector: + app: ingress + ports: + - protocol: TCP + name: http + port: 80 + targetPort: 80 + - protocol: TCP + name: https + port: 443 + targetPort: 443 + type: LoadBalancer +--- +apiVersion: appmesh.k8s.aws/v1alpha1 +kind: VirtualNode +metadata: + name: ingress + namespace: test +spec: + meshName: global.appmesh-system + listeners: + - portMapping: + port: 80 + protocol: http + serviceDiscovery: + dns: + hostName: ingress.test + backends: + - virtualService: + virtualServiceName: podinfo.test \ No newline at end of file diff --git a/artifacts/eks/appmesh-prometheus.yaml b/artifacts/eks/appmesh-prometheus.yaml new file mode 100644 index 00000000..c9386d6f --- /dev/null +++ b/artifacts/eks/appmesh-prometheus.yaml @@ -0,0 +1,264 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRole +metadata: + name: prometheus + labels: + app: prometheus +rules: + - apiGroups: [""] + resources: + - nodes + - services + - endpoints + - pods + - nodes/proxy + verbs: ["get", "list", "watch"] + - apiGroups: [""] + resources: + - configmaps + verbs: ["get"] + - nonResourceURLs: ["/metrics"] + verbs: ["get"] +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: prometheus + labels: + app: prometheus +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: prometheus +subjects: + - kind: ServiceAccount + name: prometheus + namespace: appmesh-system +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: prometheus + namespace: appmesh-system + labels: + app: prometheus +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: prometheus + namespace: appmesh-system + labels: + app: prometheus +data: + prometheus.yml: |- + global: + scrape_interval: 5s + scrape_configs: + + # Scrape config for AppMesh Envoy sidecar + - job_name: 'appmesh-envoy' + metrics_path: /stats/prometheus + kubernetes_sd_configs: + - role: pod + + relabel_configs: + - source_labels: [__meta_kubernetes_pod_container_name] + action: keep + regex: '^envoy$' + - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port] + action: replace + regex: ([^:]+)(?::\d+)?;(\d+) + replacement: ${1}:9901 + target_label: __address__ + - action: labelmap + regex: __meta_kubernetes_pod_label_(.+) + - source_labels: [__meta_kubernetes_namespace] + action: replace + target_label: kubernetes_namespace + - source_labels: [__meta_kubernetes_pod_name] + action: replace + target_label: kubernetes_pod_name + + # Exclude high cardinality metrics + metric_relabel_configs: + - source_labels: [ cluster_name ] + regex: '(outbound|inbound|prometheus_stats).*' + action: drop + - source_labels: [ tcp_prefix ] + regex: '(outbound|inbound|prometheus_stats).*' + action: drop + - source_labels: [ listener_address ] + regex: '(.+)' + action: drop + - source_labels: [ http_conn_manager_listener_prefix ] + regex: '(.+)' + action: drop + - source_labels: [ http_conn_manager_prefix ] + regex: '(.+)' + action: drop + - source_labels: [ __name__ ] + regex: 'envoy_tls.*' + action: drop + - source_labels: [ __name__ ] + regex: 'envoy_tcp_downstream.*' + action: drop + - source_labels: [ __name__ ] + regex: 'envoy_http_(stats|admin).*' + action: drop + - source_labels: [ __name__ ] + regex: 'envoy_cluster_(lb|retry|bind|internal|max|original).*' + action: drop + + # Scrape config for API servers + - job_name: 'kubernetes-apiservers' + kubernetes_sd_configs: + - role: endpoints + namespaces: + names: + - default + scheme: https + tls_config: + ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt + bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token + relabel_configs: + - source_labels: [__meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name] + action: keep + regex: kubernetes;https + + # Scrape config for nodes + - job_name: 'kubernetes-nodes' + scheme: https + tls_config: + ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt + bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token + kubernetes_sd_configs: + - role: node + relabel_configs: + - action: labelmap + regex: __meta_kubernetes_node_label_(.+) + - target_label: __address__ + replacement: kubernetes.default.svc:443 + - source_labels: [__meta_kubernetes_node_name] + regex: (.+) + target_label: __metrics_path__ + replacement: /api/v1/nodes/${1}/proxy/metrics + + # scrape config for cAdvisor + - job_name: 'kubernetes-cadvisor' + scheme: https + tls_config: + ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt + bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token + kubernetes_sd_configs: + - role: node + relabel_configs: + - action: labelmap + regex: __meta_kubernetes_node_label_(.+) + - target_label: __address__ + replacement: kubernetes.default.svc:443 + - source_labels: [__meta_kubernetes_node_name] + regex: (.+) + target_label: __metrics_path__ + replacement: /api/v1/nodes/${1}/proxy/metrics/cadvisor + + # scrape config for pods + - job_name: kubernetes-pods + kubernetes_sd_configs: + - role: pod + relabel_configs: + - action: keep + regex: true + source_labels: + - __meta_kubernetes_pod_annotation_prometheus_io_scrape + - source_labels: [ __address__ ] + regex: '.*9901.*' + action: drop + - action: replace + regex: (.+) + source_labels: + - __meta_kubernetes_pod_annotation_prometheus_io_path + target_label: __metrics_path__ + - action: replace + regex: ([^:]+)(?::\d+)?;(\d+) + replacement: $1:$2 + source_labels: + - __address__ + - __meta_kubernetes_pod_annotation_prometheus_io_port + target_label: __address__ + - action: labelmap + regex: __meta_kubernetes_pod_label_(.+) + - action: replace + source_labels: + - __meta_kubernetes_namespace + target_label: kubernetes_namespace + - action: replace + source_labels: + - __meta_kubernetes_pod_name + target_label: kubernetes_pod_name +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: prometheus + namespace: appmesh-system + labels: + app: prometheus +spec: + replicas: 1 + selector: + matchLabels: + app: prometheus + template: + metadata: + labels: + app: prometheus + annotations: + version: "appmesh-v1alpha1" + spec: + serviceAccountName: prometheus + containers: + - name: prometheus + image: "docker.io/prom/prometheus:v2.7.1" + imagePullPolicy: IfNotPresent + args: + - '--storage.tsdb.retention=6h' + - '--config.file=/etc/prometheus/prometheus.yml' + ports: + - containerPort: 9090 + name: http + livenessProbe: + httpGet: + path: /-/healthy + port: 9090 + readinessProbe: + httpGet: + path: /-/ready + port: 9090 + resources: + requests: + cpu: 10m + memory: 128Mi + volumeMounts: + - name: config-volume + mountPath: /etc/prometheus + volumes: + - name: config-volume + configMap: + name: prometheus +--- +apiVersion: v1 +kind: Service +metadata: + name: prometheus + namespace: appmesh-system + labels: + name: prometheus +spec: + selector: + app: prometheus + ports: + - name: http + protocol: TCP + port: 9090 diff --git a/artifacts/namespaces/test.yaml b/artifacts/namespaces/test.yaml index 6126d753..cff2ab62 100644 --- a/artifacts/namespaces/test.yaml +++ b/artifacts/namespaces/test.yaml @@ -4,3 +4,4 @@ metadata: name: test labels: istio-injection: enabled + appmesh.k8s.aws/sidecarInjectorWebhook: enabled diff --git a/charts/flagger/Chart.yaml b/charts/flagger/Chart.yaml index 2a2c3f8d..5491e73c 100644 --- a/charts/flagger/Chart.yaml +++ b/charts/flagger/Chart.yaml @@ -6,7 +6,7 @@ kubeVersion: ">=1.11.0-0" engine: gotpl description: Flagger is a Kubernetes operator that automates the promotion of canary deployments using Istio routing for traffic shifting and Prometheus metrics for canary analysis. home: https://docs.flagger.app -icon: https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/logo/flagger-icon.png +icon: https://raw.githubusercontent.com/weaveworks/flagger/master/docs/logo/flagger-icon.png sources: - https://github.com/weaveworks/flagger maintainers: diff --git a/charts/grafana/Chart.yaml b/charts/grafana/Chart.yaml index b515e7a0..9c985be8 100644 --- a/charts/grafana/Chart.yaml +++ b/charts/grafana/Chart.yaml @@ -3,7 +3,7 @@ name: grafana version: 1.0.0 appVersion: 5.4.3 description: Grafana dashboards for monitoring Flagger canary deployments -icon: https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/logo/flagger-icon.png +icon: https://raw.githubusercontent.com/weaveworks/flagger/master/docs/logo/flagger-icon.png home: https://flagger.app sources: - https://github.com/weaveworks/flagger diff --git a/charts/grafana/README.md b/charts/grafana/README.md index 913436c2..15c54f98 100644 --- a/charts/grafana/README.md +++ b/charts/grafana/README.md @@ -2,7 +2,7 @@ Grafana dashboards for monitoring progressive deployments powered by Istio, Prometheus and Flagger. -![flagger-grafana](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/screens/grafana-canary-analysis.png) +![flagger-grafana](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/screens/grafana-canary-analysis.png) ## Prerequisites diff --git a/charts/loadtester/Chart.yaml b/charts/loadtester/Chart.yaml index 01a00e86..9743f58b 100644 --- a/charts/loadtester/Chart.yaml +++ b/charts/loadtester/Chart.yaml @@ -6,7 +6,7 @@ kubeVersion: ">=1.11.0-0" engine: gotpl description: Flagger's load testing services based on rakyll/hey that generates traffic during canary analysis when configured as a webhook. home: https://docs.flagger.app -icon: https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/logo/flagger-icon.png +icon: https://raw.githubusercontent.com/weaveworks/flagger/master/docs/logo/flagger-icon.png sources: - https://github.com/weaveworks/flagger maintainers: diff --git a/docs/diagrams/flagger-canary-overview.png b/docs/diagrams/flagger-canary-overview.png index 53bed9e0..a0e6ff89 100644 Binary files a/docs/diagrams/flagger-canary-overview.png and b/docs/diagrams/flagger-canary-overview.png differ diff --git a/docs/diagrams/flagger-gitops-aws.png b/docs/diagrams/flagger-gitops-aws.png new file mode 100644 index 00000000..f9b275c2 Binary files /dev/null and b/docs/diagrams/flagger-gitops-aws.png differ diff --git a/docs/gitbook/README.md b/docs/gitbook/README.md index 670620e6..4f6c4ed7 100644 --- a/docs/gitbook/README.md +++ b/docs/gitbook/README.md @@ -1,5 +1,5 @@ --- -description: Flagger is an Istio progressive delivery Kubernetes operator +description: Flagger is a progressive delivery Kubernetes operator --- # Introduction @@ -13,7 +13,7 @@ Flagger implements a control loop that gradually shifts traffic to the canary wh indicators like HTTP requests success rate, requests average duration and pods health. Based on analysis of the **KPIs** a canary is promoted or aborted, and the analysis result is published to **Slack**. -![Flagger overview diagram](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/diagrams/flagger-canary-overview.png) +![Flagger overview diagram](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/diagrams/flagger-canary-overview.png) Flagger can be configured with Kubernetes custom resources and is compatible with any CI/CD solutions made for Kubernetes. Since Flagger is declarative and reacts to Kubernetes events, diff --git a/docs/gitbook/SUMMARY.md b/docs/gitbook/SUMMARY.md index 771a49be..4ce8974e 100644 --- a/docs/gitbook/SUMMARY.md +++ b/docs/gitbook/SUMMARY.md @@ -11,8 +11,9 @@ ## Usage -* [Canary Deployments](usage/progressive-delivery.md) -* [A/B Testing](usage/ab-testing.md) +* [Istio Canary Deployments](usage/progressive-delivery.md) +* [Istio A/B Testing](usage/ab-testing.md) +* [App Mesh Canary Deployments](usage/appmesh-progressive-delivery.md) * [Monitoring](usage/monitoring.md) * [Alerting](usage/alerting.md) diff --git a/docs/gitbook/how-it-works.md b/docs/gitbook/how-it-works.md index 03378a7a..bd4ba089 100644 --- a/docs/gitbook/how-it-works.md +++ b/docs/gitbook/how-it-works.md @@ -4,7 +4,7 @@ a horizontal pod autoscaler \(HPA\) and creates a series of objects \(Kubernetes deployments, ClusterIP services and Istio virtual services\) to drive the canary analysis and promotion. -![Flagger Canary Process](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/diagrams/flagger-canary-hpa.png) +![Flagger Canary Process](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/diagrams/flagger-canary-hpa.png) ### Canary Custom Resource @@ -251,7 +251,7 @@ and for backend HTTP APIs that are accessible only from inside the mesh. ### Canary Stages -![Flagger Canary Stages](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/diagrams/flagger-canary-steps.png) +![Flagger Canary Stages](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/diagrams/flagger-canary-steps.png) A canary deployment is triggered by changes in any of the following objects: @@ -579,12 +579,12 @@ Flagger metric checks will fail with "no values found for metric istio_requests_ Flagger comes with a load testing service based on [rakyll/hey](https://github.com/rakyll/hey) that generates traffic during analysis when configured as a webhook. -![Flagger Load Testing Webhook](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/diagrams/flagger-load-testing.png) +![Flagger Load Testing Webhook](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/diagrams/flagger-load-testing.png) First you need to deploy the load test runner in a namespace with Istio sidecar injection enabled: ```bash -export REPO=https://raw.githubusercontent.com/stefanprodan/flagger/master +export REPO=https://raw.githubusercontent.com/weaveworks/flagger/master kubectl -n test apply -f ${REPO}/artifacts/loadtester/deployment.yaml kubectl -n test apply -f ${REPO}/artifacts/loadtester/service.yaml diff --git a/docs/gitbook/install/flagger-install-on-eks-appmesh.md b/docs/gitbook/install/flagger-install-on-eks-appmesh.md index 4fed0684..19552fa8 100644 --- a/docs/gitbook/install/flagger-install-on-eks-appmesh.md +++ b/docs/gitbook/install/flagger-install-on-eks-appmesh.md @@ -125,12 +125,6 @@ Install the App Mesh sidecar injector in the `appmesh-system` namespace: The above script generates a certificate signed by Kubernetes CA, registers the App Mesh mutating webhook and deploys the injector. -Deploy Prometheus in the `appmesh-system` namespace: - -```bash -kubectl apply -f ./prometheus -``` - Create a mesh called global in the `appmesh-system` namespace: ```bash @@ -145,7 +139,20 @@ kubectl -n appmesh-system describe mesh Status: Mesh Condition: Status: True - Type: Active + Type: MeshActive +``` + +### Install Prometheus + +In order to expose the App Mesh metrics to Flagger, +you'll need to use Prometheus to scrapes the Envoy sidecars. + +Deploy Prometheus in the `appmesh-system` namespace: + +```bash +REPO=https://raw.githubusercontent.com/weaveworks/flagger/master + +kubectl apply -f ${REPO}/artifacts/eks/appmesh-prometheus.yaml ``` ### Install Flagger and Grafana @@ -162,7 +169,7 @@ Deploy Flagger in the _**appmesh-system**_ namespace: helm upgrade -i flagger flagger/flagger \ --namespace=appmesh-system \ --set meshProvider=appmesh \ ---set metricsServer=http://prometheus.appmesh:9090 +--set metricsServer=http://prometheus.appmesh-system:9090 ``` You can install Flagger in any namespace as long as it can talk to the Istio Prometheus service on port 9090. diff --git a/docs/gitbook/install/flagger-install-on-google-cloud.md b/docs/gitbook/install/flagger-install-on-google-cloud.md index bdb0da57..94a2f7b7 100644 --- a/docs/gitbook/install/flagger-install-on-google-cloud.md +++ b/docs/gitbook/install/flagger-install-on-google-cloud.md @@ -2,7 +2,7 @@ This guide walks you through setting up Flagger and Istio on Google Kubernetes Engine. -![GKE Cluster Overview](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/diagrams/flagger-gke-istio.png) +![GKE Cluster Overview](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/diagrams/flagger-gke-istio.png) ### Prerequisites @@ -208,12 +208,12 @@ stable/cert-manager ### Istio Gateway TLS setup -![Istio Let's Encrypt](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/diagrams/istio-cert-manager-gke.png) +![Istio Let's Encrypt](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/diagrams/istio-cert-manager-gke.png) Create a generic Istio Gateway to expose services outside the mesh on HTTPS: ```bash -REPO=https://raw.githubusercontent.com/stefanprodan/flagger/master +REPO=https://raw.githubusercontent.com/weaveworks/flagger/master kubectl apply -f ${REPO}/artifacts/gke/istio-gateway.yaml ``` @@ -332,7 +332,7 @@ Because Flagger uses the Istio HTTP metrics to run the canary analysis you have Prometheus configuration that's similar to the one that comes with the official Istio Helm chart. ```bash -REPO=https://raw.githubusercontent.com/stefanprodan/flagger/master +REPO=https://raw.githubusercontent.com/weaveworks/flagger/master kubectl apply -f ${REPO}/artifacts/gke/istio-prometheus.yaml ``` diff --git a/docs/gitbook/install/flagger-install-on-kubernetes.md b/docs/gitbook/install/flagger-install-on-kubernetes.md index 2a07ff62..73120559 100644 --- a/docs/gitbook/install/flagger-install-on-kubernetes.md +++ b/docs/gitbook/install/flagger-install-on-kubernetes.md @@ -132,7 +132,7 @@ helm upgrade -i flagger-loadtester flagger/loadtester \ Deploy with kubectl: ```bash -export REPO=https://raw.githubusercontent.com/stefanprodan/flagger/master +export REPO=https://raw.githubusercontent.com/weaveworks/flagger/master kubectl -n test apply -f ${REPO}/artifacts/loadtester/deployment.yaml kubectl -n test apply -f ${REPO}/artifacts/loadtester/service.yaml diff --git a/docs/gitbook/tutorials/canary-helm-gitops.md b/docs/gitbook/tutorials/canary-helm-gitops.md index a8a73b49..9117f1ff 100644 --- a/docs/gitbook/tutorials/canary-helm-gitops.md +++ b/docs/gitbook/tutorials/canary-helm-gitops.md @@ -29,7 +29,7 @@ You can find the chart source [here](https://github.com/stefanprodan/flagger/tre Create a test namespace with Istio sidecar injection enabled: ```bash -export REPO=https://raw.githubusercontent.com/stefanprodan/flagger/master +export REPO=https://raw.githubusercontent.com/weaveworks/flagger/master kubectl apply -f ${REPO}/artifacts/namespaces/test.yaml ``` @@ -79,7 +79,7 @@ Flagger will route all traffic to the primary pods and scale to zero the `fronte Open your browser and navigate to the frontend URL: -![Podinfo Frontend](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/screens/demo-frontend.png) +![Podinfo Frontend](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/screens/demo-frontend.png) Now let's install the `backend` release without exposing it outside the mesh: @@ -104,7 +104,7 @@ frontend Initialized 0 2019-02-12T17:50:50Z Click on the ping button in the `frontend` UI to trigger a HTTP POST request that will reach the `backend` app: -![Jaeger Tracing](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/screens/demo-frontend-jaeger.png) +![Jaeger Tracing](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/screens/demo-frontend-jaeger.png) We'll use the `/echo` endpoint (same as the one the ping button calls) to generate load on both apps during a canary deployment. @@ -155,7 +155,7 @@ You can monitor the canary deployment with Grafana. Open the Flagger dashboard, select `test` from the namespace dropdown, `frontend-primary` from the primary dropdown and `frontend` from the canary dropdown. -![Flagger Grafana Dashboard](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/screens/demo-frontend-dashboard.png) +![Flagger Grafana Dashboard](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/screens/demo-frontend-dashboard.png) Now trigger a canary deployment for the `backend` app, but this time you'll change a value in the configmap: @@ -213,7 +213,7 @@ Copying backend.test template spec to backend-primary.test Promotion completed! Scaling down backend.test ``` -![Flagger Grafana Dashboard](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/screens/demo-backend-dashboard.png) +![Flagger Grafana Dashboard](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/screens/demo-backend-dashboard.png) If the number of failed checks reaches the canary analysis threshold, the traffic is routed back to the primary, the canary is scaled to zero and the rollout is marked as failed. @@ -237,7 +237,7 @@ In the [GitOps model](https://www.weave.works/technologies/gitops/), any change to production must be committed in source control prior to being applied on the cluster. This way rollback and audit logs are provided by Git. -![Helm GitOps Canary Deployment](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/diagrams/flagger-flux-gitops.png) +![Helm GitOps Canary Deployment](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/diagrams/flagger-flux-gitops.png) In order to apply the GitOps pipeline model to Flagger canary deployments you'll need a Git repository with your workloads definitions in YAML format, diff --git a/docs/gitbook/usage/ab-testing.md b/docs/gitbook/usage/ab-testing.md index 1a67ecc5..fdb08c5d 100644 --- a/docs/gitbook/usage/ab-testing.md +++ b/docs/gitbook/usage/ab-testing.md @@ -1,17 +1,17 @@ -# A/B Testing +# Istio A/B Testing -This guide shows you how to automate A/B testing with Flagger. +This guide shows you how to automate A/B testing with Istio and Flagger. Besides weighted routing, Flagger can be configured to route traffic to the canary based on HTTP match conditions. In an A/B testing scenario, you'll be using HTTP headers or cookies to target a certain segment of your users. This is particularly useful for frontend applications that require session affinity. -![Flagger A/B Testing Stages](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/diagrams/flagger-abtest-steps.png) +![Flagger A/B Testing Stages](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/diagrams/flagger-abtest-steps.png) Create a test namespace with Istio sidecar injection enabled: ```bash -export REPO=https://raw.githubusercontent.com/stefanprodan/flagger/master +export REPO=https://raw.githubusercontent.com/weaveworks/flagger/master kubectl apply -f ${REPO}/artifacts/namespaces/test.yaml ``` diff --git a/docs/gitbook/usage/alerting.md b/docs/gitbook/usage/alerting.md index 27a475d3..4c13e68e 100644 --- a/docs/gitbook/usage/alerting.md +++ b/docs/gitbook/usage/alerting.md @@ -15,12 +15,12 @@ helm upgrade -i flagger flagger/flagger \ Once configured with a Slack incoming **webhook**, Flagger will post messages when a canary deployment has been initialised, when a new revision has been detected and if the canary analysis failed or succeeded. -![flagger-slack](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/screens/slack-canary-notifications.png) +![flagger-slack](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/screens/slack-canary-notifications.png) A canary deployment will be rolled back if the progress deadline exceeded or if the analysis reached the maximum number of failed checks: -![flagger-slack-errors](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/screens/slack-canary-failed.png) +![flagger-slack-errors](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/screens/slack-canary-failed.png) ### Prometheus Alert Manager diff --git a/docs/gitbook/usage/appmesh-progressive-delivery.md b/docs/gitbook/usage/appmesh-progressive-delivery.md new file mode 100644 index 00000000..4690a72f --- /dev/null +++ b/docs/gitbook/usage/appmesh-progressive-delivery.md @@ -0,0 +1,279 @@ +# App Mesh Canary Deployments + +This guide shows you how to use App Mesh and Flagger to automate canary deployments. +You'll need an EKS cluster configured with App Mesh, you can find the install guide +[here](https://docs.flagger.app/install/flagger-install-on-eks-appmesh). + +### Bootstrap + +Flagger takes a Kubernetes deployment and optionally a horizontal pod autoscaler (HPA), +then creates a series of objects (Kubernetes deployments, ClusterIP services, App Mesh virtual nodes and services). +These objects expose the application on the mesh and drive the canary analysis and promotion. +The only App Mesh object you need to creat by yourself is the mesh resource. + +Create a mesh called `global` in the `appmesh-system` namespace: + +```bash +export REPO=https://raw.githubusercontent.com/weaveworks/flagger/master + +kubectl apply -f ${REPO}/artifacts/appmesh/global-mesh.yaml +``` + +Create a test namespace with App Mesh sidecar injection enabled: + +```bash +kubectl apply -f ${REPO}/artifacts/namespaces/test.yaml +``` + +Create a deployment and a horizontal pod autoscaler: + +```bash +kubectl apply -f ${REPO}/artifacts/appmesh/deployment.yaml +kubectl apply -f ${REPO}/artifacts/appmesh/hpa.yaml +``` + +Deploy the load testing service to generate traffic during the canary analysis: + +```bash +helm upgrade -i flagger-loadtester flagger/loadtester \ +--namespace=test \ +--set meshName=global.appmesh-system \ +--set backends[0]=podinfo.test +``` + +Create a canary custom resource: + +```yaml +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: podinfo + namespace: test +spec: + # deployment reference + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: podinfo + # the maximum time in seconds for the canary deployment + # to make progress before it is rollback (default 600s) + progressDeadlineSeconds: 60 + # HPA reference (optional) + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: podinfo + service: + # container port + port: 9898 + # App Mesh reference + meshName: global.appmesh-system + # App Mesh egress (optional) + backends: + - backend.test + # define the canary analysis timing and KPIs + canaryAnalysis: + # schedule interval (default 60s) + interval: 10s + # max number of failed metric checks before rollback + threshold: 10 + # max traffic percentage routed to canary + # percentage (0-100) + maxWeight: 50 + # canary increment step + # percentage (0-100) + stepWeight: 5 + # App Mesh Prometheus checks + metrics: + - name: envoy_cluster_upstream_rq + # minimum req success rate (non 5xx responses) + # percentage (0-100) + threshold: 99 + interval: 1m + # external checks (optional) + webhooks: + - name: load-test + url: http://flagger-loadtester.test/ + timeout: 5s + metadata: + cmd: "hey -z 1m -q 10 -c 2 http://podinfo.test:9898/" +``` + +Save the above resource as podinfo-canary.yaml and then apply it: + +```bash +kubectl apply -f ./podinfo-canary.yaml +``` + +After a couple of seconds Flagger will create the canary objects: + +```bash +# applied +deployment.apps/podinfo +horizontalpodautoscaler.autoscaling/podinfo +canary.flagger.app/podinfo + +# generated Kubernetes objects +deployment.apps/podinfo-primary +horizontalpodautoscaler.autoscaling/podinfo-primary +service/podinfo +service/podinfo-canary +service/podinfo-primary + +# generated App Mesh objects +virtualnode.appmesh.k8s.aws/podinfo +virtualnode.appmesh.k8s.aws/podinfo-canary +virtualnode.appmesh.k8s.aws/podinfo-primary +virtualservice.appmesh.k8s.aws/podinfo.test +``` + +The App Mesh specific settings are: + +```yaml + service: + port: 9898 + meshName: global.appmesh-system + backends: + - backend1.test + - backend2.test +``` + +App Mesh blocks all egress traffic by default. If your application needs to call another service, you have to create an +App Mesh virtual service for it and add the virtual service name to the backend list. + +### Setup App Mesh ingress (optional) + +In order to expose the podinfo app outside the mesh you'll be using an Envoy ingress and an AWS classic load balancer. +The ingress binds to an internet domain and forwards the calls into the mesh through the App Mesh sidecar. +If podinfo becomes unavailable due to a HPA downscaling or a node restart, +the ingress will retry the calls for a short period of time. + +Deploy the ingress and the AWS ELB service: + +```bash +kubectl apply -f ${REPO}/artifacts/appmesh/ingress.yaml +``` + +Find the ingress public address: + +```bash +kubectl -n test describe svc/ingress | grep Ingress + +LoadBalancer Ingress: yyy-xx.us-west-2.elb.amazonaws.com +``` + +Open your browser and navigate to the ingress address to access podinfo UI. + +### Automated canary promotion + +Trigger a canary deployment by updating the container image: + +```bash +kubectl -n test set image deployment/podinfo \ +podinfod=quay.io/stefanprodan/podinfo:1.4.1 +``` + +Flagger detects that the deployment revision changed and starts a new rollout: + +```text +kubectl -n test describe canary/podinfo + +Status: + Canary Weight: 0 + Failed Checks: 0 + Phase: Succeeded +Events: + Type Reason Age From Message + ---- ------ ---- ---- ------- + Normal Synced 3m flagger New revision detected podinfo.test + Normal Synced 3m flagger Scaling up podinfo.test + Warning Synced 3m flagger Waiting for podinfo.test rollout to finish: 0 of 1 updated replicas are available + Normal Synced 3m flagger Advance podinfo.test canary weight 5 + Normal Synced 3m flagger Advance podinfo.test canary weight 10 + Normal Synced 3m flagger Advance podinfo.test canary weight 15 + Normal Synced 2m flagger Advance podinfo.test canary weight 20 + Normal Synced 2m flagger Advance podinfo.test canary weight 25 + Normal Synced 1m flagger Advance podinfo.test canary weight 30 + Normal Synced 1m flagger Advance podinfo.test canary weight 35 + Normal Synced 55s flagger Advance podinfo.test canary weight 40 + Normal Synced 45s flagger Advance podinfo.test canary weight 45 + Normal Synced 35s flagger Advance podinfo.test canary weight 50 + Normal Synced 25s flagger Copying podinfo.test template spec to podinfo-primary.test + Warning Synced 15s flagger Waiting for podinfo-primary.test rollout to finish: 1 of 2 updated replicas are available + Normal Synced 5s flagger Promotion completed! Scaling down podinfo.test +``` + +**Note** that if you apply new changes to the deployment during the canary analysis, Flagger will restart the analysis. + +During the analysis the canary’s progress can be monitored with Grafana: + +![App Mesh Canary Dashboard](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/screens/flagger-grafana-appmesh.png) + +You can monitor all canaries with: + +```bash +watch kubectl get canaries --all-namespaces + +NAMESPACE NAME STATUS WEIGHT LASTTRANSITIONTIME +test podinfo Progressing 15 2019-03-16T14:05:07Z +prod frontend Succeeded 0 2019-03-15T16:15:07Z +prod backend Failed 0 2019-03-14T17:05:07Z +``` + +If you’ve enabled the Slack notifications, you should receive the following messages: + +![flagger-slack](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/screens/slack-canary-notifications.png) + +### Automated rollback + +During the canary analysis you can generate HTTP 500 errors to test if Flagger pauses the rollout. + +Trigger a canary deployment: + +```bash +kubectl -n test set image deployment/podinfo \ +podinfod=quay.io/stefanprodan/podinfo:1.4.2 +``` + +Exec into the load tester pod with: + +```bash +kubectl -n test exec -it flagger-loadtester-xx-xx sh +``` + +Generate HTTP 500 errors: + +```bash +hey -z 1m -c 5 -q 5 http://podinfo.test:9898/status/500 +``` + +When the number of failed checks reaches the canary analysis threshold, the traffic is routed back to the primary, +the canary is scaled to zero and the rollout is marked as failed. + +```text +kubectl -n test describe canary/podinfo + +Status: + Canary Weight: 0 + Failed Checks: 10 + Phase: Failed +Events: + Type Reason Age From Message + ---- ------ ---- ---- ------- + Normal Synced 3m flagger Starting canary deployment for podinfo.test + Normal Synced 3m flagger Advance podinfo.test canary weight 5 + Normal Synced 3m flagger Advance podinfo.test canary weight 10 + Normal Synced 3m flagger Advance podinfo.test canary weight 15 + Normal Synced 3m flagger Halt podinfo.test advancement success rate 69.17% < 99% + Normal Synced 2m flagger Halt podinfo.test advancement success rate 61.39% < 99% + Normal Synced 2m flagger Halt podinfo.test advancement success rate 55.06% < 99% + Normal Synced 2m flagger Halt podinfo.test advancement success rate 47.00% < 99% + Normal Synced 2m flagger (combined from similar events): Halt podinfo.test advancement success rate 38.08% < 99% + Warning Synced 1m flagger Rolling back podinfo.test failed checks threshold reached 10 + Warning Synced 1m flagger Canary failed! Scaling down podinfo.test +``` + +If you’ve enabled the Slack notifications, you’ll receive a message if the progress deadline is exceeded, +or if the analysis reached the maximum number of failed checks: + +![flagger-slack-errors](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/screens/slack-canary-failed.png) diff --git a/docs/gitbook/usage/monitoring.md b/docs/gitbook/usage/monitoring.md index 03aa1663..103239dd 100644 --- a/docs/gitbook/usage/monitoring.md +++ b/docs/gitbook/usage/monitoring.md @@ -14,7 +14,7 @@ helm upgrade -i flagger-grafana flagger/grafana \ The dashboard shows the RED and USE metrics for the primary and canary workloads: -![canary dashboard](https://raw.githubusercontent.com/stefanprodan/flagger/master/docs/screens/grafana-canary-analysis.png) +![canary dashboard](https://raw.githubusercontent.com/weaveworks/flagger/master/docs/screens/grafana-canary-analysis.png) ### Logging diff --git a/docs/gitbook/usage/progressive-delivery.md b/docs/gitbook/usage/progressive-delivery.md index e1ebf033..f0660e63 100644 --- a/docs/gitbook/usage/progressive-delivery.md +++ b/docs/gitbook/usage/progressive-delivery.md @@ -1,11 +1,11 @@ -# Canary Deployments +# Istio Canary Deployments This guide shows you how to use Istio and Flagger to automate canary deployments. Create a test namespace with Istio sidecar injection enabled: ```bash -export REPO=https://raw.githubusercontent.com/stefanprodan/flagger/master +export REPO=https://raw.githubusercontent.com/weaveworks/flagger/master kubectl apply -f ${REPO}/artifacts/namespaces/test.yaml ``` diff --git a/pkg/controller/observer.go b/pkg/controller/observer.go index 1e846c6f..19eabff0 100644 --- a/pkg/controller/observer.go +++ b/pkg/controller/observer.go @@ -114,11 +114,12 @@ func (c *CanaryObserver) GetEnvoySuccessRate(name string, namespace string, metr var rate *float64 querySt := url.QueryEscape(`sum(rate(` + metric + `{kubernetes_namespace="` + - namespace + `",app="` + - name + `",envoy_response_code!~"5.*"}[1m])) / sum(rate(` + + namespace + `",kubernetes_pod_name=~"` + + name + `-[0-9a-zA-Z]+(-[0-9a-zA-Z]+)",envoy_response_code!~"5.*"}[` + + interval + `])) / sum(rate(` + metric + `{kubernetes_namespace="` + - namespace + `",app="` + - name + `"}[` + + namespace + `",kubernetes_pod_name=~"` + + name + `-[0-9a-zA-Z]+(-[0-9a-zA-Z]+)"}[` + interval + `])) * 100 `) result, err := c.queryMetric(querySt) if err != nil { @@ -152,7 +153,8 @@ func (c *CanaryObserver) GetDeploymentCounter(name string, namespace string, met querySt := url.QueryEscape(`sum(rate(` + metric + `{reporter="destination",destination_workload_namespace=~"` + namespace + `",destination_workload=~"` + - name + `",response_code!~"5.*"}[1m])) / sum(rate(` + + name + `",response_code!~"5.*"}[` + + interval + `])) / sum(rate(` + metric + `{reporter="destination",destination_workload_namespace=~"` + namespace + `",destination_workload=~"` + name + `"}[` + diff --git a/pkg/controller/scheduler.go b/pkg/controller/scheduler.go index ad8c014c..0a8e92b1 100644 --- a/pkg/controller/scheduler.go +++ b/pkg/controller/scheduler.go @@ -25,7 +25,7 @@ func (c *Controller) scheduleCanaries() { current[name] = fmt.Sprintf("%s.%s", canary.Spec.TargetRef.Name, canary.Namespace) job, exists := c.jobs[name] - // schedule new job for exsiting job with different analysisInterval or non-existing job + // schedule new job for existing job with different analysis interval or non-existing job if (exists && job.GetCanaryAnalysisInterval() != canary.GetAnalysisInterval()) || !exists { if exists { job.Stop() diff --git a/pkg/router/appmesh.go b/pkg/router/appmesh.go index 69e40bcd..92610674 100644 --- a/pkg/router/appmesh.go +++ b/pkg/router/appmesh.go @@ -37,21 +37,21 @@ func (ar *AppMeshRouter) Sync(canary *flaggerv1.Canary) error { // sync virtual node e.g. app-namespace // DNS app.namespace - err := ar.syncVirtualNode(canary, fmt.Sprintf("%s-%s", targetName, canary.Namespace), primaryHost) + err := ar.syncVirtualNode(canary, targetName, primaryHost) if err != nil { return err } // sync virtual node e.g. app-primary-namespace // DNS app-primary.namespace - err = ar.syncVirtualNode(canary, fmt.Sprintf("%s-%s", primaryName, canary.Namespace), primaryHost) + err = ar.syncVirtualNode(canary, primaryName, primaryHost) if err != nil { return err } // sync virtual node e.g. app-canary-namespace // DNS app-canary.namespace - err = ar.syncVirtualNode(canary, fmt.Sprintf("%s-%s", canaryName, canary.Namespace), canaryHost) + err = ar.syncVirtualNode(canary, canaryName, canaryHost) if err != nil { return err } @@ -150,8 +150,8 @@ func (ar *AppMeshRouter) syncVirtualNode(canary *flaggerv1.Canary, name string, // syncVirtualService creates or updates a virtual service func (ar *AppMeshRouter) syncVirtualService(canary *flaggerv1.Canary, name string) error { targetName := canary.Spec.TargetRef.Name - canaryVirtualNode := fmt.Sprintf("%s-canary-%s", targetName, canary.Namespace) - primaryVirtualNode := fmt.Sprintf("%s-primary-%s", targetName, canary.Namespace) + canaryVirtualNode := fmt.Sprintf("%s-canary", targetName) + primaryVirtualNode := fmt.Sprintf("%s-primary", targetName) // App Mesh supports only URI prefix routePrefix := "/" @@ -164,11 +164,11 @@ func (ar *AppMeshRouter) syncVirtualService(canary *flaggerv1.Canary, name strin vsSpec := &appmeshv1alpha1.VirtualServiceSpec{ MeshName: canary.Spec.Service.MeshName, VirtualRouter: &appmeshv1alpha1.VirtualRouter{ - Name: fmt.Sprintf("%s-%s-router", targetName, canary.Namespace), + Name: fmt.Sprintf("%s-router", targetName), }, Routes: []appmeshv1alpha1.Route{ { - Name: fmt.Sprintf("%s-%s-route", targetName, canary.Namespace), + Name: fmt.Sprintf("%s-route", targetName), Http: appmeshv1alpha1.HttpRoute{ Match: appmeshv1alpha1.HttpRouteMatch{ Prefix: routePrefix, @@ -265,10 +265,10 @@ func (ar *AppMeshRouter) GetRoutes(canary *flaggerv1.Canary) ( targets := vs.Spec.Routes[0].Http.Action.WeightedTargets for _, t := range targets { - if t.VirtualNodeName == fmt.Sprintf("%s-canary-%s", targetName, canary.Namespace) { + if t.VirtualNodeName == fmt.Sprintf("%s-canary", targetName) { canaryWeight = int(t.Weight) } - if t.VirtualNodeName == fmt.Sprintf("%s-primary-%s", targetName, canary.Namespace) { + if t.VirtualNodeName == fmt.Sprintf("%s-primary", targetName) { primaryWeight = int(t.Weight) } } @@ -301,11 +301,11 @@ func (ar *AppMeshRouter) SetRoutes( vsClone.Spec.Routes[0].Http.Action = appmeshv1alpha1.HttpRouteAction{ WeightedTargets: []appmeshv1alpha1.WeightedTarget{ { - VirtualNodeName: fmt.Sprintf("%s-canary-%s", targetName, canary.Namespace), + VirtualNodeName: fmt.Sprintf("%s-canary", targetName), Weight: int64(canaryWeight), }, { - VirtualNodeName: fmt.Sprintf("%s-primary-%s", targetName, canary.Namespace), + VirtualNodeName: fmt.Sprintf("%s-primary", targetName), Weight: int64(primaryWeight), }, }, diff --git a/pkg/router/appmesh_test.go b/pkg/router/appmesh_test.go index 13fd88b8..8f7a20d1 100644 --- a/pkg/router/appmesh_test.go +++ b/pkg/router/appmesh_test.go @@ -38,7 +38,7 @@ func TestAppmeshRouter_Sync(t *testing.T) { } // check virtual node - vnName := fmt.Sprintf("%s-%s", mocks.appmeshCanary.Spec.TargetRef.Name, mocks.appmeshCanary.Namespace) + vnName := mocks.appmeshCanary.Spec.TargetRef.Name vn, err := router.appmeshClient.AppmeshV1alpha1().VirtualNodes("default").Get(vnName, metav1.GetOptions{}) if err != nil { t.Fatal(err.Error()) @@ -72,7 +72,7 @@ func TestAppmeshRouter_Sync(t *testing.T) { } // verify - vnCanaryName := fmt.Sprintf("%s-canary-%s", mocks.appmeshCanary.Spec.TargetRef.Name, mocks.appmeshCanary.Namespace) + vnCanaryName := fmt.Sprintf("%s-canary", mocks.appmeshCanary.Spec.TargetRef.Name) vnCanary, err := router.appmeshClient.AppmeshV1alpha1().VirtualNodes("default").Get(vnCanaryName, metav1.GetOptions{}) if err != nil { t.Fatal(err.Error())