mirror of
https://github.com/jangraefen/hcloud-pricing-exporter
synced 2024-11-10 05:54:15 +00:00
Add helm chart for easy deployment
This commit is contained in:
parent
0e83f7a8d1
commit
10f0aafb35
15 changed files with 380 additions and 0 deletions
1
.chartreleaser.yaml
Normal file
1
.chartreleaser.yaml
Normal file
|
@ -0,0 +1 @@
|
|||
release-name-template: "helm-v{{ .Version }}"
|
52
.github/workflows/build-helm.yaml
vendored
Normal file
52
.github/workflows/build-helm.yaml
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
name: Build Charts
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
paths:
|
||||
- helm/**
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
paths:
|
||||
- helm/**
|
||||
|
||||
jobs:
|
||||
lint-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Helm
|
||||
uses: azure/setup-helm@v1
|
||||
with:
|
||||
version: v3.4.2
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.7
|
||||
|
||||
- name: Set up chart-testing
|
||||
uses: helm/chart-testing-action@v2.0.1
|
||||
with:
|
||||
version: v3.3.0
|
||||
|
||||
- name: Run chart-testing (list-changed)
|
||||
id: list-changed
|
||||
run: |
|
||||
changed=$(ct list-changed --config helm/ct.yaml)
|
||||
if [[ -n "$changed" ]]; then
|
||||
echo "::set-output name=changed::true"
|
||||
fi
|
||||
- name: Run chart-testing (lint)
|
||||
run: ct lint --config helm/ct.yaml --check-version-increment=false
|
||||
|
||||
- name: Create kind cluster
|
||||
uses: helm/kind-action@v1.1.0
|
||||
if: steps.list-changed.outputs.changed == 'true'
|
||||
|
||||
- name: Run chart-testing (install)
|
||||
run: ct install --config helm/ct.yaml
|
|
@ -8,8 +8,15 @@ on:
|
|||
- LICENSE
|
||||
- .gitignore
|
||||
- .editorconfig
|
||||
- helm/**
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
paths-ignore:
|
||||
- README.md
|
||||
- LICENSE
|
||||
- .gitignore
|
||||
- .editorconfig
|
||||
- helm/**
|
||||
|
||||
jobs:
|
||||
lint:
|
33
.github/workflows/release-helm.yaml
vendored
Normal file
33
.github/workflows/release-helm.yaml
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
name: Release Charts
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- version.yaml
|
||||
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config user.name "$GITHUB_ACTOR"
|
||||
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
||||
- name: Install Helm
|
||||
uses: azure/setup-helm@v1
|
||||
with:
|
||||
version: v3.4.2
|
||||
|
||||
- name: Run chart-releaser
|
||||
uses: helm/chart-releaser-action@v1.2.0
|
||||
with:
|
||||
charts_dir: helm
|
||||
config: .chartreleaser.yaml
|
||||
env:
|
||||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
23
helm/hcloud-pricing-exporter/.helmignore
Normal file
23
helm/hcloud-pricing-exporter/.helmignore
Normal file
|
@ -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/
|
8
helm/hcloud-pricing-exporter/Chart.yaml
Normal file
8
helm/hcloud-pricing-exporter/Chart.yaml
Normal file
|
@ -0,0 +1,8 @@
|
|||
apiVersion: v2
|
||||
name: hcloud-pricing-exporter
|
||||
description: A prometheus exporter for the current pricing and costs of your HCloud account
|
||||
|
||||
type: application
|
||||
|
||||
version: 0.1.1-r1
|
||||
appVersion: 0.1.1
|
51
helm/hcloud-pricing-exporter/templates/_helpers.tpl
Normal file
51
helm/hcloud-pricing-exporter/templates/_helpers.tpl
Normal file
|
@ -0,0 +1,51 @@
|
|||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "hcloud-pricing-exporter.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 "hcloud-pricing-exporter.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 "hcloud-pricing-exporter.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "hcloud-pricing-exporter.labels" -}}
|
||||
helm.sh/chart: {{ include "hcloud-pricing-exporter.chart" . }}
|
||||
{{ include "hcloud-pricing-exporter.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "hcloud-pricing-exporter.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "hcloud-pricing-exporter.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
67
helm/hcloud-pricing-exporter/templates/deployment.yaml
Normal file
67
helm/hcloud-pricing-exporter/templates/deployment.yaml
Normal file
|
@ -0,0 +1,67 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "hcloud-pricing-exporter.fullname" . }}
|
||||
labels:
|
||||
{{- include "hcloud-pricing-exporter.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "hcloud-pricing-exporter.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "hcloud-pricing-exporter.selectorLabels" . | nindent 8 }}
|
||||
spec:
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
env:
|
||||
- name: HCLOUD_TOKEN
|
||||
{{- if .Values.secret.create }}
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "hcloud-pricing-exporter.fullname" . }}
|
||||
key: token
|
||||
{{- else }}
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ .Values.secret.reference.name }}
|
||||
key: {{ .Values.secret.reference.key }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8080
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: http
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: http
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
41
helm/hcloud-pricing-exporter/templates/ingress.yaml
Normal file
41
helm/hcloud-pricing-exporter/templates/ingress.yaml
Normal file
|
@ -0,0 +1,41 @@
|
|||
{{- if .Values.ingress.enabled -}}
|
||||
{{- $fullName := include "hcloud-pricing-exporter.fullname" . -}}
|
||||
{{- $svcPort := .Values.service.port -}}
|
||||
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||
apiVersion: networking.k8s.io/v1beta1
|
||||
{{- else -}}
|
||||
apiVersion: extensions/v1beta1
|
||||
{{- end }}
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ $fullName }}
|
||||
labels:
|
||||
{{- include "hcloud-pricing-exporter.labels" . | nindent 4 }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if .Values.ingress.tls }}
|
||||
tls:
|
||||
{{- range .Values.ingress.tls }}
|
||||
- hosts:
|
||||
{{- range .hosts }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
secretName: {{ .secretName }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range .Values.ingress.hosts }}
|
||||
- host: {{ .host | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ .path }}
|
||||
backend:
|
||||
serviceName: {{ $fullName }}
|
||||
servicePort: {{ $svcPort }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
9
helm/hcloud-pricing-exporter/templates/secret.yaml
Normal file
9
helm/hcloud-pricing-exporter/templates/secret.yaml
Normal file
|
@ -0,0 +1,9 @@
|
|||
{{- if .Values.secret.create }}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "hcloud-pricing-exporter.fullname" . }}
|
||||
type: Opaque
|
||||
data:
|
||||
token: {{ required "An token to access the HCloud API is required" .Values.secret.token | b64enc }}
|
||||
{{- end }}
|
15
helm/hcloud-pricing-exporter/templates/service.yaml
Normal file
15
helm/hcloud-pricing-exporter/templates/service.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "hcloud-pricing-exporter.fullname" . }}
|
||||
labels:
|
||||
{{- include "hcloud-pricing-exporter.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
{{- include "hcloud-pricing-exporter.selectorLabels" . | nindent 4 }}
|
27
helm/hcloud-pricing-exporter/templates/servicemonitor.yaml
Normal file
27
helm/hcloud-pricing-exporter/templates/servicemonitor.yaml
Normal file
|
@ -0,0 +1,27 @@
|
|||
{{ if .Values.serviceMonitor.create }}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: {{ include "hcloud-pricing-exporter.fullname" . }}
|
||||
labels:
|
||||
{{- include "hcloud-pricing-exporter.labels" . | nindent 4 }}
|
||||
{{- if .Values.serviceMonitor.labels }}
|
||||
{{- toYaml .Values.serviceMonitor.labels | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
endpoints:
|
||||
- honorLabels: true
|
||||
targetPort: http
|
||||
{{- with .Values.serviceMonitor.interval }}
|
||||
interval: {{ . }}
|
||||
{{- end }}
|
||||
{{- with .Values.serviceMonitor.scrapeTimeout }}
|
||||
scrapeTimeout: {{ . }}
|
||||
{{- end }}
|
||||
namespaceSelector:
|
||||
matchNames:
|
||||
- "{{ .Release.Namespace }}"
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "hcloud-pricing-exporter.selectorLabels" . | nindent 6 }}
|
||||
{{- end }}
|
44
helm/hcloud-pricing-exporter/values.yaml
Normal file
44
helm/hcloud-pricing-exporter/values.yaml
Normal file
|
@ -0,0 +1,44 @@
|
|||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: jangraefen/hcloud-pricing-exporter
|
||||
pullPolicy: IfNotPresent
|
||||
tag: ""
|
||||
|
||||
imagePullSecrets: [ ]
|
||||
nameOverride: ""
|
||||
fullnameOverride: ""
|
||||
|
||||
podAnnotations: { }
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 8080
|
||||
|
||||
ingress:
|
||||
enabled: false
|
||||
annotations: { }
|
||||
hosts:
|
||||
- host: chart-example.local
|
||||
tls: [ ]
|
||||
|
||||
secret:
|
||||
create: true
|
||||
token:
|
||||
reference:
|
||||
name:
|
||||
key:
|
||||
|
||||
serviceMonitor:
|
||||
create: false
|
||||
interval:
|
||||
labels:
|
||||
scrapeTimeout:
|
||||
|
||||
resources: { }
|
||||
|
||||
nodeSelector: { }
|
||||
|
||||
tolerations: [ ]
|
||||
|
||||
affinity: { }
|
2
version.yaml
Normal file
2
version.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
version: 0.1.1
|
||||
helmRevision: r1
|
Loading…
Reference in a new issue