Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Kustomize installer #232

Merged
merged 8 commits into from
Jul 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))" && \
Expand Down
128 changes: 95 additions & 33 deletions docs/gitbook/install/flagger-install-on-kubernetes.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -9,34 +9,33 @@ 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:

```bash
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
```

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 Istio Prometheus service on port 9090.
You can install Flagger in any namespace as long as it can talk to the Prometheus service on port 9090.

Enable **Slack** notifications:

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -115,31 +114,94 @@ 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
kubectl apply -k github.com/weaveworks/flagger/kustomize/linkerd
```

# apply
kubectl apply -f $HOME/flagger-loadtester.yaml
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
```

> **Note** that the load tester should be deployed in a namespace with Istio sidecar injection enabled.
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
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 <<EOF
namespace: istio-system
bases:
- github.com/weaveworks/flagger/kustomize/base/flagger
patchesStrategicMerge:
- patch.yaml
EOF
```

Create a patch and enable Slack notifications by setting the slack channel and hook URL:

```bash
cat > patch.yaml <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: flagger
spec:
template:
spec:
containers:
- name: flagger
args:
- -mesh-provider=istio
- -metrics-server=http://prometheus.istio-system:9090
- -slack-user=flagger
- -slack-channel=alerts
- -slack-url=https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK
EOF
```

Install Flagger with Slack:

```bash
kubectl apply -k .
```
89 changes: 89 additions & 0 deletions kustomize/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Flagger Kustomize installer

As an alternative to Helm, Flagger can be installed with Kustomize.

## 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 <<EOF
namespace: istio-system
bases:
- github.com/weaveworks/flagger/kustomize/base/flagger
patchesStrategicMerge:
- patch.yaml
EOF
```

Create a patch and enable Slack notifications by setting the slack channel and hook URL:

```bash
cat > patch.yaml <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: flagger
spec:
template:
spec:
containers:
- name: flagger
args:
- -mesh-provider=istio
- -metrics-server=http://prometheus.istio-system:9090
- -slack-user=flagger
- -slack-channel=alerts
- -slack-url=https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK
EOF
```

Install Flagger with Slack:

```bash
kubectl apply -k .
```

6 changes: 6 additions & 0 deletions kustomize/base/flagger/account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: flagger
namespace: flagger-system

Loading