ingress.class can not be set when the class field is also set

1 minute readKnowledge base

Issue

When you create a new controller, you encounter the error:

Error Failure executing: POST at: .../apis/networking.k8s.io/v1/namespaces/ci/ingresses. Message: Ingress.extensions "controller" is invalid: annotations.kubernetes.io/ingress.class: Invalid value: "external": can not be set when the class field is also set.

Environment

Resolution

Starting in CloudBees CI 2.319.2.5, we use Ingress v1 and an IngressClass is required. We mention this in the release notes: CloudBees CI on modern cloud platforms 2.319.2.5.

If you installed nginx yourself, you will need to upgrade the Ingress Nginx Controller deployment to 1.x so that it supports Ingress v1 and adds an IngressClass.

If you installed nginx using the CloudBees CI helm chart (via helm value ingress-nginx.Enabled: true), you wouldn’t have encountered this issue, since ingress-nginx v1.1.0 (or newer) would have been deployed via https://github.com/kubernetes/ingress-nginx/tree/main/charts/ingress-nginx.

Workaround

There is no workaround available, because if you don’t upgrade Ingress Nginx V1 or later, there is no IngressClass and therefore CloudBees CI controller Ingresses will not be considered by the Ingress Controller. Additionally, annotations cannot be added because the Master Provisioning Kubernetes uses Ingress V1 to create the Ingress object and it is now forbidden under V1 to have both an ingress.class annotation at the same time as ingressClassName: https://kubernetes.io/docs/concepts/services-networking/ingress/#deprecated-annotation

Tested product/plugin versions

CloudBees CI on Modern Cloud Platforms version 2.319.2.7

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.