A helper script of pks
cli for AWS.
This script a bit reduces the pain of creating a PKS cluster on AWS.
⚠️ Since TKGI (formerly PKS) 1.8,pks
cli has been renamed totkgi
. According to this change, renamepks-aws
totkgi-aws
.
# for PKS ~1.7
sudo wget -O /usr/local/bin/pks-aws https://raw.githubusercontent.com/making/pks-cli-aws/master/pks-aws
sudo chmod +x /usr/local/bin/pks-aws
# for TKGI 1.8~
sudo wget -O /usr/local/bin/tkgi-aws https://raw.githubusercontent.com/making/pks-cli-aws/master/pks-aws
sudo chmod +x /usr/local/bin/tkgi-aws
Following CLIs are required.
pks
CLI and login aspks.clusters.admin
.aws
CLI and login as a user who installed PKS.default
profile is used.jq
The PKS environment you want to manage must have
${ENV_NAME}-public-subnet*
subnets${ENV_NAME}-pks-master-security-group
or${ENV_NAME}-pks-api-lb-sg
security group${ENV_NAME}-vms-security-group
or${ENV_NAME}-platform-vms-sg
security group
Objects above should be created by https://github.com/pivotal-cf/terraforming-aws or https://github.com/pivotal/paving .
pks-aws create-lb <CLUSTER_NAME> <ENV_NAME>
-
CLUSTER_NAME
should be same as the name you will use withpks create-cluster <CLUSTER_NAME>
. -
ENV_NAME
is the value you configured interraform.tfvars
when installing PKS.
This command creates a NLB with the name pks-<CLUSTER_NAME>
.
If you want to specify the LB name, use pks-aws create-lb <CLUSTER_NAME> <ENV_NAME> <LB_NAME>
instead.
See also https://docs.pivotal.io/pks/1-7/aws-cluster-load-balancer.html#create
pks-aws create-tags <CLUSTER_NAME> <ENV_NAME>
These commands add kubernetes.io/cluster/service-instance_${CLUSTER_UUID}
tag to public subnets and the security group of workers (vms_security_group
or platform-vms-sg
) of the given environment.
Nothing happens if the subnets already have the tag.
See also
- https://docs.pivotal.io/pks/1-7/deploy-workloads.html#aws (for public subnets)
- kubernetes/kubernetes#17626 (comment) (for the security group of workers)
pks-aws attach-lb <CLUSTER_NAME>
These commands register master vms of the given cluster behind the NLB with the name pks-<CLUSTER_NAME>
.
If you want to specify the LB name, use pks-aws attach-lb <CLUSTER_NAME> <LB_NAME>
instead.
See also https://docs.pivotal.io/pks/1-7/aws-cluster-load-balancer.html#reconfigure
pks-aws delete-tags <CLUSTER_NAME> <ENV_NAME>
pks-aws delete-lb <CLUSTER_NAME>
ENV_NAME=my-dev
CLUSTER_NAME=cluster01
MASTER_HOSTNAME=$(pks-aws create-lb ${CLUSTER_NAME} ${ENV_NAME})
pks create-cluster ${CLUSTER_NAME} -e ${MASTER_HOSTNAME} -p small -n 1 --wait
pks-aws attach-lb ${CLUSTER_NAME}
pks-aws create-tags ${CLUSTER_NAME} ${ENV_NAME}
pks get-credentials ${CLUSTER_NAME}
pks-aws delete-tags ${CLUSTER_NAME} ${ENV_NAME}
pks-aws delete-lb ${CLUSTER_NAME}
pks delete-cluster ${CLUSTER_NAME}
Originally based on: https://github.com/ronakbanka/manage-pks