Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding scaling capabilities and jumpserver #45

Open
wants to merge 148 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
c9acf0d
Initial commit
devopstoday11 Jul 27, 2022
6a89e9b
Add .whitesource configuration file
mend-bolt-for-github[bot] Jul 27, 2022
e5054e2
Merge pull request #1 from kube-tarian/whitesource/configure
devopstoday11 Jul 27, 2022
b9a795d
Add .deepsource.toml
deepsourcebot Aug 1, 2022
61feec0
Update .deepsource.toml
deepsourcebot Aug 1, 2022
cd14a55
Update .deepsource.toml
deepsourcebot Aug 1, 2022
ed3703f
adding initial version of talos controlplane
invalid-email-address Aug 19, 2022
3eeb6a6
Fixing syntax
vpramod03 Aug 19, 2022
9391d78
Activate session tokens
vpramod03 Aug 19, 2022
652a134
Fix shell code smells
vpramod03 Aug 19, 2022
a46dbc0
Fix shell code smell
vpramod03 Aug 19, 2022
8adfb9a
Merge pull request #3 from vpramod03/main
jebinjeb Aug 22, 2022
641d819
Adding k3s
vpramod03 Sep 16, 2022
289b483
Merge branch 'main' of https://github.com/vpramod03/controlplane-data…
vpramod03 Sep 16, 2022
c1cfc70
Update server_install.sh
vpramod03 Sep 23, 2022
a4f816f
Update worker_install.sh
vpramod03 Sep 23, 2022
b7592d8
Adding DB for HA
vpramod03 Sep 24, 2022
74ae12a
Update README.md
devopstoday11 Sep 29, 2022
c6f646d
Changing folder structure
vpramod03 Oct 1, 2022
ca0bf32
Add arch dig
vpramod03 Oct 17, 2022
86022c0
Add aws talos doc
vpramod03 Oct 17, 2022
53833b8
Add awstalos doc
vpramod03 Oct 17, 2022
110b259
Create aws-k3s.md
vpramod03 Oct 26, 2022
e673f1c
Create values.tfvars
vpramod03 Oct 26, 2022
4a1a57e
Add files via upload
vpramod03 Oct 26, 2022
b9d6442
Delete aws-k3s
vpramod03 Oct 26, 2022
6746931
Add files via upload
vpramod03 Oct 26, 2022
80f95eb
Update aws-k3s.md
vpramod03 Oct 26, 2022
52d2fd0
Add Azure on Talos
vpramod03 Dec 5, 2022
656fb5d
Merge branch 'main' of https://github.com/vpramod03/controlplane-data…
vpramod03 Dec 5, 2022
5249104
fix older version
vpramod0310 Dec 11, 2022
0c6f0d0
Adding openebs
Feb 5, 2023
4563cc1
Merge branch 'kube-tarian:main' into main
vpramod03 Feb 12, 2023
048f7a1
Add traefik LB
Feb 25, 2023
63cfdc8
add vault
Apr 22, 2023
fcdfda5
Merge pull request #7 from vpramod03/aws
jebinjeb Apr 22, 2023
1a81614
Remove Vault
Apr 28, 2023
1dac8f2
Merge pull request #9 from vpramod03/aws
jebinjeb Apr 28, 2023
813f7fc
Remove Vault
Apr 29, 2023
2285339
Add remote state
May 13, 2023
4246d46
Merge pull request #10 from vpramod03/aws
jebinjeb May 13, 2023
657284d
Adding canal as cni
Jun 8, 2023
0222805
add support for multi cluster creation on same region
Jun 8, 2023
c0d9f5d
Add support for multi cluster creation on same region
vpramod03 Jun 8, 2023
f6f66fe
Merge pull request #11 from vpramod03/aws
jebinjeb Jun 10, 2023
14308d7
Merge pull request #2 from kube-tarian/main
vpramod03 Jul 11, 2023
61c71a2
Fix amd talosctl issue
Jul 20, 2023
e602ff5
Merge pull request #14 from vpramod03/main
jebinjeb Jul 20, 2023
0fbb390
migrate configs to config folder
Jul 20, 2023
764de92
Merge pull request #15 from vpramod03/main
jebinjeb Jul 20, 2023
f696c27
Delete main.tf
vpramod03 Jul 31, 2023
62e627b
Delete values.tfvars
vpramod03 Jul 31, 2023
2483142
Delete stale files
vpramod03 Jul 31, 2023
3c77a11
Merge pull request #16 from vpramod03/main
jebinjeb Jul 31, 2023
7a70078
Fix lb endpoint
vpramod03 Aug 3, 2023
5672f8b
Fix path
vpramod03 Aug 3, 2023
025685d
Add configpath as var
Aug 3, 2023
c6f9d34
Merge pull request #17 from vpramod03/main
jebinjeb Aug 3, 2023
8239744
Update canal for k8s 1.27
vpramod03 Aug 6, 2023
8bd917e
Merge pull request #18 from vpramod03/main
jebinjeb Aug 6, 2023
e7f3ff0
Create controlplane.yaml
vpramod03 Aug 18, 2023
f0d086e
Create worker.yaml
vpramod03 Aug 18, 2023
3f95d12
Create talosconfig
vpramod03 Aug 18, 2023
ee6c845
Update talosconfiggen.sh
vpramod03 Aug 18, 2023
8dcc208
Merge pull request #19 from vpramod03/main
jebinjeb Aug 19, 2023
dbd20b4
Add azure V1
Aug 23, 2023
11168d9
Azure fixes
Aug 26, 2023
bcab333
Merge pull request #20 from vpramod03/main
jebinjeb Aug 27, 2023
ff16038
azure installation optimization
Aug 29, 2023
0eb0607
azure installation optimization
Aug 29, 2023
3fbf789
azure installation optimization
Aug 29, 2023
224f00a
azure installation optimization
Aug 29, 2023
c2e379e
azure installation optimization
Aug 29, 2023
3753866
Merge pull request #21 from vpramod03/main
jebinjeb Aug 29, 2023
11fb940
Update talosconfiggen.sh
vpramod03 Sep 19, 2023
8b69963
Update bootstrapetcd.sh
vpramod03 Sep 19, 2023
e0f4d6f
remove yq
Sep 22, 2023
d8a5254
Merge branch 'main' of https://github.com/vpramod03/controlplane-data…
Sep 22, 2023
0399d89
Add fixes for azure
Sep 23, 2023
90db454
Fix azure
vpramod03 Sep 23, 2023
0cfc4f2
Change filename
vpramod03 Sep 23, 2023
4921f7e
Add fixes for azure
Sep 23, 2023
dff5945
Merge branch 'main' of https://github.com/vpramod03/controlplane-data…
Sep 23, 2023
555b6bb
Merge pull request #22 from vpramod03/main
jebinjeb Sep 23, 2023
e189069
Add talosctlpath var
Oct 7, 2023
6ea078e
Add talosctlpath var
Oct 7, 2023
07a3fb9
Merge pull request #24 from vpramod03/main
jebjohns Oct 7, 2023
481e352
Added node flag in main.tf
Shifna12Zarnaz Oct 9, 2023
12e97ba
Merge pull request #25 from kube-tarian/fixbranch
jebjohns Oct 9, 2023
98a37e0
Fix aws failure for talosctl path
Oct 12, 2023
7152a0e
Merge pull request #26 from vpramod03/main
jebjohns Oct 12, 2023
bced11c
LoadBalancerHost Changed
Shifna12Zarnaz Oct 13, 2023
ed00c4d
add data disk
Oct 13, 2023
c50ac5d
Merge pull request #28 from vpramod03/main
jebjohns Oct 14, 2023
311305b
Merge pull request #27 from kube-tarian/bugfix
jebjohns Oct 15, 2023
e61ff61
fix security group for traefik
Oct 26, 2023
341fbc0
Merge pull request #29 from vpramod03/main
jebjohns Oct 27, 2023
20cee30
Added alb version
akash4sh Nov 24, 2023
963d44d
Merge pull request #30 from akash4sh/main
jebjohns Nov 24, 2023
6106150
Add support for multi cluster creation
vpramod03 Dec 6, 2023
f1d73fa
Merge pull request #34 from vpramod03/main
jebjohns Dec 6, 2023
c1a7a0f
modified azure lb
sheril5 Dec 7, 2023
7ce1556
modified vars and tfvars
sheril5 Dec 7, 2023
7ccf673
Merge pull request #35 from sheril5/main
jebjohns Dec 14, 2023
a293f00
Change OS disk size
vpramod03 Dec 14, 2023
0564c14
Update vars.tf
sheril5 Dec 15, 2023
3c3b65c
Update values.tfvars
sheril5 Dec 15, 2023
0cb2f27
Update main.tf
sheril5 Dec 15, 2023
b3eda8a
Merge pull request #37 from sheril5/main
jebjohns Dec 15, 2023
2c76284
Merge pull request #36 from vpramod03/main
jebjohns Dec 19, 2023
647936b
Merge pull request #3 from kube-tarian/main
vpramod03 Dec 19, 2023
1f11f11
Fix multi cluster issue
vpramod03 Dec 22, 2023
e57b481
Merge pull request #39 from vpramod03/main
jebjohns Dec 22, 2023
4ff280e
Update main.tf
sheril5 Dec 22, 2023
4dfdee8
Merge pull request #40 from sheril5/main
jebjohns Dec 22, 2023
857ab40
Fix worker nic creation issue
vpramod03 Dec 24, 2023
80d09a8
Merge pull request #41 from vpramod03/main
jebjohns Dec 24, 2023
8ca3ac8
Fix health probes
vpramod03 Dec 26, 2023
9e9e1a9
Merge branch 'kube-tarian:main' into main
vpramod03 Dec 26, 2023
a928cc9
Fix nats client port for azure security group
vpramod03 Dec 26, 2023
d98ebd1
change disk type to ssd
vpramod03 Jan 21, 2024
3b98828
Fix clientip lb rule
vpramod03 Feb 12, 2024
3bec1dd
adding scaling capapbility
vpramod03 Mar 3, 2024
fbdaf36
adding scaling capapbility
vpramod03 Mar 3, 2024
b823209
Merge branch 'main' of https://github.com/vpramod03/controlplane-data…
vpramod03 Mar 3, 2024
4bbb2ca
Merge branch 'main' of https://github.com/vpramod03/controlplane-data…
vpramod03 Mar 3, 2024
c183ea1
improvements for scaling
vpramod03 Mar 25, 2024
5c3cc16
improvements for scaling
vpramod03 Mar 25, 2024
1148bf4
Fix Scaling LB
vpramod03 Apr 3, 2024
b85ca3e
Fix Scaling LB
vpramod03 Apr 3, 2024
0f3bfc4
Store tfstate in azure storageaccount
vpramod03 Apr 3, 2024
be5d36b
Store tfstate in azure storageaccount
vpramod03 Apr 3, 2024
b20c7c4
Fix ZTP issue and change backend config
vpramod03 Apr 10, 2024
568ca35
Fix ZTP issue and change backend config
vpramod03 Apr 10, 2024
faae746
Add scaling for aws
vpramod03 Apr 27, 2024
a86b55d
Add scaling for aws
vpramod03 Apr 27, 2024
a139b62
Add scaling for aws
vpramod03 Apr 27, 2024
0afcc59
Add scaling for aws
vpramod03 Apr 27, 2024
691b343
Add lb for talos
vpramod03 May 2, 2024
ed40d88
Add lb for talos
vpramod03 May 2, 2024
bc46bcf
Fix lb for talos api
vpramod03 May 3, 2024
62ed83a
Fix lb for talos api
vpramod03 May 3, 2024
2abb175
Add jumpsever for aws
vpramod03 May 9, 2024
12a13e6
Add jumpsever for aws
vpramod03 May 9, 2024
6e44457
Merge branch 'main' of https://github.com/vpramod03/controlplane-data…
vpramod03 May 9, 2024
5c31306
add jumpserver for azure
vpramod03 May 13, 2024
9796dfa
add jumpserver for azure
vpramod03 May 13, 2024
174c75b
Merge branch 'main' into main
vpramod03 May 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions aws/jumpserver/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions aws/jumpserver/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
provider "aws" {
region = var.region
access_key = var.AWS_ACCESS_KEY
secret_key = var.AWS_SECRET_KEY
}

