How to use multiple docker images in a stage Gitlab CI?

Viewed 99

I need to use another image google cloud on top of this helm image because of the new gcloud update for gke

How do I add another image for those gcloud commands? because gitlab runners use different containers and the gke plugin i install doesnt get saved to the whole pipeline environment

deploy:
 stage: deploy
  image: helm:latest
  variables:
    ENVIRONMENT: staging
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
      variables:
        ENVIRONMENT: production
    - if: $CI_COMMIT_BRANCH == "staging"
      variables:
        ENVIRONMENT: staging
    - if: $CI_COMMIT_BRANCH == "new-google-auth"
      variables:
        ENVIRONMENT: staging
  environment:
    name: $ENVIRONMENT
  dependencies: 
    - authenticate
  script:
    - helm version
    - gcloud components update
    - gcloud components install gke-gcloud-auth-plugin
    - export USE_GKE_GCLOUD_AUTH_PLUGIN=True
    - export KUBECONFIG=kube.conf
    - helm upgrade $HELM_CHART_NAME ./chart --install --values=./chart/$ENVIRONMENT.yaml --namespace $KUBE_NAMESPACE
1 Answers

you can use variables in the image. look like:

deploy:
 stage: deploy
  image: $IMAGE_NAME
  variables:
    ENVIRONMENT: staging
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
      variables:
        ENVIRONMENT: production
        IMAGE_NAME: helm:latest
    - if: $CI_COMMIT_BRANCH == "staging"
      variables:
        ENVIRONMENT: staging
        IMAGE_NAME: helm:latest
    - if: $CI_COMMIT_BRANCH == "new-google-auth"
      variables:
        ENVIRONMENT: staging
        IMAGE_NAME: your-custom-image:name
  environment:
    name: $ENVIRONMENT
  dependencies: 
    - authenticate
  script:
    - helm version
Related