Compare commits

...

9 Commits

Author SHA1 Message Date
8c96c46a4f Update 'worker.tf'
Some checks reported errors
continuous-integration/drone/pr Build encountered an error
2022-09-02 13:12:01 +00:00
134256a9df add: kube-state-metrics
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing
2022-07-17 02:09:42 +02:00
837f30a6b4 ci: fix drift detection 2022-07-17 02:09:42 +02:00
4d8fc647c4 ci(apply): fix missing AWS credentials
All checks were successful
continuous-integration/drone/push Build is passing
2022-05-27 17:45:28 +02:00
7b993fb82e ci: fix drift detection by setting --detailed-exitcode if running as cron
Some checks failed
continuous-integration/drone/push Build is failing
From terraform plan --help
>  -detailed-exitcode  Return detailed exit codes when the command exits. This
>                      will change the meaning of exit codes to:
>                      0 - Succeeded, diff is empty (no changes)
>                      1 - Errored
>                      2 - Succeeded, there is a diff
2022-05-27 17:33:13 +02:00
5c0ed41b84 perm: ci manages traefik custom resources
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #2
2022-05-27 15:09:49 +00:00
601a72e1c6 perm: ci manages traefik custom resources
All checks were successful
continuous-integration/drone/pr Build is passing
2022-05-27 17:04:55 +02:00
b8d35e54ac import: traefik helm release
All checks were successful
continuous-integration/drone/push Build is passing
2022-05-27 16:08:11 +02:00
3d84db1f88 ci: fix terraform apply step
All checks were successful
continuous-integration/drone/push Build is passing
2022-05-27 15:58:53 +02:00
7 changed files with 90 additions and 11 deletions

View File

@@ -34,7 +34,7 @@ steps:
- name: terraform plan
image: hashicorp/terraform:1.1.8
commands:
- terraform plan -var-file ci.tfvars -out .tfplan
- terraform plan $([[ $${DRONE_BUILD_EVENT} = cron ]] && echo "-detailed-exitcode") -var-file ci.tfvars -out .tfplan
environment:
AWS_ACCESS_KEY_ID:
from_secret: terraform-aws-key-id
@@ -55,19 +55,12 @@ steps:
- push
image: hashicorp/terraform:1.1.8
commands:
- terraform apply -var-file ci.tfvars .tfplan
- terraform apply .tfplan
environment:
AWS_ACCESS_KEY_ID:
from_secret: terraform-aws-key-id
AWS_SECRET_ACCESS_KEY:
from_secret: terraform-aws-secret-access-key
KUBE_TOKEN:
from_secret: lawndale-k8s-ci-token
TF_VAR_lawndale_dns_key_secret:
from_secret: lawndale-dns-key-secret
TF_VAR_lawndale_dns_key_algorithm:
from_secret: lawndale-dns-key-algorithm
---
kind: pipeline
type: kubernetes
@@ -92,6 +85,6 @@ steps:
---
kind: signature
hmac: c79a45ff158cd06564765a09933921a2fd9856f6c2063716d45225fc1c45c100
hmac: 95f8db197163e884f2eee4b14af136b9ea1e0f88f626079b4a3b38b43b91c6a8
...

View File

@@ -69,7 +69,9 @@ Version:
The following resources are used by this module:
- [helm_release.coredns](https://registry.terraform.io/providers/hashicorp/helm/2.5.1/docs/resources/release) (resource)
- [helm_release.kube_state_metrics](https://registry.terraform.io/providers/hashicorp/helm/2.5.1/docs/resources/release) (resource)
- [helm_release.metrics_server](https://registry.terraform.io/providers/hashicorp/helm/2.5.1/docs/resources/release) (resource)
- [helm_release.traefik](https://registry.terraform.io/providers/hashicorp/helm/2.5.1/docs/resources/release) (resource)
- [kubernetes_cluster_role.ci_cd](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/cluster_role) (resource)
- [kubernetes_cluster_role.prometheus](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/cluster_role) (resource)
- [kubernetes_cluster_role_binding.auto_approve_node_csrs](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/cluster_role_binding) (resource)

16
ci.tf
View File

@@ -100,4 +100,20 @@ resource "kubernetes_cluster_role" "ci_cd" {
]
verbs = ["create", "delete", "get", "list", "patch", "update", "watch"]
}
rule {
api_groups = ["traefik.containo.us"]
resources = [
"ingressroutes",
"ingressroutetcps",
"ingressrouteudps",
"middlewares",
"middlewaretcps",
"serverstransports",
"tlsoptions",
"tlsstores",
"traefikservices",
]
verbs = ["create", "delete", "get", "list", "patch", "update", "watch"]
}
}

35
kube-state-metrics.tf Normal file
View File

@@ -0,0 +1,35 @@
resource "helm_release" "kube_state_metrics" {
name = "kube-state-metrics"
namespace = "kube-system"
repository = "https://prometheus-community.github.io/helm-charts"
chart = "kube-state-metrics"
version = "4.13.0"
values = [
jsonencode({
rbac = {
create = true
useClusterRole = true
}
serviceAccount = {
create = true
}
podSecurityPolicy = {
enabled = false
}
}),
jsonencode({
autosharding = {
enabled = false
}
}),
jsonencode({
customLabels = {
"prometheus.io/scrape" = "true"
"prometheus.io/port" = "8080"
"prometheus.io/scheme" = "http"
}
}),
]
}

View File

@@ -3,6 +3,7 @@ locals {
kubernetes_server = "https://nat.lawndale:6443"
kubernetes_version = "1.23.5"
cluster_dns = "10.32.0.10"
traefik_namespace = "traefik"
bootstrap_token = "${random_password.bootstrap_token_id.result}.${random_password.bootstrap_token_secret.result}"

32
traefik.tf Normal file
View File

@@ -0,0 +1,32 @@
resource "helm_release" "traefik" {
name = "traefik"
namespace = local.traefik_namespace
create_namespace = true
repository = "https://helm.traefik.io/traefik"
chart = "traefik"
values = [
jsonencode({
rbac = {
enabled = true
namespaced = false # traefik works for the whole cluster
}
podSecurityPolicy = {
enabled = false
}
deployment = {
enabled = false
}
daemonset = {
enabled = false
}
service = {
enabled = false
}
ingressroute = {
dashboard = { enabled = false }
}
})
]
}

View File

@@ -1,7 +1,7 @@
locals {
pool_name = "kubernetes-workers"
worker_id_start = 80
worker_count = 1
worker_count = 2
}
resource "libvirt_pool" "kubernetes_workers" {