/
cluster-b.sh
executable file
·35 lines (29 loc) · 1.36 KB
/
cluster-b.sh
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
##!/bin/bash
REGION=us-west-2
CLUSTER_TEMPLATE=eks-cluster-stack.yaml
VPC_STACK_NAME="eks-vpc-b-stack"
CLUSTER_STACK_NAME="eks-cluster-b-stack"
CLUSTER_NAME="EKS-CLUSTER-B"
#
# Create the EKS cluster
#
aws cloudformation deploy --stack-name $CLUSTER_STACK_NAME --template-file $CLUSTER_TEMPLATE --parameter-overrides \
VPCStackName=$VPC_STACK_NAME \
ClusterName=$CLUSTER_NAME \
--capabilities CAPABILITY_IAM --region $REGION
WORKER_TEMPLATE=eks-managed-workernode-stack.yaml
WORKER_STACK_NAME="eks-workers-b-stack"
CLUSTER_API_SERVER_URL=$(aws eks describe-cluster --name $CLUSTER_NAME --region $REGION --query cluster.endpoint --output text)
B64_CLUSTER_CA=$(aws eks describe-cluster --name $CLUSTER_NAME --region $REGION --query cluster.certificateAuthority --output text)
CLUSTER_SECURITY_GROUP_ID=$(aws eks describe-cluster --name $CLUSTER_NAME --query cluster.resourcesVpcConfig.clusterSecurityGroupId --output text --region $REGION)
#
# Create a EKS managed node group for the cluster
#
aws cloudformation deploy --stack-name $WORKER_STACK_NAME --template-file $WORKER_TEMPLATE --parameter-overrides \
VPCStackName=$VPC_STACK_NAME \
ClusterStackName=$CLUSTER_STACK_NAME \
ClusterName=$CLUSTER_NAME \
ClusterSecurityGroup=$CLUSTER_SECURITY_GROUP_ID \
ClusterEndpoint=$CLUSTER_API_SERVER_URL \
ClusterCertificateAuthority=$B64_CLUSTER_CA \
--capabilities CAPABILITY_IAM --region $REGION