Skip to content

Commit

Permalink
feat: linting and end-to-end collection tests (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
obs-gh-jeremyjackins authored Jul 27, 2023
1 parent 1d73a2b commit 0f1cb99
Show file tree
Hide file tree
Showing 50 changed files with 1,694 additions and 84 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Test Charts

on: pull_request

jobs:
lint-charts:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.12.1

- uses: actions/setup-python@v4
with:
python-version: '3.9'
check-latest: true

- name: Install chart-testing
uses: helm/[email protected]
with:
version: v3.8.0

- name: Lint charts
run: make lint

test-charts:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.12.1

- name: Install kind
uses: helm/[email protected]
with:
install_only: true

- name: Test charts
run: make test GOBUILD=false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.tgz
demo
.kubeconfig
50 changes: 41 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,49 @@
CHARTS := $(shell dirname `find . -name Chart.yaml`)
# Charts will have their dependencies built in the order defined here. Endpoint is
# a dependency of all charts, and should thus always be first in the list. Stack
# and traces are umbrella charts and should always be at the end of the list.
CHARTS := endpoint proxy events logs metrics stack traces

.PHONY: all
all: build-deps lint test

add-repos:
@helm repo add observe https://observeinc.github.io/helm-charts
@helm repo add grafana https://grafana.github.io/helm-charts
@helm repo add fluent https://fluent.github.io/helm-charts
@helm repo add otel https://open-telemetry.github.io/opentelemetry-helm-charts
helm repo up

.PHONY: update-deps
update-deps:
update-deps: add-repos
@for chart in $(CHARTS); do \
helm dependency update $$chart; \
helm dependency update --skip-refresh charts/$$chart; \
done

.PHONY: build-deps
build-deps:
helm repo add grafana https://grafana.github.io/helm-charts
helm repo add fluent https://fluent.github.io/helm-charts
helm repo add otel https://open-telemetry.github.io/opentelemetry-helm-charts
helm repo update
build-deps: add-repos
@for chart in $(CHARTS); do \
echo building chart dependencies for charts/$$chart...; \
helm dependency build --skip-refresh charts/$$chart; \
echo ; \
done

.PHONY: test
test: build-deps build-test-images
test/test.sh stack traces

.PHONY: lint
lint: build-deps
ct lint --all --helm-dependency-extra-args='--skip-refresh'

.PHONY: clean
clean:
test/clean.sh
@for chart in $(CHARTS); do \
helm dependency build --skip-refresh $$chart; \
echo rm -f charts/$$chart/charts/*.tgz; \
rm -f charts/$$chart/charts/*.tgz; \
done
make -C test/cmd clean

.PHONY: build-test-images
build-test-images:
make -C test/cmd all
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ name: endpoint
description: Observe collection endpoint utility functions
type: library
version: 0.1.3
maintainers:
- name: Observe
email: [email protected]
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

# If a collection endpoint is provided, parse the scheme from that.
# Otherwise, fall back to legacy collectorScheme value.
{{- /*
If a collection endpoint is provided, parse the scheme from that.
Otherwise, fall back to legacy collectorScheme value.
*/}}
{{- define "observe.collectorScheme" -}}{{- with .Values.global.observe -}}
{{- if .collectionEndpoint -}}
{{- with urlParse .collectionEndpoint -}}
Expand All @@ -11,9 +13,11 @@
{{- end -}}
{{- end -}}{{- end -}}

# If a collection endpoint is provided, parse the host from that and split the host from the port.
# Otherwise, use the legacy collectorHost value, the the customer part of the hostname prepended:
# <customer_id>.<collectorHost>
{{- /*
If a collection endpoint is provided, parse the host from that and split the host from the port.
Otherwise, use the legacy collectorHost value, the the customer part of the hostname prepended:
<customer_id>.<collectorHost>
*/}}
{{- define "observe.collectorHost" -}}{{- with .Values.global.observe -}}
{{- if .collectionEndpoint -}}
{{- with urlParse .collectionEndpoint -}}
Expand All @@ -25,9 +29,11 @@
{{- end -}}
{{- end -}}{{- end -}}

# If a collection endpoint is provided, look for a provided port and otherwise try to guess
# based on the scheme.
# If an endpoint is not provided, fall back to legacy collectorPort.
{{- /*
If a collection endpoint is provided, look for a provided port and otherwise try to guess
based on the scheme.
If an endpoint is not provided, fall back to legacy collectorPort.
*/}}
{{- define "observe.collectorPort" -}}{{- with .Values.global.observe -}}
{{- if .collectionEndpoint -}}
{{- with urlParse .collectionEndpoint -}}
Expand All @@ -47,8 +53,10 @@
{{- end -}}
{{- end -}}{{- end -}}

