From 8ef5250e3520a0444d3b0d04b05624205bb2ce60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20M=C3=B6llering?= Date: Thu, 23 Aug 2018 12:27:27 +0200 Subject: [PATCH 1/2] Changed documentation to store cluster name in ENV-variable for more flexibility --- .../102-your-first-cluster/readme.adoc | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/01-path-basics/102-your-first-cluster/readme.adoc b/01-path-basics/102-your-first-cluster/readme.adoc index 3b3bba51..efe72989 100644 --- a/01-path-basics/102-your-first-cluster/readme.adoc +++ b/01-path-basics/102-your-first-cluster/readme.adoc @@ -42,10 +42,18 @@ EKS can be used to create a highly available cluster, with multiple master nodes === Create the master nodes +Store the name of your Kubernetes cluster in an environment variable + + $ export EKS_CLUSTER_NAME=k8s-workshop + +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 @@ -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: ``` @@ -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}\"}]" @@ -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 From 9bf61ff2b9b6b19a83a035f5a70a5818d623dad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20M=C3=B6llering?= Date: Wed, 29 Aug 2018 12:17:47 +0200 Subject: [PATCH 2/2] - Added ENV-variable in lab-ide-build-script - Changed files to use ENV-variable - Changed documentation --- .../101-start-here/scripts/aws-auth-cm.sh | 4 ++-- .../101-start-here/scripts/create-kubeconfig.sh | 14 +++++++------- .../101-start-here/scripts/lab-ide-build.sh | 3 ++- 01-path-basics/102-your-first-cluster/readme.adoc | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/01-path-basics/101-start-here/scripts/aws-auth-cm.sh b/01-path-basics/101-start-here/scripts/aws-auth-cm.sh index 1a471281..86e66b94 100644 --- a/01-path-basics/101-start-here/scripts/aws-auth-cm.sh +++ b/01-path-basics/101-start-here/scripts/aws-auth-cm.sh @@ -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##${EKS_WORKER_ROLE}#g" aws-auth-cm.yaml kubectl apply -f aws-auth-cm.yaml diff --git a/01-path-basics/101-start-here/scripts/create-kubeconfig.sh b/01-path-basics/101-start-here/scripts/create-kubeconfig.sh index 5d032e4e..404ce58f 100644 --- a/01-path-basics/101-start-here/scripts/create-kubeconfig.sh +++ b/01-path-basics/101-start-here/scripts/create-kubeconfig.sh @@ -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 #============================================================================== @@ -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##$(aws eks describe-cluster --name k8s-workshop --query cluster.endpoint --output text)#g" $HOME/.kube/config -sed -i -e "s##$(aws eks describe-cluster --name k8s-workshop --query cluster.certificateAuthority.data --output text)#g" $HOME/.kube/config -sed -i -e "s##k8s-workshop#g" $HOME/.kube/config -sed -i -e "s##$EKS_SERVICE_ROLE#g" $HOME/.kube/config +sed -i -e "s##$(aws eks describe-cluster --name ${EKS_CLUSTER_NAME} --query cluster.endpoint --output text)#g" $HOME/.kube/config +sed -i -e "s##$(aws eks describe-cluster --name ${EKS_CLUSTER_NAME} --query cluster.certificateAuthority.data --output text)#g" $HOME/.kube/config +sed -i -e "s##$EKS_CLUSTER_NAME#g" $HOME/.kube/config +sed -i -e "s##$EKS_SERVICE_ROLE#g" $HOME/.kube/config \ No newline at end of file diff --git a/01-path-basics/101-start-here/scripts/lab-ide-build.sh b/01-path-basics/101-start-here/scripts/lab-ide-build.sh index aac87e8c..a447245d 100644 --- a/01-path-basics/101-start-here/scripts/lab-ide-build.sh +++ b/01-path-basics/101-start-here/scripts/lab-ide-build.sh @@ -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 @@ -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 diff --git a/01-path-basics/102-your-first-cluster/readme.adoc b/01-path-basics/102-your-first-cluster/readme.adoc index efe72989..42d85eec 100644 --- a/01-path-basics/102-your-first-cluster/readme.adoc +++ b/01-path-basics/102-your-first-cluster/readme.adoc @@ -42,9 +42,9 @@ EKS can be used to create a highly available cluster, with multiple master nodes === Create the master nodes -Store the name of your Kubernetes cluster in an environment variable +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=k8s-workshop + $ export EKS_CLUSTER_NAME= Please confirm the following environment variable is set correctly before executing the 'create cluster' command: