Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Changed documentation to store cluster name in ENV-variable for more flexibility #549

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 01-path-basics/101-start-here/scripts/aws-auth-cm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#title aws-auth-cm.sh
#description This script will add a ConfigMap aws-auth to the EKS cluster k8s-workshop, allowing the worker nodes to join the cluster.
#author @buzzsurfr
#contributors @buzzsurfr @dalbhanj @cloudymind
#contributors @buzzsurfr @dalbhanj @cloudymind @smoell
#date 2018-06-05
#version 0.1
#usage curl -sSL https://s3.amazonaws.com/aws-kubernetes-artifacts/v0.5/aws-auth-cm.sh | bash -s stable
#==============================================================================

curl -O https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-06-05/aws-auth-cm.yaml
export EKS_WORKER_ROLE=$(aws cloudformation describe-stacks --stack-name k8s-workshop-worker-nodes | jq -r '.Stacks[0].Outputs[]|select(.OutputKey=="NodeInstanceRole")|.OutputValue')
export EKS_WORKER_ROLE=$(aws cloudformation describe-stacks --stack-name ${EKS_CLUSTER_NAME}-worker-nodes | jq -r '.Stacks[0].Outputs[]|select(.OutputKey=="NodeInstanceRole")|.OutputValue')
sed -i -e "s#<ARN of instance role (not instance profile)>#${EKS_WORKER_ROLE}#g" aws-auth-cm.yaml
kubectl apply -f aws-auth-cm.yaml
14 changes: 7 additions & 7 deletions 01-path-basics/101-start-here/scripts/create-kubeconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#title create-kubeconfig.sh
#description This script will create a kubeconfig file based on the EKS cluster k8s-workshop.
#author @buzzsurfr
#contributors @buzzsurfr @dalbhanj @cloudymind
#date 2018-06-07
#version 0.2
#contributors @buzzsurfr @dalbhanj @cloudymind @smoell
#date 2018-08-23
#version 0.3
#usage curl -sSL https://s3.amazonaws.com/aws-kubernetes-artifacts/v0.5/create-kubeconfig.sh | bash -s stable
#==============================================================================

Expand All @@ -13,7 +13,7 @@ mkdir $HOME/.kube
aws s3 cp s3://aws-kubernetes-artifacts/v0.5/config-k8s-workshop $HOME/.kube/config

# Configure based on EKS cluster k8s-workshop
sed -i -e "s#<endpoint-url>#$(aws eks describe-cluster --name k8s-workshop --query cluster.endpoint --output text)#g" $HOME/.kube/config
sed -i -e "s#<base64-encoded-ca-cert>#$(aws eks describe-cluster --name k8s-workshop --query cluster.certificateAuthority.data --output text)#g" $HOME/.kube/config
sed -i -e "s#<cluster-name>#k8s-workshop#g" $HOME/.kube/config
sed -i -e "s#<role-arn>#$EKS_SERVICE_ROLE#g" $HOME/.kube/config
sed -i -e "s#<endpoint-url>#$(aws eks describe-cluster --name ${EKS_CLUSTER_NAME} --query cluster.endpoint --output text)#g" $HOME/.kube/config
sed -i -e "s#<base64-encoded-ca-cert>#$(aws eks describe-cluster --name ${EKS_CLUSTER_NAME} --query cluster.certificateAuthority.data --output text)#g" $HOME/.kube/config
sed -i -e "s#<cluster-name>#$EKS_CLUSTER_NAME#g" $HOME/.kube/config
sed -i -e "s#<role-arn>#$EKS_SERVICE_ROLE#g" $HOME/.kube/config
3 changes: 2 additions & 1 deletion 01-path-basics/101-start-here/scripts/lab-ide-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#title lab-ide-build.sh
#description This script will setup the Cloud9 IDE with the prerequisite packages and code for the workshop.
#author @buzzsurfr
#contributors @buzzsurfr @dalbhanj @cloudymind
#contributors @buzzsurfr @dalbhanj @cloudymind @smoell
#date 2018-05-12
#version 0.2
#usage curl -sSL https://s3.amazonaws.com/lab-ide-theomazonian/lab-ide-build.sh | bash -s stable
Expand Down Expand Up @@ -64,6 +64,7 @@ echo "EKS_VPC_ID=$EKS_VPC_ID" >> ~/.bashrc
echo "EKS_SUBNET_IDS=$EKS_SUBNET_IDS" >> ~/.bashrc
echo "EKS_SECURITY_GROUPS=$EKS_SECURITY_GROUPS" >> ~/.bashrc
echo "EKS_SERVICE_ROLE=$EKS_SERVICE_ROLE" >> ~/.bashrc
echo "EKS_CLUSTER_NAME=k8s-workshop" >> ~/.bashrc

