[Question]: Kubernetes port forwarding 3389 (RDP)
Is your question not already answered in the FAQ?
- [x] I made sure the question is not listed in the FAQ.
Is this a general question and not a technical issue?
- [x] I am sure my question is not about a technical issue.
Question
I want to run Dockurr\windows on a Kubernetes cluster.
apiVersion: apps/v1
kind: Deployment
metadata:
name: vpi-atf-deployment
labels:
name: vpi-atf
spec:
replicas: 1
selector:
matchLabels:
app: vpi-atf
template:
metadata:
labels:
app: vpi-atf
spec:
containers:
- name: vpi-atf
image: dockurr/windows
env:
- name: VERSION
value: "11"
- name: DISK_SIZE
value: "64G"
- name: USERNAME
valueFrom:
secretKeyRef:
name: vpi-atf-secret
key: vpi-atf-user
- name: PASSWORD
valueFrom:
secretKeyRef:
name: vpi-atf-secret
key: vpi-atf-password
ports:
- containerPort: 8006
name: http
protocol: TCP
- containerPort: 3389
name: rdp-tcp
protocol: TCP
- containerPort: 3389
name: rdp-udp
protocol: UDP
- containerPort: 5900
name: vnc
protocol: UDP
- containerPort: 5985
name: winrm
protocol: TCP
securityContext:
capabilities:
add:
- NET_ADMIN
privileged: true
volumeMounts:
- mountPath: /storage
name: storage
- mountPath: /dev/kvm
name: dev-kvm
- mountPath: /dev/net/tun
name: dev-tun
- mountPath: /oem
name: vpi-atf-install-bat-file-volume
terminationGracePeriodSeconds: 120
volumes:
- name: storage
persistentVolumeClaim:
claimName: vpi-atf-pvc
- hostPath:
path: /dev/kvm
name: dev-kvm
- hostPath:
path: /dev/net/tun
type: CharDevice
name: dev-tun
- name: vpi-atf-install-bat-file-volume
configMap:
name: vpi-atf-install-bat-file
---
apiVersion: v1
kind: Service
metadata:
name: vpi-atf-service
spec:
internalTrafficPolicy: Cluster
ports:
- name: http
port: 8006
protocol: TCP
targetPort: 8006
- name: rdp
port: 3389
protocol: TCP
targetPort: 3389
- name: udp
port: 3389
protocol: UDP
targetPort: 3389
- name: vnc
port: 5900
protocol: TCP
targetPort: 5900
- name: winrm
port: 5985
protocol: TCP
targetPort: 5985
selector:
app: vpi-atf
type: ClusterIP
Windows is correctly installed and up and running the cluster and with port forwarding (kubectl poport-forward <pod_name> 8006:8006) I can easily open the Windows UI in browser (localhost:8006).
There is an issue when trying to establish a RDP connection via port 3389. First port forwarding is done via kubectl poport-forward <pod_name> 3390:3389. Connecting to localhost:3390 (via Remote Desktop Connection on Windows local machine) results in:
What is the reason that it is not possible to establish the RDP connection? My assumption (which is maybe not correct) is that port forwarding of port 8006 works in the same way is any other port.
Got the same issue. The command for the port-forward is correct (using it with kubevirt works for example), but it does not work with this container, giving the following error:
Port-forwarding: 3389 -> 3389 on pod windows-7c758c4d9c-tdgls
Forwarding from 127.0.0.1:3389 -> 3389
Forwarding from [::1]:3389 -> 3389
Handling connection for 3389
E0524 04:31:32.536019 26517 portforward.go:424] "Unhandled Error" err="an error occurred forwarding 3389 -> 3389: error forwarding port 3389 to pod f027db42804673b7348323faa1b8000f8e47e77a8f9ea8fdb19c15c73e1ac547, uid : failed to execute portforward in network namespace \"/var/run/netns/cni-4860fddc-6139-f9b0-52ff-cf7799ffc0e3\": failed to connect to localhost:3389 inside namespace \"f027db42804673b7348323faa1b8000f8e47e77a8f9ea8fdb19c15c73e1ac547\", IPv4: dial tcp4 127.0.0.1:3389: connect: connection refused IPv6 dial tcp6: address localhost: no suitable address found "
error: lost connection to pod
The connection is refused, which usually happens when RDP is not ready or not listening yet.