How Do You Deploy a Kubernetes Cluster into AWS with a RHEL Server?

Problem scenario
You want to create a Kubernetes cluster in AWS via a RHEL server.  What should you do?

This will deploy additional resources in your AWS account (not on to the RHEL server). It will cost money to follow these directions.


i.  Install and configure the AWS CLI (or awscli). If you need help, see this posting.

ii.  Install kubectl.  If you need assistance, follow step #1 only of this posting.

iii.  Install kops (Kubernetes Operations command) by running these commands:

curl -Lk > /tmp/kops-linux-amd64

chmod +x /tmp/kops-linux-amd64

sudo mv /tmp/kops-linux-amd64 /usr/local/bin/kops

iv.  You need to have SSH keys set up.  You want to have a .pub file in your ~/.ssh/ directory. The directions below assume that your .pub file is; adjust the directions below when they refer to this file if you have a different name for it.

If you do not know how to create this file, run this command and press enter twice:

ssh-keygen -t rsa -P ""

(We created these directions based on a article.)

1.a.  Create a script called "" in /tmp/ with the following lines:

aws iam create-group --group-name kops

aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonEC2FullAccess --group-name kops

aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonRoute53FullAccess --group-name kops

aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess --group-name kops

aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/IAMFullAccess --group-name kops

aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonVPCFullAccess --group-name kops

aws iam create-user --user-name kops

aws iam add-user-to-group --user-name kops --group-name kops

aws iam create-access-key --user-name kops
#This comment is the last line. EOF.

1.b.  Run this: source /tmp/
The "source" command is necessary if all your AWS CLI commands on the system will work in the current shell (which is often the case if you followed the AWS configure directions available elsewhere on this website).

2.  Run these five commands (the fifth is a multi-line command) interactively (but replace us-west-9 with the region of your choice, e.g., us-east-1; to see the options available, click here):

export KOPS_CLUSTER_NAME=contint.k8s.local

aws s3api create-bucket --bucket ${KOPS_CLUSTER_NAME}-state --region $rn --create-bucket-configuration LocationConstraint=$rn


# This command will place in the "a" zone of the region (i.e., us-west-9) the cluster:

kops create cluster \
 --name=${KOPS_CLUSTER_NAME} \
 --zones=$rn"a" \
 --master-size="t2.micro" \
 --node-size="t2.medium" \
 --node-count="3" \

3.  You are done. To confirm the cluster was created, run this command:  kops get cluster

Here are possible commands (but substitute "contint" with the name you entered before ".k8s.local" in first command in step #2):

 * list clusters with: kops get cluster
 * edit this cluster with: kops edit cluster contint2.k8s.local
 * edit your node instance group: kops edit ig --name=contint2.k8s.local nodes
 * edit your master instance group: kops edit ig --name=contint2.k8s.local master-us-west-2a

Leave a comment

Your email address will not be published. Required fields are marked *