Skip to content

Commit 5cded0f

Browse files
committed
fix: replace deprecated Ingress annotation
Before the IngressClass resource and ingressClassName field were added in Kubernetes 1.18, Ingress classes were specified with a kubernetes.io/ingress.class annotation on the Ingress. This annotation was never formally defined, but was widely supported by Ingress controllers. The newer ingressClassName field on Ingresses is a replacement for that annotation, but is not a direct equivalent. While the annotation was generally used to reference the name of the Ingress controller that should implement the Ingress, the field is a reference to an IngressClass resource that contains additional Ingress configuration, including the name of the Ingress controller. Cf. https://kubernetes.io/docs/concepts/services-networking/ingress/#deprecated-annotation Signed-off-by: Guilhem Bonnefille <[email protected]>
1 parent 1392456 commit 5cded0f

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

controllers/controller/devworkspacerouting/solvers/basic_solver.go

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ var routeAnnotations = func(endpointName string) map[string]string {
3131

3232
var nginxIngressAnnotations = func(endpointName string) map[string]string {
3333
return map[string]string{
34-
"kubernetes.io/ingress.class": "nginx",
3534
"nginx.ingress.kubernetes.io/rewrite-target": "/",
3635
"nginx.ingress.kubernetes.io/ssl-redirect": "false",
3736
constants.DevWorkspaceEndpointNameAnnotation: endpointName,

controllers/controller/devworkspacerouting/solvers/common.go

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
networkingv1 "k8s.io/api/networking/v1"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
"k8s.io/apimachinery/pkg/util/intstr"
28+
"k8s.io/utils/pointer"
2829
)
2930

3031
type DevWorkspaceMetadata struct {
@@ -223,6 +224,7 @@ func getIngressForEndpoint(routingSuffix string, endpoint controllerv1alpha1.End
223224
Annotations: nginxIngressAnnotations(endpoint.Name),
224225
},
225226
Spec: networkingv1.IngressSpec{
227+
IngressClassName: pointer.String("nginx"),
226228
Rules: []networkingv1.IngressRule{
227229
{
228230
Host: hostname,

0 commit comments

Comments
 (0)