Skip to content

Commit d4950ba

Browse files
Fixed snapshot testnet download and argocd using cli
1 parent 8229094 commit d4950ba

File tree

6 files changed

+191
-21
lines changed

6 files changed

+191
-21
lines changed

charts/osmosis-fullnode/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: osmosis-fullnode
33
description: A Helm chart for deploying Osmosis fullnode with monitoring and sentinel
44
type: application
5-
version: 0.1.3
5+
version: 0.1.4
66
appVersion: "29.0.2"
77
keywords:
88
- osmosis

charts/osmosis-fullnode/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,58 @@ sentinel:
9696
config:
9797
maxDirSizeGb: 200
9898
monitorPath: "/osmosis/.osmosisd"
99+
argocdApp: "fullnodes"
100+
maxNodeRestartCount: 10
101+
# Enable/disable ArgoCD integration - set to false if ArgoCD is not available
102+
argocdEnabled: true
99103
```
100104
105+
##### ArgoCD Integration
106+
107+
The sentinel supports optional ArgoCD integration for coordinated deployments:
108+
109+
- **`argocdEnabled: true`** (default): Enables ArgoCD auto-sync pause/resume during cleanup operations
110+
- **`argocdEnabled: false`**: Disables ArgoCD integration completely
111+
112+
When enabled, the sentinel will:
113+
1. Check if ArgoCD namespace and application exist
114+
2. Install and configure ArgoCD CLI with service account authentication
115+
3. Pause auto-sync before scaling down pods using `argocd app set --sync-policy none`
116+
4. Resume auto-sync after cleanup using `argocd app set --sync-policy automated`
117+
5. Continue safely if ArgoCD is not available
118+
119+
**Configuration options:**
120+
- `argocdApp`: Name of the ArgoCD application to manage
121+
- `argocdServer`: ArgoCD server endpoint (defaults to in-cluster service)
122+
- `argocdEnabled`: Enable/disable ArgoCD integration
123+
124+
**Recommended settings:**
125+
- Set `argocdEnabled: false` if ArgoCD is not installed in your cluster
126+
- Set `argocdEnabled: true` if you want coordinated deployments with ArgoCD
127+
128+
```yaml
129+
# For environments without ArgoCD
130+
sentinel:
131+
config:
132+
argocdEnabled: false
133+
134+
# For environments with ArgoCD (default configuration)
135+
sentinel:
136+
config:
137+
argocdEnabled: true
138+
argocdApp: "fullnodes"
139+
argocdServer: "argocd-server.argocd.svc.cluster.local:80"
140+
141+
# For external ArgoCD server
142+
sentinel:
143+
config:
144+
argocdEnabled: true
145+
argocdApp: "my-osmosis-application"
146+
argocdServer: "argocd.example.com:443"
147+
```
148+
149+
**Note:** The sentinel uses the Kubernetes service account token for authentication with ArgoCD. Ensure your ArgoCD instance is configured to accept service account authentication.
150+
101151
## Parameters
102152

103153
### Global Parameters

charts/osmosis-fullnode/templates/configmaps.yaml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,30 @@ data:
8383
dasel put string -f "$OSMOSIS_HOME/config/config.toml" -s "p2p.persistent_peers" -v "$PEERS"
8484
8585
download_snapshot.sh: |
86+
echo "📷 Snapshot from $SNAPSHOT_URL"
8687
if [[ "$SNAPSHOT_URL" == *".tar.lz4" ]]; then
8788
echo "📷 Using provided snapshot from $SNAPSHOT_URL"
8889
# Verify the URL is accessible
8990
if curl --output /dev/null --silent --head --fail "$SNAPSHOT_URL"; then
9091
DOWNLOAD_URL="$SNAPSHOT_URL"
9192
else
92-
echo "⚠️ Provided snapshot URL is not accessible, falling back to snapshots.osmosis.zone"
93-
DOWNLOAD_URL=$(curl -sL https://snapshots.osmosis.zone/latest)
93+
echo "⚠️ Provided snapshot URL is not accessible, falling back to appropriate snapshots endpoint"
94+
if [[ "$SNAPSHOT_URL" == *"testnet"* ]]; then
95+
DOWNLOAD_URL=$(curl -sL https://snapshots.testnet.osmosis.zone/latest)
96+
else
97+
DOWNLOAD_URL=$(curl -sL https://snapshots.osmosis.zone/latest)
98+
fi
9499
fi
95100
else
96-
echo "📷 Fetching latest snapshot URL from snapshots.osmosis.zone"
97-
DOWNLOAD_URL=$(curl -sL https://snapshots.osmosis.zone/latest)
101+
echo "📷 Fetching latest snapshot URL from snapshots endpoint"
102+
# Check if this is a testnet environment by examining the SNAPSHOT_URL
103+
if [[ "$SNAPSHOT_URL" == *"testnet"* ]]; then
104+
echo "📷 Detected testnet environment, using testnet snapshots"
105+
DOWNLOAD_URL=$(curl -sL https://snapshots.testnet.osmosis.zone/latest)
106+
else
107+
echo "📷 Using mainnet snapshots"
108+
DOWNLOAD_URL=$(curl -sL https://snapshots.osmosis.zone/latest)
109+
fi
98110
fi
99111
echo "📷 Using snapshot from $DOWNLOAD_URL"
100112
start_time=$(date +%s)
@@ -132,4 +144,6 @@ data:
132144
max-dir-size-gb: "{{ .Values.sentinel.config.maxDirSizeGb }}"
133145
monitor-path: "{{ .Values.sentinel.config.monitorPath }}"
134146
argocd-app: "{{ .Values.sentinel.config.argocdApp }}"
135-
max-node-restart-count: "{{ .Values.sentinel.config.maxNodeRestartCount }}"
147+
max-node-restart-count: "{{ .Values.sentinel.config.maxNodeRestartCount }}"
148+
argocd-enabled: "{{ .Values.sentinel.config.argocdEnabled }}"
149+
argocd-server: "{{ .Values.sentinel.config.argocdServer | default "argocd-server.argocd.svc.cluster.local:80" }}"

charts/osmosis-fullnode/templates/cronjob.yaml

Lines changed: 108 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ spec:
7272
configMapKeyRef:
7373
name: {{ include "osmosis-fullnode.fullname" . }}-sentinel-config
7474
key: max-node-restart-count
75+
- name: ARGOCD_ENABLED
76+
valueFrom:
77+
configMapKeyRef:
78+
name: {{ include "osmosis-fullnode.fullname" . }}-sentinel-config
79+
key: argocd-enabled
80+
- name: ARGOCD_SERVER
81+
valueFrom:
82+
configMapKeyRef:
83+
name: {{ include "osmosis-fullnode.fullname" . }}-sentinel-config
84+
key: argocd-server
7585
command:
7686
- bash
7787
- -c
@@ -101,28 +111,88 @@ spec:
101111
fi
102112
}
103113
114+
# Function to check if ArgoCD is available
115+
check_argocd_available() {
116+
if [ "${ARGOCD_ENABLED:-true}" != "true" ]; then
117+
echo "📴 ArgoCD integration is disabled via configuration"
118+
return 1
119+
fi
120+
121+
# Check if ArgoCD namespace exists
122+
if ! kubectl get namespace argocd >/dev/null 2>&1; then
123+
echo "⚠️ ArgoCD namespace not found, skipping ArgoCD operations"
124+
return 1
125+
fi
126+
127+
# Check if the ArgoCD application exists
128+
if ! kubectl get application "$ARGOCD_APPLICATION" -n argocd >/dev/null 2>&1; then
129+
echo "⚠️ ArgoCD application '$ARGOCD_APPLICATION' not found, skipping ArgoCD operations"
130+
return 1
131+
fi
132+
133+
echo "✅ ArgoCD is available and configured"
134+
return 0
135+
}
136+
137+
# Function to pause ArgoCD auto-sync
138+
pause_argocd_sync() {
139+
if check_argocd_available; then
140+
echo "⏸️ Pausing ArgoCD auto-sync for application: $ARGOCD_APPLICATION"
141+
if argocd app set "$ARGOCD_APPLICATION" --sync-policy none; then
142+
echo "✅ ArgoCD auto-sync paused successfully"
143+
return 0
144+
else
145+
echo "❌ Failed to pause ArgoCD auto-sync, continuing without ArgoCD management"
146+
return 1
147+
fi
148+
else
149+
echo "ℹ️ Skipping ArgoCD pause operation"
150+
return 1
151+
fi
152+
}
153+
154+
# Function to resume ArgoCD auto-sync
155+
resume_argocd_sync() {
156+
if check_argocd_available; then
157+
echo "▶️ Resuming ArgoCD auto-sync for application: $ARGOCD_APPLICATION"
158+
if argocd app set "$ARGOCD_APPLICATION" --sync-policy automated; then
159+
echo "✅ ArgoCD auto-sync resumed successfully"
160+
else
161+
echo "⚠️ Failed to resume ArgoCD auto-sync, but cleanup completed"
162+
fi
163+
else
164+
echo "ℹ️ Skipping ArgoCD resume operation"
165+
fi
166+
}
167+
104168
# Function to handle StatefulSet scaling and cleanup
105169
handle_cleanup() {
106170
local namespace=$1
107171
local osmosis_app=$2
108172
local osmosis_pod=$3
109173
110-
# Pause ArgoCD auto-sync
111-
echo "⏸️ Pausing ArgoCD auto-sync"
112-
if ! kubectl patch application $ARGOCD_APPLICATION -n argocd --type merge -p "{\"spec\":{\"syncPolicy\":null}}"; then
113-
echo "❌ Failed to pause ArgoCD auto-sync"
114-
exit 1
174+
# Track if we paused ArgoCD to know if we should resume it
175+
local argocd_was_paused=false
176+
177+
# Pause ArgoCD auto-sync (if available)
178+
if pause_argocd_sync; then
179+
argocd_was_paused=true
115180
fi
116-
echo "✅ ArgoCD auto-sync paused successfully"
117181
118182
# Scale down the StatefulSet to 0 replicas
183+
echo "📉 Scaling down StatefulSet $osmosis_app to 0 replicas"
119184
kubectl scale statefulset $osmosis_app -n $namespace --replicas=0
120185
121186
# Wait for the pod to terminate
187+
echo "⏳ Waiting for pod $osmosis_pod to terminate..."
122188
kubectl wait --for=delete pod/$osmosis_pod -n $namespace --timeout=600s
123189
124190
if kubectl get pod $osmosis_pod -n $namespace &>/dev/null; then
125191
echo "❌ Pod $osmosis_pod is still running after timeout"
192+
# Try to resume ArgoCD if we paused it
193+
if [ "$argocd_was_paused" = true ]; then
194+
resume_argocd_sync
195+
fi
126196
exit 1
127197
fi
128198
@@ -132,13 +202,15 @@ spec:
132202
cleanup_folders $(hostname) $namespace $MONITOR_PATH
133203
134204
# Scale the StatefulSet back to 1 replica
205+
echo "📈 Scaling StatefulSet $osmosis_app back to 1 replica"
135206
kubectl scale statefulset $osmosis_app -n $namespace --replicas=1
136207
137-
# Resume ArgoCD auto-sync
138-
echo "▶️ Resuming ArgoCD auto-sync"
139-
kubectl patch application $ARGOCD_APPLICATION -n argocd --type merge -p '{"spec":{"syncPolicy":{"automated":{"prune":true,"selfHeal":true}}}}' || true
208+
# Resume ArgoCD auto-sync (if we paused it)
209+
if [ "$argocd_was_paused" = true ]; then
210+
resume_argocd_sync
211+
fi
140212
141-
echo "🔄 Cleanup completed"
213+
echo "🔄 Cleanup completed successfully"
142214
}
143215
144216
# Install required packages quietly
@@ -149,6 +221,23 @@ spec:
149221
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list
150222
apt-get update -qq && apt-get install -y -qq kubectl > /dev/null 2>&1
151223
224+
# Install ArgoCD CLI
225+
curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
226+
chmod +x /usr/local/bin/argocd
227+
echo "✅ ArgoCD CLI installed"
228+
229+
# Configure ArgoCD authentication using service account token
230+
if [ "${ARGOCD_ENABLED:-true}" = "true" ]; then
231+
export ARGOCD_SERVER="${ARGOCD_SERVER:-argocd-server.argocd.svc.cluster.local:80}"
232+
export ARGOCD_AUTH_TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
233+
# Test ArgoCD connection
234+
if argocd cluster list >/dev/null 2>&1; then
235+
echo "✅ ArgoCD authentication configured successfully"
236+
else
237+
echo "⚠️ ArgoCD authentication failed, will skip ArgoCD operations"
238+
fi
239+
fi
240+
152241
# Get pod info
153242
NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
154243
echo "🔍 Namespace: $NAMESPACE"
@@ -165,6 +254,15 @@ spec:
165254
echo "🔍 Osmosis App: $OSMOSIS_APP"
166255
echo "🔍 Osmosis Pod: $OSMOSIS_POD"
167256
257+
# Display ArgoCD configuration status
258+
echo "🔍 ArgoCD Integration: ${ARGOCD_ENABLED:-true}"
259+
if [ "${ARGOCD_ENABLED:-true}" = "true" ]; then
260+
echo "🔍 ArgoCD Application: $ARGOCD_APPLICATION"
261+
check_argocd_available || echo "⚠️ ArgoCD not available in this environment"
262+
else
263+
echo "📴 ArgoCD integration is disabled"
264+
fi
265+
168266
# Check if pod exists and get its status
169267
if ! kubectl get pod $OSMOSIS_POD -n $NAMESPACE &>/dev/null; then
170268
echo "❌ Pod $OSMOSIS_POD not found"

charts/osmosis-fullnode/values-testnet.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ containers:
9191
env:
9292
FORCE_RESET: "false"
9393
GENESIS_URL: "https://osmosis.fra1.cdn.digitaloceanspaces.com/osmo-test-5/genesis.json"
94-
#SNAPSHOT_URL: "$(curl -sL https://snapshots.testnet.osmosis.zone/latest)"
95-
SNAPSHOT_URL: "https://hel1.your-objectstorage.com/osmosis/osmo-test-5/snapshots/v29/osmosis-snapshot-202507171155-30160256.tar.lz4"
94+
SNAPSHOT_URL: "$(curl -sL https://snapshots.testnet.osmosis.zone/latest)"
95+
#SNAPSHOT_URL: "https://hel1.your-objectstorage.com/osmosis/osmo-test-5/snapshots/v29/osmosis-snapshot-202507171155-30160256.tar.lz4"
9696
ADDRBOOK_URL: "https://snapshots.polkachu.com/testnet-addrbook/osmosis/addrbook.json"
9797
STATE_SYNC: "false"
9898
MONIKER: "osmosis"
@@ -206,6 +206,10 @@ sentinel:
206206
monitorPath: "/osmosis/.osmosisd"
207207
argocdApp: "fullnodes"
208208
maxNodeRestartCount: 10
209+
# Enable/disable ArgoCD integration - set to false if ArgoCD is not available
210+
argocdEnabled: true
211+
# ArgoCD server endpoint (defaults to in-cluster service)
212+
argocdServer: "argocd-server.argocd.svc.cluster.local:80"
209213

210214

211215
# Tolerations (inherits from statefulset if not specified)
@@ -254,15 +258,15 @@ monitoring:
254258
instances: |
255259
[
256260
{
257-
"openmetrics_endpoint": "http://{{ include "osmosis-fullnode.fullname" . }}-droid:8080/metrics",
261+
"openmetrics_endpoint": "http://{{ include "osmosis-fullnode.fullname" . }}-droid.{{ .Values.namespace }}:8080/metrics",
258262
"namespace": "droid",
259263
"metrics": [
260264
{"osmosisd_info": "info"},
261265
{"osmosisd_cur_eip_base_fee": "cur_eip_base_fee"}
262266
]
263267
},
264268
{
265-
"openmetrics_endpoint": "http://{{ include "osmosis-fullnode.fullname" . }}-lcd:1317/metrics?format=prometheus",
269+
"openmetrics_endpoint": "http://{{ include "osmosis-fullnode.fullname" . }}-lcd.{{ .Values.namespace }}:1317/metrics?format=prometheus",
266270
"namespace": "osmosisd",
267271
"metrics": [
268272
"cometbft_consensus_height",
@@ -295,7 +299,7 @@ monitoring:
295299
},
296300
{
297301
"name": "droid_healthcheck",
298-
"url": "http://{{ include "osmosis-fullnode.fullname" . }}-droid:8080/health",
302+
"url": "http://{{ include "osmosis-fullnode.fullname" . }}-droid.{{ .Values.namespace }}:8080/health",
299303
"timeout": 1
300304
}
301305
]

charts/osmosis-fullnode/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ sentinel:
205205
monitorPath: "/osmosis/.osmosisd"
206206
argocdApp: "fullnodes"
207207
maxNodeRestartCount: 10
208+
# Enable/disable ArgoCD integration - set to false if ArgoCD is not available
209+
argocdEnabled: true
210+
# ArgoCD server endpoint (defaults to in-cluster service)
211+
argocdServer: "argocd-server.argocd.svc.cluster.local:80"
208212

209213
# Resources
210214
resources:

0 commit comments

Comments
 (0)