[英]Deploying to Kubernetes cluster using runner from GitLab
I've integrated GitLab with my Digital Ocean Kubernetes cluster.我已经将 GitLab 与我的 Digital Ocean Kubernetes 集群集成在一起。 I am trying to set up a simple manual build that will deploy to my Kubernetes cluster.
我正在尝试设置一个简单的手动构建,它将部署到我的 Kubernetes 集群。
My gitlab-ci-yml file details are below:我的 gitlab-ci-yml 文件详细信息如下:
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"
来自服务器的错误(禁止):从服务器检索当前配置时出错......从服务器:“web.yaml”:ingresses.extensions“hmweb-ingress”被禁止:用户“system:serviceaccount:gitlab-managed-apps:default”无法在命名空间“hm-ns01”中的 API 组“扩展”中获取资源“入口”
As far as I can understand it cannot execute the kubectl apply.. commands据我了解,它无法执行 kubectl apply.. 命令
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.至少这为我解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.