-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathicp-deploy.tf
145 lines (116 loc) · 6.75 KB
/
icp-deploy.tf
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
##################################
## This module handles all the ICP confifguration
## and prerequisites setup
##################################
# TODO: Add azure-disk and azure-file volumes
data "azurerm_client_config" "client_config" {}
locals {
# Intermediate interpolations
credentials = "${var.registry_username != "" ? join(":", list("${var.registry_username}"), list("${var.registry_password}")) : ""}"
cred_reg = "${local.credentials != "" ? join("@", list("${local.credentials}"), list("${var.private_registry}")) : ""}"
# Inception image formatted for ICP deploy module
inception_image = "${local.cred_reg != "" ? join("/", list("${local.cred_reg}"), list("${var.icp_inception_image}")) : var.icp_inception_image}"
}
module "icpprovision" {
source = "github.com/ibm-cloud-architecture/terraform-module-icp-deploy?ref=3.0.7"
bastion_host = "${azurerm_public_ip.bootnode_pip.ip_address}"
# Provide IP addresses for boot, master, mgmt, va, proxy and workers
boot-node = "${element(concat(azurerm_network_interface.boot_nic.*.private_ip_address, list("")), 0)}"
icp-host-groups = {
master = ["${azurerm_network_interface.master_nic.*.private_ip_address}"]
worker = ["${azurerm_network_interface.worker_nic.*.private_ip_address}"]
proxy = ["${azurerm_network_interface.proxy_nic.*.private_ip_address}"]
#management = ["${azurerm_network_interface.management_nic.*.private_ip_address}"]
management = "${slice(
concat(azurerm_network_interface.management_nic.*.private_ip_address, azurerm_network_interface.master_nic.*.private_ip_address),
0, var.management["nodes"] > 0 ? length(azurerm_network_interface.management_nic.*.private_ip_address) : length(azurerm_network_interface.master_nic.*.private_ip_address))}"
}
icp-inception = "${local.inception_image}"
# Workaround for terraform issue #10857
# When this is fixed, we can work this out autmatically
cluster_size = "${var.boot["nodes"] + var.master["nodes"] + var.worker["nodes"] + var.proxy["nodes"] + var.management["nodes"]}"
icp_configuration = {
"network_cidr" = "${var.network_cidr}"
"service_cluster_ip_range" = "${var.cluster_ip_range}"
"ansible_user" = "icpdeploy"
"ansible_become" = "true"
"cluster_lb_address" = "${azurerm_public_ip.master_pip.fqdn}"
"proxy_lb_address" = "${azurerm_public_ip.master_pip.fqdn}"
"cluster_CA_domain" = "${azurerm_public_ip.master_pip.fqdn}"
"cluster_name" = "${var.cluster_name}"
"private_registry_enabled" = "${var.private_registry != "" ? "true" : "false"}"
# "private_registry_server" = "${var.private_registry}"
"image_repo" = "${var.private_registry != "" ? "${var.private_registry}/${dirname(var.icp_inception_image)}" : ""}"
"docker_username" = "${var.registry_username}"
"docker_password" = "${var.registry_password}"
# An admin password will be generated if not supplied in terraform.tfvars
"default_admin_password" = "${var.icpadmin_password}"
# This is the list of disabled management services
"management_services" = "${local.disabled_management_services}"
"calico_ip_autodetection_method" = "first-found"
"kubelet_nodename" = "nodename"
"cloud_provider" = "azure"
# Azure specific arguments
"kube_controller_manager_extra_args" = ["--allocate-node-cidrs=true", "--feature-gates=ServiceNodeExclusion=true"]
"kubelet_extra_args" = ["--enable-controller-attach-detach=true"]
# Azure specific configurations
# We don't need ip in ip with Azure networking
"calico_ipip_enabled" = "false"
# Settings for patched icp-inception
"calico_networking_backend" = "none"
"calico_ipam_type" = "host-local"
"calico_ipam_subnet" = "usePodCidr"
# Try this later: "calico_cluster_type" = "k8s"
"etcd_extra_args" = [
"--grpc-keepalive-timeout=0",
"--grpc-keepalive-interval=0",
"--snapshot-count=10000",
"--heartbeat-interval=250",
"--election-timeout=1250"
]
"azure" = {
"cloud_provider_conf" = {
"cloud" = "AzurePublicCloud"
"useInstanceMetadata" = "true"
"tenantId" = "${data.azurerm_client_config.client_config.tenant_id}"
"subscriptionId" = "${data.azurerm_client_config.client_config.subscription_id}"
"resourceGroup" = "${azurerm_resource_group.icp.name}"
"useManagedIdentityExtension" = "true"
}
"cloud_provider_controller_conf" = {
"cloud" = "AzurePublicCloud"
"useInstanceMetadata" = "true"
"tenantId" = "${data.azurerm_client_config.client_config.tenant_id}"
"subscriptionId" = "${data.azurerm_client_config.client_config.subscription_id}"
"resourceGroup" = "${azurerm_resource_group.icp.name}"
"aadClientId" = "${var.aadClientId}"
"aadClientSecret" = "${var.aadClientSecret}"
"location" = "${azurerm_resource_group.icp.location}"
"subnetName" = "${element(compact(concat(list("${var.container_subnet_id}"), azurerm_subnet.container_subnet.*.id)), 0)}"
"vnetName" = "${azurerm_virtual_network.icp_vnet.name}"
"vnetResourceGroup" = "${azurerm_resource_group.icp.name}"
"routeTableName" = "${azurerm_route_table.routetb.name}"
"cloudProviderBackoff" = "false"
"loadBalancerSku" = "Standard"
"primaryAvailabilitySetName" = "${basename(element(azurerm_virtual_machine.worker.*.availability_set_id, 0))}"# "workers_availabilityset"
"securityGroupName" = "${azurerm_network_security_group.worker_sg.name}"# "hktest-worker-sg"
"excludeMasterFromStandardLB" = "true"
"useManagedIdentityExtension" = "false"
}
}
# We'll insert a dummy value here to create an implicit dependency on VMs in Terraform
"dummy_waitfor" = "${length(concat(azurerm_virtual_machine.boot.*.id, azurerm_virtual_machine.master.*.id, azurerm_virtual_machine.worker.*.id, azurerm_virtual_machine.management.*.id))}"
}
generate_key = true
ssh_user = "icpdeploy"
ssh_key_base64 = "${base64encode(tls_private_key.installkey.private_key_pem)}"
}
output "icp_admin_username" {
value = "admin"
}
output "icp_admin_password" {
value = "${module.icpprovision.default_admin_password}"
}
output "cloudctl" {
value = "cloudctl login --skip-ssl-validation -a https://${element(azurerm_public_ip.master_pip.*.fqdn, 0)}:8443 -u admin -p ${module.icpprovision.default_admin_password} -n default -c id-${var.cluster_name}-account"
}