-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
172 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
MAX_ATTEMPTS=60 | ||
SLEEP_INTERVAL=5 | ||
|
||
usage() { | ||
echo "Usage: $0 <service_name> <status_url>" | ||
echo "Example: $0 my-service http://localhost:8080/health" | ||
exit 1 | ||
} | ||
|
||
SERVICE_NAME="${1:-}" | ||
STATUS_URL="${2:-}" | ||
|
||
if [ -z "$SERVICE_NAME" ] || [ -z "$STATUS_URL" ]; then | ||
echo "Error: Missing required parameters" | ||
usage | ||
fi | ||
|
||
echo "Waiting for $SERVICE_NAME with status URL ${STATUS_URL}..." | ||
|
||
attempt=0 | ||
while true; do | ||
attempt=$((attempt + 1)) | ||
|
||
if [ $attempt -gt $MAX_ATTEMPTS ]; then | ||
echo "Error: Timeout waiting for $SERVICE_NAME after $((MAX_ATTEMPTS * SLEEP_INTERVAL)) seconds" | ||
exit 1 | ||
fi | ||
|
||
if curl --head \ | ||
--silent \ | ||
--fail \ | ||
--max-time 10 \ | ||
--retry 0 \ | ||
--output /dev/null \ | ||
"$STATUS_URL" 2>/dev/null; then | ||
echo "Service $SERVICE_NAME is up after $attempt attempts" | ||
exit 0 | ||
fi | ||
|
||
echo "Attempt $attempt of $MAX_ATTEMPTS: Service not ready yet, waiting ${SLEEP_INTERVAL} seconds..." | ||
sleep $SLEEP_INTERVAL | ||
done | ||
|
||
echo "Service $SERVICE_NAME is up" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "aztec-network.fullname" . }}-faucet | ||
labels: | ||
{{- include "aztec-network.labels" . | nindent 4 }} | ||
spec: | ||
replicas: {{ .Values.faucet.replicas }} | ||
selector: | ||
matchLabels: | ||
{{- include "aztec-network.selectorLabels" . | nindent 6 }} | ||
app: faucet | ||
template: | ||
metadata: | ||
labels: | ||
{{- include "aztec-network.selectorLabels" . | nindent 8 }} | ||
app: faucet | ||
spec: | ||
serviceAccountName: {{ include "aztec-network.fullname" . }}-node | ||
{{- if .Values.network.public }} | ||
hostNetwork: true | ||
dnsPolicy: ClusterFirstWithHostNet | ||
{{- end }} | ||
volumes: | ||
- name: config | ||
emptyDir: {} | ||
- name: scripts | ||
configMap: | ||
name: {{ include "aztec-network.fullname" . }}-scripts | ||
- name: scripts-output | ||
emptyDir: {} | ||
initContainers: | ||
{{- include "aztec-network.serviceAddressSetupContainer" . | nindent 8 }} | ||
- name: wait-for-dependencies | ||
image: {{ .Values.images.curl.image }} | ||
command: | ||
- /bin/sh | ||
- -c | ||
- | | ||
source /shared/config/service-addresses | ||
cat /shared/config/service-addresses | ||
/shared/scripts/await-service.sh "Ethereum" "$ETHEREUM_HOST" | ||
volumeMounts: | ||
- name: config | ||
mountPath: /shared/config | ||
- name: scripts | ||
mountPath: /shared/scripts | ||
containers: | ||
- name: faucet | ||
image: "{{ .Values.images.aztec.image }}" | ||
volumeMounts: | ||
- name: config | ||
mountPath: /shared/config | ||
command: | ||
- "/bin/bash" | ||
- "-c" | ||
- | | ||
source /shared/config/service-addresses | ||
cat /shared/config/service-addresses | ||
node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js start --faucet | ||
env: | ||
- name: FAUCET_PORT | ||
value: "{{ .Values.faucet.service.nodePort }}" | ||
- name: L1_CHAIN_ID | ||
value: "${{ .Values.ethereum.chainId }}" | ||
- name: MNEMONIC | ||
value: "${{ .Values.aztec.l1DeploymentMnemonic }}" | ||
- name: MNEMONIC_ACCOUNT_INDEX | ||
value: "${{ .Values.faucet.accountIndex }}" | ||
- name: EXTRA_ASSETS | ||
value: "${{ .Values.faucet.extraAssets }}" | ||
- name: LOG_JSON | ||
value: "1" | ||
- name: LOG_LEVEL | ||
value: "{{ .Values.faucet.logLevel }}" | ||
ports: | ||
- name: http | ||
containerPort: {{ .Values.faucet.service.nodePort }} | ||
protocol: TCP | ||
resources: | ||
{{- toYaml .Values.faucet.resources | nindent 12 }} | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ include "aztec-network.fullname" . }}-faucet | ||
labels: | ||
{{- include "aztec-network.labels" . | nindent 4 }} | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
{{- include "aztec-network.selectorLabels" . | nindent 4 }} | ||
app: faucet | ||
ports: | ||
- protocol: TCP | ||
port: {{ .Values.faucet.service.nodePort }} | ||
targetPort: {{ .Values.faucet.service.nodePort }} | ||
{{- if and (eq .Values.faucet.service.type "NodePort") .Values.faucet.service.nodePort }} | ||
nodePort: {{ .Values.faucet.service.nodePort }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters