Skip to content

Commit

Permalink
Merge pull request #327 from weaveworks/target-port
Browse files Browse the repository at this point in the history
Implement canary service target port
  • Loading branch information
stefanprodan authored Oct 8, 2019
2 parents 5605fab + 3345692 commit 61ab596
Show file tree
Hide file tree
Showing 56 changed files with 543 additions and 272 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ spec:
kind: HorizontalPodAutoscaler
name: podinfo
service:
# container port
# ClusterIP port number
port: 9898
# container port name or number (optional)
targetPort: 9898
# port name can be http or grpc (default http)
portName: http
# HTTP match conditions (optional)
Expand Down
3 changes: 2 additions & 1 deletion artifacts/canaries/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ spec:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9898"
labels:
app: podinfo
spec:
containers:
- name: podinfod
image: stefanprodan/podinfo:2.0.0
image: stefanprodan/podinfo:3.1.0
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9898
Expand Down
5 changes: 5 additions & 0 deletions artifacts/flagger/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ spec:
portName:
description: Container port name
type: string
targetPort:
description: Container target port name
anyOf:
- type: string
- type: number
portDiscovery:
description: Enable port dicovery
type: boolean
Expand Down
2 changes: 1 addition & 1 deletion artifacts/loadtester/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: loadtester
image: weaveworks/flagger-loadtester:0.8.0
image: weaveworks/flagger-loadtester:0.9.0
imagePullPolicy: IfNotPresent
ports:
- name: http
Expand Down
5 changes: 5 additions & 0 deletions charts/flagger/templates/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ spec:
portName:
description: Container port name
type: string
targetPort:
description: Container target port name
anyOf:
- type: string
- type: number
portDiscovery:
description: Enable port dicovery
type: boolean
Expand Down
4 changes: 2 additions & 2 deletions charts/loadtester/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
name: loadtester
version: 0.8.0
appVersion: 0.8.0
version: 0.9.0
appVersion: 0.9.0
kubeVersion: ">=1.11.0-0"
engine: gotpl
description: Flagger's load testing services based on rakyll/hey and bojand/ghz that generates traffic during canary analysis when configured as a webhook.
Expand Down
6 changes: 4 additions & 2 deletions charts/loadtester/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ replicaCount: 1

image:
repository: weaveworks/flagger-loadtester
tag: 0.8.0
tag: 0.9.0
pullPolicy: IfNotPresent

podAnnotations: {}
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8080"

logLevel: info
cmd:
Expand Down
2 changes: 1 addition & 1 deletion cmd/loadtester/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"
)

