From fea49450bd9823d88753b7fbab63d4b6321f5983 Mon Sep 17 00:00:00 2001 From: lmxia Date: Mon, 5 Aug 2024 10:37:11 +0800 Subject: [PATCH] refactor import sequence and fix typo Signed-off-by: lmxia --- README.md | 2 +- cmd/ep-controller/main.go | 4 ++-- deploy/hub/templates/NOTES.txt | 5 ++--- pkg/cnf/CNFManager.go | 12 +++++------ pkg/controller/endpointslice/endpointslice.go | 1 - .../mcs/serviceexport_controller.go | 16 --------------- pkg/controller/syncer/agent.go | 4 ---- pkg/known/constants.go | 9 +-------- utils/endpointslice.go | 16 --------------- utils/kubeconfig.go | 20 ++----------------- 10 files changed, 14 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index be2b67a7..b8a42b21 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ same node, with this second interface assigned to the ``cnf`` network namespace. ## Helm Chart Installation and Clear `Nauti` is pretty easy to install with `Helm`. Make sure you already have at least 2 Kubernetes clusters, -please refer to this installation guide. [Helm Chart Page](https://nauti-io.github.io/nauti-charts/) +please refer to this installation guide [Helm Chart Page](https://nauti-io.github.io/nauti-charts/). After the installation, add cross cluster DNS config segment, in `coredns` configmap, and restart coredns pods. The `cluster-ip` of `crossdns` is a static cluster IP, usually `10.96.0.11` , check before setting. diff --git a/cmd/ep-controller/main.go b/cmd/ep-controller/main.go index 83be0873..ed180d93 100644 --- a/cmd/ep-controller/main.go +++ b/cmd/ep-controller/main.go @@ -7,8 +7,6 @@ import ( "path/filepath" "time" - "github.com/google/uuid" - "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/informers" @@ -19,8 +17,10 @@ import ( "k8s.io/client-go/tools/leaderelection/resourcelock" "k8s.io/klog/v2" + "github.com/google/uuid" "github.com/nauti-io/nauti/pkg/controller/endpoint" "github.com/nauti-io/nauti/pkg/controller/endpointslice" + "github.com/sirupsen/logrus" ) var ( diff --git a/deploy/hub/templates/NOTES.txt b/deploy/hub/templates/NOTES.txt index 2461dc27..2a6ab430 100644 --- a/deploy/hub/templates/NOTES.txt +++ b/deploy/hub/templates/NOTES.txt @@ -4,6 +4,5 @@ Your release is named {{ .Release.Name }}. Continue to install nauti-agent on clusters, and install nauti-agent in cluster by: - helm install nauti-agent mcs/nauti-agent --namespace nauti-system --create-namespace \ - --set hub.hubURL=https://{{ .Values.tunnel.endpoint }}:6443 \ - --set tunnel.globalcidr={{ .Values.tunnel.cidr }} --set tunnel.cidr=10.113.0.0/16 --set cluster.clusterID=cluster1 \ No newline at end of file + helm install nauti-agent nauti/nauti-agent --namespace nauti-system --create-namespace \ + --set hub.hubURL=https://{{ .Values.tunnel.endpoint }}:6443 --set cluster.clusterID=cluster1 \ No newline at end of file diff --git a/pkg/cnf/CNFManager.go b/pkg/cnf/CNFManager.go index 07fc4bf1..820e6bfe 100644 --- a/pkg/cnf/CNFManager.go +++ b/pkg/cnf/CNFManager.go @@ -7,12 +7,6 @@ import ( "sync" "time" - "github.com/kelseyhightower/envconfig" - syncerConfig "github.com/nauti-io/nauti/pkg/config" - "github.com/nauti-io/nauti/pkg/controller/syncer" - tunnelcontroller "github.com/nauti-io/nauti/pkg/controller/tunnel" - octopusClientset "github.com/nauti-io/nauti/pkg/generated/clientset/versioned" - kubeinformers "github.com/nauti-io/nauti/pkg/generated/informers/externalversions" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" @@ -24,7 +18,13 @@ import ( "k8s.io/klog/v2" mcsv1a1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1" + "github.com/kelseyhightower/envconfig" + syncerConfig "github.com/nauti-io/nauti/pkg/config" + "github.com/nauti-io/nauti/pkg/controller/syncer" + tunnelcontroller "github.com/nauti-io/nauti/pkg/controller/tunnel" "github.com/nauti-io/nauti/pkg/dedinic" + octopusClientset "github.com/nauti-io/nauti/pkg/generated/clientset/versioned" + kubeinformers "github.com/nauti-io/nauti/pkg/generated/informers/externalversions" "github.com/nauti-io/nauti/pkg/known" "github.com/nauti-io/nauti/pkg/tunnel" "github.com/nauti-io/nauti/utils" diff --git a/pkg/controller/endpointslice/endpointslice.go b/pkg/controller/endpointslice/endpointslice.go index ebb087a6..014cee48 100644 --- a/pkg/controller/endpointslice/endpointslice.go +++ b/pkg/controller/endpointslice/endpointslice.go @@ -22,7 +22,6 @@ import ( "time" "golang.org/x/time/rate" - v1 "k8s.io/api/core/v1" discovery "k8s.io/api/discovery/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/controller/mcs/serviceexport_controller.go b/pkg/controller/mcs/serviceexport_controller.go index eda7f77f..a5297c9d 100644 --- a/pkg/controller/mcs/serviceexport_controller.go +++ b/pkg/controller/mcs/serviceexport_controller.go @@ -1,19 +1,3 @@ -/* -Copyright 2022 The Clusternet Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - package mcs import ( diff --git a/pkg/controller/syncer/agent.go b/pkg/controller/syncer/agent.go index 84f8dfff..46807649 100644 --- a/pkg/controller/syncer/agent.go +++ b/pkg/controller/syncer/agent.go @@ -127,7 +127,3 @@ func generateSliceName(clusterName, namespace, name string) string { return fmt.Sprintf("%s-%s-%s", namespacePart, namePart, hashPart[8:24]) } - -// func (a *Syncer) getObjectNameWithClusterID(name, namespace string) string { -// return generateSliceName(a.ClusterID, namespace, name) -// } diff --git a/pkg/known/constants.go b/pkg/known/constants.go index 12467501..9a44ad74 100644 --- a/pkg/known/constants.go +++ b/pkg/known/constants.go @@ -3,19 +3,12 @@ package known import "time" const ( - LabelValueManagedBy = "mcs.nauti.io" - OriginName = "origin-name" - OriginNamespace = "origin-namespace" - LabelSourceNamespace = "submariner-io/originatingNamespace" - LabelSourceCluster = "syncer.nauti.io/sourceCluster" - LabelSourceName = "syncer.nauti.io/sourceName" - LabelOriginNameSpace = "syncer.nauti.io/sourceNamespace" + LabelValueManagedBy = "mcs.nauti.io" ) const ( MaxNamespaceLength = 10 MaxNameLength = 10 - MaxClusternName = 10 ) type RouteOperation int diff --git a/utils/endpointslice.go b/utils/endpointslice.go index 743b6b68..5a0933bc 100644 --- a/utils/endpointslice.go +++ b/utils/endpointslice.go @@ -1,19 +1,3 @@ -/* -Copyright 2022 The Clusternet Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - package utils import ( diff --git a/utils/kubeconfig.go b/utils/kubeconfig.go index 4a0be7a4..a2361346 100644 --- a/utils/kubeconfig.go +++ b/utils/kubeconfig.go @@ -1,19 +1,3 @@ -/* -Copyright 2021 The Clusternet Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - package utils import ( @@ -55,8 +39,8 @@ func createBasicKubeConfig(serverURL, clusterName, userName string, caCert []byt // CreateKubeConfigWithToken creates a KubeConfig object with access to the API server with a token func CreateKubeConfigWithToken(serverURL, token string, caCert []byte) *clientcmdapi.Config { - userName := "clusternet" - clusterName := "clusternet-cluster" + userName := "nauti" + clusterName := "nauti-cluster" config := createBasicKubeConfig(serverURL, clusterName, userName, caCert) config.AuthInfos[userName] = &clientcmdapi.AuthInfo{ Token: token,