Skip to content

Instantly share code, notes, and snippets.

@shpwrck
Last active March 27, 2023 20:14
Show Gist options
  • Save shpwrck/4cdeb8759fad27ddfb3b51e8b9030597 to your computer and use it in GitHub Desktop.
Save shpwrck/4cdeb8759fad27ddfb3b51e8b9030597 to your computer and use it in GitHub Desktop.
Gloo & WebSockets

I used vi/websocat, but v0.10.0 because v0.11.0 didn't seem to work. Once I deployed the k8s-resources.yaml and the gloo-resources.yaml ... I:

  • Ran websocat ws://<<gateway_ip>> from within the websocat container
  • Passed in some values
  • Cancelled
  • Checked the logs for connection information.

Otherwise you can leverage piesocket. *You'll have to run the extension because "browsers don't support ws).

---
apiVersion: admin.gloo.solo.io/v2
kind: Workspace
metadata:
annotations:
name: cxp-app
namespace: gloo-mesh
spec:
workloadClusters:
- name: mgmt
namespaces:
- name: cxp-app-configs
- name: '*'
namespaces:
- name: '*'
---
apiVersion: admin.gloo.solo.io/v2
kind: WorkspaceSettings
metadata:
name: cxp-app
namespace: cxp-app-configs
spec:
exportTo:
- workspaces:
- name: '*'
importFrom:
- workspaces:
- name: '*'
options:
eastWestGateways:
- selector:
labels:
istio: eastwestgateway
federation:
enabled: false
serviceIsolation:
enabled: false
trimProxyConfig: false
---
apiVersion: networking.gloo.solo.io/v2
kind: VirtualDestination
metadata:
name: websocat
namespace: cxp-app-configs
spec:
hosts:
- websocat.mesh
ports:
- number: 8080
protocol: http
services:
- labels:
app: websocat
---
apiVersion: networking.gloo.solo.io/v2
kind: VirtualGateway
metadata:
name: vgw
namespace: cxp-app-configs
spec:
listeners:
- http: {}
port:
number: 80
workloads:
- selector:
labels:
app: solo-istio-ingressgateway
---
apiVersion: networking.gloo.solo.io/v2
kind: RouteTable
metadata:
name: websocat
namespace: cxp-app-configs
spec:
hosts:
- '*'
http:
- forwardTo:
destinations:
- kind: VIRTUAL_DESTINATION
port:
number: 8080
ref:
name: websocat
namespace: cxp-app-configs
labels:
route: websocat
virtualGateways:
- name: vgw
namespace: cxp-app-configs
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: websocat
name: websocat
namespace: default
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: websocat
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: websocat
spec:
containers:
- args:
- -s
- 0.0.0.0:8080
image: ghcr.io/vi/websocat:0.10.0
imagePullPolicy: IfNotPresent
name: websocat
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
labels:
app: websocat
name: websocat
namespace: default
spec:
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- port: 8080
protocol: TCP
targetPort: 8080
selector:
app: websocat
sessionAffinity: None
type: ClusterIP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment