apache / apache/apisix-helm-chart

feature req: support explicit nodePort with LoadBalancer service type

Open
#912 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go Template
Stars
289
Forks
282
Avg merge
15h 55m
Merged PRs (30d)
3

Description

The APISIX Helm chart only applies `nodePort` when `service.type` is `NodePort`, but ignores it for `LoadBalancer` type.
This creates deployment challenges for cloud providers (OCI, etc.) that require pre-defined node ports for security group/firewall rules.

## Current Behavior

In `templates/service-gateway.yaml` (lines 55-57, 68-71):

```yaml
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.http.nodePort))) }}
nodePort: {{ .Values.service.http.nodePort }}
{{- end }}
```

**Problem:** `nodePort` is **only** applied when `type: NodePort`, making it impossible to have both a cloud LoadBalancer AND a fixed nodePort.

## Expected Behavior (ingress-nginx 'pattern'?)

The **ingress-nginx** chart correctly handles this by checking if the service type is either `NodePort` OR `LoadBalancer`:

```yaml
{{- $setNodePorts := (or (eq .Values.controller.service.type "NodePort") (eq .Values.controller.service.type "LoadBalancer")) }}
{{- if .Values.controller.service.enableHttps }}
- name: https
port: {{ .Values.controller.service.ports.https }}
protocol: TCP
targetPort: {{ .Values.controller.service.targetPorts.https }}
{{- if (and $setNodePorts (not (empty .Values.controller.service.nodePorts.https))) }}
nodePort: {{ .Values.controller.service.nodePorts.https }}
{{- end }}
{{- end }}
```

**Key difference:** `$setNodePorts := (or (eq ... "NodePort") (eq ... "LoadBalancer"))`; nodePorts are applied for **both** service types.

## Working Example (ingress-nginx) [ingress-nginx service template](https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/templates/controller-service.yaml#L87)

```yaml
controller:
service:
type: LoadBalancer
loadBalancerIP: "1.2.3.4"
nodePorts:
https: "30443" # this works and creates nodePort: 30443
```

**Result:** LoadBalancer service with **fixed nodePort 30443**.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in templates/service-gateway.yaml around lines 55-57 and 68-71, and compare its service-type condition with the linked ingress-nginx pattern. Done means the configured nodePort values are rendered for both NodePort and LoadBalancer services while remaining absent for other service types.

Written by the indexing model from the issue text.

Assessment

Tech stack
helm, kubernetes
Domain
devops, infrastructure
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.