允许在 kubernetes 集群外连接

Allow connection outside kubernetes cluster

我的图表中有这个服务文件,如何允许 JDBC 在 kuberiq 外部连接,例如 DBeaver?我尝试配置 nodeport,但它一直失败。有人可以帮忙吗?

apiVersion: v1
    kind: Service
    metadata:
      name: {{ include "ignite.fullname" . }}
      labels:
        app: {{ include "ignite.fullname" . }}
    spec:
      ports:
        - name: jdbc
          port: 11211
          targetPort: 11211
        - name: spi-communication
          port: 47100
          targetPort: 47100
        - name: spi-discovery
          port: 47500
          targetPort: 47500
        - name: jmx
          port: 49112
          targetPort: 49112
        - name: sql
          port: 10800
          targetPort: 10800
        - name: rest
          port: 8080
          targetPort: 8080
        - name: thin-clients
          port: 10900
          targetPort: 10900
      clusterIP: None
      selector:

这是我想尝试连接的 ignite 服务,即使只是为了创建用户 $ kubectl describe svc ignite

Name:              ignite
Namespace:         production
Labels:            app=ignite
Annotations:       <none>
Selector:          app=ignite
Type:              ClusterIP
IP:                None
Port:              jdbc  11211/TCP
TargetPort:        11211/TCP
Endpoints:         10.233.112.245:11211,10.233.112.246:11211
Port:              spi-communication  47100/TCP
TargetPort:        47100/TCP
Endpoints:         10.233.112.245:47100,10.233.112.246:47100
Port:              spi-discovery  47500/TCP
TargetPort:        47500/TCP
Endpoints:         10.233.112.245:47500,10.233.112.246:47500
Port:              jmx  49112/TCP
TargetPort:        49112/TCP
Endpoints:         10.233.112.245:49112,10.233.112.246:49112
Port:              sql  10800/TCP
TargetPort:        10800/TCP
Endpoints:         10.233.112.245:10800,10.233.112.246:10800
Port:              rest  8080/TCP
TargetPort:        8080/TCP
Endpoints:         10.233.112.245:8080,10.233.112.246:8080
Port:              thin-clients  10900/TCP
TargetPort:        10900/TCP
Endpoints:         10.233.112.245:10900,10.233.112.246:10900
Session Affinity:  None
Events:            <none>

我尝试像下面这样添加节点端口,但没有保存它。怎么了?

apiVersion: v1
kind: Service
metadata:
  name: {{ include "ignite.fullname" . }}
  labels:
    app: {{ include "ignite.fullname" . }}
spec:
  ClusterIP:
  ports:
    - name: jdbc
      port: 11211
      targetPort: 11211
    - name: spi-communication
      port: 47100
      targetPort: 47100
    - name: spi-discovery
      port: 47500
      targetPort: 47500
    - name: jmx
      port: 49112
      targetPort: 49112
    - name: sql
      port: 10800
      targetPort: 10800
      nodedport: 30008
    - name: rest
      port: 8080
      targetPort: 8080
    - name: thin-clients
      port: 10900
      targetPort: 10900
  selector:
    app: {{ include "ignite.fullname" . }}
  sessionAffinity: None
  type: NodePort

总结我们对评论的讨论:

解决方案是更改 headless service to Nodeport Service

问题是编辑服务导致错误,因为某些服务的字段是不可变的(错误:Invalid value: "": field is immutable)。必须重新创建服务。

解决方案是在 helm 中使用 --force 标志。

> helm upgrade --help | grep force
--force        force resource updates through a replacement strategy