https://pulumi.com logo
#general
Title
# general
a

able-pager-97491

07/19/2021, 8:25 PM
Hey everyone! I’m trying to follow this guide (Kubernetes, GKE, typescript) to create a simple service with an ingress, and I can’t get the application ingress to find the existing endpoint associated with the service.
b

billowy-army-68599

07/19/2021, 8:27 PM
can you sharte the code you have?
a

able-pager-97491

07/19/2021, 8:29 PM
Copy code
// Create a Service for the kuard Deployment
const service = new k8s.core.v1.Service(`${name}-ingress`,
    {
        metadata: {labels: labels, namespace: config.appsNamespaceName},
        spec: {ports: [{ port: 8080, targetPort: "http" }], selector: labels},
    },
    {provider: config.provider}
);

// Export the Service name and public LoadBalancer endpoint
export const serviceName = service.metadata.name;

// Create the kuard Ingress
const ingress = new k8s.extensions.v1beta1.Ingress(`${name}-ingress`,
    {
        metadata: {
            labels: labels,
            namespace: config.appsNamespaceName,
            annotations: {"<http://kubernetes.io/ingress.class|kubernetes.io/ingress.class>": "nginx"},
        },
        spec: {
            rules: [
                {
                    host: "<http://apps.example.com|apps.example.com>",
                    http: {
                        paths: [
                            {
                                path: "/",
                                backend: {
                                    serviceName: serviceName,
                                    servicePort: "http",
                                }
                            },
                        ],
                    },
                }
            ]
        }
    },
    {
        provider: config.provider,
        customTimeouts: { create: "20m", update: "20m", delete: "20m" }
    }
);
it’s almost identical to the one in the guide. This is the error:
Copy code
kubernetes:extensions/v1beta1:Ingress (kuard-ingress):
    warning: extensions/v1beta1/Ingress is deprecated by <http://networking.k8s.io/v1beta1/Ingress|networking.k8s.io/v1beta1/Ingress> and not supported by Kubernetes v1.20+ clusters.
    error: 2 errors occurred:
    	* the Kubernetes API server reported that "apps-ybm4ftrd/kuard-ingress-qw61tuib" failed to fully initialize or become live: 'kuard-ingress-qw61tuib' timed out waiting to be Ready
    	* Ingress has at least one rule that does not target any Service. Field '.spec.rules[].http.paths[].backend.serviceName' may not match any active Service
b

billowy-army-68599

07/19/2021, 8:36 PM
so this is because the spec has changed I think. try this:
Copy code
// Create the kuard Ingress
const ingress = new k8s.extensions.v1.Ingress(`${name}-ingress`,
    {
        metadata: {
            labels: labels,
            namespace: config.appsNamespaceName,
            annotations: {"<http://kubernetes.io/ingress.class|kubernetes.io/ingress.class>": "nginx"},
        },
        spec: {
            rules: [
                {
                    host: "<http://apps.example.com|apps.example.com>",
                    http: {
                        paths: [
                            {
                                path: "/",
                                backend: {
                                    service: {
                                        name: serviceName,
                                        port: {
                                            name: "http",
                                        }
                                    }
                                }
                                }
                            },
                        ],
                    },
                }
            ]
        }
    },
    {
        provider: config.provider,
        customTimeouts: { create: "20m", update: "20m", delete: "20m" }
    }
);
(I haven't tested this, but looking through my examples this is what I go with now
a

able-pager-97491

07/19/2021, 8:53 PM
that makes sense, but I’m getting an error that the v1 is not exported by the pulumi-kubernetes typescript sdk 🤔
Copy code
k8s.networking.v1.Ingress
I will try this one…
Copy code
const ingress = new k8s.networking.v1.Ingress(`${name}-ingress`,
    {
        metadata: {
            labels: labels,
            namespace: config.appsNamespaceName,
            annotations: {"<http://kubernetes.io/ingress.class|kubernetes.io/ingress.class>": "nginx"},
        },
        spec: {
            rules: [
                {
                    host: "<http://pulumi.dev.chatpay.com.br|pulumi.dev.chatpay.com.br>",
                    http: {
                        paths: [
                            {
                                path: "/",
                                pathType: "ImplementationSpecific",
                                backend: {
                                    service: {
                                        name: serviceName,
                                        port: {name: "http"}
                                    }
                                }
                            },
                        ],
                    },
                }
            ]
        }
    },
    {
        provider: config.provider,
    }
);
I had to add the pathType that is now required and it worked! thank you @billowy-army-68599
it seems there is a mismatch between the provider checking code and the spec being used, is there any way I can avoid this?
3 Views