From 7f7cefb3b7a8a11c4d6725136ca6985cf8196823 Mon Sep 17 00:00:00 2001 From: Kacey Gambill Date: Tue, 30 Jul 2024 12:09:16 -0600 Subject: [PATCH 1/3] add readme and kustomization.yaml to support kustomize deployments --- deploy/README.md | 68 ++++++++++++++++++++++++++++++++++++--- deploy/kustomization.yaml | 18 +++++++++++ 2 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 deploy/kustomization.yaml diff --git a/deploy/README.md b/deploy/README.md index 38afe645c..d434da2eb 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -1,11 +1,69 @@ -Example Deployment -================== +# Example Deployment 1. Make sure you've built the included Dockerfile with `TAG=latest make container`. The image should be tagged as `registry.k8s.io/prometheus-adapter/staging-prometheus-adapter:latest`. 2. `kubectl create namespace monitoring` to ensure that the namespace that we're installing the custom metrics adapter in exists. -3. `kubectl create -f manifests/`, modifying the Deployment as necessary to - point to your Prometheus server, and the ConfigMap to contain your desired - metrics discovery configuration. +3. This can be deployed via `kubectl create -f manifests/` or via `kustomize` + a. if using `kubectl create -f manifests/` modify the Deployment as necessary to point to your Prometheus server, and the ConfigMap to contain your desired metrics discovery configuration. + b. if using `kustomize` reference the kustomization file located: `http://github.com/kubernetes-sigs/prometheus-adapter/deploy?ref=release-X.XX` + example kustomization.yaml: + + ```kustomization.yaml + --- + apiVersion: kustomize.config.k8s.io/v1beta1 + kind: Kustomization + + resources: + - github.com/kubernetes-sigs/prometheus-adapter/deploy?ref=release-X.XX + + patches: + - path: deployment-patch.yaml + target: + kind: Deployment + version: v1 + name: prometheus-adapter + namespace: monitoring + - path: configmap-patch.yaml + target: + kind: ConfigMap + version: v1 + name: adapter-config + namespace: monitoring + ``` + + ```deployment-patch.yaml + kind: Deployment + apiVersion: apps/v1 + metadata: + name: prometheus-adapter # deployment name to patch + namespace: monitoring + spec: + template: + spec: + containers: + - name: prometheus-adapter # name of container + args: + - --cert-dir=/var/run/serving-cert + - --config=/etc/adapter/config.yaml + - --metrics-relist-interval=1m + - --prometheus-url=http://prometheus.monitoring.svc.cluster.local:9090/ # prometheus URL + - --secure-port=6443 + - --tls-cipher-suites=TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA + ``` + + ```configmap-patch.yaml + kind: ConfigMap + apiVersion: v1 + metadata: + labels: + app.kubernetes.io/component: metrics-adapter + app.kubernetes.io/name: prometheus-adapter + app.kubernetes.io/version: 0.12.0 + name: adapter-config + namespace: monitoring + data: + config.yaml: |- + # your rules would go here + ``` diff --git a/deploy/kustomization.yaml b/deploy/kustomization.yaml new file mode 100644 index 000000000..0129216c1 --- /dev/null +++ b/deploy/kustomization.yaml @@ -0,0 +1,18 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: monitoring +resources: + - ./manifests/api-service.yaml + - ./manifests/cluster-role-aggregated-metrics-reader.yaml + - ./manifests/cluster-role-binding-delegator.yaml + - ./manifests/cluster-role-binding-hpa-custom-metrics.yaml + - ./manifests/cluster-role-binding.yaml + - ./manifests/cluster-role-metrics-server-resources.yaml + - ./manifests/cluster-role.yaml + - ./manifests/config-map.yaml + - ./manifests/deployment.yaml + - ./manifests/network-policy.yaml + - ./manifests/pod-disruption-budget.yaml + - ./manifests/role-binding-auth-reader.yaml + - ./manifests/service-account.yaml + - ./manifests/service.yaml From 0c41d95b59462e2fddf6c20f49299c38bcfe4b34 Mon Sep 17 00:00:00 2001 From: Kacey Date: Tue, 30 Jul 2024 17:41:23 -0600 Subject: [PATCH 2/3] remove namespace specification from kustomize --- deploy/kustomization.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/deploy/kustomization.yaml b/deploy/kustomization.yaml index 0129216c1..117fc79e7 100644 --- a/deploy/kustomization.yaml +++ b/deploy/kustomization.yaml @@ -1,6 +1,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization -namespace: monitoring resources: - ./manifests/api-service.yaml - ./manifests/cluster-role-aggregated-metrics-reader.yaml From 431d9a895ebbb16d2181a7e5a0f22cdd85d038d3 Mon Sep 17 00:00:00 2001 From: Kacey Date: Tue, 30 Jul 2024 17:43:35 -0600 Subject: [PATCH 3/3] fix path for kustomization example --- deploy/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/README.md b/deploy/README.md index d434da2eb..d222df253 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -16,7 +16,7 @@ kind: Kustomization resources: - - github.com/kubernetes-sigs/prometheus-adapter/deploy?ref=release-X.XX + - https://raw.githubusercontent.com/kubernetes-sigs/prometheus-adapter/release-X.XX/deploy patches: - path: deployment-patch.yaml