Skip to content

feat: enable Azure Key Vault provider for Secrets Store CSI Driver for Azure Kubernetes Service#1585

Draft
monteiro-renato wants to merge 1 commit into
mainfrom
feat/enable_key_vault_secrets_provider
Draft

feat: enable Azure Key Vault provider for Secrets Store CSI Driver for Azure Kubernetes Service#1585
monteiro-renato wants to merge 1 commit into
mainfrom
feat/enable_key_vault_secrets_provider

Conversation

@monteiro-renato

@monteiro-renato monteiro-renato commented Apr 28, 2025

Copy link
Copy Markdown
Contributor

Related Issue(s)

Summary by CodeRabbit

  • New Features

    • Enabled automatic secret rotation for the Key Vault Secrets Provider in the Azure Kubernetes cluster configuration.
  • Style

    • Improved formatting for better readability in the cluster configuration settings.

@monteiro-renato monteiro-renato requested a review from a team as a code owner April 28, 2025 13:02
@coderabbitai

coderabbitai Bot commented Apr 28, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The changes introduce the key_vault_secrets_provider block with the attribute secret_rotation_enabled = true to the azurerm_kubernetes_cluster resource for the k6tests AKS cluster in two Terraform configuration files. This enables secret rotation for the Key Vault Secrets Provider integration within the Kubernetes cluster. Additionally, minor formatting adjustments were made to the default_node_pool block for alignment purposes, without altering its logic or values.

Changes

File(s) Change Summary
infrastructure/adminservices-test/altinn-monitor-test-rg/k6_tests_rg_k8s.tf Added key_vault_secrets_provider block with secret_rotation_enabled = true to the AKS cluster resource.
infrastructure/adminservices-test/k6tests-rg/modules/foundational/k8s.tf Added key_vault_secrets_provider block with secret_rotation_enabled = true and reformatted node pool block.

Sequence Diagram(s)

sequenceDiagram
    participant Terraform
    participant AzureRM
    participant AKS Cluster
    participant Key Vault

    Terraform->>AzureRM: Apply AKS cluster configuration
    AzureRM->>AKS Cluster: Configure cluster with Key Vault Secrets Provider
    AKS Cluster->>Key Vault: Enable secret rotation for secrets provider
    Note right of AKS Cluster: Secrets are automatically rotated as configured
Loading

Possibly related PRs

  • Altinn/altinn-platform#1472: Both PRs modify the azurerm_kubernetes_cluster resource configuration for the k6 cluster by adding new feature-related blocks, but one enables secret rotation for Key Vault Secrets Provider while the other enables automatic stable cluster upgrades, so they are related in context but modify different aspects of the same resource.

Suggested reviewers

  • tjololo
  • khanrn

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d8e7be and 4d38ab6.