# EKS-Optimized AMI
if [ "$AWS_DEFAULT_REGION" == "us-east-1" ]; then
Expand Down
20 changes: 14 additions & 6 deletions 01-path-basics/102-your-first-cluster/readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ EKS can be used to create a highly available cluster, with multiple master nodes

=== Create the master nodes

The default name of your Kubernetes cluster is k8s-workshop and stored in the environment variable EKS_CLUSTER_NAME. If you want to change the name of your cluster, you can overwrite the value using

$ export EKS_CLUSTER_NAME=<your_cluster_name>

Please confirm the following environment variable is set correctly before executing the 'create cluster' command:

$ echo $EKS_CLUSTER_NAME

Create a Kubernetes cluster using the following command. Run it in the "bash" terminal tab at the bottom of the Cloud9 IDE. This will create a cluster with master nodes:

$ aws eks create-cluster \
--name k8s-workshop \
--name $EKS_CLUSTER_NAME \
--role-arn $EKS_SERVICE_ROLE \
--resources-vpc-config subnetIds=${EKS_SUBNET_IDS},securityGroupIds=${EKS_SECURITY_GROUPS} \
--kubernetes-version 1.10
Expand All @@ -54,7 +62,7 @@ The `EKS_SERVICE_ROLE`, `EKS_SUBNET_IDS`, and `EKS_SECURITY_GROUPS` environment

Cluster provisioning usually takes less than 10 minutes. You can query the status of your cluster with the following command. When your cluster status is `ACTIVE`, you can proceed.

$ aws eks describe-cluster --name k8s-workshop --query cluster.status --output text
$ aws eks describe-cluster --name $EKS_CLUSTER_NAME --query cluster.status --output text

Note: If your 'create cluster' fails with an error like:
```
Expand Down Expand Up @@ -141,13 +149,13 @@ Now that your EKS master nodes are created, you can launch and configure your wo
To launch your worker nodes, run the following CloudFormation CLI command:

$ aws cloudformation create-stack \
--stack-name k8s-workshop-worker-nodes \
--stack-name ${EKS_CLUSTER_NAME}-worker-nodes \
--template-url https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-06-05/amazon-eks-nodegroup.yaml \
--capabilities "CAPABILITY_IAM" \
--parameters "[{\"ParameterKey\": \"KeyName\", \"ParameterValue\": \"${AWS_STACK_NAME}\"},
{\"ParameterKey\": \"NodeImageId\", \"ParameterValue\": \"${EKS_WORKER_AMI}\"},
{\"ParameterKey\": \"ClusterName\", \"ParameterValue\": \"k8s-workshop\"},
{\"ParameterKey\": \"NodeGroupName\", \"ParameterValue\": \"k8s-workshop-nodegroup\"},
{\"ParameterKey\": \"ClusterName\", \"ParameterValue\": \"${EKS_CLUSTER_NAME}\"},
{\"ParameterKey\": \"NodeGroupName\", \"ParameterValue\": \"${EKS_CLUSTER_NAME}-nodegroup\"},
{\"ParameterKey\": \"ClusterControlPlaneSecurityGroup\", \"ParameterValue\": \"${EKS_SECURITY_GROUPS}\"},
{\"ParameterKey\": \"VpcId\", \"ParameterValue\": \"${EKS_VPC_ID}\"},
{\"ParameterKey\": \"Subnets\", \"ParameterValue\": \"${EKS_SUBNET_IDS}\"}]"
Expand All @@ -156,7 +164,7 @@ The `AWS_STACK_NAME`, `EKS_WORKER_AMI`, `EKS_VPC_ID`, `EKS_SUBNET_IDS`, and `EKS

Node provisioning usually takes less than 5 minutes. You can query the status of your cluster with the following command. When your cluster status is `CREATE_COMPLETE`, you can proceed.

$ aws cloudformation describe-stacks --stack-name k8s-workshop-worker-nodes --query 'Stacks[0].StackStatus' --output text
$ aws cloudformation describe-stacks --stack-name ${EKS_CLUSTER_NAME}-worker-nodes --query 'Stacks[0].StackStatus' --output text

=== Enable worker nodes to join cluster

Expand Down