resource "aws_vpc" "jumpservervpc" {
cidr_block = "10.0.0.0/16"
}
# Create a public subnet
resource "aws_subnet" "public_subnet" {
vpc_id = aws_vpc.jumpservervpc.id
cidr_block = "10.0.1.0/24"
map_public_ip_on_launch = true
}

# Create an internet gateway
resource "aws_internet_gateway" "jumpserver_igw" {
vpc_id = aws_vpc.jumpservervpc.id
}

resource "aws_route_table" "jumpserverrt" {
vpc_id = aws_vpc.jumpservervpc.id

route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.jumpserver_igw.id
}

tags = {
Name = "jumpserverrt"
}
}

# Associate the route table with the public subnet
resource "aws_route_table_association" "public_subnet_association" {
subnet_id = aws_subnet.public_subnet.id
route_table_id = aws_route_table.jumpserverrt.id
}

# Create a security group allowing SSH only from your IP
resource "aws_security_group" "ssh_sg" {
vpc_id = aws_vpc.jumpservervpc.id

ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["${var.localserverip}/32"] # Replace your_ip with your actual IP address
}
}

# Create an EC2 instance
resource "aws_instance" "my_instance" {
ami = "ami-0a283ac1aafe112d5" # Replace with your AMI ID
instance_type = "t2.micro"
subnet_id = aws_subnet.public_subnet.id
key_name = aws_key_pair.jumpserverkey.key_name
security_groups = [aws_security_group.ssh_sg.name]

tags = {
Name = "talosJumpserver"
}
}

