Skip to content

Instantly share code, notes, and snippets.

@ymesika
Last active September 10, 2019 08:43
Show Gist options
  • Save ymesika/c64326e3d8b4ff2c1e2b53c1e13ac72a to your computer and use it in GitHub Desktop.
Save ymesika/c64326e3d8b4ff2c1e2b53c1e13ac72a to your computer and use it in GitHub Desktop.
Websockets Demo (Istio v0.7.1 / Istio Nightly Build)
apiVersion: v1
kind: Service
metadata:
name: tornado
labels:
app: tornado
spec:
ports:
- port: 8888
name: http
selector:
app: tornado
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: tornado
spec:
replicas: 1
template:
metadata:
labels:
app: tornado
version: v1
spec:
containers:
- name: tornado
image: hiroakis/tornado-websocket-example
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8888
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: tornado-gateway
annotations:
kubernetes.io/ingress.class: "istio"
spec:
rules:
- http:
paths:
- path: /.*
backend:
serviceName: tornado
servicePort: 8888
apiVersion: config.istio.io/v1alpha2
kind: RouteRule
metadata:
name: tornado-websocket
spec:
destination:
name: tornado
match:
request:
headers:
uri:
prefix: /
websocketUpgrade: true
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: tornado-gateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: tornado
spec:
hosts:
- "*"
gateways:
- tornado-gateway
http:
- match:
- uri:
prefix: /
route:
- destination:
host: tornado
weight: 100
websocketUpgrade: true
@ymesika
Copy link
Author

ymesika commented Jun 7, 2018

Prerequisites

  • Istio v0.7.1 installed (kubectl create -f install/kubernetes/istio.yaml)

Installation

Save the files in this gist and:

  • kubectl apply -f <(bin/istioctl kube-inject --debug -f tornado.yaml)
  • bin/istioctl create -f tornado_rule.yaml

Test

  • Find your ingress IP and port
  • Access http://${GATEWAY_URL}/ with your browser
  • The WebSocket status should show a green open status which means that a websocket connection to the server has been established.

@ymesika
Copy link
Author

ymesika commented Jun 7, 2018

IMPORTANT

Current Istio v0.8.0 release with v1alpha3 routing rules are not supporting the websocket upgrade protocol.
Trying to run this example (after converting to v1alpha3) will result in the web page correctly loading but the WebSocket status will be red close.

It has been fixed and will be included in future releases.

@musicformellons
Copy link

musicformellons commented Dec 24, 2018

When I install this using the tornado_rule_v3.yaml the tornado-gateway part of the tornado.yaml should be left out I think. However when I do that I get a 503 when I open the ip address in the browser. No idea what I am doing wrong following the instructions closely and tried several times now... Any idea?

Actually the 'kubectl get ingress -o wide' to find the ingress ip and port returns: 'No resources found'. But I can find the ip and port from the GKE UI I think, however this returns the 503.

istio: 1.0.3
gke: 1.10.9-gke.5

@cfregly
Copy link

cfregly commented Dec 26, 2018

I'm seeing the same thing - 503.

istio 1.0.5, self-managed kube cluster (1.10)

@musicformellons
Copy link

I retried using this (which is not really different...?!) and have no idea what was different from my earlier attempts (I did a restart setting up a new cluster etc.), but now it works!!

@musicformellons
Copy link

When I 'kubectl delete' the two .yaml files and then try to 'kubectl create' them again I end up with 503 again... How can I get it working again...?!

@musicformellons
Copy link

Ah, when I delete the istio-ingressgateway via the gui it restarts itself and then it works again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment