From f1884da02d9158b17925736a35f10e00f49de5b5 Mon Sep 17 00:00:00 2001 From: Yossi Mesika Date: Mon, 11 Feb 2019 21:39:32 +0200 Subject: [PATCH] Break up the helloworld sample into versions (#11650) * Break up the helloworld sample into versions * Moved to default namespace * Seperated gateway file and added labels * Update the doc * Cleanup section updated too --- samples/helloworld/README.md | 4 ++- samples/helloworld/helloworld-gateway.yaml | 33 +++++++++++++++++++ samples/helloworld/helloworld.yaml | 38 +++------------------- 3 files changed, 40 insertions(+), 35 deletions(-) create mode 100644 samples/helloworld/helloworld-gateway.yaml diff --git a/samples/helloworld/README.md b/samples/helloworld/README.md index 4a2e59c40550..c4fc5529b470 100644 --- a/samples/helloworld/README.md +++ b/samples/helloworld/README.md @@ -20,10 +20,11 @@ containers within the `helloworld.yaml` are pre-defined with the request. The (m injected istio-proxy containers also have the requests cpu therefore making the `helloworld` ready for autoscaling. -Now create the deployment using the updated yaml file: +Now create the deployment using the updated yaml file and create the gateway configuration: ```bash kubectl create -f helloworld-istio.yaml +kubectl create -f helloworld-gateway.yaml ``` Follow the [instructions](https://preliminary.istio.io/docs/tasks/traffic-management/ingress.html#determining-the-ingress-ip-and-ports) to set the INGRESS_HOST and INGRESS_PORT variables then confirm it's running using curl. @@ -63,5 +64,6 @@ value > 1. ```bash kubectl delete -f helloworld-istio.yaml +kubectl delete -f helloworld-gateway.yaml kubectl delete hpa helloworld-v1 helloworld-v2 ``` diff --git a/samples/helloworld/helloworld-gateway.yaml b/samples/helloworld/helloworld-gateway.yaml new file mode 100644 index 000000000000..43afc14b6fe2 --- /dev/null +++ b/samples/helloworld/helloworld-gateway.yaml @@ -0,0 +1,33 @@ +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: helloworld-gateway +spec: + selector: + istio: ingressgateway # use istio default controller + servers: + - port: + number: 80 + name: http + protocol: HTTP + hosts: + - "*" +--- +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: helloworld +spec: + hosts: + - "*" + gateways: + - helloworld-gateway + http: + - match: + - uri: + exact: /hello + route: + - destination: + host: helloworld + port: + number: 5000 diff --git a/samples/helloworld/helloworld.yaml b/samples/helloworld/helloworld.yaml index 52baa92630a7..787e25d12ba0 100644 --- a/samples/helloworld/helloworld.yaml +++ b/samples/helloworld/helloworld.yaml @@ -15,6 +15,8 @@ apiVersion: extensions/v1beta1 kind: Deployment metadata: name: helloworld-v1 + labels: + version: v1 spec: replicas: 1 template: @@ -37,6 +39,8 @@ apiVersion: extensions/v1beta1 kind: Deployment metadata: name: helloworld-v2 + labels: + version: v2 spec: replicas: 1 template: @@ -54,37 +58,3 @@ spec: imagePullPolicy: IfNotPresent #Always ports: - containerPort: 5000 ---- -apiVersion: networking.istio.io/v1alpha3 -kind: Gateway -metadata: - name: helloworld-gateway -spec: - selector: - istio: ingressgateway # use istio default controller - servers: - - port: - number: 80 - name: http - protocol: HTTP - hosts: - - "*" ---- -apiVersion: networking.istio.io/v1alpha3 -kind: VirtualService -metadata: - name: helloworld -spec: - hosts: - - "*" - gateways: - - helloworld-gateway - http: - - match: - - uri: - exact: /hello - route: - - destination: - host: helloworld - port: - number: 5000