Skip to content

Commit

Permalink
Prepare ns dev for deploy with github runner
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Khramtsov committed Aug 19, 2024
1 parent bfb50d2 commit f2938b9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
38 changes: 38 additions & 0 deletions terraform/modules/k8s-addons/eks-dev-namespace.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
locals {
dev_namespace = {
namespace = local.namespaces[index(local.namespaces.*.id, "dev")].id
enabled = local.namespaces[index(local.namespaces.*.id, "dev")].enabled
}
}

module "dev_namespace" {
count = local.dev_namespace.enabled ? 1 : 0

source = "../eks-kubernetes-namespace"
name = local.dev_namespace.namespace
network_policies = []

depends_on = [helm_release.gha_runner_scale_set]
}
resource "kubectl_manifest" "github_runner_role_binding" {
count = local.dev_namespace.enabled && local.gha_runner_scale_set_controller.enabled ? 1 : 0

yaml_body = <<EOF
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: github-runner-role-binding
namespace: ${local.dev_namespace.namespace}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: gha-runner-scale-set-gha-rs-no-permission
namespace: ${module.gha_runner_scale_set_controller_namespace[0].name}
EOF

depends_on = [module.dev_namespace]
}

1 change: 1 addition & 0 deletions terraform/modules/k8s-addons/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ locals {
ssl_certificate_arn = var.ssl_certificate_arn

helm_releases = yamldecode(file("${path.module}/helm-releases.yaml"))["releases"]
namespaces = yamldecode(file("${path.module}/namespaces.yaml"))["namespaces"]
}
3 changes: 3 additions & 0 deletions terraform/modules/k8s-addons/namespaces.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespaces:
- id: dev
enabled: true

0 comments on commit f2938b9

Please sign in to comment.