Skip to content

Commit 3f9a748

Browse files
kilokangRoberto Santalladpacheconr
authored
Fix host network (newrelic#596)
* Update hostnetwork configuration for ksm deployment Co-authored-by: Roberto Santalla <[email protected]> Co-authored-by: dpacheconr <[email protected]>
1 parent 0bf9e05 commit 3f9a748

File tree

8 files changed

+143
-7
lines changed

8 files changed

+143
-7
lines changed

charts/newrelic-infrastructure/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sources:
88
- https://github.com/newrelic/nri-kubernetes/tree/main/charts/newrelic-infrastructure
99
- https://github.com/newrelic/infrastructure-agent/
1010

11-
version: 3.10.0
11+
version: 3.11.0
1212
appVersion: 3.6.0
1313

1414
dependencies:

charts/newrelic-infrastructure/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ integrations that you have configured.
153153
| ksm.config.selector | string | `"app.kubernetes.io/name=kube-state-metrics"` | Label selector that will be used to automatically discover an instance of kube-state-metrics running in the cluster. |
154154
| ksm.config.timeout | string | `"10s"` | Timeout for the ksm API contacted by the integration |
155155
| ksm.enabled | bool | `true` | Enable cluster state monitoring. Advanced users only. Setting this to `false` is not supported and will break the New Relic experience. |
156+
| ksm.hostNetwork | bool | Not set | Sets pod's hostNetwork. When set bypasses global/common variable |
156157
| ksm.resources | object | 100m/150M -/850M | Resources for the KSM scraper pod. Keep in mind that sharding is not supported at the moment, so memory usage for this component ramps up quickly on large clusters. |
157158
| ksm.tolerations | list | Schedules in all tainted nodes | Tolerations for the KSM Deployment. |
158159
| kubelet | object | See `values.yaml` | Configuration for the DaemonSet that collects metrics from the Kubelet. |
@@ -164,6 +165,7 @@ integrations that you have configured.
164165
| kubelet.extraEnvFrom | list | `[]` | Add user environment from configMaps or secrets as variables to the agent |
165166
| kubelet.extraVolumeMounts | list | `[]` | Defines where to mount volumes specified with `extraVolumes` |
166167
| kubelet.extraVolumes | list | `[]` | Volumes to mount in the containers |
168+
| kubelet.hostNetwork | bool | Not set | Sets pod's hostNetwork. When set bypasses global/common variable |
167169
| kubelet.tolerations | list | Schedules in all tainted nodes | Tolerations for the control plane DaemonSet. |
168170
| labels | object | `{}` | Additional labels for chart objects. Can be configured also with `global.labels` |
169171
| licenseKey | string | `""` | This set this license key to use. Can be configured also with `global.licenseKey` |
@@ -179,7 +181,7 @@ integrations that you have configured.
179181
| proxy | string | `""` | Configures the integration to send all HTTP/HTTPS request through the proxy in that URL. The URL should have a standard format like `https://user:password@hostname:port`. Can be configured also with `global.proxy` |
180182
| rbac.create | bool | `true` | Whether the chart should automatically create the RBAC objects required to run. |
181183
| rbac.pspEnabled | bool | `false` | Whether the chart should create Pod Security Policy objects. |
182-
| selfMonitoring.pixie.enabled | bool | `true` | Enables the Pixie Health Check nri-flex config. This Flex config performs periodic checks of the Pixie /healthz and /statusz endpoints exposed by the Pixie Cloud Connector. A status for each endpoint is sent to New Relic in a pixieHealthCheck event. |
184+
| selfMonitoring.pixie.enabled | bool | `false` | Enables the Pixie Health Check nri-flex config. This Flex config performs periodic checks of the Pixie /healthz and /statusz endpoints exposed by the Pixie Cloud Connector. A status for each endpoint is sent to New Relic in a pixieHealthCheck event. |
183185
| serviceAccount | object | See `values.yaml` | Settings controlling ServiceAccount creation. |
184186
| serviceAccount.create | bool | `true` | Whether the chart should automatically create the ServiceAccount objects required to run. |
185187
| strategy | object | `type: Recreate` | Update strategy for the deployed Deployments. |
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{/* Returns whether the ksm scraper should run with hostNetwork: true based on the user configuration. */}}
2+
{{- define "nriKubernetes.ksm.hostNetwork" -}}
3+
{{- /* `get` will return "" (empty string) if value is not found, and the value otherwise, so we can type-assert with kindIs */ -}}
4+
{{- if get .Values.ksm "hostNetwork" | kindIs "bool" -}}
5+
{{- if .Values.ksm.hostNetwork -}}
6+
{{- .Values.ksm.hostNetwork -}}
7+
{{- end -}}
8+
{{- else if include "newrelic.common.hostNetwork" . -}}
9+
{{- include "newrelic.common.hostNetwork" . -}}
10+
{{- end -}}
11+
{{- end -}}
12+
13+
14+
15+
{{/* Abstraction of "nriKubernetes.ksm.hostNetwork" that returns true of false directly */}}
16+
{{- define "nriKubernetes.ksm.hostNetwork.value" -}}
17+
{{- if include "nriKubernetes.ksm.hostNetwork" . -}}
18+
true
19+
{{- else -}}
20+
false
21+
{{- end -}}
22+
{{- end -}}

