forked from kubernetes-sigs/kubebuilder
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/fix: enhance cert-manager integration for metrics endpoints (fol…
…low-up to PR kubernetes-sigs#4243) This commit is a follow-up to PR kubernetes-sigs#4243, which introduced support for using cert-manager certificates for securing the metrics endpoint and ServiceMonitor. Key enhancements: - Added support for configuring certificate integration via a Kustomize patch. - Introduced configurable flags for greater flexibility in customization. - (fix)Updated the patch logic to append volumes and arguments without overwriting existing configurations, ensuring seamless integration. These improvements enhance usability and adaptability while maintaining compatibility with the initial implementation. As the feature has not yet been released, this update ensures a polished and user-friendly integration for upcoming releases.
- Loading branch information
1 parent
781e93f
commit 551f773
Showing
37 changed files
with
431 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 35 additions & 21 deletions
56
...c/cronjob-tutorial/testdata/project/config/default/certmanager_metrics_manager_patch.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,35 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
labels: | ||
app.kubernetes.io/name: project | ||
app.kubernetes.io/managed-by: kustomize | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: manager | ||
volumeMounts: | ||
- mountPath: /tmp/k8s-metrics-server/metrics-certs | ||
name: metrics-certs | ||
readOnly: true | ||
volumes: | ||
- name: metrics-certs | ||
secret: | ||
secretName: metrics-server-cert | ||
# This patch adds the args and volumes to allow the manager to use the metrics-server certs | ||
# Ensure the volumeMounts field exists by creating it if missing | ||
- op: add | ||
path: /spec/template/spec/containers/0/volumeMounts | ||
value: [] | ||
# Add the volume mount for the serving certificates | ||
- op: add | ||
path: /spec/template/spec/containers/0/volumeMounts/- | ||
value: | ||
mountPath: /tmp/k8s-metrics-server/metrics-certs | ||
name: metrics-certs | ||
readOnly: true | ||
# Add the cert-dir argument | ||
- op: add | ||
path: /spec/template/spec/containers/0/args/- | ||
value: --cert-dir=/tmp/k8s-metrics-server/metrics-certs | ||
# Add the cert-name argument | ||
- op: add | ||
path: /spec/template/spec/containers/0/args/- | ||
value: --cert-name=/tmp/k8s-metrics-server/metrics-certs/tls.cert | ||
# Add the cert-key argument | ||
- op: add | ||
path: /spec/template/spec/containers/0/args/- | ||
value: --cert-key=/tmp/k8s-metrics-server/metrics-certs/tls.key | ||
# Ensure the volumes field exists by creating it if missing | ||
- op: add | ||
path: /spec/template/spec/volumes | ||
value: [] | ||
# Add the volume for the serving certificates | ||
- op: add | ||
path: /spec/template/spec/volumes/- | ||
value: | ||
name: metrics-certs | ||
secret: | ||
secretName: metrics-server-cert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 35 additions & 21 deletions
56
...rc/getting-started/testdata/project/config/default/certmanager_metrics_manager_patch.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,35 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
labels: | ||
app.kubernetes.io/name: project | ||
app.kubernetes.io/managed-by: kustomize | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: manager | ||
volumeMounts: | ||
- mountPath: /tmp/k8s-metrics-server/metrics-certs | ||
name: metrics-certs | ||
readOnly: true | ||
volumes: | ||
- name: metrics-certs | ||
secret: | ||
secretName: metrics-server-cert | ||
# This patch adds the args and volumes to allow the manager to use the metrics-server certs | ||
# Ensure the volumeMounts field exists by creating it if missing | ||
- op: add | ||
path: /spec/template/spec/containers/0/volumeMounts | ||
value: [] | ||
# Add the volume mount for the serving certificates | ||
- op: add | ||
path: /spec/template/spec/containers/0/volumeMounts/- | ||
value: | ||
mountPath: /tmp/k8s-metrics-server/metrics-certs | ||
name: metrics-certs | ||
readOnly: true | ||
# Add the cert-dir argument | ||
- op: add | ||
path: /spec/template/spec/containers/0/args/- | ||
value: --cert-dir=/tmp/k8s-metrics-server/metrics-certs | ||
# Add the cert-name argument | ||
- op: add | ||
path: /spec/template/spec/containers/0/args/- | ||
value: --cert-name=/tmp/k8s-metrics-server/metrics-certs/tls.cert | ||
# Add the cert-key argument | ||
- op: add | ||
path: /spec/template/spec/containers/0/args/- | ||
value: --cert-key=/tmp/k8s-metrics-server/metrics-certs/tls.key | ||
# Ensure the volumes field exists by creating it if missing | ||
- op: add | ||
path: /spec/template/spec/volumes | ||
value: [] | ||
# Add the volume for the serving certificates | ||
- op: add | ||
path: /spec/template/spec/volumes/- | ||
value: | ||
name: metrics-certs | ||
secret: | ||
secretName: metrics-server-cert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 35 additions & 21 deletions
56
...tiversion-tutorial/testdata/project/config/default/certmanager_metrics_manager_patch.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,35 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
labels: | ||
app.kubernetes.io/name: project | ||
app.kubernetes.io/managed-by: kustomize | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: manager | ||
volumeMounts: | ||
- mountPath: /tmp/k8s-metrics-server/metrics-certs | ||
name: metrics-certs | ||
readOnly: true | ||
volumes: | ||
- name: metrics-certs | ||
secret: | ||
secretName: metrics-server-cert | ||
# This patch adds the args and volumes to allow the manager to use the metrics-server certs | ||
# Ensure the volumeMounts field exists by creating it if missing | ||
- op: add | ||
path: /spec/template/spec/containers/0/volumeMounts | ||
value: [] | ||
# Add the volume mount for the serving certificates | ||
- op: add | ||
path: /spec/template/spec/containers/0/volumeMounts/- | ||
value: | ||
mountPath: /tmp/k8s-metrics-server/metrics-certs | ||
name: metrics-certs | ||
readOnly: true | ||
# Add the cert-dir argument | ||
- op: add | ||
path: /spec/template/spec/containers/0/args/- | ||
value: --cert-dir=/tmp/k8s-metrics-server/metrics-certs | ||
# Add the cert-name argument | ||
- op: add | ||
path: /spec/template/spec/containers/0/args/- | ||
value: --cert-name=/tmp/k8s-metrics-server/metrics-certs/tls.cert | ||
# Add the cert-key argument | ||
- op: add | ||
path: /spec/template/spec/containers/0/args/- | ||
value: --cert-key=/tmp/k8s-metrics-server/metrics-certs/tls.key | ||
# Ensure the volumes field exists by creating it if missing | ||
- op: add | ||
path: /spec/template/spec/volumes | ||
value: [] | ||
# Add the volume for the serving certificates | ||
- op: add | ||
path: /spec/template/spec/volumes/- | ||
value: | ||
name: metrics-certs | ||
secret: | ||
secretName: metrics-server-cert |
Oops, something went wrong.