# Return true if the scheme is "https", as parsed from the collection endpoint.
# If a collection endpoint is not provided, look at the legacy collectorScheme value.
{{- /*
Return true if the scheme is "https", as parsed from the collection endpoint.
If a collection endpoint is not provided, look at the legacy collectorScheme value.
*/}}
{{- define "observe.useTLS" -}}{{- with .Values.global.observe -}}
{{- if .collectionEndpoint -}}
{{- if eq "http" (urlParse .collectionEndpoint).scheme -}}
Expand All @@ -65,9 +73,11 @@
{{- end -}}
{{- end -}}{{- end -}}

# If a collection endpoint is provided, use that.
# Otherwise, generate the endpoint using the legacy values.
# Re-constructing the parsed URL eliminates any path that was included in the value.
{{- /*
If a collection endpoint is provided, use that.
Otherwise, generate the endpoint using the legacy values.
Re-constructing the parsed URL eliminates any path that was included in the value.
*/}}
{{- define "observe.collectionEndpoint" -}}
{{- if .Values.global.observe.collectionEndpoint -}}
{{- with urlParse .Values.global.observe.collectionEndpoint -}}
Expand All @@ -78,7 +88,9 @@
{{- end -}}
{{- end -}}

# Same as "observe.collectionEndpoint", but with the token provided as part of the URL.
{{- /*
mychart.shortname provides a 6 char truncated version of the release name.
*/}}
{{- define "observe.collectionEndpointWithToken" -}}
{{- if .Values.global.observe.collectionEndpoint -}}
{{- with urlParse .Values.global.observe.collectionEndpoint -}}
Expand Down
9 changes: 9 additions & 0 deletions charts/endpoint/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
global:
observe:
collectionEndpoint: ""

# Legacy configuration values, only used if collectionEndpoint is not set
customer: ""
collectorScheme: "https"
collectorHost: "collect.observeinc.com"
collectorPort: "443"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ dependencies:
- name: endpoint
version: 0.1.3
repository: file://../endpoint
maintainers:
- name: Observe
email: [email protected]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
global:
# https://github.com/helm/helm/issues/8489 workaround
observe: {}

image:
kube_cluster_info:
repository: observeinc/kube-cluster-info
Expand Down
2 changes: 1 addition & 1 deletion charts/internal/logs/Chart.lock → charts/logs/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ dependencies:
repository: file://../endpoint
version: 0.1.3
digest: sha256:53c32af7f65d7683aed0aa325738388ab0be6379c25b6a0d90724e520050f54b
generated: "2023-07-11T11:35:39.457678-07:00"
generated: "2023-07-20T15:01:44.474585-07:00"
3 changes: 3 additions & 0 deletions charts/internal/logs/Chart.yaml → charts/logs/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ dependencies:
- name: endpoint
version: 0.1.3
repository: file://../endpoint
maintainers:
- name: Observe
email: [email protected]
14 changes: 8 additions & 6 deletions charts/internal/logs/values.yaml → charts/logs/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
global:
# https://github.com/helm/helm/issues/8489 workaround
observe: {}

fluent-bit:
nameOverride: logs
env:
Expand Down Expand Up @@ -39,8 +43,6 @@ fluent-bit:
buffer_max_size: 256k
dns_mode: UDP
dns_resolver: LEGACY
docker_mode: On
docker_mode_flush: 4
flush: 2
grace: 10
hc_errors_count: 5
Expand All @@ -50,14 +52,14 @@ fluent-bit:
mem_buf_limit: 10MB
node_log_include_path: /var/log/kube-apiserver-audit.log
node_log_exclude_path: nomatch
read_from_head: True
read_from_head: "true"
refresh_interval: 2
retry_limit: 5
rotate_wait: 5
storage_metrics: Off
storage_metrics: "off"
grep_match_tag: "nothing"
grep_exclude: "nomatch ^$"
inotify_watcher: true
inotify_watcher: "true"

service: |
[SERVICE]
Expand Down Expand Up @@ -170,7 +172,7 @@ fluent-bit:
Header Authorization Bearer ${OBSERVE_TOKEN}
Compress gzip
Retry_Limit {{.Values.config.retry_limit}}
customParsers: |
[PARSER]
Name kube-custom
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ dependencies:
- name: endpoint
version: 0.1.3
repository: file://../endpoint
maintainers:
- name: Observe
email: [email protected]
80 changes: 42 additions & 38 deletions charts/internal/metrics/values.yaml → charts/metrics/values.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
global:
# https://github.com/helm/helm/issues/8489 workaround
observe: {}

