Skip to content

Commit

Permalink
add gateway public service controller
Browse files Browse the repository at this point in the history
  • Loading branch information
珩轩 committed Aug 31, 2023
1 parent 8b94570 commit 0618706
Show file tree
Hide file tree
Showing 7 changed files with 1,102 additions and 14 deletions.
2 changes: 2 additions & 0 deletions pkg/yurtmanager/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/openyurtio/openyurt/pkg/yurtmanager/controller/raven/dns"
"github.com/openyurtio/openyurt/pkg/yurtmanager/controller/raven/gatewayinternalservice"
"github.com/openyurtio/openyurt/pkg/yurtmanager/controller/raven/gatewaypickup"
"github.com/openyurtio/openyurt/pkg/yurtmanager/controller/raven/gatewaypublicservice"
"github.com/openyurtio/openyurt/pkg/yurtmanager/controller/servicetopology"
servicetopologyendpoints "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/servicetopology/endpoints"
servicetopologyendpointslice "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/servicetopology/endpointslice"
Expand Down Expand Up @@ -68,6 +69,7 @@ func init() {
controllerAddFuncs[raven.GatewayPickupControllerName] = []AddControllerFn{gatewaypickup.Add}
controllerAddFuncs[raven.GatewayDNSControllerName] = []AddControllerFn{dns.Add}
controllerAddFuncs[raven.GatewayInternalServiceController] = []AddControllerFn{gatewayinternalservice.Add}
controllerAddFuncs[raven.GatewayPublicServiceController] = []AddControllerFn{gatewaypublicservice.Add}
}

// If you want to add additional RBAC, enter it here !!! @kadisi
Expand Down
1 change: 1 addition & 0 deletions pkg/yurtmanager/controller/raven/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ const (
ControllerName = "gateway"
GatewayPickupControllerName = "raven-gateway-pickup"
GatewayInternalServiceController = "raven-gateway-internal-service"
GatewayPublicServiceController = "raven-gateway-public-service"
GatewayDNSControllerName = "raven-dns"
)
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,18 @@ import (

type EnqueueRequestForGatewayEvent struct{}

func logGatewayError() {
klog.Error(Format("fail to assert runtime Object to v1beta1.Gateway"))
}

func logConfigmapError() {
klog.Error(Format("fail to assert runtime Object to v1.Configmap"))
}

func (h *EnqueueRequestForGatewayEvent) Create(e event.CreateEvent, q workqueue.RateLimitingInterface) {
gw, ok := e.Object.(*ravenv1beta1.Gateway)
if !ok {
klog.Error(Format("fail to assert runtime Object to v1alpha1.Gateway"))
logGatewayError()
return
}
if gw.Spec.ExposeType == "" {
Expand All @@ -46,12 +54,12 @@ func (h *EnqueueRequestForGatewayEvent) Create(e event.CreateEvent, q workqueue.
func (h *EnqueueRequestForGatewayEvent) Update(e event.UpdateEvent, q workqueue.RateLimitingInterface) {
newGw, ok := e.ObjectNew.(*ravenv1beta1.Gateway)
if !ok {
klog.Error(Format("fail to assert runtime Object to v1alpha1.Gateway"))
logGatewayError()
return
}
oldGw, ok := e.ObjectOld.(*ravenv1beta1.Gateway)
if !ok {
klog.Error(Format("fail to assert runtime Object to v1alpha1.Gateway"))
logGatewayError()
return
}
if oldGw.Spec.ExposeType == "" && newGw.Spec.ExposeType == "" {
Expand All @@ -64,7 +72,7 @@ func (h *EnqueueRequestForGatewayEvent) Update(e event.UpdateEvent, q workqueue.
func (h *EnqueueRequestForGatewayEvent) Delete(e event.DeleteEvent, q workqueue.RateLimitingInterface) {
gw, ok := e.Object.(*ravenv1beta1.Gateway)
if !ok {
klog.Error(Format("fail to assert runtime Object to v1alpha1.Gateway"))
logGatewayError()
return
}
if gw.Spec.ExposeType == "" {
Expand All @@ -83,7 +91,7 @@ type EnqueueRequestForConfigEvent struct{}
func (h *EnqueueRequestForConfigEvent) Create(e event.CreateEvent, q workqueue.RateLimitingInterface) {
cm, ok := e.Object.(*corev1.ConfigMap)
if !ok {
klog.Error(Format("fail to assert runtime Object to corev1.Configmap"))
logConfigmapError()
return
}
if cm.Data == nil {
Expand All @@ -108,12 +116,12 @@ func (h *EnqueueRequestForConfigEvent) Create(e event.CreateEvent, q workqueue.R
func (h *EnqueueRequestForConfigEvent) Update(e event.UpdateEvent, q workqueue.RateLimitingInterface) {
newCm, ok := e.ObjectNew.(*corev1.ConfigMap)
if !ok {
klog.Error(Format("fail to assert runtime Object to corev1.Configmap"))
logConfigmapError()
return
}
oldCm, ok := e.ObjectOld.(*corev1.ConfigMap)
if !ok {
klog.Error(Format("fail to assert runtime Object to corev1.Configmap"))
logConfigmapError()
return
}
_, newInsecurePort, newErr := net.SplitHostPort(newCm.Data[utils.ProxyServerInsecurePortKey])
Expand Down
Loading

0 comments on commit 0618706

Please sign in to comment.