Skip to content

Commit 79169cd

Browse files
authored
Merge pull request #76 from equinix/v1.8.0
Anthos 1.8.3, CCM 3.2.2, and more!
2 parents e2d8891 + 7a79b76 commit 79169cd

File tree

14 files changed

+152
-186
lines changed

14 files changed

+152
-186
lines changed

.terraform.lock.hcl

Lines changed: 71 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,9 @@ A complete list of variables can be found at <https://registry.terraform.io/modu
182182
| gcp_keys_path | string | n/a | The path to a directory with GCP service account keys |
183183
| bgp_asn | string | 65000 | BGP ASN to peer with Equinix Metal |
184184
| ccm_version | string | v2.0.0 | The version of the Equinix Metal CCM |
185-
| kube_vip_version | string | 0.2.3 | The version of Kube-VIP to install |
185+
| kube_vip_version | string | 0.3.8 | The version of Kube-VIP to install |
186186
| anthos_version | string | 1.7.0 | The version of Google Anthos to install |
187187
| ccm_deploy_url | string | **Too Long to put here...** | The deploy url for the Equinix Metal CCM |
188-
| kube_vip_daemonset_url | string | **Too Long to put here...** | The deploy url for the Kube-VIP Daemonset |
189188
| storage_provider | string | n/a | Enable a Storage module (examples: "portworx", "rook") |
190189
| storage_options | map | n/a | Options specific to the storage module |
191190

gcp-apis.tf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
locals {
22
enabled_apis = [
33
"anthos.googleapis.com",
4+
"anthosaudit.googleapis.com",
45
"anthosgke.googleapis.com",
56
"cloudresourcemanager.googleapis.com",
67
"container.googleapis.com",
7-
"iam.googleapis.com",
88
"gkeconnect.googleapis.com",
9-
"serviceusage.googleapis.com",
10-
"stackdriver.googleapis.com",
9+
"gkehub.googleapis.com",
10+
"iam.googleapis.com",
11+
"opsconfigmonitoring.googleapis.com",
12+
"logging.googleapis.com",
1113
"monitoring.googleapis.com",
12-
"logging.googleapis.com"
14+
"serviceusage.googleapis.com",
15+
"stackdriver.googleapis.com"
1316
]
1417
}
1518

gcp-service-accts.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ resource "google_project_iam_member" "cloud_ops_sa_role_dashboard" {
7070
member = format("%s:%s", local.sa_text, google_service_account.cloud_ops_sa[count.index].email)
7171
}
7272

73+
resource "google_project_iam_member" "cloud_ops_sa_role_metadata_writer" {
74+
count = local.sa_count
75+
role = "roles/opsconfigmonitoring.resourceMetadata.writer"
76+
member = format("%s:%s", local.sa_text, google_service_account.cloud_ops_sa[count.index].email)
77+
}
78+
79+
7380
resource "google_project_iam_member" "bmctl_sa_compute" {
7481
count = local.sa_count
7582
role = "roles/compute.viewer"

main.tf

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ locals {
3434
register_sa_key = var.gcp_keys_path == "" ? base64decode(google_service_account_key.register_sa_key[0].private_key) : file("${var.gcp_keys_path}/register.json")
3535
cloud_ops_sa_key = var.gcp_keys_path == "" ? base64decode(google_service_account_key.cloud_ops_sa_key[0].private_key) : file("${var.gcp_keys_path}/cloud-ops.json")
3636
bmctl_sa_key = var.gcp_keys_path == "" ? base64decode(google_service_account_key.bmctl_sa_key[0].private_key) : file("${var.gcp_keys_path}/bmctl.json")
37+
ccm_deploy_url = format("https://github.com/equinix/cloud-provider-equinix-metal/releases/download/%s/deployment.yaml", var.ccm_version)
3738
}
3839

3940
resource "tls_private_key" "ssh_key_pair" {
@@ -140,7 +141,9 @@ data "template_file" "deploy_anthos_cluster" {
140141
cp_vip = cidrhost(metal_reserved_ip_block.cp_vip.cidr_notation, 0)
141142
ingress_vip = cidrhost(metal_reserved_ip_block.ingress_vip.cidr_notation, 0)
142143
cp_ips = join(" ", metal_device.control_plane.*.access_private_ipv4)
144+
cp_ids = join(" ", metal_device.control_plane.*.id)
143145
worker_ips = join(" ", metal_device.worker_nodes.*.access_private_ipv4)
146+
worker_ids = join(" ", metal_device.worker_nodes.*.id)
144147
anthos_ver = var.anthos_version
145148
}
146149
}
@@ -289,8 +292,10 @@ data "template_file" "add_remaining_cps" {
289292
template = file("${path.module}/templates/add_remaining_cps.sh")
290293
vars = {
291294
cluster_name = local.cluster_name
292-
cp_2 = metal_device.control_plane.1.access_private_ipv4
293-
cp_3 = metal_device.control_plane.2.access_private_ipv4
295+
cp_ip_2 = metal_device.control_plane.1.access_private_ipv4
296+
cp_id_2 = metal_device.control_plane.1.id
297+
cp_ip_3 = metal_device.control_plane.2.access_private_ipv4
298+
cp_id_3 = metal_device.control_plane.2.id
294299
}
295300
}
296301

@@ -342,39 +347,6 @@ resource "null_resource" "kube_vip_install_remaining_cp" {
342347
}
343348
}
344349

