-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from furiousme/develop
Task: K8s Cluster Configuration and Creation
- Loading branch information
Showing
8 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
resource "aws_instance" "terraform_course_bastion" { | ||
ami = var.ami | ||
instance_type = "t2.micro" | ||
subnet_id = aws_subnet.terraform_course_public_subnet_1.id | ||
key_name = var.ec2_key_name | ||
security_groups = [aws_security_group.terraform_course_bastion_sg.id] | ||
|
||
tags = { | ||
Name = "terraform_course_bastion" | ||
} | ||
} | ||
|
||
output "terraform_course_bastion_ip_addr" { | ||
value = aws_instance.terraform_course_bastion.public_ip | ||
sensitive = true | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
resource "aws_instance" "terraform_course_k8s_server" { | ||
ami = var.ami | ||
instance_type = "t2.micro" | ||
subnet_id = aws_subnet.terraform_course_private_subnet_1.id | ||
key_name = var.ec2_key_name | ||
security_groups = [aws_security_group.terraform_course_k8s_sg.id] | ||
|
||
user_data = <<-EOF | ||
#!/bin/bash | ||
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.21.3+k3s1 sh -s - server \ | ||
--token=${var.k3s_token} \ | ||
--disable traefik | ||
chmod 644 /etc/rancher/k3s/k3s.yaml | ||
EOF | ||
|
||
user_data_replace_on_change = true | ||
|
||
tags = { | ||
Name = "terraform_course_k8s_server" | ||
} | ||
} | ||
|
||
resource "aws_instance" "terraform_course_k8s_agent" { | ||
ami = var.ami | ||
instance_type = "t2.micro" | ||
subnet_id = aws_subnet.terraform_course_private_subnet_2.id | ||
key_name = var.ec2_key_name | ||
security_groups = [aws_security_group.terraform_course_k8s_sg.id] | ||
depends_on = [aws_instance.terraform_course_k8s_server] | ||
|
||
user_data = <<-EOF | ||
#!/bin/bash | ||
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.21.3+k3s1 K3S_URL=https://${aws_instance.terraform_course_k8s_server.private_ip}:6443 K3S_TOKEN=${var.k3s_token} sh - | ||
chmod 644 /etc/rancher/k3s/k3s.yaml | ||
EOF | ||
|
||
|
||
user_data_replace_on_change = true | ||
|
||
tags = { | ||
Name = "terraform_course_k8s_agent" | ||
} | ||
} | ||
|
||
output "terraform_course_k8s_server_ip_addr" { | ||
value = aws_instance.terraform_course_k8s_server.private_ip | ||
sensitive = true | ||
} | ||
|
||
output "terraform_course_k8s_agent_ip_addr" { | ||
value = aws_instance.terraform_course_k8s_agent.private_ip | ||
sensitive = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
curl -sfL https://get.k3s.io | K3S_URL="https://${server_private_ip}:6443" K3S_TOKEN=${token} sh -s - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
curl -sfL https://get.k3s.io | sh - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters