-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgenerate-config.sh
More file actions
executable file
·95 lines (87 loc) · 2.49 KB
/
generate-config.sh
File metadata and controls
executable file
·95 lines (87 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
# Show debug info about the environment files
echo "==== The content of env_input ===="
cat ./env_input
echo "==============================================="
echo "==== The content of env_vars ===="
cat ./env_vars
echo "==============================================="
source ./env_input
source ./env_vars
# Start writing the JSON
cat > hyperpod-config.json << EOL
{
"ClusterName": "${HYPERPOD_NAME}",
"Orchestrator": {
"Eks":
{
"ClusterArn": "${EKS_CLUSTER_ARN}"
}
},
"InstanceGroups": [
{
"InstanceGroupName": "worker-group-1",
"InstanceType": "${ACCEL_INSTANCE_TYPE}",
"InstanceCount": ${ACCEL_COUNT},
"InstanceStorageConfigs": [
{
"EbsVolumeConfig": {
"VolumeSizeInGB": ${ACCEL_VOLUME_SIZE}
}
}
],
"LifeCycleConfig": {
"SourceS3Uri": "s3://${S3_BUCKET_NAME}",
"OnCreate": "on_create.sh"
},
"ExecutionRole": "${EXECUTION_ROLE}",
"ThreadsPerCore": 1
EOL
# Conditionally add OnStartDeepHealthChecks only if not empty
if [ -n "${ONSTART_DEEP_HEALTHCHECKS}" ]; then
echo ' ,"OnStartDeepHealthChecks": '${ONSTART_DEEP_HEALTHCHECKS} >> hyperpod-config.json
fi
# Finish writing the JSON
cat >> hyperpod-config.json << EOL
},
{
"InstanceGroupName": "worker-group-2",
"InstanceType": "${GEN_INSTANCE_TYPE}",
"InstanceCount": ${GEN_COUNT},
"InstanceStorageConfigs": [
{
"EbsVolumeConfig": {
"VolumeSizeInGB": ${GEN_VOLUME_SIZE}
}
}
],
"LifeCycleConfig": {
"SourceS3Uri": "s3://${S3_BUCKET_NAME}",
"OnCreate": "on_create.sh"
},
"ExecutionRole": "${EXECUTION_ROLE}",
"ThreadsPerCore": 1
}
],
"VpcConfig": {
"SecurityGroupIds": ["$SECURITY_GROUP_ID"],
"Subnets":["$PRIVATE_SUBNET_ID"]
},
"NodeRecovery": "${NODE_RECOVERY}"
}
EOL
# Display the generated JSON file
echo "==== Generated hyperpod-config.json ===="
cat hyperpod-config.json
echo "=================================================="
# Validate the JSON if jq is available
if command -v jq &> /dev/null; then
echo "==== Validate output JSON ===="
if jq empty hyperpod-config.json 2>/dev/null; then
echo "JSON is valid"
else
echo "ERROR: Invalid JSON"
jq empty hyperpod-config.json
fi
echo "=================================="
fi