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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Claudie doesn't support multiple Provider configurations for the same cloud provider #1296

Closed
JKBGIT1 opened this issue Mar 26, 2024 · 5 comments · Fixed by #1348
Closed
Assignees
Labels
bug Something isn't working groomed Task that everybody agrees to pass the gatekeeper

Comments

@JKBGIT1
Copy link
Contributor

JKBGIT1 commented Mar 26, 2024

Current Behaviour

Using multiple Provider (at least two) configurations for the same cloud provider results in the following error in terraformer

Error: Duplicate provider configuration
jakub-blog-test-z7ep12d │ 
jakub-blog-test-z7ep12d │   on jakub-blog-test-z7ep12d-azure-2-provider.tf line 1:
jakub-blog-test-z7ep12d │    1: provider "azurerm" {
jakub-blog-test-z7ep12d │ 
jakub-blog-test-z7ep12d │ A provider configuration for "azurerm" with alias "nodepool" was already
jakub-blog-test-z7ep12d │ given at jakub-blog-test-z7ep12d-azure-1-provider.tf:1,1-19. Each
jakub-blog-test-z7ep12d │ configuration for the same provider must have a distinct alias.

Expected Behaviour

Claudie builds an infrastructure for the same cloud provider using multiple Provider configurations.

Steps To Reproduce

  1. Create at least two secrets for Providers configuration. I created one secret with credentials for our sponsorship subscription and the other one with our pay-as-you-go subscription credentials.
  2. Apply an InputManifest that provisions at least two node pools, each with a different Provider configuration. I've used the following one
apiVersion: claudie.io/v1beta1
kind: InputManifest
metadata:
  name: jakub-blog-test
  labels:
    app.kubernetes.io/part-of: claudie
spec:
  providers:
    - name: cloudflare-1
      providerType: cloudflare
      secretRef:
        name: cloudflare-secret
        namespace: default
    - name: azure-1
      providerType: azure
      secretRef:
        name: berops-azure-secret
        namespace: default
    - name: azure-2
      providerType: azure
      secretRef:
        name: sponsor-azure-secret
        namespace: default

  nodePools:
    dynamic:
      - name: control-azure-1
        providerSpec:
          name: azure-1
          region: westeurope
          zone: "1"
        count: 1
        serverType: Standard_B2s
        image: Canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts:22.04.202212120

      - name: compute-azure-1
        providerSpec:
          name: azure-1
          region: westeurope
          zone: "2"
        count: 1
        serverType: Standard_B2s
        image: Canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts:22.04.202212120
        storageDiskSize: 50

      - name: compute-azure-2
        providerSpec:
          name: azure-1
          region: northeurope
          zone: "3"
        count: 1
        serverType: Standard_B2s
        image: Canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts:22.04.202212120
        storageDiskSize: 50

      - name: loadbalancer-1
        providerSpec:
          name: azure-1
          region: northeurope
          zone: "1"
        count: 1
        serverType: Standard_B2s
        image: Canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts:22.04.202212120
        storageDiskSize: 50

  kubernetes:
    clusters:
      - name: jakub-blog-test
        version: "v1.26.0"
        network: 192.168.2.0/24
        pools:
          control:
            - control-azure-1
          compute:
            - compute-azure-1
            - compute-azure-2
  loadBalancers:
    roles:
      - name: apiserver
        protocol: tcp
        port: 6443
        targetPort: 6443
        targetPools:
          - control-azure-1
    clusters:
      - name: apiserver-lb-claudie
        roles:
          - apiserver
        dns:
          dnsZone: claudie.dev
          provider: cloudflare-1
        targetedK8s: jakub-blog-test
        pools:
          - loadbalancer-1

It should also work without a loadbalancer.

Anything else to note

This issue first occurred in this blog.

@JKBGIT1 JKBGIT1 added the bug Something isn't working label Mar 26, 2024
@bernardhalas
Copy link
Member

This should be fairly easily supported with provider aliases.

@MarioUhrik
Copy link
Contributor

Hey guys, looks like here's the culprit for azure:
https://github.com/berops/claudie/blob/master/services/terraformer/templates/azure/provider.tpl#L7C22-L7C30

It seems you're doing it right for other providers, though to me it seems better to base these on provider.name rather than provider.region:
https://github.com/berops/claudie/blob/master/services/terraformer/templates/aws/provider.tpl

@MiroslavRepka
Copy link
Contributor

MiroslavRepka commented Apr 1, 2024

@MarioUhrik is right about the azure bug.

Regarding the provider.name, I think that does not work as a single provider can be used for more nodepools, which can be spread in different regions, but provider specification can require region, i.e. in AWS.

Therefore, in case you have one AWS provider and two nodepools, each in a different region, you have to have provider specification in terraform twice, once for every region used.

@bernardhalas
Copy link
Member

Indeed, and given the fact, that in Claudie the design allows the usage of two different AWS provider configs in the same region (e.g. for billing or reporting purposes), the current code imposes a limitation.

@JKBGIT1
Copy link
Contributor Author

JKBGIT1 commented Apr 5, 2024

At first, we have to check whether changing the TF provider name triggers a resource recreation. We need to check the provider alias for all the cloud providers.

@JKBGIT1 JKBGIT1 added good first issue Good for newcomers groomed Task that everybody agrees to pass the gatekeeper labels Apr 5, 2024
@Despire Despire self-assigned this Apr 19, 2024
@Despire Despire removed the good first issue Good for newcomers label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working groomed Task that everybody agrees to pass the gatekeeper
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants