From ed66a5f113efab4c54f44cd3dfab2dd8113641d9 Mon Sep 17 00:00:00 2001 From: Chris Mark Date: Thu, 30 May 2024 13:33:34 +0300 Subject: [PATCH] [chore] add Makefile target for installing the collector as k8s deployment (#33220) **Description:** This PR adds a makefile target for installing a locally built collector image (on a local k8s kind cluster) in deployment mode. **Link to tracking Issue:** Fixes https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/32348 Follow up of https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/32349 **Testing:** **Documentation:** Added /cc @andrzej-stencel who reviewed the daemonset target PR --------- Signed-off-by: ChrsMark Co-authored-by: Andrzej Stencel --- Makefile | 14 ++- .../kubernetes/deployment-collector-dev.yaml | 93 +++++++++++++++++++ examples/kubernetes/dev-docs.md | 10 ++ 3 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 examples/kubernetes/deployment-collector-dev.yaml diff --git a/Makefile b/Makefile index f4befbba4b8f..5adbfaf09e38 100644 --- a/Makefile +++ b/Makefile @@ -407,14 +407,24 @@ kind-build: kind-ready docker-otelcontribcol .PHONY: kind-install-daemonset kind-install-daemonset: kind-ready kind-uninstall-daemonset## Install a local Collector version into the cluster. - @echo "Installing Collector" + @echo "Installing daemonset collector" helm install daemonset-collector-dev open-telemetry/opentelemetry-collector --values ./examples/kubernetes/daemonset-collector-dev.yaml .PHONY: kind-uninstall-daemonset kind-uninstall-daemonset: kind-ready - @echo "Uninstalling Collector" + @echo "Uninstalling daemonset collector" helm uninstall --ignore-not-found daemonset-collector-dev +.PHONY: kind-install-deployment +kind-install-deployment: kind-ready kind-uninstall-deployment## Install a local Collector version into the cluster. + @echo "Installing deployment collector" + helm install deployment-collector-dev open-telemetry/opentelemetry-collector --values ./examples/kubernetes/deployment-collector-dev.yaml + +.PHONY: kind-uninstall-deployment +kind-uninstall-deployment: kind-ready + @echo "Uninstalling deployment collector" + helm uninstall --ignore-not-found deployment-collector-dev + .PHONY: all-checklinks all-checklinks: $(MAKE) $(FOR_GROUP_TARGET) TARGET="checklinks" diff --git a/examples/kubernetes/deployment-collector-dev.yaml b/examples/kubernetes/deployment-collector-dev.yaml new file mode 100644 index 000000000000..c2a383e46506 --- /dev/null +++ b/examples/kubernetes/deployment-collector-dev.yaml @@ -0,0 +1,93 @@ +mode: deployment + +image: + repository: otelcontribcol-dev + tag: "0.0.1" + pullPolicy: IfNotPresent + +command: + name: otelcontribcol + +extraEnvs: + - name: K8S_NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + +clusterRole: + create: true + rules: + - apiGroups: + - "" + resources: + - events + - namespaces + - namespaces/status + - nodes + - nodes/spec + - pods + - pods/status + - replicationcontrollers + - replicationcontrollers/status + - resourcequotas + - services + verbs: + - get + - list + - watch + - apiGroups: + - apps + resources: + - daemonsets + - deployments + - replicasets + - statefulsets + verbs: + - get + - list + - watch + - apiGroups: + - extensions + resources: + - daemonsets + - deployments + - replicasets + verbs: + - get + - list + - watch + - apiGroups: + - batch + resources: + - jobs + - cronjobs + verbs: + - get + - list + - watch + - apiGroups: + - autoscaling + resources: + - horizontalpodautoscalers + verbs: + - get + - list + - watch + +config: + exporters: + debug: + verbosity: detailed + receivers: + k8s_cluster: + collection_interval: 10s + metrics: + k8s.container.cpu_limit: + enabled: false + + service: + pipelines: + metrics: + receivers: [k8s_cluster] + processors: [batch] + exporters: [debug] \ No newline at end of file diff --git a/examples/kubernetes/dev-docs.md b/examples/kubernetes/dev-docs.md index b42e59c1e1ab..9c08dec1b9ac 100644 --- a/examples/kubernetes/dev-docs.md +++ b/examples/kubernetes/dev-docs.md @@ -19,3 +19,13 @@ This only stands as a sample configuration and users need to tune this according #### Uninstall the Daemonset `make kind-uninstall-daemonset` + +#### Install the Collector as Deployment +`make kind-install-deployment` + +This command will install the Collector using the [`deployment-collector-dev.yaml`](./deployment-collector-dev.yaml) +configuration sample. +This only stands as a sample configuration and users need to tune this according to their needs. + +#### Uninstall the Deployment +`make kind-uninstall-deployment`