charts/newrelic-infrastructure/templates/ksm/deployment.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ spec:
4949
{{- . | nindent 8 }}
5050
{{- end }}
5151
serviceAccountName: {{ include "newrelic.common.serviceAccount.name" . }}
52-
hostNetwork: {{ include "newrelic.common.hostNetwork.value" . }}
53-
{{- if include "nriKubernetes.controlPlane.hostNetwork" . }}
52+
hostNetwork: {{ include "nriKubernetes.ksm.hostNetwork.value" . }}
53+
{{- if include "nriKubernetes.ksm.hostNetwork" . }}
5454
dnsPolicy: ClusterFirstWithHostNet
5555
{{- end }}
56-
56+
5757
{{- if .Values.ksm.initContainers }}
5858
initContainers: {{- tpl (.Values.ksm.initContainers | toYaml) . | nindent 8 }}
5959
{{- end }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{/* Returns whether the kubelet scraper should run with hostNetwork: true based on the user configuration. */}}
2+
{{- define "nriKubernetes.kubelet.hostNetwork" -}}
3+
{{- /* `get` will return "" (empty string) if value is not found, and the value otherwise, so we can type-assert with kindIs */ -}}
4+
{{- if get .Values.kubelet "hostNetwork" | kindIs "bool" -}}
5+
{{- if .Values.kubelet.hostNetwork -}}
6+
{{- .Values.kubelet.hostNetwork -}}
7+
{{- end -}}
8+
{{- else if include "newrelic.common.hostNetwork" . -}}
9+
{{- include "newrelic.common.hostNetwork" . -}}
10+
{{- end -}}
11+
{{- end -}}
12+
13+
14+
15+
{{/* Abstraction of "nriKubernetes.kubelet.hostNetwork" that returns true of false directly */}}
16+
{{- define "nriKubernetes.kubelet.hostNetwork.value" -}}
17+
{{- if include "nriKubernetes.kubelet.hostNetwork" . -}}
18+
true
19+
{{- else -}}
20+
false
21+
{{- end -}}
22+
{{- end -}}

charts/newrelic-infrastructure/templates/kubelet/daemonset.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ spec:
5050
{{- . | nindent 8 }}
5151
{{- end }}
5252
serviceAccountName: {{ include "newrelic.common.serviceAccount.name" . }}
53-
hostNetwork: {{ include "newrelic.common.hostNetwork.value" . }}
54-
{{- if include "nriKubernetes.controlPlane.hostNetwork" . }}
53+
hostNetwork: {{ include "nriKubernetes.kubelet.hostNetwork.value" . }}
54+
{{- if include "nriKubernetes.kubelet.hostNetwork" . }}
5555
dnsPolicy: ClusterFirstWithHostNet
5656
{{- end }}
5757

