Skip to content

Commit 5bfaed3

Browse files
authored
Merge pull request #44 from Prajyot-Parab/main
Mark apikey vars sensitive and fix formatting
2 parents 4c52609 + 7428065 commit 5bfaed3

File tree

10 files changed

+111
-109
lines changed

10 files changed

+111
-109
lines changed

kubetest2-tf/data/config.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ variable "cluster_name" {
44

55
variable "release_marker" {
66
description = "Kubernetes release marker"
7-
default = "ci/latest"
7+
default = "ci/latest"
88
}
99

1010
variable "build_version" {
@@ -13,7 +13,7 @@ variable "build_version" {
1313

1414
variable "ssh_private_key" {
1515
description = "SSH Private Key file's complete path"
16-
default = "~/.ssh/id_rsa"
16+
default = "~/.ssh/id_rsa"
1717
}
1818

1919
variable "kubeconfig_path" {
@@ -22,10 +22,10 @@ variable "kubeconfig_path" {
2222

2323
variable "workers_count" {
2424
description = "Number of workers in the cluster"
25-
default = 1
25+
default = 1
2626
}
2727

2828
variable "bootstrap_token" {
2929
description = "Kubeadm bootstrap token used for installing and joining the cluster"
30-
default = "abcdef.0123456789abcdef"
30+
default = "abcdef.0123456789abcdef"
3131
}
Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
data "ibm_pi_network" "power_network" {
2-
pi_network_name = var.network
3-
pi_cloud_instance_id = var.powervs_service_instance_id
2+
pi_network_name = var.network
3+
pi_cloud_instance_id = var.powervs_service_instance_id
44
}
55

66
data "ibm_pi_image" "power_images" {
7-
pi_image_name = var.image_name
8-
pi_cloud_instance_id = var.powervs_service_instance_id
7+
pi_image_name = var.image_name
8+
pi_cloud_instance_id = var.powervs_service_instance_id
99
}
1010

1111
resource "ibm_pi_instance" "pvminstance" {
12-
count = var.instance_count
13-
pi_memory = var.memory
14-
pi_processors = var.processors
15-
pi_instance_name = var.instance_count == 1 ? var.vm_name : "${var.vm_name}-${count.index}"
16-
pi_proc_type = var.proc_type
17-
pi_image_id = data.ibm_pi_image.power_images.id
18-
pi_key_pair_name = var.ssh_key_name
19-
pi_sys_type = var.system_type
20-
pi_storage_type = var.storage_tier
21-
pi_cloud_instance_id = var.powervs_service_instance_id
22-
pi_user_data = var.user_data
23-
# Wait for the WARNING state instead of OK state to save some time because we aren't performing any DLPAR operations
24-
# on this LPARS and later in the flow we also have ssh connectivity check to confirm deployed vms are up and running.
25-
pi_health_status = "WARNING"
12+
count = var.instance_count
13+
pi_memory = var.memory
14+
pi_processors = var.processors
15+
pi_instance_name = var.instance_count == 1 ? var.vm_name : "${var.vm_name}-${count.index}"
16+
pi_proc_type = var.proc_type
17+
pi_image_id = data.ibm_pi_image.power_images.id
18+
pi_key_pair_name = var.ssh_key_name
19+
pi_sys_type = var.system_type
20+
pi_storage_type = var.storage_tier
21+
pi_cloud_instance_id = var.powervs_service_instance_id
22+
pi_user_data = var.user_data
23+
# Wait for the WARNING state instead of OK state to save some time because we aren't performing any DLPAR operations
24+
# on this LPARS and later in the flow we also have ssh connectivity check to confirm deployed vms are up and running.
25+
pi_health_status = "WARNING"
2626

27-
pi_network {
28-
network_id = data.ibm_pi_network.power_network.id
29-
}
30-
timeouts {
31-
create = "30m"
32-
delete = "30m"
33-
}
27+
pi_network {
28+
network_id = data.ibm_pi_network.power_network.id
29+
}
30+
timeouts {
31+
create = "30m"
32+
delete = "30m"
33+
}
3434
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
output "addresses" {
2-
value = ibm_pi_instance.pvminstance.*.pi_network
2+
value = ibm_pi_instance.pvminstance.*.pi_network
33
}

kubetest2-tf/data/powervs/instance/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
terraform {
22
required_providers {
33
ibm = {
4-
source = "IBM-Cloud/ibm"
4+
source = "IBM-Cloud/ibm"
55
version = ">= 1.12.0"
66
}
77
}
Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,85 @@
11

22
variable "ibmcloud_api_key" {
3-
description = "Denotes the IBM Cloud API key to use"
3+
description = "Denotes the IBM Cloud API key to use"
4+
sensitive = true
45
}
56

67
variable "ibmcloud_region" {
7-
description = "Denotes which IBM Cloud region to connect to"
8+
description = "Denotes which IBM Cloud region to connect to"
89
}
910

1011
variable "ibmcloud_zone" {
11-
description = "Denotes which IBM Cloud zone to connect to - .i.e: eu-de-1 eu-de-2 us-south etc."
12+
description = "Denotes which IBM Cloud zone to connect to - .i.e: eu-de-1 eu-de-2 us-south etc."
1213
}
1314

1415
variable "vm_name" {
15-
description = "Name of the VM"
16+
description = "Name of the VM"
1617
}
1718

1819
variable "powervs_service_instance_id" {
19-
description = "Power Virtual Server service instance ID"
20+
description = "Power Virtual Server service instance ID"
2021
}
2122

2223
variable "memory" {
23-
description = "Amount of memory (GB) to be allocated to the VM"
24+
description = "Amount of memory (GB) to be allocated to the VM"
2425
}
2526

2627
variable "processors" {
27-
description = "Number of virtual processors to allocate to the VM"
28+
description = "Number of virtual processors to allocate to the VM"
2829
}
2930

3031
variable "proc_type" {
31-
description = "Processor type for the LPAR - shared/dedicated"
32-
default = "shared"
32+
description = "Processor type for the LPAR - shared/dedicated"
33+
default = "shared"
3334
}
3435

3536
variable "ssh_key_name" {
36-
description = "SSH key name in IBM Cloud to be used for SSH logins"
37+
description = "SSH key name in IBM Cloud to be used for SSH logins"
3738
}
3839

3940
variable "shareable" {
40-
description = "Should the data volume be shared or not - true/false"
41-
default = "false"
41+
description = "Should the data volume be shared or not - true/false"
42+
default = "false"
4243
}
4344

4445
variable "network" {
45-
description = "Network that should be attached to the VM - Create this network before running terraform"
46+
description = "Network that should be attached to the VM - Create this network before running terraform"
4647
}
4748

4849
variable "system_type" {
49-
description = "Type of system on which the VM should be created - s922/e980"
50-
default = "s922"
50+
description = "Type of system on which the VM should be created - s922/e980"
51+
default = "s922"
5152
}
5253

5354
variable "storage_tier" {
54-
description = "I/O operation per second (IOPS) based storage on requirement - tier0, tier1, tier3 or tier5k"
55+
description = "I/O operation per second (IOPS) based storage on requirement - tier0, tier1, tier3 or tier5k"
5556
}
5657

5758
variable "image_name" {
58-
description = "Name of the image from which the VM should be deployed - IBM i image name"
59+
description = "Name of the image from which the VM should be deployed - IBM i image name"
5960
}
6061

6162
variable "replication_policy" {
62-
description = "Replication policy of the VM"
63-
default = "none"
63+
description = "Replication policy of the VM"
64+
default = "none"
6465
}
6566

6667
variable "replication_scheme" {
67-
description = "Replication scheme for the VM"
68-
default = "suffix"
68+
description = "Replication scheme for the VM"
69+
default = "suffix"
6970
}
7071

7172
variable "replicants" {
72-
description = "Number of VM instances to deploy"
73-
default = "1"
73+
description = "Number of VM instances to deploy"
74+
default = "1"
7475
}
7576

7677
variable "user_data" {
77-
description = "User data in base64 encoded format"
78-
default = ""
78+
description = "User data in base64 encoded format"
79+
default = ""
7980
}
8081

8182
variable "instance_count" {
82-
description = "Number of instances"
83-
default = 1
84-
}
83+
description = "Number of instances"
84+
default = 1
85+
}

kubetest2-tf/data/powervs/main.tf

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,55 +5,55 @@ data "ibm_pi_network" "existing_net" {
55
}
66

77
resource "ibm_pi_network" "public_network" {
8-
count = var.powervs_network_name == "" ? 1 : 0
9-
pi_network_name = "${var.cluster_name}-pub-net"
10-
pi_cloud_instance_id = var.powervs_service_id
11-
pi_network_type = "pub-vlan"
12-
pi_dns = [ "8.8.4.4", "8.8.8.8"]
8+
count = var.powervs_network_name == "" ? 1 : 0
9+
pi_network_name = "${var.cluster_name}-pub-net"
10+
pi_cloud_instance_id = var.powervs_service_id
11+
pi_network_type = "pub-vlan"
12+
pi_dns = ["8.8.4.4", "8.8.8.8"]
1313
}
1414

1515
module "master" {
1616
source = "./instance"
1717

18-
ibmcloud_api_key = var.powervs_api_key
19-
image_name = var.powervs_image_name
20-
memory = var.controlplane_powervs_memory
21-
network = var.powervs_network_name == "" ? ibm_pi_network.public_network[0].network_id : data.ibm_pi_network.existing_net[0].id
18+
ibmcloud_api_key = var.powervs_api_key
19+
image_name = var.powervs_image_name
20+
memory = var.controlplane_powervs_memory
21+
network = var.powervs_network_name == "" ? ibm_pi_network.public_network[0].network_id : data.ibm_pi_network.existing_net[0].id
2222
powervs_service_instance_id = var.powervs_service_id
23-
processors = var.controlplane_powervs_processors
24-
ssh_key_name = var.powervs_ssh_key
25-
system_type = var.powervs_system_type
26-
storage_tier = var.powervs_storage_tier
27-
vm_name = "${var.cluster_name}-master"
28-
ibmcloud_region = var.powervs_region
29-
ibmcloud_zone = var.powervs_zone
23+
processors = var.controlplane_powervs_processors
24+
ssh_key_name = var.powervs_ssh_key
25+
system_type = var.powervs_system_type
26+
storage_tier = var.powervs_storage_tier
27+
vm_name = "${var.cluster_name}-master"
28+
ibmcloud_region = var.powervs_region
29+
ibmcloud_zone = var.powervs_zone
3030
}
3131

3232
module "workers" {
33-
source = "./instance"
33+
source = "./instance"
3434
instance_count = var.workers_count
3535

36-
ibmcloud_api_key = var.powervs_api_key
37-
image_name = var.powervs_image_name
38-
memory = var.powervs_memory
39-
network = var.powervs_network_name == "" ? ibm_pi_network.public_network[0].network_id : data.ibm_pi_network.existing_net[0].id
36+
ibmcloud_api_key = var.powervs_api_key
37+
image_name = var.powervs_image_name
38+
memory = var.powervs_memory
39+
network = var.powervs_network_name == "" ? ibm_pi_network.public_network[0].network_id : data.ibm_pi_network.existing_net[0].id
4040
powervs_service_instance_id = var.powervs_service_id
41-
processors = var.powervs_processors
42-
ssh_key_name = var.powervs_ssh_key
43-
system_type = var.powervs_system_type
44-
storage_tier = var.powervs_storage_tier
45-
vm_name = "${var.cluster_name}-worker"
46-
ibmcloud_region = var.powervs_region
47-
ibmcloud_zone = var.powervs_zone
41+
processors = var.powervs_processors
42+
ssh_key_name = var.powervs_ssh_key
43+
system_type = var.powervs_system_type
44+
storage_tier = var.powervs_storage_tier
45+
vm_name = "${var.cluster_name}-worker"
46+
ibmcloud_region = var.powervs_region
47+
ibmcloud_zone = var.powervs_zone
4848
}
4949

5050
resource "null_resource" "wait-for-master-completes" {
5151
connection {
52-
type = "ssh"
53-
user = "root"
54-
host = module.master.addresses[0][0].external_ip
52+
type = "ssh"
53+
user = "root"
54+
host = module.master.addresses[0][0].external_ip
5555
private_key = file(var.ssh_private_key)
56-
timeout = "20m"
56+
timeout = "20m"
5757
}
5858
provisioner "remote-exec" {
5959
inline = [
@@ -65,11 +65,11 @@ resource "null_resource" "wait-for-master-completes" {
6565
resource "null_resource" "wait-for-workers-completes" {
6666
count = var.workers_count
6767
connection {
68-
type = "ssh"
69-
user = "root"
70-
host = module.workers.addresses[count.index][0].external_ip
68+
type = "ssh"
69+
user = "root"
70+
host = module.workers.addresses[count.index][0].external_ip
7171
private_key = file(var.ssh_private_key)
72-
timeout = "15m"
72+
timeout = "15m"
7373
}
7474
provisioner "remote-exec" {
7575
inline = [
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
output "masters" {
2-
value = module.master.addresses[*][0].external_ip
2+
value = module.master.addresses[*][0].external_ip
33
description = "k8s master node IP addresses"
44
}
55

66
output "workers" {
7-
value = module.workers.addresses[*][0].external_ip
7+
value = module.workers.addresses[*][0].external_ip
88
description = "k8s worker node IP addresses"
99
}
1010

1111
output "masters_private" {
12-
value = module.master.addresses[*][0].ip_address
12+
value = module.master.addresses[*][0].ip_address
1313
description = "k8s master nodes private IP addresses"
1414
}
1515

1616
output "workers_private" {
17-
value = module.workers.addresses[*][0].ip_address
17+
value = module.workers.addresses[*][0].ip_address
1818
description = "k8s worker nodes private IP addresses"
1919
}
2020

2121
output "network" {
22-
value = ibm_pi_network.public_network
22+
value = ibm_pi_network.public_network
2323
description = "Network used for the deployment"
2424
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
terraform {
22
required_providers {
33
ibm = {
4-
source = "IBM-Cloud/ibm"
4+
source = "IBM-Cloud/ibm"
55
version = ">= 1.12.0"
66
}
77
}
88
}
99

1010
provider "ibm" {
1111
ibmcloud_api_key = var.powervs_api_key
12-
region = var.powervs_region
13-
zone = var.powervs_zone
12+
region = var.powervs_region
13+
zone = var.powervs_zone
1414
}

0 commit comments

Comments
 (0)