Skip to content

Commit 2bdd5a1

Browse files
committed
fix: allow opting-into upstream probes
Allow users to opt-into upstream probe definitions. Signed-off-by: Pranshu Srivastava <[email protected]>
1 parent f3c2f84 commit 2bdd5a1

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

jsonnet/kube-prometheus/components/kube-rbac-proxy.libsonnet

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ local defaults = {
3838
'TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305',
3939
'TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305',
4040
],
41+
// Corresponds to KRP's --ignore-paths flag.
42+
// Some components (for e.g., KSM) may utilize the flag to allow for communication with external parties in scenarios
43+
// where the originating request(s) cannot be modified to the proxy's expectations, and thus, are passed through, as
44+
// is, to certain endpoints that they target, without the proxy's intervention. The kubelet, in KSM's case, can thus
45+
// query health probe endpoints without being blocked by KRP, thus allowing for http-based probes over exec-based
46+
// ones.
47+
ignorePaths:: [],
4148
};
4249

4350

@@ -50,10 +57,11 @@ function(params) {
5057
name: krp._config.name,
5158
image: krp._config.image,
5259
args: [
53-
'--secure-listen-address=' + krp._config.secureListenAddress,
54-
'--tls-cipher-suites=' + std.join(',', krp._config.tlsCipherSuites),
55-
'--upstream=' + krp._config.upstream,
56-
],
60+
'--secure-listen-address=' + krp._config.secureListenAddress,
61+
'--tls-cipher-suites=' + std.join(',', krp._config.tlsCipherSuites),
62+
'--upstream=' + krp._config.upstream,
63+
] // Optionals.
64+
+ if std.length(krp._config.ignorePaths) > 0 then ['--ignore-paths=' + std.join(',', krp._config.ignorePaths)] else defaults.ignorePaths,
5765
resources: krp._config.resources,
5866
ports: krp._config.ports,
5967
securityContext: {

jsonnet/kube-prometheus/components/kube-state-metrics.libsonnet

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ local defaults = {
4646
runbookURLPattern: 'https://runbooks.prometheus-operator.dev/runbooks/kube-state-metrics/%s',
4747
},
4848
},
49+
// `enableProbes` allows users to opt-into upstream definitions for health probes.
50+
enableProbes:: false,
4951
};
5052

5153
function(params) (import 'github.com/kubernetes/kube-state-metrics/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet') {
@@ -112,6 +114,8 @@ function(params) (import 'github.com/kubernetes/kube-state-metrics/jsonnet/kube-
112114
{ name: 'https-main', containerPort: 8443 },
113115
],
114116
image: ksm._config.kubeRbacProxyImage,
117+
// When enabling probes, kube-rbac-proxy needs to always allow the /livez endpoint.
118+
ignorePaths: if ksm._config.enableProbes then ['/livez'] else super.ignorePaths,
115119
}),
116120

117121
local kubeRbacProxySelf = krp(ksm._config.kubeRbacProxySelf {
@@ -122,6 +126,8 @@ function(params) (import 'github.com/kubernetes/kube-state-metrics/jsonnet/kube-
122126
{ name: 'https-self', containerPort: 9443 },
123127
],
124128
image: ksm._config.kubeRbacProxyImage,
129+
// When enabling probes, kube-rbac-proxy needs to always allow the /readyz endpoint.
130+
ignorePaths: if ksm._config.enableProbes then ['/readyz'] else super.ignorePaths,
125131
}),
126132

127133
networkPolicy: {
@@ -162,14 +168,15 @@ function(params) (import 'github.com/kubernetes/kube-state-metrics/jsonnet/kube-
162168
automountServiceAccountToken: true,
163169
containers: std.map(function(c) c {
164170
ports:: null,
165-
livenessProbe:: null,
166-
readinessProbe:: null,
167171
securityContext+: {
168172
runAsGroup: 65534,
169173
},
170174
args: ['--host=127.0.0.1', '--port=8081', '--telemetry-host=127.0.0.1', '--telemetry-port=8082'],
171175
resources: ksm._config.resources,
172-
}, super.containers) + [kubeRbacProxyMain, kubeRbacProxySelf],
176+
} + if !ksm._config.enableProbes then {
177+
livenessProbe:: null,
178+
readinessProbe:: null,
179+
} else {}, super.containers) + [kubeRbacProxyMain, kubeRbacProxySelf],
173180
},
174181
},
175182
},

0 commit comments

Comments
 (0)