Skip to content

Commit ab1e4a9

Browse files
committed
feat: convert services to new install script template
1 parent 82b4ae6 commit ab1e4a9

File tree

5 files changed

+201
-222
lines changed

5 files changed

+201
-222
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Helm GitHub Actions for redis-sentinel
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- base-helm-configs/redis-sentinel/**
7+
- base-kustomize/redis-sentinel/**
8+
- .github/workflows/helm-redis-sentinel.yaml
9+
jobs:
10+
helm:
11+
strategy:
12+
matrix:
13+
overlays:
14+
- base
15+
name: Helm
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
- uses: azure/setup-helm@v3
21+
with:
22+
version: latest
23+
token: "${{ secrets.GITHUB_TOKEN }}"
24+
id: helm
25+
- name: Add ot-helm (redis) to helm
26+
run: |
27+
${{ steps.helm.outputs.helm-path }} repo add ot-helm https://ot-container-kit.github.io/helm-charts/
28+
${{ steps.helm.outputs.helm-path }} repo update
29+
- name: Run Helm Template
30+
run: |
31+
${{ steps.helm.outputs.helm-path }} template redis-sentinel ot-helm/redis-sentinel \
32+
--create-namespace \
33+
--namespace=redis-system \
34+
-f ${{ github.workspace }}//base-helm-configs/redis-sentinel/redis-sentinel-helm-overrides.yaml \
35+
--post-renderer ${{ github.workspace }}/base-kustomize/kustomize.sh \
36+
--post-renderer-args redis-sentinel/${{ matrix.overlays }} > /tmp/rendered.yaml
37+
- name: Return helm Build
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: helm-redis-sentinel-artifact-${{ matrix.overlays }}
41+
path: /tmp/rendered.yaml
Lines changed: 0 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -1,178 +1,11 @@
11
---
22
redisSentinel:
3-
name: ""
4-
clusterSize: 3
53
image: quay.io/opstree/redis-sentinel
64
tag: v8.2.2
7-
imagePullPolicy: IfNotPresent
8-
imagePullSecrets: []
9-
# - name: Secret with Registry credentials
10-
redisSecret:
11-
secretName: ""
12-
secretKey: ""
13-
serviceType: ClusterIP
145
resources: {}
156
# requests:
167
# cpu: 100m
178
# memory: 128Mi
189
# limits:
1910
# cpu: 100m
2011
# memory: 128Mi
21-
ignoreAnnotations: []
22-
# - "redis.opstreelabs.in/ignore"
23-
minReadySeconds: 0
24-
# -- Some fields of statefulset are immutable, such as volumeClaimTemplates.
25-
# When set to true, the operator will delete the statefulset and recreate it. Default is false.
26-
recreateStatefulSetOnUpdateInvalid: false
27-
28-
# Overwite name for resources
29-
# name: ""
30-
31-
labels: {}
32-
# foo: bar
33-
# test: echo
34-
35-
redisSentinelConfig:
36-
redisReplicationName: "redis-replication"
37-
redisReplicationPassword:
38-
secretName: ""
39-
secretKey: ""
40-
masterGroupName: ""
41-
resolveHostnames: ""
42-
announceHostnames: ""
43-
redisPort: ""
44-
quorum: ""
45-
parallelSyncs: ""
46-
failoverTimeout: ""
47-
downAfterMilliseconds: ""
48-
49-
externalConfig:
50-
enabled: false
51-
data: |
52-
tcp-keepalive 400
53-
slowlog-max-len 158
54-
stream-node-max-bytes 2048
55-
56-
externalService:
57-
enabled: false
58-
# annotations:
59-
# foo: bar
60-
serviceType: NodePort
61-
port: 26379
62-
#nodePort: 31000
63-
64-
serviceMonitor:
65-
enabled: false
66-
interval: 30s
67-
scrapeTimeout: 10s
68-
namespace: monitoring
69-
# -- extraLabels are added to the servicemonitor when enabled set to true
70-
extraLabels: {}
71-
# foo: bar
72-
# team: devops
73-
74-
redisExporter:
75-
enabled: false
76-
image: quay.io/opstree/redis-exporter
77-
tag: "v1.44.0"
78-
imagePullPolicy: IfNotPresent
79-
resources: {}
80-
# requests:
81-
# cpu: 100m
82-
# memory: 128Mi
83-
# limits:
84-
# cpu: 100m
85-
# memory: 128Mi
86-
env: []
87-
# - name: VAR_NAME
88-
# value: "value1"
89-
securityContext: {}
90-
91-
initContainer:
92-
enabled: false
93-
image: ""
94-
imagePullPolicy: "IfNotPresent"
95-
resources: {}
96-
# requests:
97-
# memory: "64Mi"
98-
# cpu: "250m"
99-
# limits:
100-
# memory: "128Mi"
101-
# cpu: "500m"
102-
env: []
103-
command: []
104-
args: []
105-
106-
sidecars:
107-
name: ""
108-
image: ""
109-
imagePullPolicy: "IfNotPresent"
110-
resources:
111-
limits:
112-
cpu: "100m"
113-
memory: "128Mi"
114-
requests:
115-
cpu: "50m"
116-
memory: "64Mi"
117-
env: []
118-
# - name: MY_ENV_VAR
119-
# value: "my-env-var-value"
120-
121-
priorityClassName: ""
122-
123-
nodeSelector: {}
124-
# memory: medium
125-
126-
podSecurityContext:
127-
runAsUser: 1000
128-
fsGroup: 1000
129-
130-
securityContext: {}
131-
132-
affinity: {}
133-
# nodeAffinity:
134-
# requiredDuringSchedulingIgnoredDuringExecution:
135-
# nodeSelectorTerms:
136-
# - matchExpressions:
137-
# - key: disktype
138-
# operator: In
139-
# values:
140-
# - ssd
141-
142-
tolerations: []
143-
# - key: "key"
144-
# operator: "Equal"
145-
# value: "value"
146-
# effect: "NoSchedule"
147-
148-
serviceAccountName: ""
149-
150-
TLS:
151-
ca: ca.key
152-
cert: tls.crt
153-
key: tls.key
154-
secret:
155-
secretName: ""
156-
157-
pdb:
158-
enabled: false
159-
minAvailable: 1
160-
maxUnavailable: null
161-
162-
livenessProbe:
163-
failureThreshold: 3
164-
initialDelaySeconds: 1
165-
periodSeconds: 10
166-
successThreshold: 1
167-
timeoutSeconds: 1
168-
169-
readinessProbe:
170-
failureThreshold: 3
171-
initialDelaySeconds: 1
172-
periodSeconds: 10
173-
successThreshold: 1
174-
timeoutSeconds: 1
175-
176-
env: []
177-
# - name: VAR_NAME
178-
# value: "value1"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sortOptions:
2+
order: fifo
3+
resources:
4+
- all.yaml

bin/install-argocd.sh

Lines changed: 78 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,96 @@
11
#!/bin/bash
2+
# Description: Fetches the version for SERVICE_NAME from the specified
3+
# YAML file and executes a helm upgrade/install command with dynamic values files.
24

3-
# Default parameter value
4-
TARGET=${1:-base}
5+
# Disable SC2124 (unused array), SC2145 (array expansion issue), SC2294 (eval)
6+
# shellcheck disable=SC2124,SC2145,SC2294
57

6-
# Directory to check for YAML files
7-
CONFIG_DIR="/etc/genestack/helm-configs/argocd"
8+
# Service
9+
SERVICE_NAME="argocd"
10+
SERVICE_NAMESPACE="argocd"
811

9-
# Read argocd version from helm-chart-versions.yaml
12+
# Helm
13+
HELM_REPO_NAME="bitnami"
14+
HELM_REPO_URL="https://charts.bitnami.com/bitnami"
15+
16+
# Base directories provided by the environment
17+
GENESTACK_BASE_DIR="${GENESTACK_BASE_DIR:-/opt/genestack}"
18+
GENESTACK_OVERRIDES_DIR="${GENESTACK_OVERRIDES_DIR:-/etc/genestack}"
19+
20+
# Define service-specific override directories based on the framework
21+
SERVICE_BASE_OVERRIDES="${SERVICE_BASE_OVERRIDES:-$GENESTACK_BASE_DIR/base-helm-configs/$SERVICE_NAME}"
22+
SERVICE_CUSTOM_OVERRIDES="${SERVICE_CUSTOM_OVERRIDES:-$GENESTACK_OVERRIDES_DIR/helm-configs/$SERVICE_NAME}"
23+
24+
# Read the desired chart version from VERSION_FILE
1025
VERSION_FILE="/etc/genestack/helm-chart-versions.yaml"
26+
1127
if [ ! -f "$VERSION_FILE" ]; then
12-
echo "Error: helm-chart-versions.yaml not found at $VERSION_FILE"
28+
echo "Error: helm-chart-versions.yaml not found at $VERSION_FILE" >&2
1329
exit 1
1430
fi
1531

16-
# Extract argocd version using grep and sed
17-
ARGOCD_VERSION=$(grep 'argocd:' "$VERSION_FILE" | sed 's/.*argocd: *//')
32+
# Extract version dynamically using the SERVICE_NAME variable
33+
SERVICE_VERSION=$(grep "${SERVICE_NAME}:" "$VERSION_FILE" | sed "s/.*${SERVICE_NAME}: *//")
1834

