-- added readme

-- commented not working code
This commit is contained in:
Rick 2024-07-31 08:47:31 +02:00
parent b84f53b07e
commit 51102e7f4c
No known key found for this signature in database
GPG Key ID: 095CF60F2BBC75B7
2 changed files with 90 additions and 79 deletions

11
terraform/K3S/README.MD Normal file
View File

@ -0,0 +1,11 @@
## K3S using terraform and openstack
Using these scripts a K3S culster will be installed in the openstack cluster.
To change the values such as node count, DNS, PV size please use the tfvars file which is located in the same location.
- A wait time has been implimented as we were not able to set a time till the cluster comes up. we clould have also checked the file but in K3S as soon as the process in executed the file is created so we cant base it thus we have added a timer of 120s but depends on cluster load and netspeed
- Note of `num_worker_nodes` is set to `0` the master will become a single node K3S cluster. if its more than 0 then a taint will be applied into master so no pods can go there
- In the script we have allowed all inbound traffic which should not be done a sample code to allow specific ports are given there. Its always good idea to open only needed ports

View File

@ -388,96 +388,96 @@ resource "openstack_compute_volume_attach_v2" "k3s_worker_volume_attach" {
## Works till here ## Works till here
data "kubernetes_namespace" "existing" { # data "kubernetes_namespace" "existing" {
metadata { # metadata {
name = "kube-system" # name = "kube-system"
} # }
} # }
resource "kubernetes_namespace" "default" { # resource "kubernetes_namespace" "default" {
count = data.kubernetes_namespace.existing.id != null ? 0 : 1 # count = data.kubernetes_namespace.existing.id != null ? 0 : 1
depends_on = [null_resource.delay_workers] # depends_on = [null_resource.delay_workers]
metadata { # metadata {
name = "kube-system" # name = "kube-system"
} # }
} # }
resource "kubernetes_deployment" "traefik" { # resource "kubernetes_deployment" "traefik" {
metadata { # metadata {
name = "traefik" # name = "traefik"
namespace = "kube-system" # namespace = "kube-system"
labels = { # labels = {
app = "traefik" # app = "traefik"
} # }
} # }
spec { # spec {
replicas = 1 # replicas = 1
selector { # selector {
match_labels = { # match_labels = {
app = "traefik" # app = "traefik"
} # }
} # }
template { # template {
metadata { # metadata {
labels = { # labels = {
app = "traefik" # app = "traefik"
} # }
} # }
spec { # spec {
container { # container {
name = "traefik" # name = "traefik"
image = "traefik:v2.4" # image = "traefik:v2.4"
args = ["--providers.kubernetescrd", "--entrypoints.web.Address=:80", "--entrypoints.websecure.Address=:443"] # args = ["--providers.kubernetescrd", "--entrypoints.web.Address=:80", "--entrypoints.websecure.Address=:443"]
port { # port {
name = "web" # name = "web"
container_port = 80 # container_port = 80
} # }
port { # port {
name = "websecure" # name = "websecure"
container_port = 443 # container_port = 443
} # }
} # }
} # }
} # }
} # }
} # }
resource "kubernetes_service" "traefik" { # resource "kubernetes_service" "traefik" {
metadata { # metadata {
name = "traefik" # name = "traefik"
namespace = "kube-system" # namespace = "kube-system"
labels = { # labels = {
app = "traefik" # app = "traefik"
} # }
} # }
spec { # spec {
selector = { # selector = {
app = "traefik" # app = "traefik"
} # }
type = "LoadBalancer" # type = "LoadBalancer"
port { # port {
name = "web" # name = "web"
port = 80 # port = 80
target_port = 80 # target_port = 80
} # }
port { # port {
name = "websecure" # name = "websecure"
port = 443 # port = 443
target_port = 443 # target_port = 443
} # }
} # }
} # }
output "traefik_lb_ip" { # output "traefik_lb_ip" {
value = flatten([for s in kubernetes_service.traefik.status : [for i in s.load_balancer.ingress : i.ip]]) # value = flatten([for s in kubernetes_service.traefik.status : [for i in s.load_balancer.ingress : i.ip]])
} # }