From f62830625904abe8e7cce01cea469e0a8d585396 Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Tue, 2 Jul 2024 14:52:29 +0800 Subject: [PATCH] support --configfile for kubenest Signed-off-by: duanmengkk --- cmd/kubenest/operator/app/operator.go | 4 +-- .../kosmos/kosmos_join_controller.go | 2 +- pkg/kubenest/controlplane/etcd.go | 30 +++++++++---------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cmd/kubenest/operator/app/operator.go b/cmd/kubenest/operator/app/operator.go index eab8b3cbb..00b0e3b40 100644 --- a/cmd/kubenest/operator/app/operator.go +++ b/cmd/kubenest/operator/app/operator.go @@ -61,7 +61,7 @@ func NewVirtualClusterOperatorCommand(ctx context.Context) *cobra.Command { } func runCommand(ctx context.Context, opts *options.Options) error { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(ctx) defer cancel() kc, err := SetupConfig(opts) @@ -74,7 +74,7 @@ func runCommand(ctx context.Context, opts *options.Options) error { func SetupConfig(opts *options.Options) (*config.Config, error) { c := &config.Config{} - koc := v1alpha1.KubeNestConfiguration{} + var koc v1alpha1.KubeNestConfiguration if len(opts.ConfigFile) != 0 { ko, err := loadConfig(opts.ConfigFile) if err != nil { diff --git a/pkg/kubenest/controller/kosmos/kosmos_join_controller.go b/pkg/kubenest/controller/kosmos/kosmos_join_controller.go index 05307886c..becfca6c3 100644 --- a/pkg/kubenest/controller/kosmos/kosmos_join_controller.go +++ b/pkg/kubenest/controller/kosmos/kosmos_join_controller.go @@ -4,7 +4,6 @@ import ( "context" "encoding/base64" "fmt" - restclient "k8s.io/client-go/rest" "os" "reflect" "sync" @@ -15,6 +14,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" + restclient "k8s.io/client-go/rest" "k8s.io/client-go/tools/record" "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" diff --git a/pkg/kubenest/controlplane/etcd.go b/pkg/kubenest/controlplane/etcd.go index eff90477a..39c9b4438 100644 --- a/pkg/kubenest/controlplane/etcd.go +++ b/pkg/kubenest/controlplane/etcd.go @@ -73,21 +73,21 @@ func installEtcd(client clientset.Interface, name, namespace string, kubeNestCon ETCDStorageClass, ETCDStorageSize string IPV6First bool }{ - StatefulSetName: fmt.Sprintf("%s-%s", name, "etcd"), - Namespace: namespace, - ImageRepository: imageRepository, - Version: imageVersion, - EtcdClientService: fmt.Sprintf("%s-%s", name, "etcd-client"), - CertsSecretName: fmt.Sprintf("%s-%s", name, "etcd-cert"), - EtcdPeerServiceName: fmt.Sprintf("%s-%s", name, "etcd"), - EtcdDataVolumeName: constants.EtcdDataVolumeName, - InitialCluster: strings.Join(initialClusters, ","), - EtcdCipherSuites: strings.Join(flag.PreferredTLSCipherNames(), ","), - Replicas: constants.EtcdReplicas, - EtcdListenClientPort: constants.EtcdListenClientPort, - EtcdListenPeerPort: constants.EtcdListenPeerPort, - ETCDStorageClass: kubeNestConfiguration.KubeInKubeConfig.ETCDStorageClass, - ETCDStorageSize: resourceQuantity.String(), + StatefulSetName: fmt.Sprintf("%s-%s", name, "etcd"), + Namespace: namespace, + ImageRepository: imageRepository, + Version: imageVersion, + EtcdClientService: fmt.Sprintf("%s-%s", name, "etcd-client"), + CertsSecretName: fmt.Sprintf("%s-%s", name, "etcd-cert"), + EtcdPeerServiceName: fmt.Sprintf("%s-%s", name, "etcd"), + EtcdDataVolumeName: constants.EtcdDataVolumeName, + InitialCluster: strings.Join(initialClusters, ","), + EtcdCipherSuites: strings.Join(flag.PreferredTLSCipherNames(), ","), + Replicas: constants.EtcdReplicas, + EtcdListenClientPort: constants.EtcdListenClientPort, + EtcdListenPeerPort: constants.EtcdListenPeerPort, + ETCDStorageClass: kubeNestConfiguration.KubeInKubeConfig.ETCDStorageClass, + ETCDStorageSize: resourceQuantity.String(), VirtualControllerLabel: vclabel, IPV6First: IPV6FirstFlag, })