345-
data "template_file" "worker_kubelet_flags" {
346-
template = file("${path.module}/templates/worker_kubelet_flags.sh")
347-
}
348-
349-
resource "null_resource" "add_kubelet_flags_to_workers" {
350-
count = var.worker_count
351-
depends_on = [
352-
null_resource.kube_vip_install_remaining_cp,
353-
null_resource.deploy_anthos_cluster,
354-
null_resource.kube_vip_install_first_cp
355-
]
356-
connection {
357-
type = "ssh"
358-
user = "root"
359-
private_key = chomp(tls_private_key.ssh_key_pair.private_key_pem)
360-
host = element(metal_device.worker_nodes.*.access_public_ipv4, count.index)
361-
}
362-
provisioner "remote-exec" {
363-
inline = [
364-
"mkdir -p /root/bootstrap/"
365-
]
366-
}
367-
provisioner "file" {
368-
content = data.template_file.worker_kubelet_flags.rendered
369-
destination = "/root/bootstrap/worker_kubelet_flags.sh"
370-
}
371-
provisioner "remote-exec" {
372-
inline = [
373-
"bash /root/bootstrap/worker_kubelet_flags.sh"
374-
]
375-
}
376-
}
377-
378350
data "template_file" "ccm_secret" {
379351
template = file("${path.module}/templates/ccm_secret.yaml")
380352
vars = {
@@ -385,7 +357,9 @@ data "template_file" "ccm_secret" {
385357

386358
resource "null_resource" "install_ccm" {
387359
depends_on = [
388-
null_resource.add_kubelet_flags_to_workers
360+
null_resource.kube_vip_install_remaining_cp,
361+
null_resource.deploy_anthos_cluster,
362+
null_resource.kube_vip_install_first_cp
389363
]
390364
connection {
391365
type = "ssh"
@@ -400,13 +374,16 @@ resource "null_resource" "install_ccm" {
400374
provisioner "remote-exec" {
401375
inline = [
402376
"kubectl --kubeconfig /root/baremetal/bmctl-workspace/${local.cluster_name}/${local.cluster_name}-kubeconfig apply -f /root/bootstrap/ccm_secret.yaml",
403-
"kubectl --kubeconfig /root/baremetal/bmctl-workspace/${local.cluster_name}/${local.cluster_name}-kubeconfig apply -f ${var.ccm_deploy_url}"
377+
"kubectl --kubeconfig /root/baremetal/bmctl-workspace/${local.cluster_name}/${local.cluster_name}-kubeconfig apply -f ${local.ccm_deploy_url}"
404378
]
405379
}
406380
}
407381

408382
data "template_file" "kube_vip_ds" {
409383
template = file("${path.module}/templates/kube_vip_ds.yaml")
384+
vars = {
385+
kube_vip_ver = var.kube_vip_version
386+
}
410387
}
411388

412389
resource "null_resource" "install_kube_vip_daemonset" {
@@ -447,9 +424,6 @@ resource "null_resource" "worker_pre_reqs" {
447424
inline = ["mkdir -p /root/bootstrap/"]
448425
}
449426

450-
# Unless /root/bootstrap/ is created in advance, this will be
451-
# copied to /root/bootstrap (file)
452-
# https://github.com/hashicorp/terraform/issues/16330
453427
provisioner "file" {
454428
content = data.template_file.pre_reqs_worker.rendered
455429
destination = "/root/bootstrap/pre_reqs_worker.sh"
@@ -464,7 +438,7 @@ module "storage" {
464438
source = "./modules/storage"
465439

466440
depends_on = [
467-
null_resource.add_kubelet_flags_to_workers,
441+
null_resource.install_ccm,
468442
]
469443

470444
ssh = {

modules/rook/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ variable "rook_version" {
66

77
variable "latest_rook_version" {
88
type = string
9-
description = "The version of Rook to install"
10-
default = "v1.5.10"
9+
description = "The latest version of Rook that has been tested"
10+
default = "v1.7.3"
1111
}
1212

1313
variable "ssh" {

modules/storage/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
variable "storage_module" {
2-
description = "The name of the Storage provider module (ex. \"portworx\")"
2+
description = "The name of the Storage provider module (ex. \"rook\")"
33
default = ""
44
}
55

templates/add_remaining_cps.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#!/bin/bash
22

33
CLUSTER_NAME='${cluster_name}'
4-
CP_2='${cp_2}'
5-
CP_3='${cp_3}'
4+
CP_IP_2='${cp_ip_2}'
5+
CP_ID_2='${cp_id_2}'
6+
CP_IP_3='${cp_ip_3}'
7+
CP_ID_3='${cp_id_3}'
68

7-
# Wait a minute for things to settle
8-
#echo "Waiting for 60 seconds to let the cluster settle"
9-
#sleep 60
109
kubectl \
1110
--kubeconfig /root/baremetal/bmctl-workspace/$CLUSTER_NAME/$CLUSTER_NAME-kubeconfig \
1211
-n cluster-$CLUSTER_NAME \
@@ -17,14 +16,16 @@ kubectl \
1716
"op": "add",
1817
"path": "/spec/controlPlane/nodePoolSpec/nodes/1",
1918
"value": {
20-
"address": "'$CP_2'"
19+
"address": "'$CP_IP_2'",
20+
"providerID": "equinixmetal://'$CP_ID_2'"
2121
}
2222
},
2323
{
2424
"op": "add",
2525
"path": "/spec/controlPlane/nodePoolSpec/nodes/2",
2626
"value": {
27-
"address": "'$CP_3'"
27+
"address": "'$CP_IP_3'",
28+
"providerID": "equinixmetal://'$CP_ID_3'"
2829
}
2930
}
3031
]'

0 commit comments

Comments
 (0)