Skip to content

Commit

Permalink
[KYUUBI #6806] [K8S][HELM] Headless service renders ports for enabled…
Browse files Browse the repository at this point in the history
… protocols only

# 🔍 Description
## Issue References 🔗

Headless service exposes ports for all protocols (enabled and disabled).

## Describe Your Solution 🔧

Add condition to render ports for enabled protocols only.

## Types of changes 🔖

- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Test Plan 🧪

> Note: `thrift-binary` and `rest` protocols are enabled by default

#### Behavior Without This Pull Request ⚰️
```shell
helm template kyuubi charts/kyuubi -s templates/kyuubi-headless-service.yaml
---
# Source: kyuubi/templates/kyuubi-headless-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: kyuubi-headless
  labels:
    helm.sh/chart: kyuubi-0.1.0
    app.kubernetes.io/name: kyuubi
    app.kubernetes.io/instance: kyuubi
    app.kubernetes.io/version: "1.9.2"
    app.kubernetes.io/managed-by: Helm
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: mysql
      port: 3309
      targetPort: 3309
    - name: rest
      port: 10099
      targetPort: 10099
    - name: thrift-binary
      port: 10009
      targetPort: 10009
    - name: thrift-http
      port: 10010
      targetPort: 10010
    - name: prometheus
      port: 10019
      targetPort: prometheus
  selector:
    app.kubernetes.io/name: kyuubi
    app.kubernetes.io/instance: kyuubi
```

#### Behavior With This Pull Request 🎉
```shell
helm template kyuubi charts/kyuubi -s templates/kyuubi-headless-service.yaml
---
# Source: kyuubi/templates/kyuubi-headless-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: kyuubi-headless
  labels:
    helm.sh/chart: kyuubi-0.1.0
    app.kubernetes.io/name: kyuubi
    app.kubernetes.io/instance: kyuubi
    app.kubernetes.io/version: "1.9.2"
    app.kubernetes.io/managed-by: Helm
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - name: rest
      port: 10099
      targetPort: 10099
    - name: thrift-binary
      port: 10009
      targetPort: 10009
    - name: prometheus
      port: 10019
      targetPort: prometheus
  selector:
    app.kubernetes.io/name: kyuubi
    app.kubernetes.io/instance: kyuubi
```

---

# Checklist 📝

- [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)

Closes #6806 from dnskr/headless-service-renders-enabled-protocol-ports.

Closes #6806

9d3f074 [dnskr] [K8S][HELM] Headless service renders ports for enabled protocols only

Authored-by: dnskr <[email protected]>
Signed-off-by: Kent Yao <[email protected]>
  • Loading branch information
dnskr authored and yaooqinn committed Nov 14, 2024
1 parent a4eaacd commit 2453efe
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions charts/kyuubi/templates/kyuubi-headless-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ spec:
clusterIP: None
ports:
{{- range $name, $frontend := .Values.server }}
{{- if $frontend.enabled }}
- name: {{ $name | kebabcase }}
port: {{ tpl $frontend.service.port $ }}
targetPort: {{ $frontend.port }}
{{- end }}
{{- end }}
{{- if and .Values.metrics.enabled (.Values.metrics.reporters | nospace | splitList "," | has "PROMETHEUS") }}
- name: prometheus
port: {{ .Values.metrics.prometheusPort }}
Expand Down

0 comments on commit 2453efe

Please sign in to comment.