Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for postBuild substitution in flux_configuration #24081

Open
1 task done
endakelly opened this issue Nov 30, 2023 · 1 comment 路 May be fixed by #25695
Open
1 task done

Support for postBuild substitution in flux_configuration #24081

endakelly opened this issue Nov 30, 2023 · 1 comment 路 May be fixed by #25695

Comments

@endakelly
Copy link

endakelly commented Nov 30, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Description

I would be great to have support to add postBuild substitutions in the azurerm_flux_configuration resource. Presently, this can be done using a patch request to the API but this is not ideal. The setting is also not yet exposed in the azure cli or azure portal.

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_flux_configuration#kustomizations

This is the api endpoint that can be used https://learn.microsoft.com/en-us/rest/api/kubernetesconfiguration/flux-configurations/update?view=rest-kubernetesconfiguration-2023-05-01&tabs=HTTP#kustomizationpatchdefinition

Here is an example request:

az rest --method patch --headers "{'Content-Type': 'application/json'}" --uri https://management.azure.com/subscriptions/<sub-id>/resourceGroups/<my-rg>/providers/Microsoft.ContainerService/managedClusters/<my-cluster>/providers/Microsoft.KubernetesConfiguration/fluxConfigurations/flux-system\?api-version\=2023-05-01 --body "{'properties':{'gitRepository':{'url':'https://github.com/my-flux-config.git','repositoryRef':{'branch':'my-branch'}},'kustomizations':{'flux-system':{'path':'./clusters/sbox/01','syncIntervalInSeconds':300,'postBuild':{'substitute':{'WI_NAME':'flux-system','ENVIRONMENT':'sbox','WI_ENVIRONMENT':'sbox','CLUSTER':'01','ISSUER_URL':'https://uksouth.oic.prod-aks.azure.com/<tenant-id>/<federated-credential-id>/','ENV_MONITOR_CHANNEL':'aks-monitor-sbox','KEYVAULT_ENVIRONMENT':'sbox'}}}}}}"

New or Affected Resource(s)/Data Source(s)

azurerm_kubernetes_flux_configuration

Potential Terraform Configuration

resource "azurerm_kubernetes_flux_configuration" "microsoft_flux_configuration" {
  name       = "flux-system"
  cluster_id = azurerm_kubernetes_cluster.kubernetes_cluster.id
  namespace  = "flux-system"

  git_repository {
    url             = "https://github.com/my-flux-config"
    reference_type  = "branch"
    reference_value = "my-branch"
  }

  kustomizations {
    name = "flux-system"
    path = "./clusters/${var.environment}/${var.cluster_number}"
    postBuild = {
     substitute = {
      WI_NAME: "flux-system"
      ENVIRONMENT: "sbox"
      WI_ENVIRONMENT: "sbox"
      CLUSTER: "01"
      ISSUER_URL: "https://uksouth.oic.prod-aks.azure.com/<tenant-id>/<federated-credential-id>/"
      ENV_MONITOR_CHANNEL: "aks-monitor-sbox"
      KEYVAULT_ENVIRONMENT: "sbox"
      }
    }
  }

  scope = "cluster"

  depends_on = [
    azurerm_kubernetes_cluster_extension.microsoft_flux_extension
  ]
}

References

No response

@jayctran
Copy link

Hi @rcskosir, is the pull request I provided to resolve this issue able to be reviewed please? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants