Skip to content

Commit

Permalink
Merge pull request kosmos-io#424 from GreatLazyMan/virtualcluster_joi…
Browse files Browse the repository at this point in the history
…n_controller

title: virtualcluster join controller
  • Loading branch information
kosmos-robot authored Mar 12, 2024
2 parents ff48a76 + 09c7910 commit 57f162a
Show file tree
Hide file tree
Showing 7 changed files with 544 additions and 12 deletions.
14 changes: 11 additions & 3 deletions cmd/clustertree-operator/app/tree_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/spf13/cobra"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/client-go/tools/clientcmd"
cliflag "k8s.io/component-base/cli/flag"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -55,9 +56,15 @@ func run(ctx context.Context, opts *options.Options) error {
}
config.QPS, config.Burst = opts.KubernetesOptions.QPS, opts.KubernetesOptions.Burst

newscheme := scheme.NewSchema()
err = apiextensionsv1.AddToScheme(newscheme)
if err != nil {
panic(err)
}

mgr, err := controllerruntime.NewManager(config, controllerruntime.Options{
Logger: klog.Background(),
Scheme: scheme.NewSchema(),
Scheme: newscheme,
LeaderElection: opts.LeaderElection.LeaderElect,
LeaderElectionID: opts.LeaderElection.ResourceName,
LeaderElectionNamespace: opts.LeaderElection.ResourceNamespace,
Expand All @@ -76,8 +83,9 @@ func run(ctx context.Context, opts *options.Options) error {
}

VirtualClusterJoinController := controller.VirtualClusterJoinController{
Client: mgr.GetClient(),
EventRecorder: mgr.GetEventRecorderFor(constants.JoinControllerName),
Client: mgr.GetClient(),
EventRecorder: mgr.GetEventRecorderFor(constants.JoinControllerName),
KubeconfigPath: opts.KubernetesOptions.KubeConfig,
}
if err = VirtualClusterJoinController.SetupWithManager(mgr); err != nil {
return fmt.Errorf("error starting %s: %v", constants.JoinControllerName, err)
Expand Down
6 changes: 0 additions & 6 deletions deploy/crds/kosmos.io_virtualclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,3 @@ spec:
type: object
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
3 changes: 2 additions & 1 deletion pkg/kosmosctl/manifest/manifest_crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ spec:
properties:
clusterLinkOptions:
properties:
autodetectionMethod:
type: string
bridgeCIDRs:
default:
ip: 220.0.0.0/8
Expand Down Expand Up @@ -652,7 +654,6 @@ spec:
storage: true
subresources: {}
`

const NodeConfig = `---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
5 changes: 5 additions & 0 deletions pkg/treeoperator/constants/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ package constants
const (
InitControllerName = "virtual-cluster-init-controller"
JoinControllerName = "virtual-cluster-join-controller"

DefauleImageRepositoryEnv = "IMAGE_REPOSITIRY"
DefauleImageVersionEnv = "IMAGE_VERSION"
VirtualClusterStatusCompleted = "Completed"
VirtualClusterFinalizerName = "kosmos.io/virtual-cluster-finalizer"
)
Loading

0 comments on commit 57f162a

Please sign in to comment.