From 982338e16296bfe9f882e7d2c93d4f94b154cf7c Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Thu, 4 Jul 2019 13:26:08 +0300 Subject: [PATCH 1/8] Kustomize installer: add Flagger base manifests --- kustomize/base/flagger/account.yaml | 6 + kustomize/base/flagger/crd.yaml | 172 ++++++++++++++++++++++ kustomize/base/flagger/deployment.yaml | 57 +++++++ kustomize/base/flagger/kustomization.yaml | 11 ++ kustomize/base/flagger/rbac.yaml | 90 +++++++++++ 5 files changed, 336 insertions(+) create mode 100644 kustomize/base/flagger/account.yaml create mode 100644 kustomize/base/flagger/crd.yaml create mode 100644 kustomize/base/flagger/deployment.yaml create mode 100644 kustomize/base/flagger/kustomization.yaml create mode 100644 kustomize/base/flagger/rbac.yaml diff --git a/kustomize/base/flagger/account.yaml b/kustomize/base/flagger/account.yaml new file mode 100644 index 00000000..95980a36 --- /dev/null +++ b/kustomize/base/flagger/account.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: flagger + namespace: flagger-system + diff --git a/kustomize/base/flagger/crd.yaml b/kustomize/base/flagger/crd.yaml new file mode 100644 index 00000000..b1467d67 --- /dev/null +++ b/kustomize/base/flagger/crd.yaml @@ -0,0 +1,172 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: canaries.flagger.app + annotations: + helm.sh/resource-policy: keep +spec: + group: flagger.app + version: v1alpha3 + versions: + - name: v1alpha3 + served: true + storage: true + - name: v1alpha2 + served: true + storage: false + - name: v1alpha1 + served: true + storage: false + names: + plural: canaries + singular: canary + kind: Canary + categories: + - all + scope: Namespaced + subresources: + status: {} + additionalPrinterColumns: + - name: Status + type: string + JSONPath: .status.phase + - name: Weight + type: string + JSONPath: .status.canaryWeight + - name: LastTransitionTime + type: string + JSONPath: .status.lastTransitionTime + validation: + openAPIV3Schema: + properties: + spec: + required: + - targetRef + - service + - canaryAnalysis + properties: + provider: + type: string + progressDeadlineSeconds: + type: number + targetRef: + type: object + required: ['apiVersion', 'kind', 'name'] + properties: + apiVersion: + type: string + kind: + type: string + name: + type: string + autoscalerRef: + anyOf: + - type: string + - type: object + required: ['apiVersion', 'kind', 'name'] + properties: + apiVersion: + type: string + kind: + type: string + name: + type: string + ingressRef: + anyOf: + - type: string + - type: object + required: ['apiVersion', 'kind', 'name'] + properties: + apiVersion: + type: string + kind: + type: string + name: + type: string + service: + type: object + required: ['port'] + properties: + port: + type: number + portName: + type: string + portDiscovery: + type: boolean + meshName: + type: string + timeout: + type: string + skipAnalysis: + type: boolean + canaryAnalysis: + properties: + interval: + type: string + pattern: "^[0-9]+(m|s)" + iterations: + type: number + threshold: + type: number + maxWeight: + type: number + stepWeight: + type: number + metrics: + type: array + properties: + items: + type: object + required: ['name', 'threshold'] + properties: + name: + type: string + interval: + type: string + pattern: "^[0-9]+(m|s)" + threshold: + type: number + query: + type: string + webhooks: + type: array + properties: + items: + type: object + required: ['name', 'url', 'timeout'] + properties: + name: + type: string + type: + type: string + enum: + - "" + - pre-rollout + - rollout + - post-rollout + url: + type: string + format: url + timeout: + type: string + pattern: "^[0-9]+(m|s)" + status: + properties: + phase: + type: string + enum: + - "" + - Initialized + - Progressing + - Succeeded + - Failed + canaryWeight: + type: number + failedChecks: + type: number + iterations: + type: number + lastAppliedSpec: + type: string + lastTransitionTime: + type: string diff --git a/kustomize/base/flagger/deployment.yaml b/kustomize/base/flagger/deployment.yaml new file mode 100644 index 00000000..17bcc3b2 --- /dev/null +++ b/kustomize/base/flagger/deployment.yaml @@ -0,0 +1,57 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: flagger + namespace: flagger-system +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app: flagger + template: + metadata: + labels: + app: flagger + annotations: + prometheus.io/scrape: "true" + spec: + serviceAccountName: flagger + containers: + - name: flagger + image: weaveworks/flagger:0.16.0 + imagePullPolicy: IfNotPresent + ports: + - name: http + containerPort: 8080 + livenessProbe: + exec: + command: + - wget + - --quiet + - --tries=1 + - --timeout=2 + - --spider + - http://localhost:8080/healthz + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - wget + - --quiet + - --tries=1 + - --timeout=2 + - --spider + - http://localhost:8080/healthz + timeoutSeconds: 5 + resources: + limits: + memory: "512Mi" + cpu: "1000m" + requests: + memory: "32Mi" + cpu: "10m" + securityContext: + readOnlyRootFilesystem: true + runAsUser: 10001 diff --git a/kustomize/base/flagger/kustomization.yaml b/kustomize/base/flagger/kustomization.yaml new file mode 100644 index 00000000..620bece3 --- /dev/null +++ b/kustomize/base/flagger/kustomization.yaml @@ -0,0 +1,11 @@ +namespace: flagger-system +commonLabels: + app: flagger +resources: + - account.yaml + - rbac.yaml + - crd.yaml + - deployment.yaml +images: + - name: weaveworks/flagger + newTag: 0.16.0 diff --git a/kustomize/base/flagger/rbac.yaml b/kustomize/base/flagger/rbac.yaml new file mode 100644 index 00000000..3a7d0745 --- /dev/null +++ b/kustomize/base/flagger/rbac.yaml @@ -0,0 +1,90 @@ +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRole +metadata: + name: flagger +rules: + - apiGroups: + - "" + resources: + - events + - configmaps + - secrets + - services + verbs: ["*"] + - apiGroups: + - apps + resources: + - deployments + verbs: ["*"] + - apiGroups: + - autoscaling + resources: + - horizontalpodautoscalers + verbs: ["*"] + - apiGroups: + - "extensions" + resources: + - ingresses + - ingresses/status + verbs: ["*"] + - apiGroups: + - flagger.app + resources: + - canaries + - canaries/status + verbs: ["*"] + - apiGroups: + - networking.istio.io + resources: + - virtualservices + - virtualservices/status + - destinationrules + - destinationrules/status + verbs: ["*"] + - apiGroups: + - appmesh.k8s.aws + resources: + - meshes + - meshes/status + - virtualnodes + - virtualnodes/status + - virtualservices + - virtualservices/status + verbs: ["*"] + - apiGroups: + - split.smi-spec.io + resources: + - trafficsplits + verbs: ["*"] + - apiGroups: + - gloo.solo.io + resources: + - settings + - upstreams + - upstreamgroups + - proxies + - virtualservices + verbs: ["*"] + - apiGroups: + - gateway.solo.io + resources: + - virtualservices + - gateways + verbs: ["*"] + - nonResourceURLs: + - /version + verbs: + - get +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: flagger +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: flagger +subjects: +- kind: ServiceAccount + name: flagger + namespace: flagger-system From a2f747e16f7f6ac1f85697f1680d8a663bec6483 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Thu, 4 Jul 2019 13:26:22 +0300 Subject: [PATCH 2/8] Kustomize installer: add Prometheus base manifests --- kustomize/base/prometheus/account.yaml | 5 + kustomize/base/prometheus/deployment.yaml | 52 +++++++ kustomize/base/prometheus/kustomization.yaml | 15 ++ kustomize/base/prometheus/prometheus.yml | 144 +++++++++++++++++++ kustomize/base/prometheus/rbac.yaml | 32 +++++ kustomize/base/prometheus/service.yaml | 12 ++ 6 files changed, 260 insertions(+) create mode 100644 kustomize/base/prometheus/account.yaml create mode 100644 kustomize/base/prometheus/deployment.yaml create mode 100644 kustomize/base/prometheus/kustomization.yaml create mode 100644 kustomize/base/prometheus/prometheus.yml create mode 100644 kustomize/base/prometheus/rbac.yaml create mode 100644 kustomize/base/prometheus/service.yaml diff --git a/kustomize/base/prometheus/account.yaml b/kustomize/base/prometheus/account.yaml new file mode 100644 index 00000000..67b446df --- /dev/null +++ b/kustomize/base/prometheus/account.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: flagger-prometheus + namespace: flagger-system diff --git a/kustomize/base/prometheus/deployment.yaml b/kustomize/base/prometheus/deployment.yaml new file mode 100644 index 00000000..3d5a2736 --- /dev/null +++ b/kustomize/base/prometheus/deployment.yaml @@ -0,0 +1,52 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: flagger-prometheus + namespace: flagger-system +spec: + replicas: 1 + selector: + matchLabels: + app: flagger-prometheus + template: + metadata: + labels: + app: flagger-prometheus + annotations: + appmesh.k8s.aws/sidecarInjectorWebhook: disabled + sidecar.istio.io/inject: "false" + spec: + serviceAccountName: flagger-prometheus + containers: + - name: prometheus + image: prom/prometheus:v2.10.0 + imagePullPolicy: IfNotPresent + args: + - '--storage.tsdb.retention=2h' + - '--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 + - name: data-volume + mountPath: /prometheus/data + volumes: + - name: config-volume + configMap: + name: flagger-prometheus + - name: data-volume + emptyDir: {} \ No newline at end of file diff --git a/kustomize/base/prometheus/kustomization.yaml b/kustomize/base/prometheus/kustomization.yaml new file mode 100644 index 00000000..e93975f6 --- /dev/null +++ b/kustomize/base/prometheus/kustomization.yaml @@ -0,0 +1,15 @@ +namespace: flagger-system +commonLabels: + app: flagger-prometheus +resources: + - account.yaml + - rbac.yaml + - service.yaml + - deployment.yaml +configMapGenerator: + - name: flagger-prometheus + files: + - prometheus.yml +images: + - name: prom/prometheus + newTag: v2.10.0 diff --git a/kustomize/base/prometheus/prometheus.yml b/kustomize/base/prometheus/prometheus.yml new file mode 100644 index 00000000..2cb993e5 --- /dev/null +++ b/kustomize/base/prometheus/prometheus.yml @@ -0,0 +1,144 @@ +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 diff --git a/kustomize/base/prometheus/rbac.yaml b/kustomize/base/prometheus/rbac.yaml new file mode 100644 index 00000000..7f5d2c54 --- /dev/null +++ b/kustomize/base/prometheus/rbac.yaml @@ -0,0 +1,32 @@ +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRole +metadata: + name: flagger-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: flagger-prometheus +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: flagger-prometheus +subjects: +- kind: ServiceAccount + name: flagger-prometheus + namespace: flagger-system diff --git a/kustomize/base/prometheus/service.yaml b/kustomize/base/prometheus/service.yaml new file mode 100644 index 00000000..ad0df80a --- /dev/null +++ b/kustomize/base/prometheus/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: flagger-prometheus + namespace: flagger-system +spec: + selector: + app: flagger-prometheus + ports: + - name: http + protocol: TCP + port: 9090 \ No newline at end of file From 2e802432c4b178a017d71a65792214aad261d56c Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Thu, 4 Jul 2019 13:26:52 +0300 Subject: [PATCH 3/8] Kustomize installer: add Kubernetes overlay --- kustomize/README.md | 87 +++++++++++++++++++++++++ kustomize/kubernetes/kustomization.yaml | 8 +++ kustomize/kubernetes/namespace.yaml | 9 +++ kustomize/kubernetes/patch.yaml | 15 +++++ 4 files changed, 119 insertions(+) create mode 100644 kustomize/README.md create mode 100644 kustomize/kubernetes/kustomization.yaml create mode 100644 kustomize/kubernetes/namespace.yaml create mode 100644 kustomize/kubernetes/patch.yaml diff --git a/kustomize/README.md b/kustomize/README.md new file mode 100644 index 00000000..df82afbd --- /dev/null +++ b/kustomize/README.md @@ -0,0 +1,87 @@ +# Flagger Kustomize installer + +## Service mesh specific installers + +Install Flagger for Istio: + +```bash +kubectl apply -k github.com/weaveworks/flagger/kustomize/istio +``` + +This deploys Flagger in the `istio-system` namespace and sets the metrics server URL to `http://prometheus.istio-system:9090`. + +Install Flagger for Linkerd: + +```bash +kubectl apply -k github.com/weaveworks/flagger/kustomize/linkerd +``` + +This deploys Flagger in the `linkerd` namespace and sets the metrics server URL to `http://linkerd-prometheus.linkerd:9090`. + +## Generic installer + +Install Flagger and Prometheus: + +```bash +kubectl apply -k github.com/weaveworks/flagger/kustomize/kubernetes +``` + +This deploys Flagger and Prometheus in the `flagger-system` namespace, +sets the metrics server URL to `http://flagger-prometheus.flagger-system:9090` and the mesh provider to `kubernetes`. + +To target a specific provider you need to specify it in the canary custom resource: + +```yaml +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: app + namespace: test +spec: + # can be: kubernetes, istio, appmesh, linkerd, smi, nginx, gloo, supergloo + # use the kubernetes provider for Blue/Green style deployments + provider: nginx +``` + +## Customized installer + +Create a kustomization file using flagger as base: + +```bash +cat > kustomization.yaml < patch.yaml < Date: Thu, 4 Jul 2019 13:27:03 +0300 Subject: [PATCH 4/8] Kustomize installer: add Istio overlay --- kustomize/istio/kustomization.yaml | 5 +++++ kustomize/istio/patch.yaml | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 kustomize/istio/kustomization.yaml create mode 100644 kustomize/istio/patch.yaml diff --git a/kustomize/istio/kustomization.yaml b/kustomize/istio/kustomization.yaml new file mode 100644 index 00000000..fba329ba --- /dev/null +++ b/kustomize/istio/kustomization.yaml @@ -0,0 +1,5 @@ +namespace: istio-system +bases: + - ../base/flagger/ +patchesStrategicMerge: + - patch.yaml diff --git a/kustomize/istio/patch.yaml b/kustomize/istio/patch.yaml new file mode 100644 index 00000000..b78e3514 --- /dev/null +++ b/kustomize/istio/patch.yaml @@ -0,0 +1,15 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: flagger +spec: + template: + spec: + containers: + - name: flagger + args: + - -mesh-provider=istio + - -metrics-server=http://prometheus:9090 + - -slack-user=flagger + - -slack-channel= + - -slack-url= From 22045982e24eea7be996360243098d3064fa2ae2 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Thu, 4 Jul 2019 13:27:23 +0300 Subject: [PATCH 5/8] Kustomize installer: add Linkerd overlay --- kustomize/linkerd/kustomization.yaml | 5 +++++ kustomize/linkerd/patch.yaml | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 kustomize/linkerd/kustomization.yaml create mode 100644 kustomize/linkerd/patch.yaml diff --git a/kustomize/linkerd/kustomization.yaml b/kustomize/linkerd/kustomization.yaml new file mode 100644 index 00000000..0b11fff0 --- /dev/null +++ b/kustomize/linkerd/kustomization.yaml @@ -0,0 +1,5 @@ +namespace: linkerd +bases: + - ../base/flagger/ +patchesStrategicMerge: + - patch.yaml diff --git a/kustomize/linkerd/patch.yaml b/kustomize/linkerd/patch.yaml new file mode 100644 index 00000000..def51ccf --- /dev/null +++ b/kustomize/linkerd/patch.yaml @@ -0,0 +1,15 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: flagger +spec: + template: + spec: + containers: + - name: flagger + args: + - -mesh-provider=linkerd + - -metrics-server=http://linkerd-prometheus:9090 + - -slack-user=flagger + - -slack-channel= + - -slack-url= From d24a23f3bd0807f58f609a0f2339af5c18005dfc Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Thu, 4 Jul 2019 13:29:02 +0300 Subject: [PATCH 6/8] Kustomize installer: add installer readme --- kustomize/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kustomize/README.md b/kustomize/README.md index df82afbd..343725aa 100644 --- a/kustomize/README.md +++ b/kustomize/README.md @@ -1,5 +1,7 @@ # Flagger Kustomize installer +As an alternative to Helm, Flagger can be installed with Kustomize. + ## Service mesh specific installers Install Flagger for Istio: From c4b066c845b50d17bf32b4426df4e9e15faf3260 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Thu, 4 Jul 2019 13:45:56 +0300 Subject: [PATCH 7/8] Add Kustomize installer to docs --- .../install/flagger-install-on-kubernetes.md | 127 +++++++++++++----- 1 file changed, 93 insertions(+), 34 deletions(-) diff --git a/docs/gitbook/install/flagger-install-on-kubernetes.md b/docs/gitbook/install/flagger-install-on-kubernetes.md index 80013f75..023d003d 100644 --- a/docs/gitbook/install/flagger-install-on-kubernetes.md +++ b/docs/gitbook/install/flagger-install-on-kubernetes.md @@ -1,6 +1,6 @@ # Flagger install on Kubernetes -This guide walks you through setting up Flagger on a Kubernetes cluster. +This guide walks you through setting up Flagger on a Kubernetes cluster with Helm or Kustomize. ### Prerequisites @@ -9,18 +9,7 @@ Flagger requires a Kubernetes cluster **v1.11** or newer with the following admi * MutatingAdmissionWebhook * ValidatingAdmissionWebhook -Flagger depends on [Istio](https://istio.io/docs/setup/kubernetes/quick-start/) **v1.0.3** or newer -with traffic management, telemetry and Prometheus enabled. - -A minimal Istio installation should contain the following services: - -* istio-pilot -* istio-ingressgateway -* istio-sidecar-injector -* istio-telemetry -* prometheus - -### Install Flagger +### Install Flagger with Helm Add Flagger Helm repository: @@ -28,15 +17,25 @@ Add Flagger Helm repository: helm repo add flagger https://flagger.app ``` -Deploy Flagger in the _**istio-system**_ namespace: +Deploy Flagger for Istio: ```bash helm upgrade -i flagger flagger/flagger \ --namespace=istio-system \ ---set metricsServer=http://prometheus.istio-system:9090 +--set meshProvider=istio \ +--set metricsServer=http://prometheus:9090 ``` -You can install Flagger in any namespace as long as it can talk to the Istio Prometheus service on port 9090. +Deploy Flagger for Linkerd: + +```bash +helm upgrade -i flagger flagger/flagger \ +--namespace=linkerd \ +--set meshProvider=linkerd \ +--set metricsServer=http://linkerd-prometheus:9090 +``` + +You can install Flagger in any namespace as long as it can talk to the Prometheus service on port 9090. Enable **Slack** notifications: @@ -81,7 +80,7 @@ If you want to remove all the objects created by Flagger you have delete the Can kubectl delete crd canaries.flagger.app ``` -### Install Grafana +### Install Grafana with Helm Flagger comes with a Grafana dashboard made for monitoring the canary analysis. @@ -115,31 +114,91 @@ You can access Grafana using port forwarding: kubectl -n istio-system port-forward svc/flagger-grafana 3000:80 ``` -### Install Load Tester +### Install Flagger with Kustomize -Flagger comes with an optional load testing service that generates traffic -during canary analysis when configured as a webhook. +As an alternative to Helm, Flagger can be installed with Kustomize. -Deploy the load test runner with Helm: +**Service mesh specific installers** + +Install Flagger for Istio: ```bash -helm upgrade -i flagger-loadtester flagger/loadtester \ ---namespace=test \ ---set cmd.timeout=1h +kubectl apply -k github.com/weaveworks/flagger/kustomize/istio ``` -Deploy with kubectl: +This deploys Flagger in the `istio-system` namespace and sets the metrics server URL to `http://prometheus.istio-system:9090`. + +Install Flagger for Linkerd: ```bash -helm fetch --untar --untardir . flagger/loadtester && -helm template loadtester \ ---name flagger-loadtester \ ---namespace=test -> $HOME/flagger-loadtester.yaml - -# apply -kubectl apply -f $HOME/flagger-loadtester.yaml +kubectl apply -k github.com/weaveworks/flagger/kustomize/linkerd ``` -> **Note** that the load tester should be deployed in a namespace with Istio sidecar injection enabled. +This deploys Flagger in the `linkerd` namespace and sets the metrics server URL to `http://linkerd-prometheus.linkerd:9090`. +**Generic installer** + +Install Flagger and Prometheus: + +```bash +kubectl apply -k github.com/weaveworks/flagger/kustomize/kubernetes +``` + +This deploys Flagger and Prometheus in the `flagger-system` namespace, +sets the metrics server URL to `http://flagger-prometheus.flagger-system:9090` and the mesh provider to `kubernetes`. + +To target a specific provider you need to specify it in the canary custom resource: + +```yaml +apiVersion: flagger.app/v1alpha3 +kind: Canary +metadata: + name: app + namespace: test +spec: + # can be: kubernetes, istio, appmesh, linkerd, smi, nginx, gloo, supergloo + # use the kubernetes provider for Blue/Green style deployments + provider: nginx +``` + +**Customized installer** + +Create a kustomization file using flagger as base: + +```bash +cat > kustomization.yaml < patch.yaml < Date: Thu, 4 Jul 2019 15:07:05 +0300 Subject: [PATCH 8/8] Mention Prometheus data retention in docs --- Makefile | 3 ++- docs/gitbook/install/flagger-install-on-kubernetes.md | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 89ea050e..fbca7d9c 100644 --- a/Makefile +++ b/Makefile @@ -71,7 +71,8 @@ version-set: sed -i '' "s/tag: $$current/tag: $$next/g" charts/flagger/values.yaml && \ sed -i '' "s/appVersion: $$current/appVersion: $$next/g" charts/flagger/Chart.yaml && \ sed -i '' "s/version: $$current/version: $$next/g" charts/flagger/Chart.yaml && \ - echo "Version $$next set in code, deployment and charts" + sed -i '' "s/newTag: $$current/newTag: $$next/g" kustomize/base/flagger/kustomization.yaml && \ + echo "Version $$next set in code, deployment, chart and kustomize" version-up: @next="$(VERSION_MINOR).$$(($(PATCH) + 1))" && \ diff --git a/docs/gitbook/install/flagger-install-on-kubernetes.md b/docs/gitbook/install/flagger-install-on-kubernetes.md index 023d003d..659face1 100644 --- a/docs/gitbook/install/flagger-install-on-kubernetes.md +++ b/docs/gitbook/install/flagger-install-on-kubernetes.md @@ -147,6 +147,9 @@ kubectl apply -k github.com/weaveworks/flagger/kustomize/kubernetes This deploys Flagger and Prometheus in the `flagger-system` namespace, sets the metrics server URL to `http://flagger-prometheus.flagger-system:9090` and the mesh provider to `kubernetes`. +The Prometheus instance has a two hours data retention and is configured to scrape all pods in your cluster that +have the `prometheus.io/scrape: "true"` annotation. + To target a specific provider you need to specify it in the canary custom resource: ```yaml