How to add password to yaml file

Hi,

Im new to docker and kubernetes,

Im trying to build my own helm chart applications en one of those applications is VNC application. Im using deployment.yaml file as shown down beow. This works great, now Im trying to pass a username and a password to remote the VNC, does someone know to get this done?

apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: vnc
name: vnc
spec:
replicas: 1
selector:
matchLabels:
app: vnc
template:
metadata:
labels:
app: vnc
spec:
containers:
- VNC_PASSWORD=mypassword
- name: “vnc”
image: dorowu/ubuntu-desktop-lxde-vnc
ports:
- containerPort: 5901

Like this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: vnc
  labels:
    app: vnc
spec:
  replicas: 1
  selector:
    matchLabels:
      app: vnc
  template:
      metadata:
        labels:
          app: vnc
      spec:
        containers:
        - name: vnc
          image: dorowu/ubuntu-desktop-lxde-vnc
          env:
          - name: VNC_PASSWORD
            value: "mypassword"
          ports:
          - containerPort: 5901

Though, typicaly people use secrets to pass credentials into the deployment, see: https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-environment-variables

1 Like

It works, thank you!