How to run GUI software in K8S pod?

Viewed 49

I'm trying to run xclock inside the K8S pod after connecting to it via MobarXterm tool, but I've been unsuccessful, so please tell me how to run a GUI software like xclock inside the K8S pod.

I write a matlab-deployment.yaml , the content is :

apiVersion: v1
kind: Service
metadata:
  name: matlab
spec:
  type: NodePort
  ports:
  - nodePort: 30005
    port: 2222
    protocol: TCP
    targetPort: 22
    name: ssh
  selector:
    app: matlab
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: matlab-deployment
spec:
  selector:
    matchLabels:
      app: matlab
  replicas: 1
  template:
    metadata:
      labels:
        app: matlab
    spec:
      containers:
      - name: matlab
        image: docker-harvor/train/matlab
        env:
        - name: DISPLAY
          value: ":0.0"
        ports:
        - name: ssh
          containerPort: 22
        volumeMounts:
        - name: x-11
          mountPath: "/tmp/.X11-unix"
        - name: localtime
          mountPath: "/etc/localtime"
      volumes:
      - name: x-11
        hostPath:
          path: "/tmp/.X11-unix"
          type: Directory
      - name: localtime
        hostPath:
          path: "/etc/localtime"
          type: File

Then I use command:

kubectl apply -f matlab-deployment.yaml

And I use command into a pod:

kubectl exec -it matlab-deployment-698fff79dc-d92jc /bin/bash

When I run xclock inside the pod, there is no graphical display of:

enter image description here

This image docker-harvor/train/matlab itself comes with a graphical interface

If I want to run xclock inside a pod with a graphical interface, what do I need to change

0 Answers
Related