/
create_vpc_kubernetes_cluster_with_terraform.sh
79 lines (63 loc) · 2.12 KB
/
create_vpc_kubernetes_cluster_with_terraform.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# **************** Global variables
source ./.env
#export TF_LOG=debug
export TF_VAR_flavor="bx2.4x16"
export TF_VAR_worker_count="2"
export TF_VAR_kubernetes_pricing="tiered-pricing"
export TF_VAR_resource_group=$GROUP
export TF_VAR_vpc_name="watson-stt-tsuedbro"
export TF_VAR_region=$REGION
export TF_VAR_kube_version="1.25.5"
export TF_VAR_cluster_name="watson-stt-tsuedbro"
# **************** logon with IBM Cloud CLI ****************
echo "*********************************"
echo ""
echo "1. Logon with IBM Cloud CLI "
ibmcloud login --apikey $IC_API_KEY
ibmcloud resource groups
ibmcloud resource group-create $REGION
ibmcloud target -r $REGION
ibmcloud target -g $GROUP
ibmcloud plugin update
ibmcloud plugin list
ibmcloud is target --gen 2
# **************** install needed plugins ****************
#ibmcloud plugin install vpc-infrastructure
#ibmcloud plugin install container-service
# **************** init ****************
echo "*********************************"
echo ""
echo "2. Initialize Terraform on IBM Cloud"
terraform init
# **************** plan ****************
echo "*********************************"
echo ""
echo "3. Generate a Terraform on IBM Cloud execution plan for the VPC infrastructure resources"
terraform plan
# **************** apply ***************
echo "*********************************"
echo ""
echo "4. Apply a the Terraform on IBM Cloud execution plan for the VPC infrastructure resources"
terraform apply
echo "*********************************"
echo ""
echo "Verify the setup with the IBM Cloud CLI"
ibmcloud is vpcs
ibmcloud is subnets
ibmcloud is security-groups
ibmcloud is keys
ibmcloud ks cluster ls
echo "*********************************"
echo ""
echo "5. Verify the created VPC instructure on IBM Cloud: https://cloud.ibm.com/vpc-ext/vpcLayout"
read ANYKEY
echo "*********************************"
echo ""
echo "6. Verify the created Kubernetes Cluster instance on IBM Cloud: https://cloud.ibm.com/kubernetes/clusters"
read ANYKEY
# **************** destroy *************
echo "*********************************"
echo ""
echo "7. Remove VPC infrastructure resources"
#terraform destroy