apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-dep-secret
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx-secret
  template:
    metadata:
      labels:
        app: nginx-secret
    spec:
      containers:
      - name: nginx-pod-secret
        image: shahanawaj/nginx
        ports:
        - name: ng-secret-port
          containerPort: 80
        env:  #set env variable
        - name: mysecret  # name of variable to set
          valueFrom:  # need value for this variable
            secretKeyRef:  # we are taking value from secrte
              name: secretvin # secret name to fetch value from 
              key: username.txt  # field from secrte like username or password or db_name or java_home path
        - name: mysecretpass
          valueFrom:
            secretKeyRef:
              name: secretvin
              key: password.txt
      imagePullSecrets:
      - name: dockersecret
