简体   繁体   中英

Deploying to Kubernetes cluster using runner from GitLab

I've integrated GitLab with my Digital Ocean Kubernetes cluster. I am trying to set up a simple manual build that will deploy to my Kubernetes cluster.

My gitlab-ci-yml file details are below:

deploy:
  stage: deploy
  image: bitnami/kubectl:latest
  script:
    - kubectl version
    - kubectl apply -f web.yaml

I am not sure why this is not working. Currently getting the following error:

Error from server (Forbidden): error when retrieving current configuration... from server for: "web.yaml": ingresses.extensions "hmweb-ingress" is forbidden: User "system:serviceaccount:gitlab-managed-apps:default" cannot get resource "ingresses" in API group "extensions" in the namespace "hm-ns01"

As far as I can understand it cannot execute the kubectl apply.. commands

Am I doing something wrong?

I think you are missing the environment in your deploy job. Modify your job definition to look something like this:

deploy:
  stage: deploy
  image: bitnami/kubectl:latest
  environment:
    name: production
  script:
    - kubectl version
    - kubectl apply -f web.yaml

Where "production" is interchangable with any environment name.

At least that fixed the issue for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM