Skip to content

Commit

Permalink
Populate etcd config file with env vars (CASMINST-6572) (#34)
Browse files Browse the repository at this point in the history
Also add a test chart that we can use without disturbing real products.

Co-authored-by: Brad Klein <[email protected]>
  • Loading branch information
bklei and Brad Klein authored Aug 2, 2023
1 parent 02bb2f4 commit f36886c
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 5 deletions.
7 changes: 5 additions & 2 deletions Jenkinsfile.github
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ pipeline {
getChartVersion(name: "cray-etcd-backup", chartDirectory: "charts", isStable: env.IS_STABLE),
getChartVersion(name: "cray-etcd-defrag", chartDirectory: "charts", isStable: env.IS_STABLE),
getChartVersion(name: "cray-etcd-base", chartDirectory: "charts", isStable: env.IS_STABLE),
getChartVersion(name: "cray-etcd-migration-setup", chartDirectory: "charts", isStable: env.IS_STABLE)
getChartVersion(name: "cray-etcd-migration-setup", chartDirectory: "charts", isStable: env.IS_STABLE),
getChartVersion(name: "cray-etcd-test", chartDirectory: "charts", isStable: env.IS_STABLE)
].join(" ")
}
steps {
sh "make"
withCredentials([usernamePassword(credentialsId: 'artifactory-algol60-readonly', passwordVariable: 'ARTIFACTORY_PASSWORD', usernameVariable: 'ARTIFACTORY_USERNAME')]) {
sh "make"
}
}
}

Expand Down
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@ HELM_IMAGE ?= artifactory.algol60.net/csm-docker/stable/docker.io/alpine/helm:3.
HELM_UNITTEST_IMAGE ?= artifactory.algol60.net/csm-docker/stable/docker.io/quintush/helm-unittest:latest
HELM_DOCS_IMAGE ?= artifactory.algol60.net/csm-docker/stable/docker.io/jnorwood/helm-docs:v1.5.0

ifeq ($(shell uname -s),Darwin)
HELM_CONFIG_HOME ?= $(HOME)/Library/Preferences/helm
else
HELM_CONFIG_HOME ?= $(HOME)/.config/helm
endif
COMMA := ,

all: dep-up lint test package

helm:
docker run --rm \
--user $(shell id -u):$(shell id -g) \
--mount type=bind,src="$(shell pwd)",dst=/src \
$(if $(wildcard $(HELM_CONFIG_HOME)/.),--mount type=bind$(COMMA)src=$(HELM_CONFIG_HOME)$(COMMA)dst=/tmp/.helm/config) \
-w /src \
-e HELM_CACHE_HOME=/src/.helm/cache \
-e HELM_CONFIG_HOME=/src/.helm/config \
-e HELM_CONFIG_HOME=/tmp/.helm/config \
-e HELM_DATA_HOME=/src/.helm/data \
$(HELM_IMAGE) \
$(CMD)
Expand All @@ -24,12 +32,14 @@ lint:
CMD="lint charts/cray-etcd-defrag" $(MAKE) helm
CMD="lint charts/cray-etcd-base" $(MAKE) helm
CMD="lint charts/cray-etcd-migration-setup" $(MAKE) helm
CMD="lint charts/cray-etcd-test" $(MAKE) helm

dep-up:
CMD="dep up charts/cray-etcd-backup" $(MAKE) helm
CMD="dep up charts/cray-etcd-defrag" $(MAKE) helm
CMD="dep up charts/cray-etcd-base" $(MAKE) helm
CMD="dep up charts/cray-etcd-migration-setup" $(MAKE) helm
CMD="dep up charts/cray-etcd-test" $(MAKE) helm

test:
docker run --rm \
Expand All @@ -39,14 +49,16 @@ test:
cray-etcd-backup \
cray-etcd-defrag \
cray-etcd-base \
cray-etcd-migration-setup
cray-etcd-migration-setup \
cray-etcd-test

package:
ifdef CHART_VERSIONS
CMD="package charts/cray-etcd-backup --version $(word 1, $(CHART_VERSIONS)) -d packages" $(MAKE) helm
CMD="package charts/cray-etcd-defrag --version $(word 2, $(CHART_VERSIONS)) -d packages" $(MAKE) helm
CMD="package charts/cray-etcd-base --version $(word 3, $(CHART_VERSIONS)) -d packages" $(MAKE) helm
CMD="package charts/cray-etcd-migration-setup --version $(word 4, $(CHART_VERSIONS)) -d packages" $(MAKE) helm
CMD="package charts/cray-etcd-test --version $(word 4, $(CHART_VERSIONS)) -d packages" $(MAKE) helm
else
CMD="package charts/* -d packages" $(MAKE) helm
endif
Expand All @@ -65,6 +77,7 @@ images:
CHART=charts/cray-etcd-defrag $(MAKE) -s extracted-images annotated-images; \
CHART=charts/cray-etcd-base $(MAKE) -s extracted-images annotated-images; \
CHART=charts/cray-etcd-migration-setup $(MAKE) -s extracted-images annotated-images; \
CHART=charts/cray-etcd-test $(MAKE) -s extracted-images annotated-images; \
} | sort -u