📒 Files selected for processing (2)
  • infrastructure/adminservices-test/altinn-monitor-test-rg/k6_tests_rg_k8s.tf (1 hunks)
  • infrastructure/adminservices-test/k6tests-rg/modules/foundational/k8s.tf (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (3)
infrastructure/adminservices-test/k6tests-rg/modules/foundational/k8s.tf (2)

13-15: Ensure AzureRM provider version supports key_vault_secrets_provider.
The key_vault_secrets_provider block was introduced in AzureRM v3.27.0. Verify that your Terraform configuration has a required_providers constraint (or lockfile) specifying azurerm >= 3.27.0 to avoid plan errors.


32-37: Approve: Formatting consistency in default_node_pool.
The vertical alignment of attributes in the default_node_pool block enhances readability without functional changes.

Also applies to: 39-39

infrastructure/adminservices-test/altinn-monitor-test-rg/k6_tests_rg_k8s.tf (1)

75-77: Verify provider compatibility for Key Vault integration.
This adds key_vault_secrets_provider { secret_rotation_enabled = true }. Confirm your AzureRM provider version is ≥ 3.27.0 so Terraform supports this block.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions

github-actions Bot commented Apr 28, 2025

Copy link
Copy Markdown
Contributor

Terraform environment test

Format and Style 🖌success

Initialization ⚙️success

Validation 🤖success

Validation Output

Success! The configuration is valid.


Plan 📖success

Show Plan

[Lines containing Refreshing state removed]
[Truncated to 120000 bytes! See logoutput for complete plan]
Acquiring state lock. This may take a few moments...
data.azurerm_resource_group.rg_dp_stag: Reading...
data.azurerm_client_config.current: Reading...
data.azurerm_client_config.current: Read complete after 0s [id=Y2xpZW50Q29uZmlncy9jbGllbnRJZD1mMDNmNzU3OS01ZjM5LTRkN2YtYmNlYS04ZTVjYjZkN2FjYTQ7b2JqZWN0SWQ9MDJiMTdkMjgtN2VjOC00MDg0LTkyY2UtZDI2MDUxZmE0OTk4O3N1YnNjcmlwdGlvbklkPTFjZThlOWFmLWMyZDYtNDRlNy05YzVlLTA5OWEzMDgwNTZmZTt0ZW5hbnRJZD1jZDAwMjZkOC0yODNiLTRhNTUtOWJmYS1kMGVmNGE4YmEyMWM=]
data.azurerm_monitor_data_collection_rule.prometheus: Reading...
data.azurerm_resource_group.rd_dp_test["dp-be-yt01-rg"]: Reading...
data.azurerm_resource_group.rd_dp_test["dp-be-test-rg"]: Reading...
data.azurerm_log_analytics_workspace.dp_law_test["dp-be-test-insightsWorkspace"]: Reading...
data.azurerm_resource_group.rg_dp_stag: Read complete after 1s [id=/subscriptions/e4926efc-0577-47b3-9c3d-757925630eca/resourceGroups/dp-be-staging-rg]
data.azurerm_log_analytics_workspace.dp_law_test["dp-be-yt01-insightsWorkspace"]: Reading...
data.azurerm_resource_group.rd_dp_test["dp-be-yt01-rg"]: Read complete after 1s [id=/subscriptions/8a353de8-d81d-468d-a40d-f3574b6bb3f4/resourceGroups/dp-be-yt01-rg]
data.azurerm_resource_group.rg_dp_prod: Reading...
data.azurerm_monitor_data_collection_rule.prometheus: Read complete after 1s [id=/subscriptions/1ce8e9af-c2d6-44e7-9c5e-099a308056fe/resourceGroups/MA_k6tests-amw_norwayeast_managed/providers/Microsoft.Insights/dataCollectionRules/k6tests-amw]
data.azurerm_log_analytics_workspace.dp_law_stag: Reading...
data.azurerm_resource_group.rg_dp_prod: Read complete after 0s [id=/subscriptions/c595f787-450d-4c57-84fa-abc5f95d5459/resourceGroups/dp-be-prod-rg]
data.azurerm_resource_group.rd_dp_test["dp-be-test-rg"]: Read complete after 2s [id=/subscriptions/8a353de8-d81d-468d-a40d-f3574b6bb3f4/resourceGroups/dp-be-test-rg]
data.azurerm_log_analytics_workspace.dp_law_test["dp-be-test-insightsWorkspace"]: Read complete after 1s [id=/subscriptions/8a353de8-d81d-468d-a40d-f3574b6bb3f4/resourceGroups/dp-be-test-rg/providers/Microsoft.OperationalInsights/workspaces/dp-be-test-insightsWorkspace]
data.azurerm_log_analytics_workspace.dp_law_test["dp-be-yt01-insightsWorkspace"]: Read complete after 1s [id=/subscriptions/8a353de8-d81d-468d-a40d-f3574b6bb3f4/resourceGroups/dp-be-yt01-rg/providers/Microsoft.OperationalInsights/workspaces/dp-be-yt01-insightsWorkspace]
data.azurerm_log_analytics_workspace.dp_law_prod: Reading...
data.azurerm_log_analytics_workspace.dp_law_stag: Read complete after 1s [id=/subscriptions/e4926efc-0577-47b3-9c3d-757925630eca/resourceGroups/dp-be-staging-rg/providers/Microsoft.OperationalInsights/workspaces/dp-be-staging-insightsWorkspace]
data.azurerm_resource_group.rg_studio_dev: Reading...
data.azurerm_resource_group.rg_studio_stag: Reading...
data.azurerm_resource_group.rg_studio_law_test: Reading...
data.azurerm_resource_group.rg_studio_dev: Read complete after 1s [id=/subscriptions/971ddbb1-27d0-4cc7-a016-461dab5cec05/resourceGroups/studio-dev-rg]
data.azurerm_resource_group.rg_studio_law_test: Read complete after 0s [id=/subscriptions/971ddbb1-27d0-4cc7-a016-461dab5cec05/resourceGroups/altinn-rg]
data.azurerm_log_analytics_workspace.studio_law_test: Reading...
data.azurerm_log_analytics_workspace.dp_law_prod: Read complete after 1s [id=/subscriptions/c595f787-450d-4c57-84fa-abc5f95d5459/resourceGroups/dp-be-prod-rg/providers/Microsoft.OperationalInsights/workspaces/dp-be-prod-insightsWorkspace]
data.azurerm_resource_group.rg_studio_stag: Read complete after 2s [id=/subscriptions/971ddbb1-27d0-4cc7-a016-461dab5cec05/resourceGroups/studio-staging-rg]
data.azurerm_log_analytics_workspace.studio_law_test: Read complete after 1s [id=/subscriptions/971ddbb1-27d0-4cc7-a016-461dab5cec05/resourceGroups/altinn-rg/providers/Microsoft.OperationalInsights/workspaces/altinn-studio-test-log]
data.azurerm_resource_group.rg_studio_law_prod: Reading...
data.azurerm_resource_group.rg_studio_prod: Reading...
data.azurerm_resource_group.rg_studio_law_prod: Read complete after 0s [id=/subscriptions/f66298ed-870c-40e0-bb74-6db89c1a364b/resourceGroups/altinn-rg]
data.azurerm_resource_group.rg_studio_prod: Read complete after 0s [id=/subscriptions/f66298ed-870c-40e0-bb74-6db89c1a364b/resourceGroups/studio-prod-rg]
data.azurerm_log_analytics_workspace.studio_law_prod: Reading...
data.azurerm_log_analytics_workspace.studio_law_prod: Read complete after 1s [id=/subscriptions/f66298ed-870c-40e0-bb74-6db89c1a364b/resourceGroups/altinn-rg/providers/Microsoft.OperationalInsights/workspaces/altinn-studio-prod-log]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # azurerm_kubernetes_cluster.k6tests will be updated in-place
  ~ resource "azurerm_kubernetes_cluster" "k6tests" {
        id                                  = "/subscriptions/1ce8e9af-c2d6-44e7-9c5e-099a308056fe/resourceGroups/k6tests-rg/providers/Microsoft.ContainerService/managedClusters/k6tests-cluster"
        name                                = "k6tests-cluster"
        tags                                = {}
        # (37 unchanged attributes hidden)

      + key_vault_secrets_provider {
          + secret_identity          = (known after apply)
          + secret_rotation_enabled  = true
          + secret_rotation_interval = "2m"
        }

        # (7 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: tfplan.out

To perform exactly these actions, run the following command to apply:
    terraform apply "tfplan.out"
Releasing state lock. This may take a few moments...

Context Values
Pusher @monteiro-renato
Action pull_request
Working Directory ./infrastructure/adminservices-test/altinn-monitor-test-rg
State File github.com/altinn/altinn-platform/environments/test/altinn-monitor-test-rg.tfstate
Plan File github.com_altinn_altinn-platform_environments_test_altinn-monitor-test-rg.tfstate.tfplan

@monteiro-renato

monteiro-renato commented Apr 28, 2025

Copy link
Copy Markdown
Contributor Author

😞, looks like the automagical way is not available yet (In the Terraform provider).

@monteiro-renato monteiro-renato marked this pull request as draft April 29, 2025 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant