Skip to content

making/pks-cli-aws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

pks-aws CLI

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 to tkgi. According to this change, rename pks-aws to tkgi-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

Prerequisite

Following CLIs are required.

  • pks CLI and login as pks.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 .

How to use

Create a Load Balancer (NLB)

pks-aws create-lb <CLUSTER_NAME> <ENV_NAME>
  • CLUSTER_NAME should be same as the name you will use with pks create-cluster <CLUSTER_NAME>.

  • ENV_NAME is the value you configured in terraform.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

Create tags for public subnets

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

Attach a LB to IPs of master VMs

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

Delete tags for public subnets

pks-aws delete-tags <CLUSTER_NAME> <ENV_NAME>

Delete a LB

pks-aws delete-lb <CLUSTER_NAME>

Typical workflow

Create a new cluster

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}

Delete a cluter

pks-aws delete-tags ${CLUSTER_NAME} ${ENV_NAME}
pks-aws delete-lb ${CLUSTER_NAME}
pks delete-cluster ${CLUSTER_NAME}

Author

Originally based on: https://github.com/ronakbanka/manage-pks

About

A helper script of PKS/TKGI cli for AWS.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages