Skip to content

Commit

Permalink
Merge pull request #57 from backguynn/multicluster-v1
Browse files Browse the repository at this point in the history
add CRD(multiclusterLBService) & CRD manager & change kube-loxilb.yaml
  • Loading branch information
backguynn authored Sep 25, 2023
2 parents e7da563 + 6c56840 commit 51badd6
Show file tree
Hide file tree
Showing 7 changed files with 436 additions and 19 deletions.
16 changes: 15 additions & 1 deletion cmd/loxilb-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import (

"github.com/loxilb-io/kube-loxilb/pkg/agent/config"
"github.com/loxilb-io/kube-loxilb/pkg/agent/manager/loadbalancer"
"github.com/loxilb-io/kube-loxilb/pkg/agent/manager/multicluster"
crdinformers "github.com/loxilb-io/kube-loxilb/pkg/client/informers/externalversions"

"github.com/loxilb-io/kube-loxilb/pkg/api"
"github.com/loxilb-io/kube-loxilb/pkg/ippool"
"github.com/loxilb-io/kube-loxilb/pkg/k8s"
Expand Down Expand Up @@ -54,12 +57,14 @@ func run(o *Options) error {
klog.Infof(" Build: %s", BuildInfo)

// create k8s Clientset, CRD Clientset and SharedInformerFactory for the given config.
k8sClient, _, _, err := k8s.CreateClients(o.config.ClientConnection, "")
k8sClient, _, crdClient, _, err := k8s.CreateClients(o.config.ClientConnection, "")
if err != nil {
return fmt.Errorf("error creating k8s clients: %v", err)
}

informerFactory := informers.NewSharedInformerFactory(k8sClient, informerDefaultResync)
crdInformerFactory := crdinformers.NewSharedInformerFactory(crdClient, informerDefaultResync)
multiclusterLBInformer := crdInformerFactory.Multicluster().V1().MultiClusterLBServices()

// networkReadyCh is used to notify that the Node's network is ready.
// Functions that rely on the Node's network should wait for the channel to close.
Expand Down Expand Up @@ -176,6 +181,13 @@ func run(o *Options) error {
informerFactory,
)

multiClusterLBManager := multicluster.NewMulticlusterLBManager(
crdClient,
loxilbClients,
networkConfig,
multiclusterLBInformer,
)

go wait.Until(func() {
if len(networkConfig.LoxilbURLs) <= 0 {
lbManager.DiscoverLoxiLBServices(loxiLBLiveCh, loxiLBPurgeCh)
Expand All @@ -188,8 +200,10 @@ func run(o *Options) error {

log.StartLogFileNumberMonitor(stopCh)
informerFactory.Start(stopCh)
crdInformerFactory.Start(stopCh)

go lbManager.Run(stopCh, loxiLBLiveCh, loxiLBPurgeCh, loxiLBSelMasterEvent)
go multiClusterLBManager.Run(stopCh, loxiLBLiveCh, loxiLBPurgeCh, loxiLBSelMasterEvent)

<-stopCh

Expand Down
132 changes: 132 additions & 0 deletions manifest/crds/multicluster-lb-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
name: multiclusterlbservices.multicluster.loxilb.io
spec:
group: multicluster.loxilb.io
names:
kind: MultiClusterLBService
listKind: MultiClusterLBServiceList
plural: multiclusterlbservices
singular: multiclusterlbservice
scope: Cluster
versions:
- name: v1
schema:
openAPIV3Schema:
description: MultiClusterLBService is the Schema for the multiclusterlbservices
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: MultiClusterLBServiceSpec defines the desired state of MultiClusterLBService
properties:
lbModel:
properties:
endpoints:
items:
properties:
endpointIP:
type: string
state:
type: string
targetPort:
type: integer
weight:
type: integer
required:
- endpointIP
- targetPort
- weight
type: object
type: array
secondaryIPs:
items:
properties:
secondaryIP:
type: string
required:
- secondaryIP
type: object
type: array
serviceArguments:
properties:
BGP:
type: boolean
Monitor:
type: boolean
block:
type: integer
externalIP:
type: string
inactiveTimeOut:
format: int32
type: integer
managed:
type: boolean
mode:
format: int32
type: integer
port:
type: integer
probeport:
type: integer
probereq:
type: string
proberesp:
type: string
probetype:
type: string
protocol:
type: string
sel:
description: 'EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU
TO OWN! NOTE: json tags are required. Any new fields you
add must have json tags for the fields to be serialized.'
type: integer
required:
- block
- externalIP
- inactiveTimeOut
- mode
- port
- sel
type: object
required:
- endpoints
- serviceArguments
type: object
required:
- lbModel
type: object
status:
description: MultiClusterLBServiceStatus defines the observed state of
MultiClusterLBService
properties:
externalIP:
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state
of cluster Important: Run "make" to regenerate code after modifying
this file'
type: string
required:
- externalIP
type: object
type: object
served: true
storage: true
subresources:
status: {}
11 changes: 11 additions & 0 deletions manifest/kube-loxilb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ rules:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- multicluster.loxilb.io
resources:
- multiclusterlbservices
verbs:
- get
- watch
- list
- create
- update
- delete
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
Loading

0 comments on commit 51badd6

Please sign in to comment.