Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add helm chart for azure-resourcemanager-exporter #4

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fe0db4a
feat: add helm chart for azure-resourcemanager-exporter
cyril-corbon Feb 3, 2021
8670c19
Update helm/azure-resourcemanager-exporter/templates/NOTES.txt
cyril-corbon Feb 4, 2021
f837d98
Update helm/azure-resourcemanager-exporter/templates/_helpers.tpl
cyril-corbon Feb 4, 2021
05760d2
Update helm/azure-resourcemanager-exporter/templates/_helpers.tpl
cyril-corbon Feb 4, 2021
e621b0e
Update helm/azure-resourcemanager-exporter/values.yaml
cyril-corbon Feb 4, 2021
417eb6d
Update helm/azure-resourcemanager-exporter/templates/NOTES.txt
cyril-corbon Feb 4, 2021
0d6555f
Update helm/azure-resourcemanager-exporter/templates/_helpers.tpl
cyril-corbon Feb 9, 2021
ea3ed6b
define ingress api version in templates
cyril-corbon Feb 9, 2021
afc59cd
Update helm/azure-resourcemanager-exporter/Chart.yaml
cyril-corbon Feb 23, 2021
9208908
Update helm/azure-resourcemanager-exporter/Chart.yaml
cyril-corbon Feb 23, 2021
dcc2408
apply review, add labels and annotations to deployment and some docs
cyril-corbon Feb 23, 2021
59fb682
feat(ci): add helm lint
cyril-corbon Feb 24, 2021
bc7f448
disable release-docker workflow
HamzaZo Mar 9, 2021
c052d5c
add publish chart
HamzaZo Mar 9, 2021
d0c1e7f
add publish chart
Mar 9, 2021
eb40239
fix publisher
Mar 9, 2021
b515f89
rename branch
Mar 9, 2021
2fab054
create charts directory
Mar 9, 2021
59c6b9b
update workflow
Mar 9, 2021
aec5a39
fix path
Mar 9, 2021
004eeb9
fix path
Mar 9, 2021
b62dbfa
testing publish
Mar 9, 2021
c35e234
testing
Mar 9, 2021
e822ec5
update workflow
Mar 9, 2021
1358ae5
update workflow
Mar 9, 2021
6c29e97
update readme and chart
Mar 10, 2021
8b94868
Update README.md
HamzaZo Mar 10, 2021
2e211a0
update readme
Mar 10, 2021
7b24f75
Update README.md
HamzaZo Mar 10, 2021
e969275
Update README.md
HamzaZo Mar 10, 2021
d0e9250
Update README.md
HamzaZo Mar 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/lint-helm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Lint: helm chart"
on:
push:
branches:
- '**'
paths:
- '.github/workflows/lint-helm.yml'
workflow_dispatch:

jobs:
helm3-lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Helm
uses: azure/setup-helm@v1

- name: Helm lint
run: helm lint charts/azure-resourcemanager-exporter
30 changes: 30 additions & 0 deletions .github/workflows/publish-helm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Publish: helm chart"
on:
push:
tags:
- '*'
paths:
- '.github/workflows/publish-helm.yml'
workflow_dispatch:

jobs:
publish-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 "[email protected]"

- name: Set up Helm
uses: azure/setup-helm@v1

- name: Publish Helm charts
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,34 @@ Azure ResourceManager Exporter

Prometheus exporter for Azure Resources and information.

Configuration
Installation
-------------

