Skip to content

Commit

Permalink
Merge pull request #66 from kuskoman/helm-chart
Browse files Browse the repository at this point in the history
Add basic Helm chart for the application
  • Loading branch information
kuskoman authored Apr 12, 2023
2 parents 21fefa4 + e196540 commit 9415663
Show file tree
Hide file tree
Showing 20 changed files with 950 additions and 5 deletions.
83 changes: 82 additions & 1 deletion .github/workflows/go-application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,82 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

verify-helm-readme:
name: Verify that Helm README is up to date
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Node 18
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install README generator
run: make install-helm-readme

- name: Generate README
run: make helm-readme

- name: Verify that there are no changes
run: git diff --exit-code || echo "README.md is not up to date. Please use helm-readme and commit the changes."

lint-helm-chart:
name: Lint Helm chart
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3

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

- name: Lint Helm chart
working-directory: ./chart
run: helm lint .

template-helm-chart:
name: Verify templating chart with default values
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3

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

- name: Template Helm chart
working-directory: ./chart
run: helm template . > /dev/null

test-helm-integration:
name: Test integration with Helm chart
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3

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

- name: Include current chart versions
working-directory: .helm/logstash-integration-test-chart
run: helm dependency update

- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.4.0

- name: Install Helm chart
working-directory: .helm/logstash-integration-test-chart
run: helm install --atomic --wait --timeout 15m --debug logstash-integration-test-chart .

test-integration:
name: Test integration with Prometheus
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -203,7 +279,12 @@ jobs:
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_id: ${{ steps.create_release.outputs.id }}
needs: [build-linux, build-darwin, build-windows, build-linux-docker-image]
needs:
- build-linux
- build-darwin
- build-windows
- build-linux-docker-image
- test-integration
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
Expand Down
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,17 @@ tmp/

# Release notes temporary file
release_notes.txt

# Helm artifacts
charts/
*.tgz
tmpcharts/
tmp-charts/
_debug.yml
_debug*.yml
_debug/
_debug.yaml
_debug*.yaml

# Readme generator files
helm-generator/
23 changes: 23 additions & 0 deletions .helm/logstash-integration-test-chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
15 changes: 15 additions & 0 deletions .helm/logstash-integration-test-chart/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
dependencies:
- name: logstash
repository: https://helm.elastic.co
version: 8.5.1
- name: apache
repository: https://charts.bitnami.com/bitnami
version: 9.2.23
- name: prometheus
repository: https://prometheus-community.github.io/helm-charts
version: 20.2.0
- name: logstash-exporter
repository: file://../../chart/
version: v1.0.2
digest: sha256:1733217c222c212aac4b58826c147d7acb2f61fe01ce6985b139050803915d92
generated: "2023-04-12T10:38:00.905306965+02:00"
23 changes: 23 additions & 0 deletions .helm/logstash-integration-test-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v2
name: logstash-integration-test-chart
description: Helm chart for testing the logstash-exporter Helm chart
type: application
version: 0.1.0
dependencies:
- name: logstash
version: "8.5.1"
repository: https://helm.elastic.co
condition: logstash.enabled
# we are replacing elasticsearch with apache for testing purposes
- name: apache
version: "^9.2.23"
repository: https://charts.bitnami.com/bitnami
condition: apache.enabled
- name: prometheus
version: "^20.2.0"
repository: https://prometheus-community.github.io/helm-charts
condition: prometheus.enabled
- name: logstash-exporter
version: "*"
repository: file://../../chart/
condition: logstash-exporter.enabled
48 changes: 48 additions & 0 deletions .helm/logstash-integration-test-chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
logstash:
enabled: true
config: |
input {
generator {
type => "dummy"
count => -1
message => '{"message": "dummy log"}'
}
}
filter {
json {
source => "message"
}
}
output {
elasticsearch {
hosts => ["http://logstash-integration-test-chart:9200"]
}
}
prometheus:
enabled: true
service:
type: ClusterIP
config: |
global:
scrape_interval: 5s
scrape_configs:
- job_name: "logstash-exporter"
scrape_interval: 5s
scrape_timeout: 5s
metrics_path: "/metrics"
scheme: "http"
static_configs:
- targets: ["exporter:9198"]
apache:
enabled: true
service:
type: ClusterIP

logstash-exporter:
enabled: true
fullnameOverride: logstash-exporter
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ build-windows: out/main-windows
build-docker:
docker build -t logstash-exporter .

# Builds for Linux X86, Apple Silicon/AWS Graviton. Requires docker buildx (Docker 19.03+)
build-docker-multi:
docker buildx build --platform linux/amd64,linux/arm64 -t logstash-exporter .

clean:
rm -f $(GOOS_EXES)

Expand All @@ -37,7 +41,7 @@ compose-down:
docker-compose down

verify-metrics:
./scripts/verify-metrics.sh
./scripts/verify_metrics.sh

pull:
docker-compose pull
Expand All @@ -48,4 +52,10 @@ logs:
minify:
upx -9 $(GOOS_EXES)

install-helm-readme:
./scripts/install_helm_readme_generator.sh

helm-readme:
./scripts/generate_helm_readme.sh

.DEFAULT_GOAL := run
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ The application can be run in two ways:
- using the binary executable
- using the Docker image

Additionally [Helm chart](./chart/) is provided for easy deployment to Kubernetes.

#### Binary Executable

The binary executable can be downloaded from the [releases page](https://github.com/kuskoman/logstash-exporter/releases).
Expand Down Expand Up @@ -70,6 +72,10 @@ To pull the image from command line simply use:

docker pull ghcr.io/kuskoman/logstash-exporter:master

#### Helm Chart

The Helm chart has its own [README](./chart/README.md).

### Endpoints

- `/metrics`: Exposes metrics in Prometheus format.
Expand Down Expand Up @@ -97,6 +103,7 @@ All configuration variables can be checked in the [config directory](./config/).
- `make run`: Runs the Go Exporter application.
- `make build-<OS>`: Builds a binary executable for the specified OS (`<OS>` can be linux, darwin, or windows).
- `make build-docker`: Builds a Docker image for the Go Exporter application.
- `make build-docker-multi`: Builds a multi-arch Docker image (`amd64` and `arm64`) for the Go Exporter application.
- `make clean`: Deletes all binary executables in the out directory.
- `make test`: Runs all tests.
- `make compose`: Starts a Docker-compose configuration.
Expand Down Expand Up @@ -190,12 +197,12 @@ Usage:
This [script](./scripts/create_release_notes.sh) is used to create release notes for the GitHub release.
Used primarily by the [CI workflow](./.github/workflows/go-application.yml).

### verify-metrics.sh
### verify_metrics.sh

This [script](./scripts/verify-metrics.sh) is used to verify the metrics from the Go Exporter application.
This [script](./scripts/verify_metrics.sh) is used to verify the metrics from the Go Exporter application.
Can be used both locally and in the CI workflow.

./scripts/verify-metrics.sh
./scripts/verify_metrics.sh

## Testing process

Expand Down
23 changes: 23 additions & 0 deletions chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: logstash-exporter
description: Prometheus exporter for Logstash written in Go
type: application
version: v1.0.2
appVersion: 1.0.2
Loading

0 comments on commit 9415663

Please sign in to comment.