Skip to content

Commit 1f1c56e

Browse files
authored
Add AWS region support (#203)
1 parent 202d482 commit 1f1c56e

File tree

8 files changed

+32
-13
lines changed

8 files changed

+32
-13
lines changed

cortex.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ fi
108108
export CORTEX_LOG_GROUP="${CORTEX_LOG_GROUP:-cortex}"
109109
export CORTEX_BUCKET="${CORTEX_BUCKET:-""}"
110110
export CORTEX_REGION="${CORTEX_REGION:-us-west-2}"
111+
export CORTEX_ZONES="${CORTEX_ZONES:-""}"
111112

112113
export CORTEX_CLUSTER="${CORTEX_CLUSTER:-cortex}"
113114
export CORTEX_NODE_TYPE="${CORTEX_NODE_TYPE:-t3.small}"
@@ -141,25 +142,30 @@ export CORTEX_ENABLE_TELEMETRY="${CORTEX_ENABLE_TELEMETRY:-""}"
141142
##########################
142143

143144
function install_eks() {
145+
echo
144146
docker run --entrypoint /root/install_eks.sh \
145147
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
146148
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
147149
-e CORTEX_CLUSTER=$CORTEX_CLUSTER \
150+
-e CORTEX_REGION=$CORTEX_REGION \
148151
-e CORTEX_NODE_TYPE=$CORTEX_NODE_TYPE \
149152
-e CORTEX_NODES_MIN=$CORTEX_NODES_MIN \
150153
-e CORTEX_NODES_MAX=$CORTEX_NODES_MAX \
151154
$CORTEX_IMAGE_MANAGER
152155
}
153156

154157
function uninstall_eks() {
158+
echo
155159
docker run --entrypoint /root/uninstall_eks.sh \
156160
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
157161
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
158162
-e CORTEX_CLUSTER=$CORTEX_CLUSTER \
163+
-e CORTEX_REGION=$CORTEX_REGION \
159164
$CORTEX_IMAGE_MANAGER
160165
}
161166

162167
function install_cortex() {
168+
echo
163169
docker run --entrypoint /root/install_cortex.sh \
164170
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
165171
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
@@ -190,28 +196,34 @@ function install_cortex() {
190196
}
191197

192198
function uninstall_cortex() {
199+
echo
193200
docker run --entrypoint /root/uninstall_cortex.sh \
194201
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
195202
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
196203
-e CORTEX_CLUSTER=$CORTEX_CLUSTER \
204+
-e CORTEX_REGION=$CORTEX_REGION \
197205
-e CORTEX_NAMESPACE=$CORTEX_NAMESPACE \
198206
$CORTEX_IMAGE_MANAGER
199207
}
200208

201209
function uninstall_operator() {
210+
echo
202211
docker run --entrypoint /root/uninstall_operator.sh \
203212
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
204213
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
205214
-e CORTEX_CLUSTER=$CORTEX_CLUSTER \
215+
-e CORTEX_REGION=$CORTEX_REGION \
206216
-e CORTEX_NAMESPACE=$CORTEX_NAMESPACE \
207217
$CORTEX_IMAGE_MANAGER
208218
}
209219

210220
function info() {
221+
echo
211222
docker run --entrypoint /root/info.sh \
212223
-e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
213224
-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
214225
-e CORTEX_CLUSTER=$CORTEX_CLUSTER \
226+
-e CORTEX_REGION=$CORTEX_REGION \
215227
-e CORTEX_NAMESPACE=$CORTEX_NAMESPACE \
216228
$CORTEX_IMAGE_MANAGER
217229
}

docs/cluster/config.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export CORTEX_BUCKET="cortex-[RANDOM_ID]"
2020
# The AWS region Cortex will use
2121
export CORTEX_REGION="us-west-2"
2222

23+
# The AWS zones Cortex will use (e.g. "us-east-1a,us-east-1b")
24+
export CORTEX_ZONES=""
25+
2326
# The name of the EKS cluster Cortex will use
2427
export CORTEX_CLUSTER="cortex"
2528

manager/info.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ function get_apis_endpoint() {
2626
kubectl -n=$CORTEX_NAMESPACE get service nginx-controller-apis -o json | tr -d '[:space:]' | sed 's/.*{\"hostname\":\"\(.*\)\".*/\1/'
2727
}
2828

29-
eksctl utils write-kubeconfig --name=$CORTEX_CLUSTER | grep -v "saved kubeconfig as" || true
29+
eksctl utils write-kubeconfig --name=$CORTEX_CLUSTER --region=$CORTEX_REGION | grep -v "saved kubeconfig as" || true
3030

3131
operator_endpoint=$(get_operator_endpoint)
3232
apis_endpoint=$(get_apis_endpoint)
3333

34-
echo
3534
echo "Operator endpoint: $operator_endpoint"
3635
echo "APIs endpoint: $apis_endpoint"

manager/install_cortex.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ function setup_bucket() {
2525
if ! aws s3api head-bucket --bucket $CORTEX_BUCKET --output json 2>/dev/null; then
2626
if aws s3 ls "s3://$CORTEX_BUCKET" --output json 2>&1 | grep -q 'NoSuchBucket'; then
2727
echo "✓ Creating an S3 bucket: $CORTEX_BUCKET"
28-
aws s3api create-bucket --bucket $CORTEX_BUCKET \
29-
--region $CORTEX_REGION \
30-
--create-bucket-configuration LocationConstraint=$CORTEX_REGION \
31-
>/dev/null
28+
if [ "$CORTEX_REGION" == "us-east-1" ]; then
29+
aws s3api create-bucket --bucket $CORTEX_BUCKET \
30+
--region $CORTEX_REGION \
31+
>/dev/null
32+
else
33+
aws s3api create-bucket --bucket $CORTEX_BUCKET \
34+
--region $CORTEX_REGION \
35+
--create-bucket-configuration LocationConstraint=$CORTEX_REGION \
36+
>/dev/null
37+
fi
3238
else
3339
echo "A bucket named \"${CORTEX_BUCKET}\" already exists, but you do not have access to it"
3440
exit 1
@@ -152,7 +158,7 @@ function validate_cortex() {
152158

153159
eksctl utils write-kubeconfig --name=$CORTEX_CLUSTER --region=$CORTEX_REGION | grep -v "saved kubeconfig as" || true
154160

155-
echo -e "\nInstalling Cortex ..."
161+
echo "Installing Cortex ..."
156162

157163
setup_bucket
158164
setup_cloudwatch_logs

manager/install_eks.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
set -e
1818

19-
echo -e "\nSpinning up the cluster ... (this will about 15 minutes)"
19+
echo -e "Spinning up the cluster ... (this will take about 15 minutes)\n"
2020

21-
echo
2221
eksctl create cluster --name=$CORTEX_CLUSTER \
2322
--region=$CORTEX_REGION \
23+
--zones=$CORTEX_ZONES \
2424
--node-type=$CORTEX_NODE_TYPE \
2525
--nodes-min=$CORTEX_NODES_MIN \
2626
--nodes-max=$CORTEX_NODES_MAX \

manager/uninstall_cortex.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set -e
1818

1919
eksctl utils write-kubeconfig --name=$CORTEX_CLUSTER --region=$CORTEX_REGION | grep -v "saved kubeconfig as" || true
2020

21-
echo -e "\nUninstalling Cortex ..."
21+
echo "Uninstalling Cortex ..."
2222

2323
# Remove finalizers on sparkapplications (they sometimes create deadlocks)
2424
if kubectl get namespace $CORTEX_NAMESPACE >/dev/null 2>&1 && kubectl get customresourcedefinition sparkapplications.sparkoperator.k8s.io >/dev/null 2>&1; then

manager/uninstall_eks.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616

1717
set -e
1818

19-
echo -e "\nSpinning down the cluster ... (this will take a few minutes)"
19+
echo -e "Spinning down the cluster ... (this will take a few minutes)\n"
2020

21-
echo
2221
eksctl delete cluster --name=$CORTEX_CLUSTER --region=$CORTEX_REGION
2322

2423
echo -e "\n✓ Spun down the cluster"

manager/uninstall_operator.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ set -e
2020

2121
eksctl utils write-kubeconfig --name=$CORTEX_CLUSTER --region=$CORTEX_REGION | grep -v "saved kubeconfig as" || true
2222

23-
echo -e "\nUninstalling the Cortex operator ..."
23+
echo "Uninstalling the Cortex operator ..."
2424

2525
kubectl -n=$CORTEX_NAMESPACE delete --ignore-not-found=true deployment operator >/dev/null 2>&1
2626

0 commit comments

Comments
 (0)