Skip to content

Commit

Permalink
Add k8s makefile targets (#32349)
Browse files Browse the repository at this point in the history
**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
First attempt for
#32348.

**Link to tracking Issue:** <Issue number if applicable>
#32348

**Testing:** <Describe what testing was performed and which tests were
added.>

**Documentation:** <Describe the documentation added.>

---------

Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
  • Loading branch information
ChrsMark authored May 22, 2024
1 parent cab59ab commit 54b25f7
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
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`

0 comments on commit 54b25f7

Please sign in to comment.