Skip to content
Snippets Groups Projects
Commit 9fa16c07 authored by MUNIER Florian's avatar MUNIER Florian
Browse files

[add] add k3s on bastion

parent 423ac475
No related branches found
No related tags found
No related merge requests found
resource "null_resource" "install_kubernetes" {
resource "null_resource" "install_kubernetes_bastion" {
connection {
type = "ssh"
......@@ -9,52 +9,18 @@ resource "null_resource" "install_kubernetes" {
}
# Install Kubernetes on the instance bastion
for_each = toset(var.INSTANCE_ORCHEST_NAME)
provisioner "remote-exec" {
inline = [
"curl -sfL https://get.k3s.io | sh -",
"sudo cat /var/lib/rancher/k3s/server/node-token > k3s_token",
"scp k3s_token -i .ssh/cluster_key.pem ubuntu@${openstack_compute_instance_v2.orchestration_instance[each.key].access_ip_v4}:k3s_token"]
"sudo apt update",
"curl -sfL https://get.k3s.io | sh -s - server",
"mkdir ~/.kube",
"sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube",
]
}
depends_on = [openstack_compute_instance_v2.bastion_instance,
openstack_compute_instance_v2.orchestration_instance]
openstack_compute_instance_v2.orchestration_instance,
null_resource.copy_keypair_cluster]
}
# Define the node token as an output
# # Join the worker nodes to the Kubernetes cluster
# resource "null_resource" "join_worker_nodes" {
# for_each = toset(var.INSTANCE_ORCHEST_NAME)
# # Connexion aux instances du cluster
# connection {
# type = "ssh"
# user = "ubuntu"
# bastion_private_key = "${openstack_compute_keypair_v2.keypair_project.private_key}"
# bastion_host = "${openstack_networking_floatingip_v2.floatip_admin.address}"
# private_key = "${openstack_compute_keypair_v2.keypair_cluster.private_key}"
# host = "${openstack_compute_instance_v2.orchestration_instance[each.key].access_ip_v4}"
# agent = "false"
# }
# provisioner "remote-exec" {
# inline = [
# "sudo curl -sfL https://get.k3s.io | K3S_URL=https://${openstack_networking_floatingip_v2.floatip_admin.address}:6443 K3S_TOKEN=${output.node_token} sh -"]
# }
# depends_on = [openstack_compute_instance_v2.bastion_instance,
# openstack_compute_instance_v2.orchestration_instance]
# }
# # Configure the Kubernetes network settings
# resource "kubernetes_network_policy" "default" {
# policy_types = ["Ingress", "Egress"]
# depends_on = [null_resource.install_kubernetes,
# null_resource.join_worker_nodes]
# }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment