pulumi / pulumi-kubernetes

A Pulumi resource provider for Kubernetes to manage API resources and workloads in running clusters
https://www.pulumi.com/docs/reference/clouds/kubernetes/
Apache License 2.0
404 stars 115 forks source link

Gateway API CRD installation is not fully completed when Gateway Fabric starts #3137

Closed blackat closed 1 month ago

blackat commented 1 month ago

What happened?

Hello, it seems to me the Gateway API installation is not fully completed when the Gateway Fabric installation starts. The first time the Gateway Fabric failsm but second time everything runs fine.

Example

const nginxGatewayApi = new k8s.kustomize.Directory("gateway-api-crd", {
  directory: "https://github.com/nginxinc/nginx-gateway-fabric/config/crd/gateway-api/standard?ref=v1.3.0"
}, {
  provider: k8sProvider
});

/**
 * Install NGINX Gateway Fabric, implementation of the Gateway API, from GitHub OCI repository.
 */
const gatewayFabricChart = new k8s.helm.v3.Release("gateway-fabric-chart", {
  chart: "oci://ghcr.io/nginxinc/charts/nginx-gateway-fabric",
  version: "1.3.0",
  namespace: inwoNamespace,
  name: nginxGatewayFabricServiceName,
  values: {
    crd: {
      keep: true
    }
  }
}, {
  dependsOn: [nginxGatewayApi],
  provider: k8sProvider
});

First time I run Pulumi up, Gateway Fabric fails:

  Type                                                               Name                                       Status                        Info
 +   pulumi:pulumi:Stack                                                infra-gateway-dev                          **creating failed (14s)**     1 error; 3 messages
 +   ├─ pulumi:providers:kubernetes                                     k8s-provider                               created (0.27s)               
 +   ├─ kubernetes:kustomize:Directory                                  gateway-api-crd                            created (1s)                  
 +   │  ├─ kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition  referencegrants.gateway.networking.k8s.io  created (0.29s)               
 +   │  ├─ kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition  gatewayclasses.gateway.networking.k8s.io   created (1s)                  
 +   │  ├─ kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition  gateways.gateway.networking.k8s.io         created (1s)                  
 +   │  ├─ kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition  grpcroutes.gateway.networking.k8s.io       created (1s)                  
 +   │  └─ kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition  httproutes.gateway.networking.k8s.io       created (2s)                  
 +   ├─ kubernetes:core/v1:Namespace                                    cert-manager-namespace                     created (0.58s)               
 +   └─ kubernetes:helm.sh/v3:Release                                   gateway-fabric-chart                       **creating failed**           1 error

Diagnostics:
  pulumi:pulumi:Stack (infra-gateway-dev):
    stack name: dev
    cluster name: blackat/infra-cluster/dev
    namespace: inwo

    error: update failed

  kubernetes:helm.sh/v3:Release (gateway-fabric-chart):
    error: unable to build kubernetes objects from release manifest: resource mapping not found for name: "nginx" namespace: "" from "": no matches for kind "GatewayClass" in version "gateway.networking.k8s.io/v1"
    ensure CRDs are installed first

Resources:
    + 9 created

Duration: 15s

Second time I run Pulumi up, Gateway Fabric installation is successful:


     Type                              Name                  Status            Info
     pulumi:pulumi:Stack               infra-gateway-dev                       3 messages
 +   ├─ kubernetes:helm.sh/v3:Release  gateway-fabric-chart  created (14s)     
 +   └─ kubernetes:helm.sh/v3:Release  cert-manager-chart    created (24s)     

Diagnostics:
  pulumi:pulumi:Stack (infra-gateway-dev):
    stack name: dev
    cluster name: blackat/infra-cluster/dev
    namespace: inwo

Resources:
    + 2 created
    9 unchanged

Duration: 48s

Output of pulumi about

CLI          
Version      3.127.0
Go Version   go1.22.5
Go Compiler  gc

Plugins
KIND      NAME          VERSION
resource  azure-native  2.51.0
resource  kubernetes    4.15.0
language  nodejs        unknown

Host     
OS       darwin
Version  14.5
Arch     arm64

This project is written in nodejs: executable='/Users/eugenio/.nvm/versions/node/v18.13.0/bin/node' version='v18.13.0'

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/blackat
User           blackat
Organizations  blackat
Token type     personal

Dependencies:
NAME                  VERSION
@pulumi/pulumi        3.127.0
@types/node           18.19.42
typescript            5.5.4
@pulumi/azure-native  2.51.0
@pulumi/kubernetes    4.15.0

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

justinvp commented 1 month ago

This looks specific to the Kubernetes provider. Transferring this issue to the k8s repo and someone will take a look soon.

blampe commented 1 month ago

@blackat do you see the same behavior when using v2 Directory?

blackat commented 1 month ago

Hello @blampe, I have just tried and it works like a charm, do I close the issue?

blampe commented 1 month ago

Glad that worked for you @blackat! Yes, I think we can close this as working by design.

blackat commented 1 month ago

Hello @blampe, what does it mean it works by design? I would expect both should work in the same way, just for my knowledge 😄