Skip to content

Trouble running code-server on Digital Ocean kubernetes #1376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aleleba opened this issue Feb 27, 2020 · 5 comments
Closed

Trouble running code-server on Digital Ocean kubernetes #1376

aleleba opened this issue Feb 27, 2020 · 5 comments
Labels
waiting-for-info Waiting for more information from submitter

Comments

@aleleba
Copy link

aleleba commented Feb 27, 2020

  • code-server version:
    v2
  • OS Version:
    Kubernetes DO 1.16.6-do.0

Description

I'm having trouble running code-server on Digital Ocean kubernetes. The problem seems to be with websokets. In the Javasript console I get this error: ERR [remote-connection] [Management] [ee9c0…] [initial] [p-lao.tk:80] socketFactory.connect () failed. Error: Error: WebSocket close with status code 1006

ERR Assertion Failed: argument is undefined or null: Error: Assertion Failed: argument is undefined or null

Please help me solve this error.

First of all, Thanks

My YAML File

apiVersion: v1
kind: Namespace
metadata:
  name: code-server
---
apiVersion: v1
kind: Service
metadata:
 name: code-server
 namespace: code-server
spec:
 ports:
 - name: code-server-main
   port: 80
   targetPort: 8080
   name: https
   protocol: TCP
 selector:
   app: code-server
 type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: code-server
  name: code-server
  namespace: code-server
spec:
  selector:
    matchLabels:
      app: code-server
  replicas: 1
  template:
    metadata:
      labels:
        app: code-server
    spec:
      containers:
      - image: codercom/code-server:v2
        imagePullPolicy: Always
        name: code-server
        env:
        - name: PASSWORD
          value: "password"
        ports:
        - containerPort: 8080
          name: https
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
  namespace: code-server
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: p-lao.tk
    http:
      paths:
      - path: /
        backend:
          serviceName: code-server
          servicePort: 80
@aleleba aleleba added the bug Something isn't working label Feb 27, 2020
@aleleba aleleba changed the title I'm having trouble running code-server on Digital Ocean kubernetes Trouble running code-server on Digital Ocean kubernetes Feb 27, 2020
@nhooyr
Copy link
Contributor

nhooyr commented Feb 27, 2020

1006 means the websocket cannot connect. Are you using some sort of proxy that doesn't allow WebSockets to go through?

@nhooyr nhooyr added waiting-for-info Waiting for more information from submitter and removed bug Something isn't working labels Feb 27, 2020
@aleleba
Copy link
Author

aleleba commented Feb 27, 2020

Thank to respond @nhooyr, I am using Ingress Controller for proxy the trafic. And Cert-Manager to get SSL Certificate

@aleleba
Copy link
Author

aleleba commented Feb 28, 2020

My YAML File

apiVersion: v1
kind: Namespace
metadata:
  name: code-server
---
apiVersion: v1
kind: Service
metadata:
 name: code-server
 namespace: code-server
spec:
 ports:
 - name: code-server-main
   port: 80
   targetPort: 8080
   name: https
   protocol: TCP
 selector:
   app: code-server
 type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: code-server
  name: code-server
  namespace: code-server
spec:
  selector:
    matchLabels:
      app: code-server
  replicas: 1
  template:
    metadata:
      labels:
        app: code-server
    spec:
      containers:
      - image: codercom/code-server:v2
        imagePullPolicy: Always
        name: code-server
        env:
        - name: PASSWORD
          value: "password"
        ports:
        - containerPort: 8080
          name: https
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
  namespace: code-server
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: p-lao.tk
    http:
      paths:
      - path: /
        backend:
          serviceName: code-server
          servicePort: 80

@aleleba
Copy link
Author

aleleba commented Feb 28, 2020

My YAML Exposes Ingress from a Load Balancer

apiVersion: v1
kind: Service
metadata:
  name: nginx-ingress
  namespace: nginx-ingress
spec:
  type: LoadBalancer
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
      name: http
    - protocol: TCP
      port: 443
      targetPort: 443
      name: https
  selector:
    app: nginx-ingress

@aleleba
Copy link
Author

aleleba commented Feb 28, 2020

I have solved the problem. In case someone has the same problem. In my Ingress.yaml I had to add an annotation to allow connections to websockets.
The annotation I add to ingress.yaml:

annotations:
    nginx.org/websocket-services: "serviceName"

My YAML Ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
  namespace: code-server
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.org/websocket-services: "code-server"
spec:
  rules:
  - host: p-lao.tk
    http:
      paths:
      - path: /
        backend:
          serviceName: code-server
          servicePort: 80

@aleleba aleleba closed this as completed Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-info Waiting for more information from submitter
Projects
None yet
Development

No branches or pull requests

2 participants