Skip to content

Instantly share code, notes, and snippets.

View alicek106's full-sized avatar

Chanho Yong alicek106

View GitHub Profile
root@aws-cli:/# aws eks delete-cluster --region ap-northeast-2 --name alicek106-eks-cluster
root@aws-cli:/# aws cloudformation delete-stack --stack-name eks-worker-group-stack --region ap-northeast-2
root@aws-cli:/# aws cloudformation delete-stack --stack-name eks-vpc-stack --region ap-northeast-2
root@aws-cli:/# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hostname-service LoadBalancer 10.100.236.181 a5a9d0f01521911e99dc802f1aa799a4-0a0d0a2011811a3b.elb.ap-northeast-2.amazonaws.com 80:31456/TCP 4m
kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 2h
root@aws-cli:/# git clone https://github.com/alicek106/aws-kubernetes-LB-example.git
Cloning into 'aws-kubernetes-LB-example'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 15 (delta 4), reused 15 (delta 4), pack-reused 0
Unpacking objects: 100% (15/15), done.
Checking connectivity... done.
root@aws-cli:/# kubectl apply -f aws-kubernetes-LB-example/aws-nlb/1-echo-hostname.yaml
root@aws-cli:/# export NODE_INSTANCE_ROLE=$(aws cloudformation describe-stacks --region ap-northeast-2 \
--stack-name eks-worker-group-stack | \
jq -r '.Stacks[].Outputs[] | select(.OutputKey == "NodeInstanceRole")' | \
jq -r '.OutputValue')
root@aws-cli:/# aws cloudformation create-stack --region ap-northeast-2 \
--stack-name eks-worker-group-stack \
--template-body=https://amazon-eks.s3-us-west-2.amazonaws.com/cloudformation/2019-02-11/amazon-eks-nodegroup.yaml \
--parameters=file://stack_parameter.json \
--capabilities CAPABILITY_IAM
root@aws-cli:/# cat parameter.json | sed "s/<KEY_NAME>/$KEY_NAME/g; \
s/<AMI_ID>/$AMI_ID/g; s/<SUBNET_IDS>/$SUBNET_IDS/g; \
s/<CONTROLLPLANE_SG_ID>/$CONTROLLPLANE_SG_ID/g; \
s/<VPC_ID>/$VPC_ID/g;" > stack_parameter.json
root@aws-cli:/# echo $VPC_ID
vpc-01de6f0539d2c720a
root@aws-cli:/# echo $CONTROLLPLANE_SG_ID
sg-06607725be0b75ec3
root@aws-cli:/# echo $SUBNET_IDS
subnet-0884eab9dd736ec08,subnet-083752641b7329c9a
root@aws-cli:/# export KEY_NAME=tf-kube
root@aws-cli:/# export AMI_ID=ami-0d87105164496b94b
root@aws-cli:/# export VPC_ID=$(aws cloudformation describe-stacks --region ap-northeast-2 \
--stack-name eks-vpc-stack | \
jq -r '.Stacks[].Outputs[] | select(.OutputKey == "VpcId")' | \
jq -r '.OutputValue')
[
{
"ParameterKey": "KeyName",
"ParameterValue": "<KEY_NAME>"
},
{
"ParameterKey": "NodeImageId",
"ParameterValue": "<AMI_ID>"
},
{
NAME STATUS ROLES AGE VERSION
ip-192-168-108-185.ap-northeast-2.compute.internal Ready <none> 1m v1.11.5
ip-192-168-130-68.ap-northeast-2.compute.internal Ready <none> 1m v1.11.5