Gitlab Kubernetes集成 [英] Gitlab kubernetes integration

查看:63
本文介绍了Gitlab Kubernetes集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器上有一个自定义的kubernetes集群,公共IP和DNS指向该集群(也是通配符).按照以下指南为Gitlab配置了集群:

我尝试用k8s修补对象,就像这样

  externalIPs :(为空)-1.2.3.4externalTrafficPolicy:本地(是集群) 

我怀疑问题是空的入口(滚动到末尾)对象,然后调用:

 #kubectl获取服务入口-nginx-入口控制器-n gitlab-managed-apps -o yamlapiVersion:v1种类:服务元数据:creationTimestamp:"2019-11-20T08:57:18Z"标签:应用:nginx-ingress图表:nginx-ingress-1.22.1组件:控制器遗产:耕种机释放:入口名称:入口-nginx-入口控制器命名空间:gitlab-managed-appsresourceVersion:"3940"selfLink:/api/v1/名称空间/gitlab-managed-apps/services/ingress-nginx-ingress-controlleruid:c175afcc-0b73-11ea-91ec-5254008dd01b规格:群集IP:10.107.35.248外部IP:-1.2.3.4#(公共IP)externalTrafficPolicy:本地healthCheckNodePort:30737端口:-名称:httpnodePort:31972端口:80协议:TCPtargetPort:http-名称:httpsnodePort:31746端口:443协议:TCPtargetPort:https选择器:应用:nginx-ingress组件:控制器释放:入口sessionAffinity:无类型:LoadBalancer地位:loadBalancer:{} 

但是Gitlab仍然找不到入口端点.我尝试重新启动集群和Gitlab.Gitlab中的网络检查始终显示以下响应:

  ...名称入口安装状态status_reason为空版本1.22.1external_ip nullexternal_hostname nullupdate_available否can_uninstall否... 

有什么想法要有一个有效的Ingress端点吗?

GitLab:12.4.3(4d477238500)k8s:1.16.3-00

解决方案

我遇到了与您完全相同的问题,终于找到了解决方法.

首先要了解的是,在裸机上,如果不使用MetalLB,就无法使其工作,因为它调用了必需的Kubernetes API,从而使其接受您提供给 Service 的IP地址. LoadBalancer 类型.

因此第一步是部署MetalLB 到您的集群.

然后,您需要拥有另一台计算机,运行NGiNX或HAproxy之类的服务,或者可以进行某些负载平衡的任何机器.

最后但并非最不重要的一点是,您必须将Load Balancer机器的IP地址提供给MetalLB,以便它可以将其分配给 Service .通常,MetalLB需要一定范围的IP地址,但是您也可以像我一样提供一个IP地址:

  apiVersion:v1种类:ConfigMap元数据:命名空间:metallb-system名称:config数据:配置:|地址池:-名称:staging-public-ips协议:layer2地址:-1.2.3.4/32 

这样,MetalLB将为类型为 LoadBalancer Service 分配IP地址,Gitlab最终将找到IP地址.

警告:MetalLB仅会分配一次 IP地址.如果需要许多类型为 LoadBalancer Service ,则将需要许多运行NGiNX/HAproxy的计算机,依此类推,并将其IP地址添加到MetalLB addresses 游泳池.

为供您参考,我已将所有技术详细信息发布到我的Gitlab在这里发布.

I have a custom kubernetes cluster on a serve with public IP and DNS pointing to it (also wildcard). Gitlab was configured with the cluster following this guide: https://gitlab.touch4it.com/help/user/project/clusters/index#add-existing-kubernetes-cluster

However, after installing Ingress, the ingress endpoint is never detected:

I tried patching the object in k8s, like so

externalIPs: (was empty)
 - 1.2.3.4
externalTrafficPolicy: local (was cluster)

I suspect that the problem is empty ingress (scroll to the end) object then calling:

# kubectl get service ingress-nginx-ingress-controller -n gitlab-managed-apps -o yaml
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: "2019-11-20T08:57:18Z"
  labels:
    app: nginx-ingress
    chart: nginx-ingress-1.22.1
    component: controller
    heritage: Tiller
    release: ingress
  name: ingress-nginx-ingress-controller
  namespace: gitlab-managed-apps
  resourceVersion: "3940"
  selfLink: /api/v1/namespaces/gitlab-managed-apps/services/ingress-nginx-ingress-controller
  uid: c175afcc-0b73-11ea-91ec-5254008dd01b
spec:
  clusterIP: 10.107.35.248
  externalIPs:
  - 1.2.3.4 # (public IP)
  externalTrafficPolicy: Local
  healthCheckNodePort: 30737
  ports:
  - name: http
    nodePort: 31972
    port: 80
    protocol: TCP
    targetPort: http
  - name: https
    nodePort: 31746
    port: 443
    protocol: TCP
    targetPort: https
  selector:
    app: nginx-ingress
    component: controller
    release: ingress
  sessionAffinity: None
  type: LoadBalancer
status:
  loadBalancer: {}

But Gitlab still cant find the ingress endpoint. I tried restarting cluster and Gitlab. The network inspection in Gitlab always shows this response:

...
name    ingress
status  installed
status_reason   null
version 1.22.1
external_ip null
external_hostname   null
update_available    false
can_uninstall   false
...

Any ideas how to have a working Ingress Endpoint?

GitLab: 12.4.3 (4d477238500) k8s: 1.16.3-00

解决方案

I had the exact same issue as you, and I finally figured out how to solve it.

The first to understand, is that on bare metal, you can't make it working without using MetalLB, because it calls the required Kubernetes APIs making it accepting the IP address you give to the Service of LoadBalancer type.

So first step is to deploy MetalLB to your cluster.

Then you need to have another machine, running a service like NGiNX or HAproxy or whatever can do some load balancing.

Last but not least, you have to give the Load Balancer machine IP address to MetalLB so that it can assign it to the Service. Usually MetalLB requires a range of IP addresses, but you can also give one IP address like I did:

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: staging-public-ips
      protocol: layer2
      addresses:
      - 1.2.3.4/32

This way, MetalLB will assign the IP address to the Service with type LoadBalancer and Gitlab will finally find the IP address.

WARNING: MetalLB will assign only once an IP address. If you need many Service with type LoadBalancer, you will need many machines running NGiNX/HAproxy and so on and add its IP address in the MetalLB addresses pool.

For your information, I've posted all the technical details to my Gitlab issue here.

这篇关于Gitlab Kubernetes集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