I use terraform to set up a cluster and install fluxcd on it. The cluster is set up correctly (i see both in azure portal).
In the bootstrap step however, i get an error showing that flux tries to access a cluster that i do not know and do not have access to (can't find it in azure portal).
Error: Bootstrap run error
│
│ with module.flux.flux_bootstrap_git.this,
│ on modules/flux/main.tf line 58, in resource "flux_bootstrap_git" "this":
│ 58: resource "flux_bootstrap_git" "this" {
│
│ CustomResourceDefinition/alerts.notification.toolkit.fluxcd.io dry-run failed: Get
│ "https://****-*****.westeurope.azmk8s.io:443/api?timeout=32s": dial tcp: lookup
│ ****-*****.westeurope.azmk8s.io on ***.***.***.53:53: no such host
Here is how i setup/install flux on the cluster:
provider "flux" {
kubernetes = {
config_path = "~/.kube/config"
}
git = {
author_email = "*******@*******.com"
url = "https://dev.azure.com/*******/*******/_git/flux"
http = {
username = "*******@*******.com"
password = "*******"
}
}
}
resource "azurerm_kubernetes_cluster_extension" "flux" {
name = "flux"
cluster_id = var.aks_cluster_id
extension_type = "microsoft.flux"
}
resource "azurerm_kubernetes_flux_configuration" "k8s_flux" {
name = "flux-system"
cluster_id = var.aks_cluster_id
namespace = "flux-system"
git_repository {
url = "https://*******@dev.azure.com/*******/*******/_git/flux"
reference_type = "branch"
reference_value = "main"
}
kustomizations {
name = "kustomization"
path = "./clusters/test/00"
sync_interval_in_seconds = 120
retry_interval_in_seconds = 120
}
scope = "cluster"
depends_on = [
azurerm_kubernetes_cluster_extension.flux
]
}
resource "flux_bootstrap_git" "this" {
path = "clusters/test/"
components = [
"source-controller",
"kustomize-controller",
"helm-controller",
"notification-controller"
]
log_level = "debug"
depends_on = [
azurerm_kubernetes_cluster_extension.flux
]
}
Here is how i export the k8s config to use in the flux setup:
resource "local_file" "kubeconfig" {
depends_on = [azurerm_kubernetes_cluster.aks]
filename = "~/.kube/config"
content = azurerm_kubernetes_cluster.aks.kube_config_raw
}
Here is how i set up the aks cluster: https://pastebin.com/aC7E7n9W