Skip to content

Commit

Permalink
feat(helm-charts): create Helm Chart for steampipe (#13)
Browse files Browse the repository at this point in the history
* feat(helm-charts): create Helm Chart for steampipe
  • Loading branch information
amartingarcia authored May 31, 2023
1 parent 7b28d9d commit e2822f1
Show file tree
Hide file tree
Showing 16 changed files with 763 additions and 30 deletions.
10 changes: 0 additions & 10 deletions .github/linters/ct.yaml

This file was deleted.

33 changes: 15 additions & 18 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,45 @@
name: Lint and test Charts
name: Lint and Test Charts

on: pull_request

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

- name: Set up Helm
uses: azure/setup-helm@v2.0
uses: azure/setup-helm@v3
with:
version: v3.8.1
version: v3.11.2

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

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.2.1
uses: helm/chart-testing-action@v2.4.0

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --config .github/linters/ct.yaml)
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: install helm unittest plugin
if: steps.list-changed.outputs.changed == 'true'
run: |
helm env
helm plugin install https://github.com/quintush/helm-unittest.git --version 0.2.8
- name: Run chart-testing (lint)
run: ct lint --config .github/linters/ct.yaml
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --target-branch ${{ github.event.repository.default_branch }} --debug

- name: Create kind cluster
uses: helm/[email protected]
if: steps.list-changed.outputs.changed == 'true'
uses: helm/[email protected]

- name: Run chart-testing (install)
run: ct install --config .github/linters/ct.yaml
if: steps.list-changed.outputs.changed == 'true'
run: ct install --target-branch ${{ github.event.repository.default_branch }} --debug
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
git config user.email "[email protected]"
- name: Set up Helm
uses: azure/setup-helm@v2.0
uses: azure/setup-helm@v3
with:
version: v3.10.1
version: v3.11.2

- name: Run chart-releaser
uses: helm/[email protected]
Expand Down
23 changes: 23 additions & 0 deletions charts/steampipe/.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/
28 changes: 28 additions & 0 deletions charts/steampipe/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v2
name: steampipe
description: A Helm chart for Kubernetes

maintainers:
- name: amartingarcia
email: [email protected]

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.20.2"
72 changes: 72 additions & 0 deletions charts/steampipe/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# steampipe

![Version: 0.1.1](https://img.shields.io/badge/Version-0.1.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.20.2](https://img.shields.io/badge/AppVersion-0.20.2-informational?style=flat-square)

A Helm chart for Kubernetes

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| amartingarcia | <[email protected]> | |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| args[0] | string | `"--foreground"` | |
| args[1] | string | `"--show-password"` | |
| command | list | `[]` | |
| configProbe | object | `{}` | |
| dashboard.enabled | bool | `false` | |
| dashboard.listen | string | `"network"` | |
| dashboard.port | int | `9194` | |
| db.enabled | bool | `false` | |
| db.listen | string | `"local"` | |
| db.port | int | `9193` | |
| envFrom | list | `[]` | |
| env[0].name | string | `"STEAMPIPE_LOG_LEVEL"` | |
| env[0].value | string | `"TRACE"` | |
| extraConfig.configMaps.data | string | `nil` | |
| extraConfig.configMaps.enabled | bool | `false` | |
| extraConfig.secrets.data | string | `nil` | |
| extraConfig.secrets.enabled | bool | `false` | |
| extraVolumeMount | string | `nil` | |
| extraVolumes | list | `[]` | |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"ghcr.io/turbot/steampipe"` | |
| image.tag | string | `""` | |
| imagePullSecrets | list | `[]` | |
| ingress.annotations | object | `{}` | |
| ingress.className | string | `""` | |
| ingress.enabled | bool | `false` | |
| ingress.hosts[0].host | string | `"chart-example.local"` | |
| ingress.hosts[0].paths[0].path | string | `"/"` | |
| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
| ingress.tls | list | `[]` | |
| initContainer.extraInitVolumeMount | list | `[]` | |
| initContainer.image.pullPolicy | string | `"IfNotPresent"` | |
| initContainer.image.repository | string | `"ghcr.io/turbot/steampipe"` | |
| initContainer.image.tag | string | `""` | |
| initContainer.mods | list | `[]` | |
| initContainer.plugins | list | `[]` | |
| initContainer.resources | object | `{}` | |
| initContainer.securityContext | object | `{}` | |
| livenessProbe | object | `{}` | |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| podAnnotations | object | `{}` | |
| podSecurityContext | object | `{}` | |
| readinessProbe | object | `{}` | |
| replicaCount | int | `1` | |
| resources | object | `{}` | |
| securityContext | object | `{}` | |
| serviceAccount.annotations | object | `{}` | |
| serviceAccount.create | bool | `true` | |
| serviceAccount.name | string | `""` | |
| tolerations | list | `[]` | |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
11 changes: 11 additions & 0 deletions charts/steampipe/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "steampipe.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
62 changes: 62 additions & 0 deletions charts/steampipe/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "steampipe.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "steampipe.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "steampipe.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "steampipe.labels" -}}
helm.sh/chart: {{ include "steampipe.chart" . }}
{{ include "steampipe.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "steampipe.selectorLabels" -}}
app.kubernetes.io/name: {{ include "steampipe.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "steampipe.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "steampipe.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/steampipe/templates/configmap-init-scripts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if or (.Values.initContainer.plugins) (.Values.initContainer.mods) }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "steampipe.fullname" . }}-scripts
labels:
{{- include "steampipe.labels" . | nindent 4 }}
data:
init.sh: |-
set -e
{{- with .Values.initContainer.plugins }}
echo "Steampipe - Install Plugins"
{{- range $key, $value := . }}
steampipe plugin install {{ $value }}
{{- end }}
{{- end }}
{{- with .Values.initContainer.mods }}
echo "Steampipe - Install Mods"
{{- range $key, $value := . }}
steampipe mod install {{ $value }}
{{- end }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/steampipe/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.extraConfig.configMaps.enabled }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "steampipe.fullname" . }}-config
labels:
{{- include "steampipe.labels" . | nindent 4 }}
data:
{{- range $key, $value := .Values.extraConfig.configMaps.data }}
{{ $key }}: |-
{{ tpl $value $| indent 4 }}
{{- end }}
{{- end }}
Loading

0 comments on commit e2822f1

Please sign in to comment.