Gitlab CI can't deploy to GKE cluster

1/23/2020

I have added my existing GKE cluster to Gitlab manually. As shown below, it shows me that the cluster have been added to Gitlab successfully.

enter image description here

However if I try to test the connection out of my Gitlab CI pipeline, the responsible environment variables which should be populated automatically are empty.

Please find below the job description of my Gitlab CI pipeline

deploy:
  image: bitnami/kubectl
  stage: deploy
  script:
    - kubectl config set-cluster k8s --server="$KUBE_URL" --insecure-skip-tls-verify=true
    - kubectl config set-credentials admin --token="$KUBE_TOKEN"
    - kubectl config set-context default --cluster=k8s --user=admin
    - kubectl config use-context default
    - kubectl get ns

How is it possible that the mentioned variables are populated with the values added through the cluster integration? Is there a better way to deploy applications to a GKE (beside the Auto DevOps option)?

-- supercoast
gitlab
gitlab-ci
google-kubernetes-engine
kubernetes

0 Answers