#!/bin/bash

export KOPS_STATE_STORE=s3://test.datasaker.io
export KOPS_CLUSTER_NAME=k8s-spot.datasaker.io

export VPC_ID="vpc-00ba2b0e9ad59f0ed"
export Network_CIDR="172.24.0.0/19"
export AMI_Image="ami-0409b7ddbc59e3222"
export Private_Subnet_ID_1="subnet-024f0deda82039fa4"
export Private_Subnet_ID_2="subnet-050d942fa1c46540a"
export Private_Subnet_ID_3="subnet-0946eb806af7377be"
export Public_Subnet_ID_1="subnet-00c363356f133411d"
export Public_Subnet_ID_2="subnet-07aa5e879a262014d"
export Public_Subnet_ID_3="subnet-0073a61bc56a68a3e"

kops_cmd="""
kops create cluster \
 --vpc "$VPC_ID" \
 --cloud aws \
 --ssh-public-key "$HOME/.ssh/id_rsa.pub" \
 --topology private --kubernetes-version "1.25.2" \
 --network-cidr "$Network_CIDR" \
 --networking calico \
 --container-runtime containerd \
 --image $AMI_Image \
 --zones ap-northeast-2a,ap-northeast-2b,ap-northeast-2c \
 --master-count 3 \
 --master-size t3.small \
 --node-count 3 \
 --node-size t3.small \
 --node-volume-size 100 \
 --subnets "$Private_Subnet_ID_1,$Private_Subnet_ID_2,$Private_Subnet_ID_3" \
 --utility-subnets "$Public_Subnet_ID_1,$Public_Subnet_ID_2,$Public_Subnet_ID_3" \
 -v 10
"""

kubeconfig="kops export kubecfg --admin8760h0m0s --kubeconfig /root/.kube/config --name=${KOPS_CLUSTER_NAME} --state=${KOPS_STATE_STORE}"
echo ${kubeconfig}
echo
echo
echo ${kops_cmd}
