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. Related to kubernetes-sigs#3871 and kubernetes-sigs#4003 Key enhancements: - Added support for configuring certificate integration via a Kustomize patch. - Introduced configurable flags for greater flexibility in customization. - Use Certwatcher to allow certificate rotation This configuration provides an option for users to be production-ready
- Loading branch information
1 parent
d240946
commit 41cffdc
Showing
76 changed files
with
1,568 additions
and
665 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
21 changes: 21 additions & 0 deletions
21
docs/book/src/cronjob-tutorial/testdata/project/config/certmanager/certificate-metrics.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# The following manifests contain a self-signed issuer CR and a metrics certificate CR. | ||
# More document can be found at https://docs.cert-manager.io | ||
apiVersion: cert-manager.io/v1 | ||
kind: Certificate | ||
metadata: | ||
labels: | ||
app.kubernetes.io/created-by: project | ||
app.kubernetes.io/part-of: project | ||
app.kubernetes.io/managed-by: kustomize | ||
name: metrics-certs # this name should match the one appeared in kustomizeconfig.yaml | ||
namespace: system | ||
spec: | ||
dnsNames: | ||
# SERVICE_NAME and SERVICE_NAMESPACE will be substituted by kustomize | ||
# replacements in the config/default/kustomization.yaml file. | ||
- SERVICE_NAME.SERVICE_NAMESPACE.svc | ||
- SERVICE_NAME.SERVICE_NAMESPACE.svc.cluster.local | ||
issuerRef: | ||
kind: Issuer | ||
name: selfsigned-issuer | ||
secretName: metrics-server-cert # this secret will not be prefixed, since it's not managed by kustomize |
21 changes: 21 additions & 0 deletions
21
docs/book/src/cronjob-tutorial/testdata/project/config/certmanager/certificate-webhook.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# The following manifests contain a self-signed issuer CR and a certificate CR. | ||
# More document can be found at https://docs.cert-manager.io | ||
apiVersion: cert-manager.io/v1 | ||
kind: Certificate | ||
metadata: | ||
labels: | ||
app.kubernetes.io/created-by: project | ||
app.kubernetes.io/part-of: project | ||
app.kubernetes.io/managed-by: kustomize | ||
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml | ||
namespace: system | ||
spec: | ||
# SERVICE_NAME and SERVICE_NAMESPACE will be substituted by kustomize | ||
# replacements in the config/default/kustomization.yaml file. | ||
dnsNames: | ||
- SERVICE_NAME.SERVICE_NAMESPACE.svc | ||
- SERVICE_NAME.SERVICE_NAMESPACE.svc.cluster.local | ||
issuerRef: | ||
kind: Issuer | ||
name: selfsigned-issuer | ||
secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize |
57 changes: 0 additions & 57 deletions
57
docs/book/src/cronjob-tutorial/testdata/project/config/certmanager/certificate.yaml
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
docs/book/src/cronjob-tutorial/testdata/project/config/certmanager/issuer.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# The following manifest contains a self-signed issuer CR. | ||
# More information can be found at https://docs.cert-manager.io | ||
# WARNING: Targets CertManager v1.0. Check https://cert-manager.io/docs/installation/upgrading/ for breaking changes. | ||
apiVersion: cert-manager.io/v1 | ||
kind: Issuer | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: project | ||
app.kubernetes.io/managed-by: kustomize | ||
name: selfsigned-issuer | ||
namespace: system | ||
spec: | ||
selfSigned: {} |
4 changes: 3 additions & 1 deletion
4
docs/book/src/cronjob-tutorial/testdata/project/config/certmanager/kustomization.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,5 +1,7 @@ | ||
resources: | ||
- certificate.yaml | ||
- issuer.yaml | ||
- certificate-webhook.yaml | ||
- certificate-metrics.yaml | ||
|
||
configurations: | ||
- kustomizeconfig.yaml |
35 changes: 35 additions & 0 deletions
35
...book/src/cronjob-tutorial/testdata/project/config/default/cert_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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# 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/serving-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/serving-certs | ||
# 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 | ||
optional: false | ||
items: | ||
- key: ca.crt | ||
path: ca.crt | ||
- key: tls.crt | ||
path: tls.crt | ||
- key: tls.key | ||
path: tls.key |
21 changes: 0 additions & 21 deletions
21
...c/cronjob-tutorial/testdata/project/config/default/certmanager_metrics_manager_patch.yaml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.