KOps Quick Bootstrapping on AWS

Balman RawatBalman Rawat
2 min read

https://kops.sigs.k8s.io/getting_started/aws/

Pre-requisite

DOMAIN=kops.balmanrawat.com.np

aws route53 create-hosted-zone \
    --name ${DOMAIN} \
    --caller-reference kops-expriment

ACCOUNT_ID=$(aws sts get-caller-identity --query 'Account' --output text)

aws s3api create-bucket \
    --bucket kops-${ACCOUNT_ID} \
    --region us-east-1

aws s3api put-bucket-versioning \
    --bucket kops-${ACCOUNT_ID} \
    --versioning-configuration Status=Enabled

OIDC

aws s3api create-bucket \
    --bucket kops-oidc-${ACCOUNT_ID} \
    --region us-east-1 \
    --object-ownership BucketOwnerPreferred

aws s3api put-public-access-block \
    --bucket kops-oidc-${ACCOUNT_ID} \
    --public-access-block-configuration BlockPublicAcls=false,IgnorePublicAcls=false,BlockPublicPolicy=false,RestrictPublicBuckets=false

aws s3api put-bucket-acl \
    --bucket kops-oidc-${ACCOUNT_ID} \
    --acl public-read

Creating Cluster

export NAME=${DOMAIN}
export KOPS_STATE_STORE=s3://kops-${ACCOUNT_ID}

# aws ec2 describe-availability-zones --region us-east-1

kops create cluster \
    --name=${NAME} \
    --cloud=aws \
    --zones=us-east-1a \
    --dns-zone=kubernetes.${DOMAIN} \
    --discovery-store=s3://kops-oidc-${ACCOUNT_ID}/${NAME}/discovery

kops update cluster --name ${NAME} --yes --admin

Validate

Suggestions:
 * validate cluster: kops validate cluster --wait 10m
 * list nodes: kubectl get nodes --show-labels
 * ssh to a control-plane node: ssh -i ~/.ssh/id_rsa ubuntu@
 * the ubuntu user is specific to Ubuntu. If not using Ubuntu please use the appropriate user based on your OS.
 * read about installing addons at: https://kops.sigs.k8s.io/addons.

Cleanup

kops delete cluster --name ${NAME} --yes

aws s3 rm s3://kops-${ACCOUNT_ID} --recursive
aws s3api delete-bucket --bucket kops-${ACCOUNT_ID} --region us-east-1

aws s3 rm s3://kops-oidc-${ACCOUNT_ID} --recursive
aws s3api delete-bucket --bucket kops-oidc-${ACCOUNT_ID} --region us-east-1

HOSTEDZONE_ID=$(aws route53 list-hosted-zones-by-name --dns-name ${DOMAIN} --query 'HostedZones[0].Id' --output text | sed 's/\/hostedzone\///')
aws route53 list-resource-record-sets --hosted-zone-id ${HOSTEDZONE_ID} > delete-record-set.json
#delete ns/soa record form the file and run the delete
aws route53 change-resource-record-sets --hosted-zone-id ${HOSTEDZONE_ID} --change-batch file://delete-record-sets.json
aws route53 delete-hosted-zone --id ${HOSTEDZONE_ID}
0
Subscribe to my newsletter

Read articles from Balman Rawat directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Balman Rawat
Balman Rawat

I love to grease knots and bolts of SDLC, nurture the underlying infra, rightly automate, monitor systems and enable the dev teams to achieve more with less.