From b346bc3d68134acc4dfe314e16d3f2638715d6c8 Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Sun, 3 Nov 2024 14:36:30 +0200 Subject: [PATCH] deployment/helm,config/crd: remove unnecessary hostPort value. Since it's now uneccessary to expose our custom metrics port on the host side, remove the required and dedicated hostPort Helm value. Add instead an optional generic 'ports' array to allow exposing arbitrary ports to the host. Similarly remove hostPort from the nriplugindeployments CRD. Signed-off-by: Krisztian Litkey --- .../config.nri_nriplugindeployments.yaml | 2 -- deployment/helm/balloons/README.md | 2 +- .../helm/balloons/templates/daemonset.yaml | 13 ++++++--- deployment/helm/balloons/values.schema.json | 29 ++++++++++++++++--- deployment/helm/balloons/values.yaml | 12 ++++++-- deployment/helm/template/README.md | 2 +- .../helm/template/templates/daemonset.yaml | 13 ++++++--- deployment/helm/template/values.schema.json | 29 ++++++++++++++++--- deployment/helm/template/values.yaml | 12 ++++++-- deployment/helm/topology-aware/README.md | 2 +- .../topology-aware/templates/daemonset.yaml | 13 ++++++--- .../helm/topology-aware/values.schema.json | 29 ++++++++++++++++--- deployment/helm/topology-aware/values.yaml | 12 ++++++-- 13 files changed, 135 insertions(+), 35 deletions(-) diff --git a/config/crd/bases/config.nri_nriplugindeployments.yaml b/config/crd/bases/config.nri_nriplugindeployments.yaml index b2f178ac4..abaf54033 100644 --- a/config/crd/bases/config.nri_nriplugindeployments.yaml +++ b/config/crd/bases/config.nri_nriplugindeployments.yaml @@ -66,8 +66,6 @@ spec: type: string description: Define which Nodes the Pods are scheduled on. type: object - hostPort: - type: integer nri: type: object properties: diff --git a/deployment/helm/balloons/README.md b/deployment/helm/balloons/README.md index 95fb5b1e2..8a2b4d7bc 100644 --- a/deployment/helm/balloons/README.md +++ b/deployment/helm/balloons/README.md @@ -99,7 +99,6 @@ customize with their own values, along with the default values. | `resources.cpu` | 500m | cpu resources for the Pod | | `resources.memory` | 512Mi | memory qouta for the Pod | | `extraEnv` | {} | extra environment variables to inject (string map) | -| `hostPort` | 8891 | metrics port to expose on the host | | `config` | see [helm chart values](tree:/deployment/helm/balloons/values.yaml) for the default configuration | plugin configuration data | | `configGroupLabel` | config.nri/group | node label for grouping configuration | | `nri.runtime.config.pluginRegistrationTimeout` | "" | set NRI plugin registration timeout in NRI config of containerd or CRI-O | @@ -114,3 +113,4 @@ customize with their own values, along with the default values. | `affinity` | [] | specify node affinity | | `nodeSelector` | [] | specify node selector labels | | `podPriorityClassNodeCritical` | true | enable [marking Pod as node critical](https://kubernetes.io/docs/tasks/administer-cluster/guaranteed-scheduling-critical-addon-pods/#marking-pod-as-critical) | +| `ports` | [] | extra ports to expose to the host | diff --git a/deployment/helm/balloons/templates/daemonset.yaml b/deployment/helm/balloons/templates/daemonset.yaml index fb4fdff34..7a60a59bc 100644 --- a/deployment/helm/balloons/templates/daemonset.yaml +++ b/deployment/helm/balloons/templates/daemonset.yaml @@ -75,11 +75,16 @@ spec: - --config-group-label - {{ .Values.configGroupLabel }} {{- end }} + {{- if (ne .Values.ports nil) }} ports: - - containerPort: 8891 - protocol: TCP - hostPort: {{ .Values.hostPort }} - name: metrics + {{- range $port := .Values.ports }} + - name: {{ $port.name }} + containerPort: {{ $port.container }} + {{- if (ne $port.host nil) }} + hostPort: {{ $port.host }} + {{- end }} + {{- end }} + {{- end }} env: - name: NODE_NAME valueFrom: diff --git a/deployment/helm/balloons/values.schema.json b/deployment/helm/balloons/values.schema.json index f2a0e68b6..1c8cf151b 100644 --- a/deployment/helm/balloons/values.schema.json +++ b/deployment/helm/balloons/values.schema.json @@ -2,7 +2,6 @@ "$schema": "http://json-schema.org/schema#", "required": [ "image", - "hostPort", "resources" ], "properties": { @@ -114,11 +113,33 @@ } } }, - "hostPort": { - "type": "integer" - }, "podPriorityClassNodeCritical": { "type": "boolean" + }, + "ports": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "container" + ], + "properties": { + "name": { + "type": "string" + }, + "container": { + "type": "integer", + "minimum": 1, + "maximum": 65535 + }, + "host": { + "type": "integer", + "minimum": 1, + "maximum": 65535 + } + } + } } } } diff --git a/deployment/helm/balloons/values.yaml b/deployment/helm/balloons/values.yaml index 54465b3f8..93da0508e 100644 --- a/deployment/helm/balloons/values.yaml +++ b/deployment/helm/balloons/values.yaml @@ -56,8 +56,6 @@ config: plugin-test: enableAPIs: false -hostPort: 8891 - resources: cpu: 500m memory: 512Mi @@ -117,3 +115,13 @@ nodeSelector: [] # autoscaling enough new nodes are brought up to leave room for the # plugin on each new node. podPriorityClassNodeCritical: true + +# extra ports to expose, and optionally to the host too +#ports: [] +# +# Example +# +# ports: +# - name: lunch +# container: 61453 +# #host: 61453 # if you want to expose this as a host-port, too diff --git a/deployment/helm/template/README.md b/deployment/helm/template/README.md index a70ab04ac..ad4607b98 100644 --- a/deployment/helm/template/README.md +++ b/deployment/helm/template/README.md @@ -99,7 +99,6 @@ customize with their own values, along with the default values. | `resources.cpu` | 500m | cpu resources for the Pod | | `resources.memory` | 512Mi | memory qouta for the Pod | | `extraEnv` | {} | extra environment variables to inject (string map) | -| `hostPort` | 8891 | metrics port to expose on the host | | `config` | see [helm chart values](tree:/deployment/helm/template/values.yaml) for the default configuration | plugin configuration data | | `configGroupLabel` | config.nri/group | node label for grouping configuration | | `nri.runtime.config.pluginRegistrationTimeout` | "" | set NRI plugin registration timeout in NRI config of containerd or CRI-O | @@ -112,3 +111,4 @@ customize with their own values, along with the default values. | `initImage.pullPolicy` | Always | init container image pull policy | | `tolerations` | [] | specify taint toleration key, operator and effect | | `podPriorityClassNodeCritical` | true | enable [marking Pod as node critical](https://kubernetes.io/docs/tasks/administer-cluster/guaranteed-scheduling-critical-addon-pods/#marking-pod-as-critical) | +| `ports` | [] | extra ports to expose to the host | diff --git a/deployment/helm/template/templates/daemonset.yaml b/deployment/helm/template/templates/daemonset.yaml index 3d8a6d628..626ba2837 100644 --- a/deployment/helm/template/templates/daemonset.yaml +++ b/deployment/helm/template/templates/daemonset.yaml @@ -68,11 +68,16 @@ spec: - --config-group-label - {{ .Values.configGroupLabel }} {{- end }} + {{- if (ne .Values.ports nil) }} ports: - - containerPort: 8891 - protocol: TCP - hostPort: {{ .Values.hostPort }} - name: metrics + {{- range $port := .Values.ports }} + - name: {{ $port.name }} + containerPort: {{ $port.container }} + {{- if (ne .Values.ports.host nil) }} + hostPort: {{ $port.host }} + {{- end }} + {{- end }} + {{- end }} env: - name: NODE_NAME valueFrom: diff --git a/deployment/helm/template/values.schema.json b/deployment/helm/template/values.schema.json index f2a0e68b6..1c8cf151b 100644 --- a/deployment/helm/template/values.schema.json +++ b/deployment/helm/template/values.schema.json @@ -2,7 +2,6 @@ "$schema": "http://json-schema.org/schema#", "required": [ "image", - "hostPort", "resources" ], "properties": { @@ -114,11 +113,33 @@ } } }, - "hostPort": { - "type": "integer" - }, "podPriorityClassNodeCritical": { "type": "boolean" + }, + "ports": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "container" + ], + "properties": { + "name": { + "type": "string" + }, + "container": { + "type": "integer", + "minimum": 1, + "maximum": 65535 + }, + "host": { + "type": "integer", + "minimum": 1, + "maximum": 65535 + } + } + } } } } diff --git a/deployment/helm/template/values.yaml b/deployment/helm/template/values.yaml index 321d46a5e..afb3e14d2 100644 --- a/deployment/helm/template/values.yaml +++ b/deployment/helm/template/values.yaml @@ -31,8 +31,6 @@ config: plugin-test: enableAPIs: false -hostPort: 8891 - resources: cpu: 500m memory: 512Mi @@ -71,3 +69,13 @@ tolerations: [] # autoscaling enough new nodes are brought up to leave room for the # plugin on each new node. podPriorityClassNodeCritical: true + +# extra ports to expose, and optionally to the host too +#ports: [] +# +# Example +# +# ports: +# - name: lunch +# container: 61453 +# #host: 61453 # if you want to expose this as a host-port, too diff --git a/deployment/helm/topology-aware/README.md b/deployment/helm/topology-aware/README.md index 41df43705..17eb13243 100644 --- a/deployment/helm/topology-aware/README.md +++ b/deployment/helm/topology-aware/README.md @@ -100,7 +100,6 @@ customize with their own values, along with the default values. | `resources.cpu` | 500m | cpu resources for the Pod | | `resources.memory` | 512Mi | memory qouta for the Pod | | `extraEnv` | {} | extra environment variables to inject (string map) | -| `hostPort` | 8891 | metrics port to expose on the host | | `config` | see [helm chart values](tree:/deployment/helm/topology-aware/values.yaml) for the default configuration | plugin configuration data | | `configGroupLabel` | config.nri/group | node label for grouping configuration | | `nri.runtime.config.pluginRegistrationTimeout` | "" | set NRI plugin registration timeout in NRI config of containerd or CRI-O | @@ -115,3 +114,4 @@ customize with their own values, along with the default values. | `affinity` | [] | specify node affinity | | `nodeSelector` | [] | specify node selector labels | | `podPriorityClassNodeCritical` | true | enable [marking Pod as node critical](https://kubernetes.io/docs/tasks/administer-cluster/guaranteed-scheduling-critical-addon-pods/#marking-pod-as-critical) | +| `ports` | [] | extra ports to expose to the host | diff --git a/deployment/helm/topology-aware/templates/daemonset.yaml b/deployment/helm/topology-aware/templates/daemonset.yaml index b012026b8..d9cffa393 100644 --- a/deployment/helm/topology-aware/templates/daemonset.yaml +++ b/deployment/helm/topology-aware/templates/daemonset.yaml @@ -75,11 +75,16 @@ spec: - --config-group-label - {{ .Values.configGroupLabel }} {{- end }} + {{- if (ne .Values.ports nil) }} ports: - - containerPort: 8891 - protocol: TCP - hostPort: {{ .Values.hostPort }} - name: metrics + {{- range $port := .Values.ports }} + - name: {{ $port.name }} + containerPort: {{ $port.container }} + {{- if (ne $port.host nil) }} + hostPort: {{ $port.host }} + {{- end }} + {{- end }} + {{- end }} env: - name: NODE_NAME valueFrom: diff --git a/deployment/helm/topology-aware/values.schema.json b/deployment/helm/topology-aware/values.schema.json index f2a0e68b6..1c8cf151b 100644 --- a/deployment/helm/topology-aware/values.schema.json +++ b/deployment/helm/topology-aware/values.schema.json @@ -2,7 +2,6 @@ "$schema": "http://json-schema.org/schema#", "required": [ "image", - "hostPort", "resources" ], "properties": { @@ -114,11 +113,33 @@ } } }, - "hostPort": { - "type": "integer" - }, "podPriorityClassNodeCritical": { "type": "boolean" + }, + "ports": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "container" + ], + "properties": { + "name": { + "type": "string" + }, + "container": { + "type": "integer", + "minimum": 1, + "maximum": 65535 + }, + "host": { + "type": "integer", + "minimum": 1, + "maximum": 65535 + } + } + } } } } diff --git a/deployment/helm/topology-aware/values.yaml b/deployment/helm/topology-aware/values.yaml index 751d28698..b388821ce 100644 --- a/deployment/helm/topology-aware/values.yaml +++ b/deployment/helm/topology-aware/values.yaml @@ -31,8 +31,6 @@ config: plugin-test: enableAPIs: false -hostPort: 8891 - resources: cpu: 500m memory: 512Mi @@ -92,3 +90,13 @@ nodeSelector: [] # autoscaling enough new nodes are brought up to leave room for the # plugin on each new node. podPriorityClassNodeCritical: true + +# extra ports to expose, and optionally to the host too +#ports: [] +# +# Example +# +# ports: +# - name: lunch +# container: 61453 +# #host: 61453 # if you want to expose this as a host-port, too