deprecated microk8s version. 90/4390/1
authorashgit301 <ashvin.p@bluemeric.com>
Fri, 6 Aug 2021 07:41:55 +0000 (13:11 +0530)
committerashgit301 <ashvin.p@bluemeric.com>
Fri, 6 Aug 2021 08:01:57 +0000 (13:31 +0530)
Change-Id: Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf5d
Signed-off-by: ashgit301 <ashvin.p@bluemeric.com>
src/foundation/microk8s/main.tf
src/foundation/microk8s/microk8s.join_token [deleted file]
src/foundation/microk8s/token
src/foundation/microk8s/variable.tf
src/foundation/microk8s/worker_user_data.tmpl

index ea33da5..fb59a14 100644 (file)
@@ -17,11 +17,11 @@ resource "aws_instance" "master" {
               apt install snapd -y >> microk8s_install.log
               snap install core >> microk8s_install.log
               export PATH=$PATH:/snap/bin
-              snap install microk8s --classic >> microk8s_install.log
+              snap install microk8s --classic --channel=1.20/stable >> microk8s_install.log
               microk8s status --wait-ready
               microk8s enable dns >> microk8s_install.log
               microk8s add-node > microk8s.join_token
-              microk8s config > configFile
+              microk8s config > configFile-master
               EOF
   key_name = "terraform"
   tags = {
@@ -46,10 +46,11 @@ resource "aws_instance" "master" {
 
   provisioner "local-exec" {
     command = <<EOT
+               touch token 
                ssh-keyscan -H ${self.public_dns} >> ~/.ssh/known_hosts
                scp -i terraform.pem ubuntu@${self.public_dns}:/microk8s.join_token .
                tail -n1 microk8s.join_token >> token
-               scp -i terraform.pem ubuntu@${self.public_dns}:/configFile .
+               scp -i terraform.pem ubuntu@${self.public_dns}:/configFile-master .
               EOT
   }
 
@@ -121,8 +122,42 @@ resource "aws_instance" "worker" {
   ]
 }
 
+resource "null_resource" "cluster" {
+  provisioner "remote-exec" {
+  inline = ["sudo microk8s kubectl get no >> kubectl.info"]
+  }
+
+  connection {
+    host = aws_instance.master.public_ip
+    type     = "ssh"
+    user     = "ubuntu"
+    password = ""
+    private_key = "${file("terraform.pem")}"
+  }
+
+  provisioner "local-exec" {
+  command = <<EOT
+               echo ${aws_instance.master.private_ip}
+               export privateIP=${aws_instance.master.private_ip}
+               export publicIP=${aws_instance.master.public_ip}
+               ssh-keyscan -H ${aws_instance.worker.public_dns} >> ~/.ssh/known_hosts
+               scp -i terraform.pem ubuntu@${aws_instance.worker.public_dns}:/configFile-worker .
+              EOT
+  }
+
+  lifecycle {
+    create_before_destroy = true
+  }
 
-output "master_ip" {
+  depends_on = [
+    aws_instance.worker,
+  ]
+}
+
+output "public_ip" {
   value         = aws_instance.master.public_ip
 }
 
+output "private_ip" {
+  value = aws_instance.master.private_ip
+}
diff --git a/src/foundation/microk8s/microk8s.join_token b/src/foundation/microk8s/microk8s.join_token
deleted file mode 100644 (file)
index 4c9e73f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-From the node you wish to join to this cluster, run the following:
-microk8s join 172.31.10.54:25000/f9b66e02527274bd62996de9e04da30b
-
-If the node you are adding is not reachable through the default interface you can use one of the following:
- microk8s join 172.31.10.54:25000/f9b66e02527274bd62996de9e04da30b
index 328ed78..b874b22 100644 (file)
@@ -1,7 +1,3 @@
- microk8s join 172.31.21.68:25000/7bbce642aec6aafd22028238f1114c88
- microk8s join 172.31.18.98:25000/629d7bf742ec927cc21963b2ff404def
- microk8s join 172.31.3.108:25000/48fb4f98b7427abd52c45f522defc268
- microk8s join 172.31.30.69:25000/ce3caa0dcffb57b71741dd4f95b8306d
- microk8s join 172.31.22.56:25000/d60f8e7fb55b5e478a634095fb1c270f
- microk8s join 172.31.16.138:25000/297050fa5e93c71e9fda831ba64b99f9
- microk8s join 172.31.10.54:25000/f9b66e02527274bd62996de9e04da30b
+ microk8s join 172.31.1.7:25000/f9248352b1c01fd71b52c29880a177b5
+ microk8s join 172.31.10.73:25000/23c77c9fff9e96b8cb5599aa6ac38eac
+ microk8s join 172.31.3.101:25000/34d8296750d285c7deba6b62e8d12e44
index 6f8a94d..288efec 100644 (file)
@@ -1,35 +1,28 @@
 variable "aws_region" {
   description = "aws_region"
-  default     = "us-east-2"
 }
 
 variable "aws_instance" {
   description = "instance_type"
-  default     = "t2.small"
 }
 
 variable "aws_ami" {
   description = "aws_ami"
-  default     = "ami-026141f3d5c6d2d0c"
 }
 
 variable "aws_subnet_id" {
   description = "subnet_id"
-  default     = "<insertsubnetID>"
 }
 
 variable "vpc_id" {
   description = "vpc_id"
-  default     = "<insertVpcID>"
 }
 
 variable "access_key" {
   description = "access_key"
-  default     = "<insertAccessKey>"
 }
 
 variable "secret_key" {
   description = "secret_key"
-  default     = "<insertSecretKey>"
 }
 
index 4878132..619ffb4 100644 (file)
@@ -2,9 +2,9 @@
 
 sudo apt update -y >> microk8s_install.log
 sudo apt install snapd -y >> microk8s_install.log
-sudo snap install microk8s --classic >> microk8s_install.log
+sudo snap install microk8s --classic --channel=1.20/stable >> microk8s_install.log
 sudo microk8s enable dns >> microk8s_install.log
 sudo ${token} >> microk8s_install.log
+microk8s config > configFile-worker
 sudo touch microk8s.complete
-