title: Kubernetes warning for clashes while using env variable in docker? why?
body: <p>We're using Gitlab for CI/CD. I'll include the script which we're using
  <strong>gitlab ci-cd file</strong></p>
  <pre><code>   services:
    - docker:19.03.11-dind
  before_script:
    - apk update &amp;&amp; apk add bash
    - apk update &amp;&amp; apk add gettext  
  workflow:
    rules:
      - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == &quot;developer&quot; || $CI_COMMIT_BRANCH == &quot;stage&quot;|| ($CI_COMMIT_BRANCH =~ (/^([A-Z]([0-9][-_])?)?SPRINT(([-_][A-Z][0-9])?)+/i))
        when: always
      - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH != &quot;developer&quot; || $CI_COMMIT_BRANCH != &quot;stage&quot;|| ($CI_COMMIT_BRANCH !~ (/^([A-Z]([0-9][-_])?)?SPRINT(([-_][A-Z][0-9])?)+/i))
        when: never 
  stages:
    - build
    - Publish
    - deploy
  cache:
    paths:
      - .m2/repository
      - target
  
  build_jar:
    image: maven:3.8.3-jdk-11
    stage: build
    script: 
      - mvn clean install package -DskipTests=true
    artifacts:
      paths:
        - target/*.jar
  
  docker_build_dev:
    stage: Publish
    image: docker:19.03.11
    services:
      - docker:19.03.11-dind      
    variables:
      IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
    script: 
      - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
      - docker build -t $IMAGE_TAG .
      - docker push $IMAGE_TAG
    only:
      - /^([A-Z]([0-9][-_])?)?SPRINT(([-_][A-Z][0-9])?)+/i
      - developer
  
  docker_build_stage:
    stage: Publish
    image: docker:19.03.11
    services:
      - docker:19.03.11-dind   
    variables:
      IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
    script: 
      - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
      - docker build -t $IMAGE_TAG .
      - docker push $IMAGE_TAG   
    only:
      - stage
  
  deploy_dev:
    stage: deploy
    image: stellacenter/aws-helm-kubectl
    variables:
      ENV_VAR_NAME: development
    before_script:
      - aws configure set aws_access_key_id ${DEV_AWS_ACCESS_KEY_ID}
      - aws configure set aws_secret_access_key ${DEV_AWS_SECRET_ACCESS_KEY}
      - aws configure set region ${DEV_AWS_DEFAULT_REGION}
    script:
      - sed -i &quot;s/&lt;VERSION&gt;/${CI_COMMIT_SHORT_SHA}/g&quot; patient-service.yml     
      - mkdir -p  $HOME/.kube
      - cp $KUBE_CONFIG_DEV $HOME/.kube/config
      - chown $(id -u):$(id -g) $HOME/.kube/config 
      - export KUBECONFIG=$HOME/.kube/config
      - cat patient-service.yml | envsubst | kubectl apply -f patient-service.yml -n ${KUBE_NAMESPACE_DEV}
    only:
      - /^([A-Z]([0-9][-_])?)?SPRINT(([-_][A-Z][0-9])?)+/i
      - developer
  
  deploy_stage:
    stage: deploy
    image: stellacenter/aws-helm-kubectl
    variables:
      ENV_VAR_NAME: stage
    before_script:
      - aws configure set aws_access_key_id ${DEV_AWS_ACCESS_KEY_ID}
      - aws configure set aws_secret_access_key ${DEV_AWS_SECRET_ACCESS_KEY}
      - aws configure set region ${DEV_AWS_DEFAULT_REGION}
    script:
      - sed -i &quot;s/&lt;VERSION&gt;/${CI_COMMIT_SHORT_SHA}/g&quot; patient-service.yml    
      - mkdir -p  $HOME/.kube
      - cp $KUBE_CONFIG_STAGE $HOME/.kube/config
      - chown $(id -u):$(id -g) $HOME/.kube/config 
      - export KUBECONFIG=$HOME/.kube/config
      - cat patient-service.yml | envsubst | kubectl apply -f patient-service.yml -n ${KUBE_NAMESPACE_STAGE}
    only:
      - stage
  </code></pre>
  <p>According to the script, we just merged the script not to face conflicts/clashes for stage and development while deployment. Previously, we having each docker files for each environment(stage and developer). Now I want to merge the dockerfile also, I merged, but the dockerfile is not fetching. Having clashes (warning shows after pipeline succeeds) in Kubernetes. I don't know how to clear the warning in Kubernetes. I'll enclose the docker file which I merged.</p>
  <pre><code>FROM maven:3.8.3-jdk-11 AS MAVEN_BUILD
  COPY pom.xml /build/
  COPY src /build/src/
  WORKDIR /build/
  RUN mvn clean install package -DskipTests=true
  FROM openjdk:11
  ARG environment_name 
  WORKDIR /app
  COPY --from=MAVEN_BUILD /build/target/patient-service-*.jar /app/patient-service.jar
  ENV PORT 8094
  ENV env_var_name=$environment_name
  EXPOSE $PORT
  ENTRYPOINT [&quot;java&quot;,&quot;-Dspring.profiles.active= $env_var_name&quot;,&quot;-jar&quot;,&quot;/app/patient-service.jar&quot;]
  </code></pre>
  <p>the last line, we used before,</p>
  <pre><code>ENTRYPOINT [&quot;java&quot;,&quot;-Dspring.profiles.active=development&quot;,&quot;-jar&quot;,&quot;/app/patient-service.jar&quot;] -for developer dockerfile
  ENTRYPOINT [&quot;java&quot;,&quot;-Dspring.profiles.active=stage&quot;,&quot;-jar&quot;,&quot;/app/patient-service.jar&quot;] - for stage dockerfile 
  </code></pre>
  <p>At the time, its working fine, I'm not facing any issue on Kubernetes. I'd just add  environment variable to fetch along with whether development or stage. You can check ,my script after the docker build. After adding the variable only, we began facing the clashes. Please help me to sort this out. Thanks in advance.</p>
  <p><strong>Yaml file</strong></p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: patient-app
    labels:
      app: patient-app
  spec:
    replicas: 1
    selector:
      matchLabels:
        app : patient-app
    template:
      metadata:
        labels:
          app: patient-app
      spec:
        containers:
        - name: patient-app
          image: registry.gitlab.com/stella-center/backend-services/patient-service:&lt;VERSION&gt;
          imagePullPolicy: Always
          ports:
            - containerPort: 8094
        imagePullSecrets:
          - name:  gitlab-registry-token-auth
  
  ---
  
  apiVersion: v1
  kind: Service
  metadata:
    name:  patient-service
  spec:
    type: NodePort
    selector:
      app:  patient-app
    ports:
    - port:  8094
      targetPort:  8094
  </code></pre>