Skip to content

Commit

Permalink
fix: replace deprecated Ingress annotation
Browse files Browse the repository at this point in the history
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 <guilhem.bonnefille@csgroup.eu>
  • Loading branch information
gbonnefille authored and amisevsk committed Jul 11, 2023
1 parent 1392456 commit 3906e0c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ var routeAnnotations = func(endpointName string) map[string]string {

var nginxIngressAnnotations = func(endpointName string) map[string]string {
return map[string]string{
"kubernetes.io/ingress.class": "nginx",
"nginx.ingress.kubernetes.io/rewrite-target": "/",
"nginx.ingress.kubernetes.io/ssl-redirect": "false",
constants.DevWorkspaceEndpointNameAnnotation: endpointName,
Expand Down
2 changes: 2 additions & 0 deletions controllers/controller/devworkspacerouting/solvers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"
)

type DevWorkspaceMetadata struct {
Expand Down Expand Up @@ -223,6 +224,7 @@ func getIngressForEndpoint(routingSuffix string, endpoint controllerv1alpha1.End
Annotations: nginxIngressAnnotations(endpoint.Name),
},
Spec: networkingv1.IngressSpec{
IngressClassName: pointer.String("nginx"),
Rules: []networkingv1.IngressRule{
{
Host: hostname,
Expand Down

0 comments on commit 3906e0c

Please sign in to comment.