Skip to content

Commit

Permalink
add hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverMKing committed Jul 11, 2023
1 parent eae43b4 commit d89d6c7
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions pkg/controller/nginx/nginx.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package nginx

import (
"context"

"github.com/Azure/aks-app-routing-operator/pkg/config"
"github.com/Azure/aks-app-routing-operator/pkg/controller/ingress"
"github.com/Azure/aks-app-routing-operator/pkg/controller/service"
"github.com/Azure/aks-app-routing-operator/pkg/manifests"
appsv1 "k8s.io/api/apps/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"
)
Expand All @@ -19,12 +24,30 @@ type nginx struct {
defaultIngConfig *manifests.NginxIngressConfig
}

const (
defaultIcName = "webapprouting.kubernetes.azure.com"
)

// New starts all resources required for provisioning Nginx ingresses and the configs used for those ingresses
func New(m manager.Manager, conf *config.Config, self *appsv1.Deployment) ([]*manifests.NginxIngressConfig, error) {
kcs, err := kubernetes.NewForConfig(m.GetConfig()) // need to use config since manager hasn't started yet
if err != nil {
return nil, err
}

defaultControllerClass := "webapprouting.kubernetes.azure.com/nginx"
defaultIc, err := kcs.NetworkingV1().IngressClasses().Get(context.Background(), defaultIcName, metav1.GetOptions{})
if err == nil {
defaultControllerClass = defaultIc.Spec.Controller
}
if err != nil && !k8serrors.IsNotFound(err) {
return nil, err
}

defaultIngConfig := &manifests.NginxIngressConfig{
ControllerClass: "webapprouting.kubernetes.azure.com/nginx",
ControllerClass: defaultControllerClass,
ResourceName: "nginx",
IcName: "webapprouting.kubernetes.azure.com",
IcName: defaultIcName,
}

// TODO: re-add for dynamic provisioning, until then serviceConfig is nil
Expand Down

0 comments on commit d89d6c7

Please sign in to comment.