Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add k8s makefile targets #32349

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,25 @@ checkmetadata: $(CHECKFILE)
checkapi:
$(GOCMD) run cmd/checkapi/main.go .

.PHONY: kind-ready
kind-ready:
@if [ -n "$(shell kind get clusters -q)" ]; then echo "kind is ready"; else echo "kind not ready"; exit 1; fi

.PHONY: kind-build
kind-build: kind-ready docker-otelcontribcol
docker tag otelcontribcol otelcontribcol-dev:0.0.1
kind load docker-image otelcontribcol-dev:0.0.1

.PHONY: kind-install-daemonset
kind-install-daemonset: kind-ready kind-uninstall-daemonset## Install a local Collector version into the cluster.
@echo "Installing 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"
helm uninstall --ignore-not-found daemonset-collector-dev

.PHONY: all-checklinks
all-checklinks:
$(MAKE) $(FOR_GROUP_TARGET) TARGET="checklinks"
Expand Down
61 changes: 61 additions & 0 deletions examples/kubernetes/daemonset-collector-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
mode: daemonset

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:
- 'pods'
- 'nodes'
verbs:
- 'get'
- 'list'
- 'watch'
- apiGroups: [ "" ]
resources: [ "nodes/stats", "nodes/proxy"]
verbs: [ "get" ]


config:
exporters:
debug:
verbosity: detailed
receivers:
kubeletstats:
collection_interval: 10s
auth_type: 'serviceAccount'
endpoint: '${env:K8S_NODE_NAME}:10250'
insecure_skip_verify: true
k8s_api_config:
auth_type: serviceAccount
metrics:
container.cpu.utilization:
enabled: true
container.cpu.time:
enabled: true
container.cpu.usage:
enabled: true
k8s.container.cpu_limit_utilization:
enabled: true

service:
pipelines:
metrics:
receivers: [kubeletstats]
processors: [batch]
exporters: [debug]
21 changes: 21 additions & 0 deletions examples/kubernetes/dev-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Running OpenTelemetry Collector from source on k8s

Developing Collector's features that target to run on a Kubernetes environment require some special handling
for building and running the patches locally.


In order to build the Collector from source and deploy it on a local kind cluster
(a kind cluster is required to be installed already) use the following Makefile targets:

#### Build the Collector
`make kind-build`

#### Install the Collector as Daemonset
`make kind-install-daemonset`

This command will install the Collector using the [`daemonset-collector-dev.yaml`](./daemonset-collector-dev.yaml)
configuration sample.
This only stands as a sample configuration and users need to tune this according to their needs.

#### Uninstall the Daemonset
`make kind-uninstall-daemonset`
Loading