grafana-agent:
nameOverride: metrics
prom_config:
batch_send_deadline: 5s
capacity: 15000
log_level: info
max_backoff: 30s
max_samples_per_send: 5000
max_shards: 10
max_wal_time: 30m
min_backoff: 1s
min_wal_time: 15s
observe_collector_insecure: false
remote_timeout: 30s
remote_flush_deadline: 1m
scrape_interval: 15s
scrape_timeout: 10s
scrape_body_size_limit: 50MB
scrape_cadvisor_action: keep
host_filter: "false"
# the following metrics are exported with 0 values in default cadvisor installs
# see
# - https://github.com/kubernetes/kubernetes/issues/60279
# - https://github.com/google/cadvisor/issues/1672
scrape_cadvisor_metric_drop_regex: container_(network_tcp_usage_total|network_udp_usage_total|tasks_state|cpu_load_average_10s)
# these are the metrics we use for our default boards
scrape_cadvisor_metric_keep_regex: container_(cpu_cfs_.*|spec_.*|cpu_cores|cpu_usage_seconds_total|memory_working_set_bytes|memory_usage_bytes|network_transmit_.*|network_receive_.*|fs_writes_total|fs_reads_total|file_descriptors)|machine_(cpu_cores|memory_bytes)
scrape_kubelet_action: drop
scrape_kubelet_metric_drop_regex:
scrape_kubelet_metric_keep_regex: (.*)
scrape_pod_action: keep
scrape_pod_namespace_drop_regex: (.*istio.*|.*ingress.*|kube-system)
scrape_pod_namespace_keep_regex: (.*)
scrape_pod_port_keep_regex: .*metrics
scrape_pod_metric_drop_regex: .*bucket
scrape_pod_metric_keep_regex: (.*)
scrape_resource_action: keep
scrape_resource_metric_drop_regex:
scrape_resource_metric_keep_regex: (.*)
scrape_sample_limit: 100000
wal_truncate_frequency: 30m
batch_send_deadline: 5s
capacity: 15000
log_level: info
max_backoff: 30s
max_samples_per_send: 5000
max_shards: 10
max_wal_time: 30m
min_backoff: 1s
min_wal_time: 15s
observe_collector_insecure: false
remote_timeout: 30s
remote_flush_deadline: 1m
scrape_interval: 15s
scrape_timeout: 10s
scrape_body_size_limit: 50MB
scrape_cadvisor_action: keep
host_filter: "false"
# the following metrics are exported with 0 values in default cadvisor installs
# see
# - https://github.com/kubernetes/kubernetes/issues/60279
# - https://github.com/google/cadvisor/issues/1672
scrape_cadvisor_metric_drop_regex: container_(network_tcp_usage_total|network_udp_usage_total|tasks_state|cpu_load_average_10s)
# these are the metrics we use for our default boards
scrape_cadvisor_metric_keep_regex: container_(cpu_cfs_.*|spec_.*|cpu_cores|cpu_usage_seconds_total|memory_working_set_bytes|memory_usage_bytes|network_transmit_.*|network_receive_.*|fs_writes_total|fs_reads_total|file_descriptors)|machine_(cpu_cores|memory_bytes)
scrape_kubelet_action: drop
scrape_kubelet_metric_drop_regex:
scrape_kubelet_metric_keep_regex: (.*)
scrape_pod_action: keep
scrape_pod_namespace_drop_regex: (.*istio.*|.*ingress.*|kube-system)
scrape_pod_namespace_keep_regex: (.*)
scrape_pod_port_keep_regex: .*metrics
scrape_pod_metric_drop_regex: .*bucket
scrape_pod_metric_keep_regex: (.*)
scrape_resource_action: keep
scrape_resource_metric_drop_regex:
scrape_resource_metric_keep_regex: (.*)
scrape_sample_limit: 100000
wal_truncate_frequency: 30m

controller:
type: deployment
Expand Down
8 changes: 8 additions & 0 deletions charts/proxy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v2
name: proxy
description: "Observe agent proxy (for testing only, do not use)"
type: application
version: 0.1.0
maintainers:
- name: Observe
email: [email protected]
Loading

0 comments on commit 0f1cb99

Please sign in to comment.