Feat: istio addon and use case demo (#2276)

fix all error and finish readme

small change

fix CI check

add canary trait back
This commit is contained in:
wyike
2021-09-13 20:10:32 +08:00
committed by GitHub
parent b66f2995a5
commit d93d8626c0
16 changed files with 1015 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
# Canary rollout use case
This chapter will introduce how to define a canary rollout workflow to implement [bookinfo demo](https://istio.io/latest/docs/examples/bookinfo/?ie=utf-8&hl=en&docs-search=Canary) by leverage [istio](https://istio.io/latest/)
## Prerequisite
enable istio addon in you cluster
```shell
vela addon enable istio
```
enable label istio injection in `default namespace`
```shell
kubectl label namespace default istio-injection=enabled
```
## First deployment
```shell
kubectl apply -f first-deploy.yaml
```
Wait a few minutes all pods have been ready. Use kubectl port-forward map gateway's service port to localhost.
```shell
kubectl port-forward service/istio-ingressgateway -n istio-system 19082:80
```
Request `127.0.0.1:19082` in your browser will see webpage like this.
![pic-v1](../../resources/canary-pic-v2.jpg)
## Canary Rollout
Update application to define a canary rollout workflow. This workflow will suspend after only upgrade one batch pods of `reviews` component and shift 10% traffic to new revision. It's give user some time to manual-check.
```shell
kubectl apply -f rollout-v2.yaml
```
Wait a few minutes new revision pods ready. Request `127.0.0.1:19082` in your browser again several times. Will see almost 90% chance see previous the webpage and 10% chance see the new webpage whose reviews will display red starts like this.
![pic-v2](../../resources/canary-pic-v3.jpg)
### Rollout rest batches and traffic
resume workflow to continue rollout rest replicas and shift all traffic to new revision.
```shell
vela workflow reumse book-info
```
By request again. You will always see the new webpage
### Cancel rollout workflow and revert.
If you find some problems after manual-check and want to revert to previous revision. You can cancel the rollout workflow and revert.
```shell
kubectl apply -f revert-in-middle.yaml
```
By request again. You will always see the old webpage

View File

@@ -0,0 +1,83 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: book-info
namespace: default
spec:
components:
- name: reviews
type: webservice
properties:
image: docker.io/istio/examples-bookinfo-reviews-v2:1.16.2
port: 9080
volumes:
- name: wlp-output
type: emptyDir
mountPath: /opt/ibm/wlp/output
- name: tmp
type: emptyDir
mountPath: /tmp
traits:
- type: expose
properties:
port:
- 9080
- type: rollout
properties:
targetSize: 2
# This means to rollout two more replicas in two batches.
rolloutBatches:
- replicas: 2
- name: productpage
type: webservice
properties:
image: docker.io/istio/examples-bookinfo-productpage-v1:1.16.2
port: 9080
traits:
- type: expose
properties:
port:
- 9080
- type: istio-gateway
properties:
hosts:
- "*"
gateway: ingressgateway
match:
- exact: /productpage
- prefix: /static
- exact: /login
- prefix: /api/v1/products
port: 9080
- name: ratings
type: webservice
properties:
image: docker.io/istio/examples-bookinfo-ratings-v1:1.16.2
port: 9080
traits:
- type: expose
properties:
port:
- 9080
- name: details
type: webservice
properties:
image: docker.io/istio/examples-bookinfo-details-v1:1.16.2
port: 9080
traits:
- type: expose
properties:
port:
- 9080

View File

@@ -0,0 +1,85 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: book-info
namespace: default
spec:
components:
- name: reviews
type: webservice
properties:
image: docker.io/istio/examples-bookinfo-reviews-v3:1.16.2
port: 9080
volumes:
- name: wlp-output
type: emptyDir
mountPath: /opt/ibm/wlp/output
- name: tmp
type: emptyDir
mountPath: /tmp
traits:
- type: expose
properties:
port:
- 9080
- type: rollout
properties:
targetRevision: reviews-v1
batchPartition: 1
targetSize: 2
# This means to rollout two more replicas in two batches.
rolloutBatches:
- replicas: 2
- name: productpage
type: webservice
properties:
image: docker.io/istio/examples-bookinfo-productpage-v1:1.16.2
port: 9080
traits:
- type: expose
properties:
port:
- 9080
- type: istio-gateway
properties:
hosts:
- "*"
gateway: ingressgateway
match:
- exact: /productpage
- prefix: /static
- exact: /login
- prefix: /api/v1/products
port: 9080
- name: ratings
type: webservice
properties:
image: docker.io/istio/examples-bookinfo-ratings-v1:1.16.2
port: 9080
traits:
- type: expose
properties:
port:
- 9080
- name: details
type: webservice
properties:
image: docker.io/istio/examples-bookinfo-details-v1:1.16.2
port: 9080
traits:
- type: expose
properties:
port:
- 9080

View File

@@ -0,0 +1,116 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: book-info
namespace: default
spec:
components:
- name: reviews
type: webservice
properties:
image: docker.io/istio/examples-bookinfo-reviews-v3:1.16.2
port: 9080
volumes:
- name: wlp-output
type: emptyDir
mountPath: /opt/ibm/wlp/output
- name: tmp
type: emptyDir
mountPath: /tmp
traits:
- type: expose
properties:
port:
- 9080
- type: rollout
properties:
targetSize: 2
# This means to rollout two more replicas in two batches.
rolloutBatches:
- replicas: 1
- replicas: 1
- type: canary-traffic
properties:
port: 9080
- name: productpage
type: webservice
properties:
image: docker.io/istio/examples-bookinfo-productpage-v1:1.16.2
port: 9080
traits:
- type: expose
properties:
port:
- 9080
- type: istio-gateway
properties:
hosts:
- "*"
gateway: ingressgateway
match:
- exact: /productpage
- prefix: /static
- exact: /login
- prefix: /api/v1/products
port: 9080
- name: ratings
type: webservice
properties:
image: docker.io/istio/examples-bookinfo-ratings-v1:1.16.2
port: 9080
traits:
- type: expose
properties:
port:
- 9080
- name: details
type: webservice
properties:
image: docker.io/istio/examples-bookinfo-details-v1:1.16.2
port: 9080
traits:
- type: expose
properties:
port:
- 9080
workflow:
steps:
- name: rollout-1st-batch
type: canary-rollout
properties:
# just upgrade first batch of component
batchPartition: 0
traffic:
weightedTargets:
- revision: reviews-v1
weight: 90 # 90% shift to new version
- revision: reviews-v2
weight: 10 # 10% shift to new version
# give user time to verify part of traffic shifting to newRevision
- name: manual-approval
type: suspend
- name: rollout-rest
type: canary-rollout
properties:
# upgrade all batches of component
batchPartition: 1
traffic:
weightedTargets:
- revision: reviews-v2
weight: 100 # 100% shift to new version