2018-08-20 03:48:22 +02:00
|
|
|
# Secure copy etcd TLS assets to controllers.
|
|
|
|
resource "null_resource" "copy-controller-secrets" {
|
2019-05-28 06:43:08 +02:00
|
|
|
count = var.controller_count
|
2018-08-20 03:48:22 +02:00
|
|
|
|
2019-05-28 06:43:08 +02:00
|
|
|
depends_on = [azurerm_virtual_machine.controllers]
|
2018-08-20 03:48:22 +02:00
|
|
|
|
|
|
|
connection {
|
|
|
|
type = "ssh"
|
2019-05-28 06:43:08 +02:00
|
|
|
host = element(azurerm_public_ip.controllers.*.ip_address, count.index)
|
2018-08-20 03:48:22 +02:00
|
|
|
user = "core"
|
|
|
|
timeout = "15m"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
2019-05-28 06:43:08 +02:00
|
|
|
content = module.bootkube.etcd_ca_cert
|
2018-08-20 03:48:22 +02:00
|
|
|
destination = "$HOME/etcd-client-ca.crt"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
2019-05-28 06:43:08 +02:00
|
|
|
content = module.bootkube.etcd_client_cert
|
2018-08-20 03:48:22 +02:00
|
|
|
destination = "$HOME/etcd-client.crt"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
2019-05-28 06:43:08 +02:00
|
|
|
content = module.bootkube.etcd_client_key
|
2018-08-20 03:48:22 +02:00
|
|
|
destination = "$HOME/etcd-client.key"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
2019-05-28 06:43:08 +02:00
|
|
|
content = module.bootkube.etcd_server_cert
|
2018-08-20 03:48:22 +02:00
|
|
|
destination = "$HOME/etcd-server.crt"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
2019-05-28 06:43:08 +02:00
|
|
|
content = module.bootkube.etcd_server_key
|
2018-08-20 03:48:22 +02:00
|
|
|
destination = "$HOME/etcd-server.key"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
2019-05-28 06:43:08 +02:00
|
|
|
content = module.bootkube.etcd_peer_cert
|
2018-08-20 03:48:22 +02:00
|
|
|
destination = "$HOME/etcd-peer.crt"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
2019-05-28 06:43:08 +02:00
|
|
|
content = module.bootkube.etcd_peer_key
|
2018-08-20 03:48:22 +02:00
|
|
|
destination = "$HOME/etcd-peer.key"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "remote-exec" {
|
|
|
|
inline = [
|
|
|
|
"sudo mkdir -p /etc/ssl/etcd/etcd",
|
|
|
|
"sudo mv etcd-client* /etc/ssl/etcd/",
|
|
|
|
"sudo cp /etc/ssl/etcd/etcd-client-ca.crt /etc/ssl/etcd/etcd/server-ca.crt",
|
|
|
|
"sudo mv etcd-server.crt /etc/ssl/etcd/etcd/server.crt",
|
|
|
|
"sudo mv etcd-server.key /etc/ssl/etcd/etcd/server.key",
|
|
|
|
"sudo cp /etc/ssl/etcd/etcd-client-ca.crt /etc/ssl/etcd/etcd/peer-ca.crt",
|
|
|
|
"sudo mv etcd-peer.crt /etc/ssl/etcd/etcd/peer.crt",
|
|
|
|
"sudo mv etcd-peer.key /etc/ssl/etcd/etcd/peer.key",
|
|
|
|
"sudo chown -R etcd:etcd /etc/ssl/etcd",
|
|
|
|
"sudo chmod -R 500 /etc/ssl/etcd",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Secure copy bootkube assets to ONE controller and start bootkube to perform
|
|
|
|
# one-time self-hosted cluster bootstrapping.
|
|
|
|
resource "null_resource" "bootkube-start" {
|
|
|
|
depends_on = [
|
2019-05-28 06:43:08 +02:00
|
|
|
module.bootkube,
|
|
|
|
module.workers,
|
|
|
|
azurerm_dns_a_record.apiserver,
|
|
|
|
null_resource.copy-controller-secrets,
|
2018-08-20 03:48:22 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
connection {
|
|
|
|
type = "ssh"
|
2019-05-28 06:43:08 +02:00
|
|
|
host = element(azurerm_public_ip.controllers.*.ip_address, 0)
|
2018-08-20 03:48:22 +02:00
|
|
|
user = "core"
|
|
|
|
timeout = "15m"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
2019-05-28 06:43:08 +02:00
|
|
|
source = var.asset_dir
|
2018-08-20 03:48:22 +02:00
|
|
|
destination = "$HOME/assets"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "remote-exec" {
|
|
|
|
inline = [
|
|
|
|
"sudo mv $HOME/assets /opt/bootkube",
|
|
|
|
"sudo systemctl start bootkube",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
2019-05-28 06:43:08 +02:00
|
|
|
|