-
Notifications
You must be signed in to change notification settings - Fork 2
feat: central/shared kubernetes platform landing zone and optional namespace creation in app landing zone #39
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
Open
lweberru
wants to merge
5
commits into
main
Choose a base branch
from
feat/lz-namespace-service-observability-demo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a9abe53
feat: add landing-zone namespace service demo and observability workflow
lweberru e0b6b44
test: extend hub-spoke coverage for platform kubernetes and namespace…
lweberru 9a6b208
fix(connectivity): allow deploys without firewall image path
lweberru 34e27c6
Finalize PR39 review follow-ups and Gateway API DNS bridge
lweberru 1a7984c
Merge origin/main and resolve connectivity outputs conflict
lweberru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,12 @@ | ||
| ################### | ||
| ## OBSERVABILITY ## | ||
| ################### | ||
|
|
||
| resource "stackit_observability_instance" "this" { | ||
| count = var.observability.enabled ? 1 : 0 | ||
|
|
||
| project_id = stackit_resourcemanager_project.this.project_id | ||
| name = var.observability.name != null ? var.observability.name : "${var.naming_pattern}-obs" | ||
| plan_name = var.observability.plan_name | ||
| acl = var.observability.acl | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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,22 @@ | ||
| locals { | ||
| project_labels = merge( | ||
| { "region" = var.region }, | ||
| var.network.mode == "sna" && var.network.sna_network_area_id != null ? { "networkArea" = var.network.sna_network_area_id } : {}, | ||
| var.labels | ||
| ) | ||
| } | ||
|
|
||
| resource "stackit_resourcemanager_project" "this" { | ||
| parent_container_id = var.parent_container_id | ||
| name = var.project_name != null ? var.project_name : var.naming_pattern | ||
| owner_email = var.owner_email | ||
| labels = length(local.project_labels) > 0 ? local.project_labels : null | ||
| } | ||
|
|
||
| resource "stackit_authorization_project_role_assignment" "this" { | ||
| for_each = { for assignment in var.role_assignments : "${assignment.role}-${assignment.subject}" => assignment } | ||
|
|
||
| resource_id = stackit_resourcemanager_project.this.project_id | ||
| role = each.value.role | ||
| subject = each.value.subject | ||
| } |
This file contains hidden or 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,12 @@ | ||
| locals { | ||
|
lweberru marked this conversation as resolved.
Outdated
|
||
| dns_extension_zones = distinct(compact(var.dns.zones)) | ||
| } | ||
|
|
||
| resource "stackit_dns_zone" "ske_extension" { | ||
| for_each = var.dns.create_zones ? { for zone in local.dns_extension_zones : zone => zone } : {} | ||
|
|
||
| project_id = stackit_resourcemanager_project.this.project_id | ||
| name = each.value | ||
| dns_name = each.value | ||
| contact_email = var.owner_email | ||
| } | ||
This file contains hidden or 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,8 @@ | ||
| resource "time_sleep" "wait_for_network_area_membership" { | ||
| count = var.network.mode == "sna" ? 1 : 0 | ||
|
lweberru marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Allow backend propagation after project label updates before SKE SNA validation. | ||
| create_duration = "30s" | ||
|
|
||
| depends_on = [stackit_resourcemanager_project.this] | ||
| } | ||
This file contains hidden or 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,8 @@ | ||
| resource "stackit_observability_instance" "this" { | ||
| count = var.observability.enabled ? 1 : 0 | ||
|
|
||
| project_id = stackit_resourcemanager_project.this.project_id | ||
| name = var.observability.name != null ? var.observability.name : "${var.naming_pattern}-obs" | ||
| plan_name = var.observability.plan_name | ||
| acl = var.observability.acl | ||
| } |
This file contains hidden or 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,8 @@ | ||
| resource "stackit_network" "sna" { | ||
|
lweberru marked this conversation as resolved.
Outdated
|
||
| count = local.use_sna ? 1 : 0 | ||
|
|
||
| project_id = stackit_resourcemanager_project.this.project_id | ||
| name = "${var.cluster.name}-sna" | ||
| ipv4_prefix_length = var.network.sna_network_prefix_length | ||
| routed = true | ||
| } | ||
This file contains hidden or 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,82 @@ | ||
| locals { | ||
| use_sna = lower(var.network.mode) == "sna" | ||
|
lweberru marked this conversation as resolved.
Outdated
|
||
|
|
||
| effective_observability_instance_id = var.observability.enabled ? stackit_observability_instance.this[0].instance_id : null | ||
|
lweberru marked this conversation as resolved.
Outdated
|
||
| effective_dns_zones = var.dns.create_zones ? sort([ | ||
| for zone in values(stackit_dns_zone.ske_extension) : zone.dns_name | ||
| ]) : local.dns_extension_zones | ||
| default_node_pools = [ | ||
|
lweberru marked this conversation as resolved.
Outdated
|
||
| { | ||
| name = "ha-a" | ||
| machine_type = "g3i.4" | ||
| minimum = 2 | ||
| maximum = 2 | ||
| availability_zones = ["${var.region}-1"] | ||
| volume_size = 20 | ||
| volume_type = "storage_premium_perf1" | ||
| os_name = "flatcar" | ||
| labels = {} | ||
| }, | ||
| { | ||
| name = "ha-b" | ||
| machine_type = "g3i.4" | ||
| minimum = 2 | ||
| maximum = 2 | ||
| availability_zones = ["${var.region}-2"] | ||
| volume_size = 20 | ||
| volume_type = "storage_premium_perf1" | ||
| os_name = "flatcar" | ||
| labels = {} | ||
| } | ||
| ] | ||
| effective_node_pools = length(var.cluster.node_pools) > 0 ? var.cluster.node_pools : local.default_node_pools | ||
| } | ||
|
|
||
| resource "stackit_ske_cluster" "this" { | ||
| project_id = stackit_resourcemanager_project.this.project_id | ||
| region = var.region | ||
| name = var.cluster.name | ||
| depends_on = [time_sleep.wait_for_network_area_membership, stackit_dns_zone.ske_extension] | ||
|
lweberru marked this conversation as resolved.
Outdated
|
||
| kubernetes_version_min = var.cluster.kubernetes_version_min | ||
| node_pools = local.effective_node_pools | ||
|
|
||
| maintenance = { | ||
|
lweberru marked this conversation as resolved.
Outdated
|
||
| enable_kubernetes_version_updates = var.cluster.maintenance.enable_kubernetes_version_updates | ||
| enable_machine_image_version_updates = var.cluster.maintenance.enable_machine_image_version_updates | ||
| start = var.cluster.maintenance.start | ||
| end = var.cluster.maintenance.end | ||
| } | ||
|
|
||
| network = local.use_sna ? { | ||
| id = stackit_network.sna[0].network_id | ||
| control_plane = { | ||
| access_scope = "SNA" | ||
| } | ||
| } : { | ||
| id = null | ||
| control_plane = { | ||
| access_scope = "PUBLIC" | ||
| } | ||
| } | ||
|
|
||
| extensions = { | ||
| observability = { | ||
| enabled = var.observability.enabled | ||
| instance_id = local.effective_observability_instance_id | ||
| } | ||
| dns = { | ||
| enabled = var.dns.enabled && length(local.effective_dns_zones) > 0 | ||
| zones = local.effective_dns_zones | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource "stackit_ske_kubeconfig" "this" { | ||
| project_id = stackit_resourcemanager_project.this.project_id | ||
| region = var.region | ||
| cluster_name = stackit_ske_cluster.this.name | ||
|
|
||
| refresh = true | ||
| expiration = 7200 | ||
| refresh_before = 1800 | ||
| } | ||
This file contains hidden or 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,50 @@ | ||
| data "stackit_service_accounts" "ske_internal" { | ||
| count = var.encrypted_volumes.enabled ? 1 : 0 | ||
|
|
||
| project_id = stackit_resourcemanager_project.this.project_id | ||
| email_suffix = "@ske.sa.stackit.cloud" | ||
|
|
||
| depends_on = [stackit_ske_cluster.this] | ||
| } | ||
|
|
||
| resource "stackit_kms_keyring" "this" { | ||
| count = var.encrypted_volumes.enabled ? 1 : 0 | ||
|
|
||
| project_id = stackit_resourcemanager_project.this.project_id | ||
| display_name = "${var.naming_pattern}-${var.encrypted_volumes.kms_keyring_name}" | ||
| } | ||
|
|
||
| resource "stackit_kms_key" "this" { | ||
| count = var.encrypted_volumes.enabled ? 1 : 0 | ||
|
|
||
| project_id = stackit_resourcemanager_project.this.project_id | ||
| keyring_id = stackit_kms_keyring.this[0].keyring_id | ||
| display_name = "${var.naming_pattern}-${var.encrypted_volumes.kms_key_name}" | ||
| protection = "software" | ||
| algorithm = "aes_256_gcm" | ||
| purpose = "symmetric_encrypt_decrypt" | ||
| } | ||
|
|
||
| resource "stackit_service_account" "kms_manager" { | ||
| count = var.encrypted_volumes.enabled ? 1 : 0 | ||
|
|
||
| project_id = stackit_resourcemanager_project.this.project_id | ||
| # STACKIT service account names are limited to 20 characters. | ||
| name = "${substr(var.naming_pattern, 0, 8)}-kms-mgr" | ||
| } | ||
|
|
||
| resource "stackit_authorization_project_role_assignment" "kms_admin" { | ||
| count = var.encrypted_volumes.enabled ? 1 : 0 | ||
|
|
||
| resource_id = stackit_resourcemanager_project.this.project_id | ||
| role = "kms.admin" | ||
| subject = stackit_service_account.kms_manager[0].email | ||
| } | ||
|
|
||
| resource "stackit_authorization_service_account_role_assignment" "ske_impersonation" { | ||
| count = var.encrypted_volumes.enabled ? 1 : 0 | ||
|
|
||
| resource_id = stackit_service_account.kms_manager[0].service_account_id | ||
| role = "user" | ||
| subject = data.stackit_service_accounts.ske_internal[0].items[0].email | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.