NoamiA
NoamiA

Reputation: 567

Allow connection outside kubernetes cluster

I have this service file in my chart, how can I allow JDBC connection outside kuberiq for example DBeaver? I tried to configure nodeport, but it keeps failing. Can someone assist here?

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:

This is the ignite services I want to try to connect even just to create user $ 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>

I tried to add nodeport like below, but it's not saving it. What is wrong?

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

Upvotes: 2

Views: 339

Answers (1)

Matt
Matt

Reputation: 8162

To summarize our discussion on comments:

The solution was to change headless service to Nodeport Service.

The problem was that edit of a service resulted in error because some service's fields are immutable (error: Invalid value: "": field is immutable). Service had to be recreated.

The solution was to use --force flag with helm.

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

Upvotes: 1

Related Questions