charts/newrelic-infrastructure/tests/hostNetwork_test.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,87 @@ tests:
114114
path: spec.template.spec.hostNetwork
115115
value: true
116116
template: templates/kubelet/daemonset.yaml
117+
118+
- it: ksm hostNetwork is overridable to true
119+
set:
120+
licenseKey: test
121+
cluster: test
122+
global.hostNetwork: null
123+
hostNetwork: false
124+
ksm.hostNetwork: true
125+
asserts:
126+
- equal:
127+
path: spec.template.spec.hostNetwork
128+
value: true
129+
template: templates/ksm/deployment.yaml
130+
- equal:
131+
path: spec.template.spec.hostNetwork
132+
value: true
133+
template: templates/controlplane/daemonset.yaml
134+
- equal:
135+
path: spec.template.spec.hostNetwork
136+
value: false
137+
template: templates/kubelet/daemonset.yaml
138+
139+
- it: ksm hostNetwork is overridable to false
140+
set:
141+
licenseKey: test
142+
cluster: test
143+
global.hostNetwork: null
144+
hostNetwork: true
145+
ksm.hostNetwork: false
146+
asserts:
147+
- equal:
148+
path: spec.template.spec.hostNetwork
149+
value: false
150+
template: templates/ksm/deployment.yaml
151+
- equal:
152+
path: spec.template.spec.hostNetwork
153+
value: true
154+
template: templates/controlplane/daemonset.yaml
155+
- equal:
156+
path: spec.template.spec.hostNetwork
157+
value: true
158+
template: templates/kubelet/daemonset.yaml
159+
160+
- it: kubelet hostNetwork is overridable to true
161+
set:
162+
licenseKey: test
163+
cluster: test
164+
global.hostNetwork: null
165+
hostNetwork: false
166+
kubelet.hostNetwork: true
167+
asserts:
168+
- equal:
169+
path: spec.template.spec.hostNetwork
170+
value: false
171+
template: templates/ksm/deployment.yaml
172+
- equal:
173+
path: spec.template.spec.hostNetwork
174+
value: true
175+
template: templates/controlplane/daemonset.yaml
176+
- equal:
177+
path: spec.template.spec.hostNetwork
178+
value: true
179+
template: templates/kubelet/daemonset.yaml
180+
181+
- it: kubelet hostNetwork is overridable to false
182+
set:
183+
licenseKey: test
184+
cluster: test
185+
global.hostNetwork: null
186+
hostNetwork: true
187+
kubelet.hostNetwork: false
188+
asserts:
189+
- equal:
190+
path: spec.template.spec.hostNetwork
191+
value: true
192+
template: templates/ksm/deployment.yaml
193+
- equal:
194+
path: spec.template.spec.hostNetwork
195+
value: true
196+
template: templates/controlplane/daemonset.yaml
197+
- equal:
198+
path: spec.template.spec.hostNetwork
199+
value: false
200+
template: templates/kubelet/daemonset.yaml

charts/newrelic-infrastructure/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ kubelet:
8484
- operator: "Exists"
8585
effect: "NoExecute"
8686
nodeSelector: {}
87+
# -- (bool) Sets pod's hostNetwork. When set bypasses global/common variable
88+
# @default -- Not set
89+
hostNetwork:
8790
affinity: {}
8891
# -- Config for the Infrastructure agent that will forward the metrics to the backend and will run the integrations in this cluster.
8992
# It will be merged with the configuration in `.common.agentConfig`. You can see all the agent configurations in
@@ -133,6 +136,9 @@ ksm:
133136
- operator: "Exists"
134137
effect: "NoExecute"
135138
nodeSelector: {}
139+
# -- (bool) Sets pod's hostNetwork. When set bypasses global/common variable
140+
# @default -- Not set
141+
hostNetwork:
136142
# -- Affinity for the KSM Deployment.
137143
# @default -- Deployed in the same node as KSM
138144
affinity:

0 commit comments

Comments
 (0)