unable to connect to novnc via nginx-ingress + HA proxy

6/11/2020

I've set up a novnc container running Kali and host it a k8s service type NodePort. I'm able to access Kali through novnc using <master-node-ip>:<service-port>. access novnc using ip address + service port

I'm trying to host the service on a customized URL using nginx-ingress + HA proxy.

When I access novnc using the URL, it shows the message something went wrong, connection is closed. access novnc using url

I've tried the same method to host a simple webpage without issue, this issue only happens for novnc services.

These are the YAML files for the deployment:

Create namespace

apiVersion: v1
kind: Namespace
metadata:
  name: training
  labels:
    name: training

Network policy

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: training-netpol
  namespace: training
spec:
  podSelector: {}
  policyTypes:
  - Ingress
  ingress:
  - ports:
    - port: 6080
  - from:
    - namespaceSelector:
        matchLabels:
          name: training

Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: kali-deployment
  namespace: training
spec:
  selector:
    matchLabels:
      app: kali-vm
  replicas: 1
  template:
    metadata:
      labels:
        app: kali-vm
    spec:
      containers:
      - name: kali-vm
        image: josephsim/kali-novnc
        ports:
        - containerPort: 6080

Service

apiVersion: v1
kind: Service
metadata:
  name: kali-svc
  namespace: training
spec:
  type: NodePort
  selector:
    app: kali-vm
  ports:
    - protocol: TCP
      port: 6080

Ingress controller

    apiVersion: networking.k8s.io/v1beta1
    kind: Ingress
    metadata:
      name: ingress-controller
      namespace: training
    spec:
      rules:
      - host: test.kali-vm.training.com
        http:
          paths:
          - backend:
              serviceName: kali-svc
              servicePort: 6080

I have also point the IP address of HA Proxy machine to the URL using /etc/hosts file.

I'm using for this setup: https://www.youtube.com/watch?v=chwofyGr80c

I'm using bare metal kubernetes cluster. Any idea on how to make this work?


EDIT: Tried using ConfigMap, the same problem persist.

ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: tcp-services
  namespace: training
data:
  6080: "training/kali-svc:6080"
-- Joe S
kubernetes
nginx-ingress
novnc

0 Answers