Skip to content

Commit

Permalink
added slicegatewayServiceType field
Browse files Browse the repository at this point in the history
Signed-off-by: Mridul <[email protected]>
  • Loading branch information
mridulgain committed Sep 19, 2023
1 parent 8a0ab6f commit 5b20b10
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 5 deletions.
10 changes: 10 additions & 0 deletions apis/controller/v1alpha1/sliceconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ type WorkerSliceGatewayProvider struct {
//+kubebuilder:default:=Local
// +kubebuilder:validation:Required
SliceCaType string `json:"sliceCaType"`

SliceGatewayServiceType []SliceGatewayServiceType `json:"sliceGatewayServiceType,omitempty"`
}

type SliceGatewayServiceType struct {
// +kubebuilder:validation:Required
Cluster string `json:"cluster,omitempty"`
// +kubebuilder:validation:Required
//+kubebuilder:validation:Enum:=NodePort;LoadBalancer
Type string `json:"type,omitempty"`
}

// QOSProfile is the QOS Profile configuration from backend
Expand Down
22 changes: 21 additions & 1 deletion apis/controller/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apis/worker/v1alpha1/workersliceconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type WorkerSliceGatewayProvider struct {
SliceGatewayType string `json:"sliceGatewayType,omitempty"`
//+kubebuilder:default:=Local
SliceCaType string `json:"sliceCaType,omitempty"`
//+kubebuilder:validation:Enum:=NodePort;LoadBalancer
SliceGatewayServiceType string `json:"sliceGatewayServiceType,omitempty"`
}

// QOSProfile is the QOS Profile configuration from backend
Expand Down
12 changes: 12 additions & 0 deletions config/crd/bases/controller.kubeslice.io_sliceconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ spec:
sliceCaType:
default: Local
type: string
sliceGatewayServiceType:
items:
properties:
cluster:
type: string
type:
enum:
- NodePort
- LoadBalancer
type: string
type: object
type: array
sliceGatewayType:
default: OpenVPN
type: string
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/worker.kubeslice.io_workersliceconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ spec:
sliceCaType:
default: Local
type: string
sliceGatewayServiceType:
enum:
- NodePort
- LoadBalancer
type: string
sliceGatewayType:
default: OpenVPN
type: string
Expand Down
7 changes: 4 additions & 3 deletions service/kube_slice_resource_names.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,10 @@ var (
)

const (
serverGateway = "Server"
clientGateway = "Client"
workerSliceGatewayType = "OpenVPN"
serverGateway = "Server"
clientGateway = "Client"
workerSliceGatewayType = "OpenVPN"
defaultSliceGatewayServiceType = "NodePort"
)

var (
Expand Down
19 changes: 18 additions & 1 deletion service/worker_slice_config_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package service
import (
"context"
"fmt"
"github.com/kubeslice/kubeslice-controller/metrics"
"time"

"github.com/kubeslice/kubeslice-controller/metrics"

"github.com/kubeslice/kubeslice-controller/events"

"go.uber.org/zap"
Expand Down Expand Up @@ -211,6 +212,22 @@ outer:
logger.With(zap.Error(err)).Errorf("Failed to deep copy external gateway configuration")
}

// Reconcile Slice gateway service type
sliceGatewayProvider := workerv1alpha1.WorkerSliceGatewayProvider{
SliceGatewayType: sliceConfig.Spec.SliceGatewayProvider.SliceGatewayType,
SliceCaType: sliceConfig.Spec.SliceGatewayProvider.SliceCaType,
}
gwSvcTypePresent := false
for _, gwSvcType := range sliceConfig.Spec.SliceGatewayProvider.SliceGatewayServiceType {
if gwSvcType.Cluster == "*" || gwSvcType.Cluster == workerSliceConfig.Labels["worker-cluster"] {
sliceGatewayProvider.SliceGatewayServiceType = gwSvcType.Type
gwSvcTypePresent = true
}
}
if !gwSvcTypePresent {
sliceGatewayProvider.SliceGatewayServiceType = defaultSliceGatewayServiceType
}

// Reconcile the Namespace Isolation Profile
controllerIsolationProfile := sliceConfig.Spec.NamespaceIsolationProfile
workerIsolationProfile := workerv1alpha1.NamespaceIsolationProfile{
Expand Down

0 comments on commit 5b20b10

Please sign in to comment.