azurekubernetesterraformkubernetes-helmazure-china

Specify proxy for helm repository in terraform for azure china


I am trying to deploy a helm chart via terraform to Azure Kubernetes Service in China. The problem is that I cannot pull images from k8s.gcr.io/ingress-nginx. I need to specify a proxy as described in https://github.com/Azure/container-service-for-azure-china/blob/master/aks/README.md#22-container-registry-proxy but I don't know how to do this via terraform. In west europe my resource simply looks like

resource "helm_release" "nginx_ingress" {
  name      = "ingress-nginx"
  chart     = "ingress-nginx"
  repository = "https://kubernetes.github.io/ingress-nginx"
  namespace = kubernetes_namespace.nginx_ingress.metadata[0].name

  set {
    name  = "controller.service.annotations.service\\.beta\\.kubernetes\\.io/azure-load-balancer-resource-group"
    value = azurerm_public_ip.nginx_ingress_pip.resource_group_name
  }

  set {
    name  = "controller.service.loadBalancerIP"
    value = azurerm_public_ip.nginx_ingress_pip.ip_address
  }
}

How do I get the proxy settings in there? Any help is greatly appreciated.


Solution

  • Turns out I had some problems figuring out how to modify the helm chart in the correct way plus the solution was not exactly a proxy configuration but to directly use a different repository for the image pull. This works:

    resource "helm_release" "nginx_ingress" {
      name      = "ingress-nginx"
      chart     = "ingress-nginx"
      repository = "https://kubernetes.github.io/ingress-nginx"
      namespace = kubernetes_namespace.nginx_ingress.metadata[0].name
    
      set {
        name  = "controller.service.annotations.service\\.beta\\.kubernetes\\.io/azure-load-balancer-resource-group"
        value = azurerm_public_ip.nginx_ingress_pip.resource_group_name
      }
    
      set {
        name  = "controller.service.loadBalancerIP"
        value = azurerm_public_ip.nginx_ingress_pip.ip_address
      }
    
      set {
        name = "controller.image.repository"
        value = "k8sgcr.azk8s.cn/ingress-nginx/controller"
      }
    }
    

    Thank you anyways for your input!