Kind: Secret - timowang1991/kubernetes-docs GitHub Wiki

Secret as a yaml file

  • Create secret file
apiVersion: v1
kind: Secret
metadata:
  name: mysecret
type: Opaque
data:
  USER_NAME: YWRtaW4=
  PASSWORD: MWYyZDFlMmU2N2Rm
  • Execute
kubectl apply -f mysecret.yaml
  • Use the secret
apiVersion: v1
kind: Pod
metadata:
  name: secret-test-pod
spec:
  containers:
    - name: test-container
      image: k8s.gcr.io/busybox
      command: [ "/bin/sh", "-c", "env" ]
      envFrom:
      - secretRef:
          name: mysecret
  restartPolicy: Never



Secret from imperative command

kubectl create secret generic pgpassword --from-literal PGPASSWORD=password123
kubectl get secrets



Github Action that turns env file to k8s secret

⚠️ **GitHub.com Fallback** ⚠️