var VERSION = "0.8.0"
var VERSION = "0.9.0"
var (
logLevel string
port string
Expand Down
4 changes: 3 additions & 1 deletion docs/gitbook/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ spec:
kind: Deployment
name: podinfo
service:
# container port (required)
# ClusterIP port number (required)
port: 9898
# container port name or number
targetPort: http
# port name can be http or grpc (default http)
portName: http
```
Expand Down
8 changes: 5 additions & 3 deletions docs/gitbook/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ spec:
kind: HorizontalPodAutoscaler
name: podinfo
service:
# container port
# ClusterIP port number
port: 9898
# port name can be http or grpc (default http)
# ClusterIP port name can be http or grpc (default http)
portName: http
# container port number or name (optional)
targetPort: 9898
# add all the other container ports
# to the ClusterIP services (default false)
portDiscovery: false
Expand Down Expand Up @@ -95,7 +97,7 @@ Besides `app` Flagger supports `name` and `app.kubernetes.io/name` selectors. If
convention you can specify your label with the `-selector-labels` flag.

The target deployment should expose a TCP port that will be used by Flagger to create the ClusterIP Services.
The container port from the target deployment should match the `service.port` value.
The container port from the target deployment should match the `service.port` or `service.targetPort`.

### Canary status

Expand Down
2 changes: 1 addition & 1 deletion docs/gitbook/usage/ab-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Trigger a canary deployment by updating the container image:

```bash
kubectl -n test set image deployment/abtest \
podinfod=stefanprodan/podinfo:2.0.1
podinfod=stefanprodan/podinfo:3.1.1
```

Flagger detects that the deployment revision changed and starts a new rollout:
Expand Down
6 changes: 2 additions & 4 deletions docs/gitbook/usage/blue-green.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ metadata:
namespace: test
spec:
# service mesh provider can be: kubernetes, istio, appmesh, nginx, gloo
# use the kubernetes provider for Blue/Green style deployments
provider: kubernetes
# deployment reference
targetRef:
Expand All @@ -96,7 +95,6 @@ spec:
kind: HorizontalPodAutoscaler
name: podinfo
service:
# container port
port: 9898
portDiscovery: true
canaryAnalysis:
Expand Down Expand Up @@ -172,7 +170,7 @@ Trigger a deployment by updating the container image:

```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.1
podinfod=stefanprodan/podinfo:3.1.1
```

Flagger detects that the deployment revision changed and starts a new rollout:
Expand Down Expand Up @@ -297,7 +295,7 @@ Trigger a deployment by updating the container image:
```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.3
podinfod=stefanprodan/podinfo:3.1.3
```

Generate 404s:
Expand Down
10 changes: 6 additions & 4 deletions docs/gitbook/usage/gloo-progressive-delivery.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ spec:
# to make progress before it is rollback (default 600s)
progressDeadlineSeconds: 60
service:
# container port
# ClusterIP port number
port: 9898
# container port number or name (optional)
targetPort: 9898
canaryAnalysis:
# schedule interval (default 60s)
interval: 10s
Expand Down Expand Up @@ -198,7 +200,7 @@ Trigger a canary deployment by updating the container image:

```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.1
podinfod=stefanprodan/podinfo:3.1.1
```

Flagger detects that the deployment revision changed and starts a new rollout:
Expand Down Expand Up @@ -252,7 +254,7 @@ Trigger another canary deployment:

```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.2
podinfod=stefanprodan/podinfo:3.1.2
```

Generate HTTP 500 errors:
Expand Down Expand Up @@ -335,7 +337,7 @@ Trigger a canary deployment by updating the container image:
```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.3
podinfod=stefanprodan/podinfo:3.1.3
```

Generate 404s:
Expand Down
12 changes: 7 additions & 5 deletions docs/gitbook/usage/linkerd-progressive-delivery.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ spec:
# to make progress before it is rollback (default 600s)
progressDeadlineSeconds: 60
service:
# container port
# ClusterIP port number
port: 9898
# container port number or name (optional)
targetPort: 9898
canaryAnalysis:
# schedule interval (default 60s)
interval: 30s
Expand Down Expand Up @@ -150,7 +152,7 @@ Trigger a canary deployment by updating the container image:

```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.1
podinfod=stefanprodan/podinfo:3.1.1
```

Flagger detects that the deployment revision changed and starts a new rollout:
Expand Down Expand Up @@ -208,7 +210,7 @@ Trigger another canary deployment:

```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.2
podinfod=stefanprodan/podinfo:3.1.2
```

Exec into the load tester pod with:
Expand Down Expand Up @@ -297,7 +299,7 @@ Trigger a canary deployment by updating the container image:
```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.3
podinfod=stefanprodan/podinfo:3.1.3
```

Generate 404s:
Expand Down Expand Up @@ -444,7 +446,7 @@ Trigger a canary deployment by updating the container image:

```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.4
podinfod=stefanprodan/podinfo:3.1.4
```

Flagger detects that the deployment revision changed and starts the A/B testing:
Expand Down
26 changes: 17 additions & 9 deletions docs/gitbook/usage/nginx-progressive-delivery.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ spec:
paths:
- backend:
serviceName: podinfo
servicePort: 9898
servicePort: 80
```
Save the above resource as podinfo-ingress.yaml and then apply it:
Expand Down Expand Up @@ -124,8 +124,10 @@ spec:
# to make progress before it is rollback (default 600s)
progressDeadlineSeconds: 60
service:
# container port
port: 9898
# ClusterIP port number
port: 80
# container port number or name
targetPort: 9898
canaryAnalysis:
# schedule interval (default 60s)
interval: 10s
Expand All @@ -144,8 +146,15 @@ spec:
# percentage (0-100)
threshold: 99
interval: 1m
# load testing (optional)
# testing (optional)
webhooks:
- name: acceptance-test
type: pre-rollout
url: http://flagger-loadtester.test/
timeout: 30s
metadata:
type: bash
cmd: "curl -sd 'test' http://podinfo-canary/token | grep token"
- name: load-test
url: http://flagger-loadtester.test/
timeout: 5s
Expand Down Expand Up @@ -190,7 +199,7 @@ Trigger a canary deployment by updating the container image:

```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.1
podinfod=stefanprodan/podinfo:3.1.1
```

Flagger detects that the deployment revision changed and starts a new rollout:
Expand Down Expand Up @@ -244,7 +253,7 @@ Trigger another canary deployment:

```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.2
podinfod=stefanprodan/podinfo:3.1.2
```

Generate HTTP 500 errors:
Expand Down Expand Up @@ -314,7 +323,7 @@ Trigger a canary deployment by updating the container image:
```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.3
podinfod=stefanprodan/podinfo:3.1.3
```

Generate high response latency:
Expand Down Expand Up @@ -388,7 +397,7 @@ Trigger a canary deployment by updating the container image:

```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.4
podinfod=stefanprodan/podinfo:3.1.4
```

Flagger detects that the deployment revision changed and starts the A/B testing:
Expand Down Expand Up @@ -419,4 +428,3 @@ Events:
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
```

8 changes: 5 additions & 3 deletions docs/gitbook/usage/progressive-delivery.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ spec:
kind: HorizontalPodAutoscaler
name: podinfo
service:
# container port
# service port number
port: 9898
# container port number or name (optional)
targetPort: 9898
# Istio gateways (optional)
gateways:
- public-gateway.istio-system.svc.cluster.local
Expand Down Expand Up @@ -142,7 +144,7 @@ Trigger a canary deployment by updating the container image:

```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.1
podinfod=stefanprodan/podinfo:3.1.1
```

Flagger detects that the deployment revision changed and starts a new rollout:
Expand Down Expand Up @@ -201,7 +203,7 @@ Trigger another canary deployment:

```bash
kubectl -n test set image deployment/podinfo \
podinfod=stefanprodan/podinfo:2.0.2
podinfod=stefanprodan/podinfo:3.1.2
```

Exec into the load tester pod with:
Expand Down
5 changes: 5 additions & 0 deletions kustomize/base/flagger/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ spec:
portName:
description: Container port name
type: string
targetPort:
description: Container target port name
anyOf:
- type: string
- type: number
portDiscovery:
description: Enable port dicovery
type: boolean
Expand Down
1 change: 1 addition & 0 deletions kustomize/podinfo/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ spec:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9797"
labels:
app: podinfo
spec:
Expand Down
Loading

0 comments on commit 61ab596

Please sign in to comment.