Search code examples
reverse-proxyx11remote-accesskubernetes-ingressx11-forwarding

Accessing xpra html5 client behind a ingress controller


I am trying to host and remotely access kicad(pcb software) on a kubernetes cluster using html5 client .

dockerfile:

FROM python:3.9.0-slim-buster

RUN apt-get update && apt install  -y \
    software-properties-common \
    wget \ 
    gnupg2 

#install xpra      
RUN wget -q https://xpra.org/gpg.asc -O- | apt-key add - && \
    add-apt-repository "deb https://xpra.org/ buster main" && \
    apt-get update && apt-get install -y  --no-install-recommends xpra xvfb xterm  

##install dependencies
RUN apt-get update && apt install  -y \
    libx11-dev libxcomposite-dev libxdamage-dev \
    libxkbfile-dev \
    openssh-client \
    sshpass \
    python3-paramiko \
    dbus-x11  \
    python3-requests \
    xpra-html5

#install kicad
RUN apt-get update && add-apt-repository -y ppa:kicad/kicad-5.1-releases && \
    apt-get install -y --no-install-recommends kicad \ 
    && rm -rf /var/lib/apt/lists/* 
    
ENV DISPLAY=:0
EXPOSE 8051
CMD  xpra start --start=kicad --no-pulseaudio --bind-tcp=0.0.0.0:8051 --html=on && tail -f /dev/null 

deployment file:

 apiVersion: apps/v1
kind: Deployment
metadata:
  name: kicad-deployment
  labels:
    app: kicad
spec:
  replicas: 2
  selector:
    matchLabels:
      app: kicad
  template:
    metadata:
      labels:
        app: kicad
    spec:
      containers:
      - name: kicad
        image: syashfr/kicad:1.0.0
        ports:
        - containerPort: 8051

service file:

apiVersion: v1 
kind: Service 
metadata:
  name: kicad-service 
spec: 
  type: LoadBalancer
  selector:
    app: kicad
  ports:
    - port: 80
      targetPort: 8051

ingress file:

kind: Ingress
metadata:
  name: kicad-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
        - path: /kicad
          backend:
            serviceName: kicad-service 
            servicePort: 80 

I assume proxy_pass should be automatically on applying ingress.yaml, therefore I have not made changes to nginx.conf (ingress controller) as stated in https://xpra.org/trac/wiki/Nginx

However when I try to access the application: http://ingress_address/kicad, I get the following page instead of the application UI:

enter image description here

It does seem that I am routed to my service, but not to the expected UI. I can however, access the kicad UI through external IP of the service. What am I missing with ingress ?


Solution

  • I've reproduced your issue and solved it by slightly modifying the ingress resource. My ingress object manifest:

    apiVersion: networking.k8s.io/v1beta1
    kind: Ingress
    metadata:
      name: kicad-ingress
      annotations:
        nginx.ingress.kubernetes.io/rewrite-target: /$1
        kubernetes.io/ingress.class: nginx
    spec:
      rules:
      - http:
          paths:
            - path: /kicad/?(.*)
              backend:
                serviceName: kicad-service 
                servicePort: 80
    

    Deployment and service yamls remained untouched. When you try to access <ingress-IP>/kicad/ you will see expected UI.