-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhf.cluster.create.sh
More file actions
executable file
·47 lines (39 loc) · 1021 Bytes
/
hf.cluster.create.sh
File metadata and controls
executable file
·47 lines (39 loc) · 1021 Bytes
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
#!/bin/bash
# Create a new cluster
# Usage: hf.cluster.create.sh <name> [region] [version]
source "$(dirname "$(realpath "$0")")/hf.lib.sh"
hf_require_config api-url api-version
NAME="${1:-my-cluster}"
REGION="${2:-us-east-1}"
VERSION="${3:-4.15.0}"
hf_require_jq
# Check if cluster exists
hf_info "Checking if cluster '$NAME' exists..."
EXISTING=$(hf_get "/clusters?search=name='$NAME'" | jq -r ".items[]? | select(.name == \"$NAME\") | .name")
if [[ -n "$EXISTING" ]]; then
hf_warn "Cluster '$NAME' already exists, skipping creation"
exit 0
fi
hf_info "Creating cluster: $NAME (region: $REGION, version: $VERSION)"
PAYLOAD=$(
cat <<EOF
{
"kind": "Cluster",
"name": "$NAME",
"labels": {
"environment": "development",
"shard": "1",
"team": "core",
"counter": "1"
},
"spec": {
"region": "$REGION",
"version": "$VERSION",
"counter": "1"
}
}
EOF
)
hf_post "/clusters" "$PAYLOAD" | jq
# Set as current cluster
"$(dirname "$(realpath "$0")")/hf.cluster.search.sh" "$NAME"