19-
if [ -z "$ARGOCD_VERSION" ]; then
20-
echo "Error: Could not extract argocd version from $VERSION_FILE"
35+
if [ -z "$SERVICE_VERSION" ]; then
36+
echo "Error: Could not extract version for '$SERVICE_NAME' from $VERSION_FILE" >&2
2137
exit 1
2238
fi
2339

24-
# Helm command setup
25-
HELM_CMD="helm upgrade --install argocd bitnami/argo-cd \
26-
--version ${ARGOCD_VERSION} \
27-
--namespace=argocd \
28-
--timeout 120m \
29-
--post-renderer /etc/genestack/kustomize/kustomize.sh \
30-
--post-renderer-args argocd/${TARGET} \
31-
-f /opt/genestack/base-helm-configs/argocd/helm-argocd-overrides.yaml"
32-
33-
# Check if YAML files exist in the specified directory
34-
if compgen -G "${CONFIG_DIR}/*.yaml" > /dev/null; then
35-
# Add all YAML files from the directory to the helm command
36-
for yaml_file in "${CONFIG_DIR}"/*.yaml; do
37-
HELM_CMD+=" -f ${yaml_file}"
40+
echo "Found version for $SERVICE_NAME: $SERVICE_VERSION"
41+
42+
# Prepare an array to collect --values arguments
43+
values_args=()
44+
45+
# Base Override Files
46+
if [[ -d "$SERVICE_BASE_OVERRIDES" ]]; then
47+
echo "Including base overrides from directory: $SERVICE_BASE_OVERRIDES"
48+
for file in "$SERVICE_BASE_OVERRIDES"/*.yaml; do
49+
# Check that there is at least one match
50+
if [[ -e "$file" ]]; then
51+
echo " - $file"
52+
values_args+=("--values" "$file")
53+
fi
54+
done
55+
else
56+
echo "Warning: Base override directory not found: $SERVICE_BASE_OVERRIDES"
57+
fi
58+
59+
# Include all YAML files from the custom SERVICE configuration directory
60+
if [[ -d "$SERVICE_CUSTOM_OVERRIDES" ]]; then
61+
echo "Including overrides from config directory:"
62+
for file in "$SERVICE_CUSTOM_OVERRIDES"/*.yaml; do
63+
if [[ -e "$file" ]]; then
64+
echo " - $file"
65+
values_args+=("--values" "$file")
66+
fi
3867
done
68+
else
69+
echo "Warning: Config directory not found: $SERVICE_CUSTOM_OVERRIDES"
3970
fi
4071

41-
helm repo add bitnami https://charts.bitnami.com/bitnami
72+
echo
73+
74+
# --- Helm Repository and Execution ---
75+
helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL"
4276
helm repo update
4377

44-
# Run the helm command
45-
echo "Executing Helm command:"
46-
echo "${HELM_CMD}"
47-
eval "${HELM_CMD}"
78+
helm_command=(
79+
helm upgrade --install "$SERVICE_NAME" "$HELM_REPO_NAME"/"$SERVICE_NAME"
80+
--create-namespace --namespace="$SERVICE_NAMESPACE" --timeout 120m
81+
--version "${SERVICE_VERSION}"
82+
83+
"${values_args[@]}"
84+
85+
# Post-renderer configuration
86+
--post-renderer "$GENESTACK_OVERRIDES_DIR/kustomize/kustomize.sh"
87+
--post-renderer-args "$SERVICE_NAME/$TARGET"
88+
"$@"
89+
)
90+
91+
echo "Executing Helm command (arguments are quoted safely):"
92+
printf '%q ' "${helm_command[@]}"
93+
echo
94+
95+
# Execute the command directly from the array
96+
"${helm_command[@]}"

0 commit comments

Comments
 (0)