# Generate SSH key pair
resource "aws_key_pair" "jumpserverkey" {
key_name = "jumpserverkey"
public_key = file("~/.ssh/id_rsa.pub")
}

output "ssh_key" {
value = aws_key_pair.jumpserverkey.key_name
}
15 changes: 15 additions & 0 deletions aws/jumpserver/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable "AWS_ACCESS_KEY" {
description = "AWS Access key"
}

variable "AWS_SECRET_KEY" {
description = "AWS Secret key"
}

variable "region" {
description = "AWS Region to deploy the resources"
}

variable "localserverip" {
description = "AWS Region to deploy the resources"
}
191 changes: 128 additions & 63 deletions aws/talos/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -125,68 +125,126 @@ data "local_file" "workerfile" {
depends_on = [ null_resource.createtalosconfig ]
}

resource "aws_instance" talos_master_instance {
resource "aws_placement_group" "talosplacemnentgroup" {
name = "talosplacemnentgroup"
strategy = "cluster"
}

count = var.mastercount
resource "aws_launch_configuration" "talosmaster" {
name = "talos-master"
image_id = data.aws_ami.talos.id
instance_type = var.instance_type
}

ami = data.aws_ami.talos.id
instance_type = var.instance_type
monitoring = var.nodemonitoringenabled
vpc_security_group_ids = [ module.security_group.security_group_id ]
subnet_id = "${element(module.vpc.private_subnets, 0)}"
resource "aws_lb" "talosapi" {
name = "talosapi"
internal = false
load_balancer_type = "network"
subnets = [for subnet in aws_subnet.public : subnet.id]

user_data = data.local_file.controllerfile.content
associate_public_ip_address = true
enable_deletion_protection = true

root_block_device {
volume_size = 200
}
}

depends_on = [ data.local_file.controllerfile ]
resource "aws_autoscaling_group" "talosmaster-static" {
name = "talosmaster-static"
max_size = 20
min_size = var.mastercount
health_check_grace_period = 300
health_check_type = "ELB"
desired_capacity = 4
force_delete = true
placement_group = aws_placement_group.talosplacemnentgroup.id
launch_configuration = aws_launch_configuration.talosmaster.name
load_balancers = aws_lb.talosapi.arn


timeouts {
delete = "15m"
}

tags = {
Name = "talosmaster"
}
}

resource "aws_autoscaling_group" "talosmaster-scalable" {
name = "talosmaster-scalable"
max_size = 20
min_size = var.mastercount
health_check_grace_period = 300
health_check_type = "ELB"
desired_capacity = 4
force_delete = true
placement_group = aws_placement_group.talosplacemnentgroup.id
launch_configuration = aws_launch_configuration.talosmaster.name


timeouts {
delete = "15m"
}

}
resource "aws_instance" talos_worker_instance {

# resource "aws_instance" talos_master_instance {

# count = var.mastercount

# ami = data.aws_ami.talos.id
# instance_type = var.instance_type
# monitoring = var.nodemonitoringenabled
# vpc_security_group_ids = [ module.security_group.security_group_id ]
# subnet_id = "${element(module.vpc.private_subnets, 0)}"

# user_data = data.local_file.controllerfile.content
# associate_public_ip_address = true

# root_block_device {
# volume_size = 200
# }

# depends_on = [ data.local_file.controllerfile ]

# tags = {
# Name = "talosmaster"
# }


# }
# resource "aws_instance" talos_worker_instance {

count = var.workercount
# count = var.workercount

ami = data.aws_ami.talos.id
instance_type = var.instance_type
monitoring = var.nodemonitoringenabled
vpc_security_group_ids = [ module.security_group.security_group_id ]
subnet_id = "${element(module.vpc.private_subnets, 0)}"
# ami = data.aws_ami.talos.id
# instance_type = var.instance_type
# monitoring = var.nodemonitoringenabled
# vpc_security_group_ids = [ module.security_group.security_group_id ]
# subnet_id = "${element(module.vpc.private_subnets, 0)}"

user_data = data.local_file.workerfile.content
associate_public_ip_address = true
# user_data = data.local_file.workerfile.content
# associate_public_ip_address = true

depends_on = [ data.local_file.workerfile ]
# depends_on = [ data.local_file.workerfile ]

root_block_device {
volume_size = 200
}
tags = {
Name = "talosworker"
}
# root_block_device {
# volume_size = 200
# }
# tags = {
# Name = "talosworker"
# }


}
# }

resource "aws_ebs_volume" "ebs_volume" {
count = "${var.workercount}"
availability_zone = "${element(aws_instance.talos_master_instance.*.availability_zone, count.index)}"
size = "200"
}
# resource "aws_ebs_volume" "ebs_volume" {
# count = "${var.workercount}"
# availability_zone = "${element(aws_instance.talos_master_instance.*.availability_zone, count.index)}"
# size = "200"
# }

resource "aws_volume_attachment" "volume_attachement" {
count = "${var.workercount}"
volume_id = "${aws_ebs_volume.ebs_volume.*.id[count.index]}"
device_name = "/dev/sdd"
instance_id = "${element(aws_instance.talos_worker_instance.*.id, count.index)}"
}
# resource "aws_volume_attachment" "volume_attachement" {
# count = "${var.workercount}"
# volume_id = "${aws_ebs_volume.ebs_volume.*.id[count.index]}"
# device_name = "/dev/sdd"
# instance_id = "${element(aws_instance.talos_worker_instance.*.id, count.index)}"
# }

resource "aws_lb_target_group" "talos-tg" {
name = var.talostg
Expand All @@ -197,15 +255,24 @@ resource "aws_lb_target_group" "talos-tg" {

}

resource "aws_lb_target_group" "traefik-tg-80" {
name = var.traefik_tg_80_name
port = var.traefikhttpport
resource "aws_lb_target_group" "talos-api" {
name = "talosapi"
port = 500000
protocol = "TCP"
target_type = "ip"
vpc_id = module.vpc.vpc_id

}

# resource "aws_lb_target_group" "traefik-tg-80" {
# name = var.traefik_tg_80_name
# port = var.traefikhttpport
# protocol = "TCP"
# target_type = "ip"
# vpc_id = module.vpc.vpc_id

# }

resource "aws_lb_target_group" "traefik-tg-443" {
name = var.traefik_tg_443_name
port = var.traefikhttpsport
Expand Down Expand Up @@ -234,14 +301,22 @@ resource "aws_lb_target_group_attachment" "registertarget" {

}

resource "aws_lb_target_group_attachment" "registertarget-traefik-80" {
resource "aws_lb_target_group_attachment" "talosapi" {

count = var.workercount
target_group_arn = aws_lb_target_group.traefik-tg-80.arn
target_id = "${element(split(",", join(",", aws_instance.talos_worker_instance.*.private_ip)), count.index)}"
depends_on = [ aws_instance.talos_worker_instance ]
count = var.mastercount
target_group_arn = aws_lb_target_group.talos-tg.arn
target_id = "${element(split(",", join(",", aws_instance.talos_master_instance.*.private_ip)), count.index)}"
depends_on = [ aws_instance.talos_master_instance ]

}
# resource "aws_lb_target_group_attachment" "registertarget-traefik-80" {

# count = var.workercount
# target_group_arn = aws_lb_target_group.traefik-tg-80.arn
# target_id = "${element(split(",", join(",", aws_instance.talos_worker_instance.*.private_ip)), count.index)}"
# depends_on = [ aws_instance.talos_worker_instance ]

# }

resource "aws_lb_target_group_attachment" "registertarget-traefik-443" {

Expand Down Expand Up @@ -301,7 +376,7 @@ resource "aws_alb_listener" "traefik-listener-443" {
}

}

resource "aws_alb_listener" "nats-listener-4222" {
load_balancer_arn = aws_lb.traefik.arn
port = 4222
Expand All @@ -313,16 +388,6 @@ resource "aws_alb_listener" "nats-listener-4222" {

}

resource "aws_alb_listener" "traefik-listener-80" {
load_balancer_arn = aws_lb.traefik.arn
port = 80
protocol = "TCP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.traefik-tg-80.arn
}

}

resource "null_resource" "bootstrap_etcd" {
provisioner "local-exec" {
Expand Down
Loading