2018-03-26 09:01:47 +02:00
|
|
|
# Secure copy etcd TLS assets to controllers.
|
|
|
|
resource "null_resource" "copy-controller-secrets" {
|
2018-03-26 09:29:57 +02:00
|
|
|
count = "${var.controller_count}"
|
2017-11-05 20:01:50 +01:00
|
|
|
|
|
|
|
connection {
|
|
|
|
type = "ssh"
|
2018-04-12 08:19:35 +02:00
|
|
|
host = "${element(local.controllers_ipv4_public, count.index)}"
|
2017-11-05 20:01:50 +01:00
|
|
|
user = "core"
|
|
|
|
timeout = "15m"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
content = "${module.bootkube.etcd_ca_cert}"
|
|
|
|
destination = "$HOME/etcd-client-ca.crt"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
content = "${module.bootkube.etcd_client_cert}"
|
|
|
|
destination = "$HOME/etcd-client.crt"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
content = "${module.bootkube.etcd_client_key}"
|
|
|
|
destination = "$HOME/etcd-client.key"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
content = "${module.bootkube.etcd_server_cert}"
|
|
|
|
destination = "$HOME/etcd-server.crt"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
content = "${module.bootkube.etcd_server_key}"
|
|
|
|
destination = "$HOME/etcd-server.key"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
content = "${module.bootkube.etcd_peer_cert}"
|
|
|
|
destination = "$HOME/etcd-peer.crt"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
content = "${module.bootkube.etcd_peer_key}"
|
|
|
|
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",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-27 06:55:39 +02:00
|
|
|
# Secure copy bootkube assets to ONE controller and start bootkube to perform
|
|
|
|
# one-time self-hosted cluster bootstrapping.
|
|
|
|
resource "null_resource" "bootkube-start" {
|
2018-03-26 09:01:47 +02:00
|
|
|
depends_on = [
|
|
|
|
"module.bootkube",
|
|
|
|
"module.workers",
|
2018-04-15 09:50:43 +02:00
|
|
|
"google_dns_record_set.apiserver",
|
2018-03-26 09:01:47 +02:00
|
|
|
"null_resource.copy-controller-secrets",
|
|
|
|
]
|
2017-06-27 06:55:39 +02:00
|
|
|
|
|
|
|
connection {
|
|
|
|
type = "ssh"
|
2018-04-12 08:19:35 +02:00
|
|
|
host = "${element(local.controllers_ipv4_public, 0)}"
|
2017-06-27 06:55:39 +02:00
|
|
|
user = "core"
|
|
|
|
timeout = "15m"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
source = "${var.asset_dir}"
|
|
|
|
destination = "$HOME/assets"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "remote-exec" {
|
|
|
|
inline = [
|
2018-03-26 09:01:47 +02:00
|
|
|
"sudo mv $HOME/assets /opt/bootkube",
|
2017-06-27 06:55:39 +02:00
|
|
|
"sudo systemctl start bootkube",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|