[Helm 3](https://helm.sh/) must be installed to use the chart. Once Helm is set up properly, add the repo as follows:

```shell
$ helm repo add azure-resourcemanager-exporter https://carrefour-group.github.io/azure-resourcemanager-exporter
$ helm repo update
```

Install Chart
-------------
The chart can be installed as follows:
```shell
$ helm install [RELEASE_NAME] azure-resourcemanager-exporter/azure-resourcemanager-exporter
```

Uninstall Chart
-------------
To uninstall the chart

```shell
$ helm uninstall [RELEASE_NAME]
```

Exporter Configuration
---------------------

Normally no configuration is needed but can be customized using environment variables.

| Environment variable | DefaultValue | Description |
Expand Down Expand Up @@ -85,3 +110,14 @@ Metrics
| `azurerm_iam_principal_info` | IAM | Azure IAM Principal information |
| `azurerm_graph_app_info` | Graph | AzureAD graph application information |
| `azurerm_graph_app_credential` | Graph | AzureAD graph application credentials (create,expiry) information |


Contributing
------------
We welcome any contributions from the community with open arms. If you're planning a new feature, please file an issue to discuss first.

How to Release
--------------
To release a new version of the helm chart, you need to bump:
* `appVersion` and `version` fields in `Chart.yaml` file.
* `image.tag` in `values.yaml` file.
5 changes: 5 additions & 0 deletions charts/azure-resourcemanager-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
description: Prometheus Azure Resource Manager Exporter
name: azure-resourcemanager-exporter
version: 20.11.1
appVersion: 20.11.1
10 changes: 10 additions & 0 deletions charts/azure-resourcemanager-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Thank you for installing {{ .Chart.Name }}.

Your release is named {{ .Release.Name }}.

To learn more about the release, try:

$ helm status {{ .Release.Name }}
$ helm get all {{ .Release.Name }}

You can find more documentation here: https://github.com/webdevops/azure-resourcemanager-exporter
53 changes: 53 additions & 0 deletions charts/azure-resourcemanager-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "azure-resourcemanager-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).
*/}}
{{- define "azure-resourcemanager-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 "azure-resourcemanager-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use.
*/}}
{{- define "azure-resourcemanager-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "azure-resourcemanager-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for ingress.
*/}}
{{- define "ingress.apiVersion" -}}
{{- if semverCompare ">=1.14.0-0" .Capabilities.KubeVersion.GitVersion }}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "extensions/v1beta1" -}}
{{- end -}}
{{- end -}}
108 changes: 108 additions & 0 deletions charts/azure-resourcemanager-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "azure-resourcemanager-exporter.fullname" . }}
{{- with .Values.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "azure-resourcemanager-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "azure-resourcemanager-exporter.chart" . }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "azure-resourcemanager-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
strategy:
{{ toYaml .Values.strategy | indent 4 }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "azure-resourcemanager-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "azure-resourcemanager-exporter.chart" . }}
{{- if .Values.pod.labels }}
{{ toYaml .Values.pod.labels | indent 8 }}
{{- end }}
annotations:
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "azure-resourcemanager-exporter.serviceAccountName" . }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations:
{{ toYaml .Values.tolerations | indent 6 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
containers:
- name: azure-resourcemanager-exporter
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.securityContext.enabled }}
securityContext:
readOnlyRootFilesystem: {{ .Values.securityContext.readOnlyRootFilesystem }}
runAsNonRoot: {{ .Values.securityContext.runAsNonRoot }}
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}
env:
{{- if .Values.credentials.useSecret }}
- name: AZURE_SUBSCRIPTION_ID
valueFrom:
secretKeyRef:
name: {{ .Values.credentials.name }}
key: AZURE_SUBSCRIPTION_ID
- name: AZURE_TENANT_ID
valueFrom:
secretKeyRef:
name: {{ .Values.credentials.name }}
key: AZURE_TENANT_ID
- name: AZURE_CLIENT_ID
valueFrom:
secretKeyRef:
name: {{ .Values.credentials.name }}
key: AZURE_CLIENT_ID
- name: AZURE_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: {{ .Values.credentials.name }}
key: AZURE_CLIENT_SECRET
{{ end }}
{{- range $key, $value := .Values.extraEnv }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
args:
{{- if .Values.extraArgs }}
{{ toYaml .Values.extraArgs | indent 12 }}
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
ports:
- containerPort: {{ .Values.containerPort }}
name: http
livenessProbe:
{{- toYaml .Values.livenessProbe | trim | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | trim | nindent 12 }}
28 changes: 28 additions & 0 deletions charts/azure-resourcemanager-exporter/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.ingress.enabled -}}
apiVersion: {{ template "ingress.apiVersion" . }}
kind: Ingress
metadata:
name: {{ template "azure-resourcemanager-exporter.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "azure-resourcemanager-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "azure-resourcemanager-exporter.chart" . }}
annotations:
{{ toYaml .Values.ingress.annotations | indent 4 }}
spec:
rules:
{{- range $host := .Values.ingress.hosts }}
- host: {{ $host }}
http:
paths:
- path: {{ $.Values.ingress.path }}
backend:
serviceName: {{ template "azure-resourcemanager-exporter.fullname" $ }}
servicePort: {{ $.Values.service.port }}
{{- end -}}
{{- if $.Values.ingress.tls }}
tls:
{{ toYaml $.Values.ingress.tls | indent 4 }}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if .Values.prometheusRule.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ template "azure-resourcemanager-exporter.fullname" . }}
{{- with .Values.prometheusRule.namespace }}
namespace: {{ . }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "azure-resourcemanager-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "azure-resourcemanager-exporter.chart" . }}
{{- with .Values.prometheusRule.additionalLabels -}}
{{- toYaml . | nindent 4 -}}
{{- end }}
spec:
{{- with .Values.prometheusRule.rules }}
groups:
- name: {{ template "azure-resourcemanager-exporter.name" $ }}
rules: {{ tpl (toYaml .) $ | nindent 8 }}
{{- end }}
{{- end }}
30 changes: 30 additions & 0 deletions charts/azure-resourcemanager-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
kind: Service
apiVersion: v1
metadata:
name: {{ template "azure-resourcemanager-exporter.fullname" . }}
{{- if .Values.service.annotations }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "azure-resourcemanager-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "azure-resourcemanager-exporter.chart" . }}
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | indent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- name: http
port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
{{- if .Values.service.externalIPs }}
externalIPs:
{{ toYaml .Values.service.externalIPs | indent 4 }}
{{- end }}
selector:
app.kubernetes.io/name: {{ include "azure-resourcemanager-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "azure-resourcemanager-exporter.serviceAccountName" . }}
labels:
app.kubernetes.io/name: {{ include "azure-resourcemanager-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "azure-resourcemanager-exporter.chart" . }}
annotations:
{{ toYaml .Values.serviceAccount.annotations | indent 4 }}
{{- end -}}
Loading