Skip to content

Commit

Permalink
Improvements (#33)
Browse files Browse the repository at this point in the history
- Allow specifying args for aerospike container
- Allow configuration of labels and annotations for services
- Pass feature key file as a base64 encoded string
- Pass aerospike configuration file as a base64 encoded string
- Configure labels, annotations for Prometheus, Alertmanager, Grafana statefulset and pods
- Pass Aerospike alert rules and Alertmanager configuration file as a base64 encoded string
  • Loading branch information
spkesan authored Apr 7, 2021
1 parent 2ad9d4a commit 04b1545
Show file tree
Hide file tree
Showing 15 changed files with 241 additions and 68 deletions.
72 changes: 26 additions & 46 deletions helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,50 +35,22 @@ For Helm v2,
helm install --name aerospike-release aerospike/aerospike --set dbReplicas=5
```

### Test Output:

```sh
NAME: aerospike-release
LAST DEPLOYED: Fri Mar 6 15:50:33 2020
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/ConfigMap
NAME DATA AGE
aerospike-release-conf 2 51m

==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
pod/aerospike-release-aerospike-0 1/1 Running 0 49m
pod/aerospike-release-aerospike-1 1/1 Running 0 49m
pod/aerospike-release-aerospike-2 1/1 Running 0 48m

==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/aerospike-release-aerospike ClusterIP None <none> 3000/TCP 49m

==> v1/StatefulSet
NAME READY AGE
statefulset.apps/aerospike-release-aerospike 3/3 49m
```

```sh
$ helm list
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
aerospike-release 1 Fri Mar 6 15:50:33 2020 DEPLOYED aerospike-5.0.0 5.0.0.4 default
```

### Apply custom Aerospike configuration

- To override the default `aerospike.template.conf`, set `confFilePath` to point to the custom `aerospike.conf` file or template.
- To override the default `aerospike.template.conf`, set `aerospikeConfFile` to point to the custom `aerospike.conf` file or template.

> `confFilePath` should be a file path on helm "client" machine (where the user is running the command `helm install`).
> `aerospikeConfFile` should be a file path on helm "client" machine (where the user is running the command `helm install`).

- `confFilePath` can be set using `--set-file` option,
- `aerospikeConfFile` can be set using `--set-file` option,
```sh
helm install aerospike-release aerospike/aerospike \
--set-file confFilePath=/tmp/aerospike_templates/aerospike.template.conf
--set-file aerospikeConfFile=/tmp/aerospike_templates/aerospike.template.conf
```

- Aerospike configuration file can also be passed in base64 encoded form. Use `aerospikeConfFileBase64` configuration to specify base64 encoded string of the Aerospike configuration file.
```sh
helm install aerospike-release aerospike/aerospike \
--set aerospikeConfFileBase64=$(base64 /tmp/aerospike_templates/aerospike.template.conf)
```

### Storage configuration
Expand Down Expand Up @@ -303,13 +275,17 @@ helm install --name aerospike-release aerospike/aerospike \
--set enableAerospikeMonitoring=true
```

Use option `--set-file prometheus.aerospikeAlertRulesFilePath` to add a custom aerospike alert rules configuration file.
Use option `--set-file prometheus.aerospikeAlertRulesFile` to add a custom aerospike alert rules configuration file.

> `prometheus.aerospikeAlertRulesFile` should be a file path on helm "client" machine (where the user is running 'helm install')

Aerospike alert rules file can also be passed in base64 encoded form. Use `prometheus.aerospikeAlertRulesFileBase64` configuration to specify base64 encoded string of the Aerospike alert rules file.

> `prometheus.aerospikeAlertRulesFilePath` should be a file path on helm "client" machine (where the user is running 'helm install')
Use option `--set-file alertmanager.alertmanagerConfFile` to add an alertmanager configuration file.

Use option `--set-file alertmanager.alertmanagerConfFilePath` to add an alertmanager configuration file.
> `alertmanager.alertmanagerConfFile` should be a file path on helm "client" machine (where the user is running 'helm install')

> `alertmanager.alertmanagerConfFilePath` should be a file path on helm "client" machine (where the user is running 'helm install')
Alertmanager configuration file can also be passed in base64 encoded form. Use `alertmanager.alertmanagerConfFileBase64` configuration to specify base64 encoded string of the alertmanager configuration file.

Check the below [configuration section](#configuration) or [`values.yaml`](values.yaml) file for more details on configuration of the `Aerospike Prometheus Exporter`, `Prometheus`, `Grafana` and `Alertmanager`.

Expand All @@ -325,7 +301,7 @@ Check the below [configuration section](#configuration) or [`values.yaml`](value
| `image.repository` | Aerospike Server Docker Image | `aerospike/aerospike-server` |
| `image.tag` | Aerospike Server Docker Image Tag | `5.4.0.3` |
| `initImage.repository` | Aerospike Kubernetes Init Container Image | `aerospike/aerospike-kubernetes-init` |
| `initImage.tag` | Aerospike Kubernetes Init Container Image Tag | `latest` |
| `initImage.tag` | Aerospike Kubernetes Init Container Image Tag | `latest` |
| `autoGenerateNodeIds` | Auto generate and assign node-id(s) based on Pod's Ordinal Index | `true` |
| `nodeIDPrefix` | Node ID prefix | `a` |
| `aerospikeNamespace` | Aerospike Namespace name | `test` |
Expand All @@ -336,6 +312,7 @@ Check the below [configuration section](#configuration) or [`values.yaml`](value
| `aerospikeHeartbeatPort` | Aerospike TCP Hearbeat Port | `3002` |
| `aerospikeFabricPort` | Aerospike TCP Fabric Port | `3001` |
| `aerospikeInfoPort` | Aerospike TCP Info Port | `3003` |
| `args` | Define additional arguments to be passed to the Aerospike container | `[]` |
| `autoRolloutConfig` | Rollout ConfigMap/Secrets changes on 'helm upgrade' | `false` |
| `hostNetwork.enabled` | Enable `hostNetwork`. Allows Pods to access host network. | `false` |
| `hostNetwork.useExternalIP` | Allow applications to connect using external IP of the instances | `false` |
Expand All @@ -360,9 +337,12 @@ Check the below [configuration section](#configuration) or [`values.yaml`](value
| `resources` | Resource configuration (`requests` and `limits`) | `{}` (nil) |
| `podSecurityContext` | Aerospike pod security context | `{}` (nil) |
| `securityContext` | Aerospike container security context | `{}` (nil) |
| `confFilePath` | Custom aerospike.conf file path on helm client machine (To be used during the runtime, `helm install` .. etc) | `not defined` |
| `prometheus.aerospikeAlertRulesFilePath` | Aerospike alert rules configuration file location on helm client machine (To be used during the runtime, `helm install` .. etc) | `not defined` |
| `alertmanager.alertmanagerConfFilePath` | Alertmanager configuration file location on helm client machine (To be used during the runtime, `helm install` .. etc) | `not defined` |
| `aerospikeConfFile` | Custom aerospike.conf file path on helm client machine (To be used during the runtime, `helm install` .. etc) | `not defined` |
| `aerospikeConfFileBase64` | Custom Aerospike configuration file as base64 encoded string | `"" (not defined)` |
| `prometheus.aerospikeAlertRulesFile` | Aerospike alert rules configuration file location on helm client machine (To be used during the runtime, `helm install` .. etc) | `not defined` |
| `prometheus.aerospikeAlertRulesFileBase64` | Aerospike alert rules file as base64 encoded string | `"" (not defined)` |
| `alertmanager.alertmanagerConfFile` | Alertmanager configuration file location on helm client machine (To be used during the runtime, `helm install` .. etc) | `not defined` |
| `alertmanager.alertmanagerConfFileBase64` | Alertmanager configuration file as base64 encoded string | `"" (not defined)` |
| `enableAerospikePrometheusExporter` | Enable Sidecar Aerospike Prometheus Exporter (only) | `false` |
| `enableAerospikeMonitoring` | Enable Aerospike Monitoring - sidecar prometheus exporter, Prometheus, Grafana, Alertmanager stack | `false` |
| `exporter.repository` | Aerospike prometheus exporter image repository | `aerospike/aerospike-prometheus-exporter` |
Expand Down
4 changes: 3 additions & 1 deletion helm/files/alertmanager.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This is an example alertmanager.yaml which sends alert notifications to a slack channel.
# Use "--set-file alertmanager.alertmanagerConfFilePath=<ConfigFilePath>" during "helm install" or "helm upgrade" to use custom alertmanager.yaml.
# Use "--set-file alertmanager.alertmanagerConfFile=<ConfigFilePath>" during "helm install" or "helm upgrade" to use custom alertmanager.yaml.
# or,
# Use "--set alertmanager.alertmanagerConfFileBase64=<base64-encoded-alertmanager-conf-file>" during "helm install" or "helm upgrade" to use custom alertmanager.yaml.

global:
slack_api_url: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
Expand Down
7 changes: 1 addition & 6 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ Define aerospike.name
Define aerospike.fullname
*/}}
{{- define "aerospike.fullname" -}}
{{- $name := default .Chart.Name -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Expand Down
23 changes: 23 additions & 0 deletions helm/templates/alertmanager-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,34 @@ metadata:
release: {{ .Release.Name }}
app.kubernetes.io/component: alertmanager
data:
# default alertmanager configuration file
{{ if .Files.Get "files/alertmanager.yaml" }}
alertmanager.yaml: {{ tpl (.Files.Get "files/alertmanager.yaml") . | quote }}
{{ end }}

{{- if and .Values.alertmanager.alertmanagerConfFilePath .Values.alertmanager.alertmanagerConfFile }}
{{ fail "Both legacy(alertmanager.alertmanagerConfFilePath) and new(alertmanager.alertmanagerConfFile) are configured! Use only one!" }}
{{- end }}

{{- if and (or .Values.alertmanager.alertmanagerConfFilePath .Values.alertmanager.alertmanagerConfFile) (.Values.alertmanager.alertmanagerConfFileBase64) }}
{{ fail "Both alertmanager.alertmanagerConfFilePath/alertmanager.alertmanagerConfFile and alertmanager.alertmanagerConfFileBase64 are configured! Use only one!" }}
{{- end }}

# old config for alertmanager configuration file
{{ if (.Values.alertmanager.alertmanagerConfFilePath) }}
alertmanager.yaml: |-
{{ .Values.alertmanager.alertmanagerConfFilePath | nindent 4 | trim }}
{{ end }}

# new config for alertmanager configuration file
{{ if (.Values.alertmanager.alertmanagerConfFile) }}
alertmanager.yaml: |-
{{ .Values.alertmanager.alertmanagerConfFile | nindent 4 | trim }}
{{ end }}

# alertmanager configuration file provided as base64 encoded string
{{ if (.Values.alertmanager.alertmanagerConfFileBase64) }}
alertmanager.yaml: |-
{{ .Values.alertmanager.alertmanagerConfFileBase64 | b64dec | nindent 4 | trim }}
{{ end }}
{{- end }}
16 changes: 14 additions & 2 deletions helm/templates/alertmanager-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ metadata:
release: {{ .Release.Name }}
app.kubernetes.io/component: alertmanager
unique-app: {{ .Release.Name }}-alertmanager
{{- with .Values.alertmanager.labels }}{{ toYaml . | nindent 4 }}{{ end }}
{{- with .Values.alertmanager.annotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
spec:
serviceName: {{ .Release.Name }}-alertmanager-operated
replicas: {{ .Values.alertmanager.replicas }}
Expand All @@ -34,15 +38,20 @@ spec:
type: {{ .Values.alertmanager.updateStrategy.type }}
revisionHistoryLimit: 10
selector:
matchLabels: *Labels
matchLabels:
<<: *Labels
{{- with .Values.alertmanager.podLabels }}{{ toYaml . | nindent 6 }}{{ end }}
template:
metadata:
labels: *Labels
labels:
<<: *Labels
{{- with .Values.alertmanager.podLabels }}{{ toYaml . | nindent 8 }}{{ end }}
annotations:
{{- if .Values.autoRolloutConfig }}
# TODO: Add an entry for secrets when used in future
checksum/config: {{ include (print $.Template.BasePath "/alertmanager-configmap.yaml") . | sha256sum }}
{{- end }}
{{- with .Values.alertmanager.podAnnotations }}{{ toYaml . | nindent 8 }}{{ end }}
spec:
serviceAccountName: {{ if .Values.rbac.create }}{{ template "aerospike.fullname" . }}{{ else }}{{ .Values.rbac.serviceAccountName }}{{ end }}
{{- if eq .Values.alertmanager.antiAffinity "hard" }}
Expand Down Expand Up @@ -158,6 +167,9 @@ spec:
- metadata:
name: {{ .Values.alertmanager.persistenceStorage.name }}
labels: *Labels
{{- with $.Values.alertmanager.annotations }}
annotations: {{- toYaml . | nindent 10 }}
{{- end }}
spec:
volumeMode: {{ .Values.alertmanager.persistenceStorage.volumeMode }}
accessModes:
Expand Down
Loading

0 comments on commit 04b1545

Please sign in to comment.