2018-03-31 22:11:42 +02:00
|
|
|
# Secure copy etcd TLS assets and kubeconfig to controllers. Activates kubelet.service
|
|
|
|
resource "null_resource" "copy-controller-secrets" {
|
|
|
|
count = "${var.controller_count}"
|
2018-03-25 09:08:03 +02:00
|
|
|
|
|
|
|
connection {
|
|
|
|
type = "ssh"
|
2018-03-31 22:11:42 +02:00
|
|
|
host = "${element(concat(digitalocean_droplet.controllers.*.ipv4_address), count.index)}"
|
2018-03-25 09:08:03 +02:00
|
|
|
user = "fedora"
|
|
|
|
timeout = "15m"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
content = "${module.bootkube.kubeconfig}"
|
|
|
|
destination = "$HOME/kubeconfig"
|
|
|
|
}
|
|
|
|
|
|
|
|
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",
|
2018-03-31 22:11:42 +02:00
|
|
|
"sudo mv $HOME/kubeconfig /etc/kubernetes/kubeconfig",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Secure copy kubeconfig to all workers. Activates kubelet.service.
|
|
|
|
resource "null_resource" "copy-worker-secrets" {
|
|
|
|
count = "${var.worker_count}"
|
|
|
|
|
|
|
|
connection {
|
|
|
|
type = "ssh"
|
|
|
|
host = "${element(concat(digitalocean_droplet.workers.*.ipv4_address), count.index)}"
|
|
|
|
user = "fedora"
|
|
|
|
timeout = "15m"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
content = "${module.bootkube.kubeconfig}"
|
|
|
|
destination = "$HOME/kubeconfig"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "remote-exec" {
|
|
|
|
inline = [
|
|
|
|
"sudo mv $HOME/kubeconfig /etc/kubernetes/kubeconfig",
|
2018-03-25 09:08:03 +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-31 22:11:42 +02:00
|
|
|
depends_on = [
|
|
|
|
"null_resource.copy-controller-secrets",
|
|
|
|
"null_resource.copy-worker-secrets",
|
|
|
|
]
|
2018-03-25 09:08:03 +02:00
|
|
|
|
|
|
|
connection {
|
|
|
|
type = "ssh"
|
|
|
|
host = "${digitalocean_droplet.controllers.0.ipv4_address}"
|
|
|
|
user = "fedora"
|
|
|
|
timeout = "15m"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
source = "${var.asset_dir}"
|
|
|
|
destination = "$HOME/assets"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "remote-exec" {
|
|
|
|
inline = [
|
2018-03-31 22:11:42 +02:00
|
|
|
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do sleep 4; done",
|
2018-04-04 09:42:45 +02:00
|
|
|
"sudo mv $HOME/assets /var/bootkube",
|
2018-03-25 09:08:03 +02:00
|
|
|
"sudo systemctl start bootkube",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|