Kubernetes:Haproxy ingress不接受任何地址

o4tp2gmn  于 2023-08-03  发布在  Kubernetes
关注(0)|答案(2)|浏览(113)

Kubernetes v1.25.9+rke2r1。我有一个Metallb正确设置与外部ip地址和haproxy入口控制器。我需要通过inge公开一个croachdb示例,我在crdb示例中正确设置了该配置,inge也正确启动了。但是没有任何IP地址。因此,当我单击时,页面会进入超时,如果我telnet端口,它也会进入超时。

k get ingress -A
NAMESPACE              NAME              CLASS     HOSTS                                                     ADDRESS   PORTS   AGE
cockroachdb-instance   sql-cockroachdb   haproxy   cockroachdb.dev-service-stage.k8s.mi1.prod.cloudfire.it             80      15m

字符串
从haproxy pod日志中,我没有看到任何错误,据我所知,入口和相应的服务设置正确。为了进一步调试或修复这个问题,我可以做些什么?

k describe ingress sql-cockroachdb -n cockroachdb-instance
Name:             sql-cockroachdb
Labels:           app.kubernetes.io/component=database
                  app.kubernetes.io/instance=cockroachdb
                  app.kubernetes.io/managed-by=cockroach-operator
                  app.kubernetes.io/name=cockroachdb
                  app.kubernetes.io/part-of=cockroachdb
                  app.kubernetes.io/version=v23.1.4
                  crdb=test
Namespace:        cockroachdb-instance
Address:          
Ingress Class:    haproxy
Default backend:  <default>
Rules:
  Host                                                     Path  Backends
  ----                                                     ----  --------
  cockroachdb.dev-service-stage.k8s.mi1.prod.cloudfire.it  
                                                              cockroachdb-public:sql (10.222.19.88:26257,10.222.196.89:26257,10.222.30.93:26257)
Annotations:                                               crdb.io/last-applied:
                                                             UEsDBBQACAAIAAAAAAAAAAAAAAAAAAAAAAAIAAAAb3JpZ2luYWyMk0GT0zAMhf+LzrG3pbvQ5ki5cIEZYLgwHGRbaTxxbK+sFDqd/HfGbelsoYe9aZSn7+kpyRFGEnQoCO0RAhoKpV...
                                                           field.cattle.io/publicEndpoints:
                                                             [{"addresses":[""],"port":80,"protocol":"HTTP","serviceName":"cockroachdb-instance:cockroachdb-public","ingressName":"cockroachdb-instance...
Events:
  Type    Reason  Age                From                Message
  ----    ------  ----               ----                -------
  Normal  CREATE  28m                ingress-controller  Ingress cockroachdb-instance/sql-cockroachdb
  Normal  CREATE  28m                ingress-controller  Ingress cockroachdb-instance/sql-cockroachdb
  Normal  UPDATE  27m (x2 over 27m)  ingress-controller  Ingress cockroachdb-instance/sql-cockroachdb
  Normal  UPDATE  27m (x2 over 27m)  ingress-controller  Ingress cockroachdb-instance/sql-cockroachdb


如果我尝试端口转发处理cocroachdb的服务,我会得到这个错误:

E0711 09:59:38.779413   43555 portforward.go:409] an error occurred forwarding 8081 -> 26258: error forwarding port 26258 to pod 8a774d302b846fdbdd7bbc6b3f35144d9712f15de9ab72d4ef9e0c8cdfa8ee85, uid : failed to execute portforward in network namespace "/var/run/netns/cni-f1c36dc8-3647-e00e-b67e-7abb019b236b": read tcp4 127.0.0.1:33424->127.0.0.1:26258: read: connection reset by peer


这是一种:CrdbCluster -通过kubectl apply使用所有默认值来安装蟑螂数据库。

apiVersion: crdb.cockroachlabs.com/v1alpha1
kind: CrdbCluster
metadata:
  # this translates to the name of the statefulset that is created
  name: cockroachdb
spec:
  dataStore:
    pvc:
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: "20Gi"
        volumeMode: Filesystem
  resources:
    requests:
      # This is intentionally low to make it work on local k3d clusters.
      cpu: 500m
      memory: 2Gi
    limits:
      cpu: 2
      memory: 4Gi
  tlsEnabled: true
   ingress:
    #ui:
    #  ingressClassName: haproxy
    #  annotations:
    #    key: value
    #  host: cockroachdb.dev-service-stage.k8s.mi1.prod.cloudfire.it
    sql:
      ingressClassName: haproxy
      annotations:
        #key: value
      host: cockroachdb.dev-service-stage.k8s.mi1.prod.cloudfire.it
# You can set either a version of the db or a specific image name
# cockroachDBVersion: v23.1.4
  image:
    name: cockroachdb/cockroach:v23.1.4
  # nodes refers to the number of crdb pods that are created
  # via the statefulset
  nodes: 3
  additionalLabels:
    crdb: test

2vuwiymt

2vuwiymt1#

入口列表中缺少IP是因为您遇到了关于端口转发服务的错误。
您出现该错误并拒绝连接的原因是,在您转发的端口(26258)上没有进程侦听,这可能与以下任何一种情况有关:

  • 您没有将默认的数据库端口更改为要转发的端口(26258)
  • 从Dockerfile中,您将暴露端口26258,即使您的DB仍在默认端口26257上
1qczuiv0

1qczuiv02#

问题出在metallb和自定义资源上
在将此添加到清单时,所有内容都已成功配置:

apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: advertisement
  namespace: metallb
spec:
  ipaddresspools:
  - first-pool

字符串

相关问题