snyk:
Expand Down
2 changes: 1 addition & 1 deletion charts/cray-etcd-base/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#
apiVersion: v2
name: cray-etcd-base
version: 1.0.10
version: 1.0.11
description: This chart should never be installed directly, instead it is intended to be a sub-chart.
home: https://github.com/Cray-HPE/cray-etcd
dependencies:
Expand Down
5 changes: 5 additions & 0 deletions charts/cray-etcd-base/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ data:
advertise-client-urls: {{ printf "%s://POD_NAME.%s.%s.svc.%s:%d" $etcdPeerProtocol $etcdHeadlessServiceName $releaseNamespace $clusterDomain $clientPort }}
listen-client-urls: http://0.0.0.0:{{ $clientPort }}
data-dir: /bitnami/etcd/data
{{- if .Values.etcd.extraEnvVars }}
{{- range $key, $value := .Values.etcd.extraEnvVars }}
{{ index $value "name" | replace "ETCD_" "" | replace "_" "-" | lower | indent 4 }}: {{ index $value "value" }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/cray-etcd-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.lock
charts
43 changes: 43 additions & 0 deletions charts/cray-etcd-test/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#
# MIT License
#
# (C) Copyright 2023 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
apiVersion: v2
appVersion: 1.0.0
dependencies:
- name: cray-service
version: "~10.0.0"
repository: https://artifactory.algol60.net/artifactory/csm-helm-charts
- name: cray-etcd-base
version: "~1.0.0"
repository: https://artifactory.algol60.net/artifactory/csm-helm-charts
description: "Test etcd chart"
home: "https://github.com/Cray-HPE/cray-etcd-test"
keywords:
- cray-etcd-test
maintainers:
- name: bklein
email: [email protected]
name: cray-etcd-test
sources:
- "https://github.com/Cray-HPE/cray-etcd-test"
version: 1.0.0
13 changes: 13 additions & 0 deletions charts/cray-etcd-test/files/etcd-load.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Create a file with random text data
dd if=/dev/urandom bs=1K count=512 | tr -dc 'a-zA-Z0-9' > data

# Load the data into etcd
for i in {1..8192}; do
echo "$i"
etcdctl put "key-$i" "$(cat data)"
done

# Delete the data file
rm data
32 changes: 32 additions & 0 deletions charts/cray-etcd-test/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# MIT License
#
# (C) Copyright 2023 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
---
apiVersion: v1
kind: ConfigMap
metadata:
name: cray-etcd-test-config
namespace: {{ .Release.Namespace }}
data:
etcd-load.sh: |-
{{- .Files.Get "files/etcd-load.sh" | nindent 4 }}
86 changes: 86 additions & 0 deletions charts/cray-etcd-test/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
cray-service:
type: Deployment
nameOverride: cray-etcd-test
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- cray-etcd-test
topologyKey: "kubernetes.io/hostname"
replicaCount: 3
strategy:
rollingUpdate:
maxUnavailable: 50%
type: RollingUpdate
containers:
busybox:
name: busybox
image:
repository: artifactory.algol60.net/csm-docker/stable/docker.io/library/busybox
tag: 1.28.0-glibc
command: ["sleep", "60000"]
etcdWaitContainer: true
cray-etcd-base:
nameOverride: cray-etcd-test
etcd:
image:
registry: artifactory.algol60.net
repository: csm-docker/stable/docker.io/bitnami/etcd
tag: 3.5.9-debian-11-r15-patch
debug: true
disasterRecovery:
cronjob:
snapshotsDir: "/snapshots/cray-etcd-test-bitnami-etcd"
schedule: "0 */1 * * *"
historyLimit: 1
snapshotHistoryLimit: 24
enabled: true
fullnameOverride: "cray-etcd-test-bitnami-etcd"
persistence:
enabled: true
accessModes:
- "ReadWriteOnce"
size: 4Gi
extraEnvVars:
- name: ETCD_HEARTBEAT_INTERVAL
value: "4200"
- name: ETCD_ELECTION_TIMEOUT
value: "21000"
- name: ETCD_MAX_SNAPSHOTS
value: "1"
- name: ETCD_QUOTA_BACKEND_BYTES
value: "10737418240"
- name: ETCD_SNAPSHOT_COUNT
value: "5000000"
- name: ETCD_SNAPSHOT_HISTORY_LIMIT
value: "24"
- name: ETCD_DISABLE_PRESTOP
value: "yes"
autoCompactionMode: revision
autoCompactionRetention: "100000"
extraVolumeMounts:
- name: cray-etcd-test-config
mountPath: /usr/local/sbin
readOnly: true
- name: etcd-config
mountPath: /csm
extraVolumes:
- configMap:
defaultMode: 420
name: cray-etcd-test-bitnami-etcd-config
name: etcd-config
- configMap:
defaultMode: 0755
name: cray-etcd-test-config
name: cray-etcd-test-config
resources:
limits:
cpu: 4
memory: 8Gi
requests:
cpu: 10m
memory: 64Mi
27 changes: 27 additions & 0 deletions ct.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,29 @@
#
# MIT License
#
# (C) Copyright 2023 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
chart-dirs:
- charts
chart-repos:
- stable=https://charts.helm.sh/stable
- csm-algol60=https://artifactory.algol60.net/artifactory/csm-helm-charts/
all: true

0 comments on commit f36886c

Please sign in to comment.