@@ -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
3940resource "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-
378350data "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
386358resource "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
408382data "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
412389resource "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 = {
0 commit comments