From a44c103c1d478fa0b9453d111d25cd4a8c9ee4ce Mon Sep 17 00:00:00 2001 From: duanmengkk Date: Sun, 4 Feb 2024 14:16:48 +0800 Subject: [PATCH] change the name of kosmos-operator to clusterlink-operator Signed-off-by: duanmengkk --- Makefile | 14 +++++------ .../clusterlink-operator}/app/operator.go | 14 +++++------ .../app/options/options.go | 0 .../app/options/validation.go | 0 .../clusterlink-operator}/main.go | 4 ++-- cmd/koslet/OWNERS | 5 ---- cmd/koslet/app/server.go | 7 ------ cmd/koslet/main.go | 15 ------------ deploy/kosmos-operator.yml | 14 +++++------ deploy/kosmos-rbac.yml | 2 +- .../kosmosctl/offline_installation_zh.md | 2 +- hack/cluster.sh | 8 +++---- hack/util.sh | 2 +- .../clusterlink-operator}/agent/agent.go | 18 +++++++------- .../clusterlink-operator}/agent/manifests.go | 0 .../clusterlink-operator}/elector/elector.go | 24 +++++++++---------- .../elector/manifests.go | 0 .../clusterlink-operator}/global/global.go | 8 +++---- .../clusterlink-operator}/global/manifests.go | 0 .../clusterlink-operator}/install.go | 14 +++++------ .../clusterlink-operator}/manager/manager.go | 24 +++++++++---------- .../manager/manifests.go | 0 .../operator_controller.go | 11 ++++----- .../clusterlink-operator}/option/option.go | 0 .../clusterlink-operator}/proxy/manifests.go | 0 .../clusterlink-operator}/proxy/proxy.go | 20 ++++++++-------- .../utils/idempotency.go | 0 .../clusterlink-operator}/utils/template.go | 0 pkg/kosmosctl/install/install.go | 2 +- .../manifest/manifest_clusterrolebindings.go | 2 +- .../manifest/manifest_deployments.go | 12 +++++----- .../manifest/manifest_serviceaccounts.go | 2 +- pkg/kosmosctl/uninstall/uninstall.go | 4 ++-- pkg/utils/constants.go | 2 +- 34 files changed, 101 insertions(+), 129 deletions(-) rename cmd/{operator => clusterlink/clusterlink-operator}/app/operator.go (87%) rename cmd/{operator => clusterlink/clusterlink-operator}/app/options/options.go (100%) rename cmd/{operator => clusterlink/clusterlink-operator}/app/options/validation.go (100%) rename cmd/{operator => clusterlink/clusterlink-operator}/main.go (63%) delete mode 100644 cmd/koslet/OWNERS delete mode 100644 cmd/koslet/app/server.go delete mode 100644 cmd/koslet/main.go rename pkg/{operator/clusterlink => clusterlink/clusterlink-operator}/agent/agent.go (81%) rename pkg/{operator/clusterlink => clusterlink/clusterlink-operator}/agent/manifests.go (100%) rename pkg/{operator/clusterlink => clusterlink/clusterlink-operator}/elector/elector.go (81%) rename pkg/{operator/clusterlink => clusterlink/clusterlink-operator}/elector/manifests.go (100%) rename pkg/{operator/clusterlink => clusterlink/clusterlink-operator}/global/global.go (80%) rename pkg/{operator/clusterlink => clusterlink/clusterlink-operator}/global/manifests.go (100%) rename pkg/{operator/clusterlink => clusterlink/clusterlink-operator}/install.go (60%) rename pkg/{operator/clusterlink => clusterlink/clusterlink-operator}/manager/manager.go (80%) rename pkg/{operator/clusterlink => clusterlink/clusterlink-operator}/manager/manifests.go (100%) rename pkg/{operator => clusterlink/clusterlink-operator}/operator_controller.go (93%) rename pkg/{operator/clusterlink => clusterlink/clusterlink-operator}/option/option.go (100%) rename pkg/{operator/clusterlink => clusterlink/clusterlink-operator}/proxy/manifests.go (100%) rename pkg/{operator/clusterlink => clusterlink/clusterlink-operator}/proxy/proxy.go (81%) rename pkg/{operator/clusterlink => clusterlink/clusterlink-operator}/utils/idempotency.go (100%) rename pkg/{operator/clusterlink => clusterlink/clusterlink-operator}/utils/template.go (100%) diff --git a/Makefile b/Makefile index df250f2eb..fbfaabce7 100644 --- a/Makefile +++ b/Makefile @@ -10,16 +10,16 @@ REGISTRY_SERVER_ADDRESS?="" KIND_IMAGE_TAG?="v1.25.3" MACOS_TARGETS := clusterlink-controller-manager \ - kosmos-operator \ + clusterlink-operator \ clusterlink-elector \ - clusterlink-network-manager \ - clusterlink-proxy \ - clustertree-cluster-manager \ - scheduler \ + clusterlink-network-manager \ + clusterlink-proxy \ + clustertree-cluster-manager \ + scheduler \ # clusterlink-agent and clusterlink-floater only support linux platform TARGETS := clusterlink-controller-manager \ - kosmos-operator \ + clusterlink-operator \ clusterlink-agent \ clusterlink-elector \ clusterlink-floater \ @@ -116,7 +116,7 @@ test: upload-images: images @echo "push images to $(REGISTRY)" docker push ${REGISTRY}/clusterlink-controller-manager:${VERSION} - docker push ${REGISTRY}/kosmos-operator:${VERSION} + docker push ${REGISTRY}/clusterlink-operator:${VERSION} docker push ${REGISTRY}/clusterlink-agent:${VERSION} docker push ${REGISTRY}/clusterlink-proxy:${VERSION} docker push ${REGISTRY}/clusterlink-network-manager:${VERSION} diff --git a/cmd/operator/app/operator.go b/cmd/clusterlink/clusterlink-operator/app/operator.go similarity index 87% rename from cmd/operator/app/operator.go rename to cmd/clusterlink/clusterlink-operator/app/operator.go index 782e47581..e00c5858c 100644 --- a/cmd/operator/app/operator.go +++ b/cmd/clusterlink/clusterlink-operator/app/operator.go @@ -16,21 +16,21 @@ import ( "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" - "github.com/kosmos.io/kosmos/cmd/operator/app/options" - "github.com/kosmos.io/kosmos/pkg/operator" + "github.com/kosmos.io/kosmos/cmd/clusterlink/clusterlink-operator/app/options" + clusterlinkoperator "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator" "github.com/kosmos.io/kosmos/pkg/scheme" "github.com/kosmos.io/kosmos/pkg/sharedcli" "github.com/kosmos.io/kosmos/pkg/sharedcli/klogflag" "github.com/kosmos.io/kosmos/pkg/utils" ) -// NewOperatorCommand creates a *cobra.Command object with default parameters -func NewOperatorCommand(ctx context.Context) *cobra.Command { +// NewLinkOperatorCommand creates a *cobra.Command object with default parameters +func NewLinkOperatorCommand(ctx context.Context) *cobra.Command { opts := options.NewOptions() cmd := &cobra.Command{ - Use: "kosmos-operator", - Long: `Deploy Kosmos components according to the cluster`, + Use: "kosmos-clusterlink-operator", + Long: `Deploy Kosmos cluster-link components according to the cluster`, RunE: func(cmd *cobra.Command, args []string) error { // validate options if errs := opts.Validate(); len(errs) != 0 { @@ -116,7 +116,7 @@ func Run(ctx context.Context, opts *options.Options) error { return err } - clusterNodeController := operator.Reconciler{ + clusterNodeController := clusterlinkoperator.Reconciler{ Scheme: mgr.GetScheme(), ControlPanelKubeConfig: controlPanelKubeConfig, ClusterName: os.Getenv(utils.EnvClusterName), diff --git a/cmd/operator/app/options/options.go b/cmd/clusterlink/clusterlink-operator/app/options/options.go similarity index 100% rename from cmd/operator/app/options/options.go rename to cmd/clusterlink/clusterlink-operator/app/options/options.go diff --git a/cmd/operator/app/options/validation.go b/cmd/clusterlink/clusterlink-operator/app/options/validation.go similarity index 100% rename from cmd/operator/app/options/validation.go rename to cmd/clusterlink/clusterlink-operator/app/options/validation.go diff --git a/cmd/operator/main.go b/cmd/clusterlink/clusterlink-operator/main.go similarity index 63% rename from cmd/operator/main.go rename to cmd/clusterlink/clusterlink-operator/main.go index 88f6d1761..040727e4e 100644 --- a/cmd/operator/main.go +++ b/cmd/clusterlink/clusterlink-operator/main.go @@ -6,12 +6,12 @@ import ( apiserver "k8s.io/apiserver/pkg/server" "k8s.io/component-base/cli" - "github.com/kosmos.io/kosmos/cmd/operator/app" + "github.com/kosmos.io/kosmos/cmd/clusterlink/clusterlink-operator/app" ) func main() { ctx := apiserver.SetupSignalContext() - cmd := app.NewOperatorCommand(ctx) + cmd := app.NewLinkOperatorCommand(ctx) code := cli.Run(cmd) os.Exit(code) } diff --git a/cmd/koslet/OWNERS b/cmd/koslet/OWNERS deleted file mode 100644 index cf0c1f609..000000000 --- a/cmd/koslet/OWNERS +++ /dev/null @@ -1,5 +0,0 @@ -approvers: - - duanmengkk -reviewers: - - duanmengkk - - yuleichun-striving diff --git a/cmd/koslet/app/server.go b/cmd/koslet/app/server.go deleted file mode 100644 index d5c17de62..000000000 --- a/cmd/koslet/app/server.go +++ /dev/null @@ -1,7 +0,0 @@ -package app - -import "github.com/spf13/cobra" - -func NewKosletCommand() *cobra.Command { - return nil -} diff --git a/cmd/koslet/main.go b/cmd/koslet/main.go deleted file mode 100644 index c8d421e7f..000000000 --- a/cmd/koslet/main.go +++ /dev/null @@ -1,15 +0,0 @@ -package main - -import ( - "os" - - "k8s.io/component-base/cli" - - "github.com/kosmos.io/kosmos/cmd/koslet/app" -) - -func main() { - command := app.NewKosletCommand() - code := cli.Run(command) - os.Exit(code) -} diff --git a/deploy/kosmos-operator.yml b/deploy/kosmos-operator.yml index 481a03f15..1d0c96a33 100644 --- a/deploy/kosmos-operator.yml +++ b/deploy/kosmos-operator.yml @@ -1,13 +1,13 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: kosmos-operator + name: clusterlink-operator namespace: kosmos-system --- apiVersion: apps/v1 kind: Deployment metadata: - name: kosmos-operator + name: clusterlink-operator namespace: kosmos-system labels: app: operator @@ -21,7 +21,7 @@ spec: labels: app: operator spec: - serviceAccountName: kosmos-operator + serviceAccountName: clusterlink-operator affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -36,11 +36,11 @@ spec: topologyKey: kubernetes.io/hostname containers: - name: operator - image: ghcr.io/kosmos-io/kosmos-operator:__VERSION__ + image: ghcr.io/kosmos-io/clusterlink-operator:__VERSION__ imagePullPolicy: IfNotPresent command: - - kosmos-operator - - --controlpanelconfig=/etc/kosmos-operator/kubeconfig + - clusterlink-operator + - --controlpanelconfig=/etc/clusterlink-operator/kubeconfig resources: limits: memory: 200Mi @@ -54,7 +54,7 @@ spec: - name: USE_PROXY value: "false" volumeMounts: - - mountPath: /etc/kosmos-operator + - mountPath: /etc/clusterlink-operator name: proxy-config readOnly: true volumes: diff --git a/deploy/kosmos-rbac.yml b/deploy/kosmos-rbac.yml index 844ffd034..6ff99e9e5 100644 --- a/deploy/kosmos-rbac.yml +++ b/deploy/kosmos-rbac.yml @@ -25,5 +25,5 @@ subjects: name: clusterlink-controller-manager namespace: kosmos-system - kind: ServiceAccount - name: kosmos-operator + name: clusterlink-operator namespace: kosmos-system diff --git a/docs/proposals/kosmosctl/offline_installation_zh.md b/docs/proposals/kosmosctl/offline_installation_zh.md index 37f79a062..e5c397e08 100644 --- a/docs/proposals/kosmosctl/offline_installation_zh.md +++ b/docs/proposals/kosmosctl/offline_installation_zh.md @@ -165,7 +165,7 @@ kosmosctl install --private-image-registry=registry.local.com --kosmos-vesion=0. ```txt ghcr.io/kosmos-io/clustertree-cluster-manager:v0.3,0 - ghcr.io/kosmos-io/kosmos-operator:v0.3.0 + ghcr.io/kosmos-io/clusterlink-operator:v0.3.0 ghcr.io/kosmos-io/clusterlink-agent:v0.3.0 ghcr.io/kosmos-io/clusterlink-network-manager:v0.3.0 ghcr.io/kosmos-io/clusterlink-controller-manager:v0.3.0 diff --git a/hack/cluster.sh b/hack/cluster.sh index 13fa5c112..e674de372 100755 --- a/hack/cluster.sh +++ b/hack/cluster.sh @@ -259,10 +259,10 @@ function deploy_cluster() { kubectl --context="kind-${clustername}" -n kosmos-system delete secret controlpanel-config || true kubectl --context="kind-${clustername}" -n kosmos-system create secret generic controlpanel-config --from-file=kubeconfig="${ROOT}/environments/cluster-host/kubeconfig" - sed -e "s|__VERSION__|$VERSION|g" -e "w ${ROOT}/environments/kosmos-operator.yml" "$ROOT"/deploy/kosmos-operator.yml - kubectl --context="kind-${clustername}" apply -f "${ROOT}/environments/kosmos-operator.yml" + sed -e "s|__VERSION__|$VERSION|g" -e "w ${ROOT}/environments/clusterlink-operator.yml" "$ROOT"/deploy/clusterlink-operator.yml + kubectl --context="kind-${clustername}" apply -f "${ROOT}/environments/clusterlink-operator.yml" - echo "cluster $clustername deploy kosmos-operator success" + echo "cluster $clustername deploy clusterlink-operator success" sed -e "s|__VERSION__|$VERSION|g" -e "w ${ROOT}/environments/kosmos-scheduler.yml" "$ROOT"/deploy/scheduler/deployment.yaml kubectl --context="kind-${clustername}" apply -f "${ROOT}/environments/kosmos-scheduler.yml" @@ -282,7 +282,7 @@ function load_cluster_images() { kind load docker-image -n "$clustername" ghcr.io/kosmos-io/clusterlink-network-manager:"${VERSION}" kind load docker-image -n "$clustername" ghcr.io/kosmos-io/clusterlink-controller-manager:"${VERSION}" kind load docker-image -n "$clustername" ghcr.io/kosmos-io/clusterlink-elector:"${VERSION}" - kind load docker-image -n "$clustername" ghcr.io/kosmos-io/kosmos-operator:"${VERSION}" + kind load docker-image -n "$clustername" ghcr.io/kosmos-io/clusterlink-operator:"${VERSION}" kind load docker-image -n "$clustername" ghcr.io/kosmos-io/clusterlink-agent:"${VERSION}" kind load docker-image -n "$clustername" ghcr.io/kosmos-io/clusterlink-proxy:"${VERSION}" kind load docker-image -n "$clustername" ghcr.io/kosmos-io/clustertree-cluster-manager:"${VERSION}" diff --git a/hack/util.sh b/hack/util.sh index 0166fa5a5..bca5811c1 100755 --- a/hack/util.sh +++ b/hack/util.sh @@ -15,7 +15,7 @@ MIN_Go_VERSION=go1.19.0 CLUSTERLINK_TARGET_SOURCE=( scheduler=cmd/scheduler clusterlink-proxy=cmd/clusterlink/proxy - kosmos-operator=cmd/operator + clusterlink-operator=cmd/clusterlink/clusterlink-operator clusterlink-elector=cmd/clusterlink/elector clusterlink-agent=cmd/clusterlink/agent clusterlink-floater=cmd/clusterlink/floater diff --git a/pkg/operator/clusterlink/agent/agent.go b/pkg/clusterlink/clusterlink-operator/agent/agent.go similarity index 81% rename from pkg/operator/clusterlink/agent/agent.go rename to pkg/clusterlink/clusterlink-operator/agent/agent.go index 226324f52..8199abfd6 100644 --- a/pkg/operator/clusterlink/agent/agent.go +++ b/pkg/clusterlink/clusterlink-operator/agent/agent.go @@ -15,9 +15,9 @@ import ( bootstrapapi "k8s.io/cluster-bootstrap/token/api" "k8s.io/klog/v2" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/option" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/utils" - utils2 "github.com/kosmos.io/kosmos/pkg/utils" + "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/option" + operatorutils "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/utils" + kosmosutils "github.com/kosmos.io/kosmos/pkg/utils" ) const ( @@ -33,11 +33,11 @@ func New() *AgentInstaller { // create daemonset func applyDaemonSet(opt *option.AddonOption) error { - clusterlinkAgentDaemonSetBytes, err := utils.ParseTemplate(clusterlinkAgentDaemonSet, DaemonSetReplace{ + clusterlinkAgentDaemonSetBytes, err := operatorutils.ParseTemplate(clusterlinkAgentDaemonSet, DaemonSetReplace{ Namespace: opt.GetSpecNamespace(), Name: ResourceName, ImageRepository: opt.GetImageRepository(), - ProxyConfigMapName: utils2.ProxySecretName, + ProxyConfigMapName: kosmosutils.ProxySecretName, Version: opt.Version, ClusterName: opt.GetName(), }) @@ -56,7 +56,7 @@ func applyDaemonSet(opt *option.AddonOption) error { return fmt.Errorf("decode agent daemonset error: %v", err) } - if err := utils.CreateOrUpdateDaemonSet(opt.KubeClientSet, clAgentDaemonSet); err != nil { + if err := operatorutils.CreateOrUpdateDaemonSet(opt.KubeClientSet, clAgentDaemonSet); err != nil { return fmt.Errorf("create clusterlink agent daemonset error: %v", err) } @@ -91,9 +91,9 @@ func applySecret(opt *option.AddonOption) error { // Create or update the Secret in the kube-public namespace klog.Infof("[bootstrap-token] creating/updating Secret in kube-public namespace") - return utils.CreateOrUpdateSecret(opt.KubeClientSet, &corev1.Secret{ + return operatorutils.CreateOrUpdateSecret(opt.KubeClientSet, &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ - Name: utils2.ProxySecretName, + Name: kosmosutils.ProxySecretName, Namespace: opt.GetSpecNamespace(), }, StringData: map[string]string{ @@ -123,7 +123,7 @@ func (i *AgentInstaller) Uninstall(opt *option.AddonOption) error { } configMapClient := opt.KubeClientSet.CoreV1().ConfigMaps(opt.GetSpecNamespace()) - if err := configMapClient.Delete(context.TODO(), utils2.ProxySecretName, metav1.DeleteOptions{}); err != nil && !apierrors.IsNotFound(err) { + if err := configMapClient.Delete(context.TODO(), kosmosutils.ProxySecretName, metav1.DeleteOptions{}); err != nil && !apierrors.IsNotFound(err) { return err } diff --git a/pkg/operator/clusterlink/agent/manifests.go b/pkg/clusterlink/clusterlink-operator/agent/manifests.go similarity index 100% rename from pkg/operator/clusterlink/agent/manifests.go rename to pkg/clusterlink/clusterlink-operator/agent/manifests.go diff --git a/pkg/operator/clusterlink/elector/elector.go b/pkg/clusterlink/clusterlink-operator/elector/elector.go similarity index 81% rename from pkg/operator/clusterlink/elector/elector.go rename to pkg/clusterlink/clusterlink-operator/elector/elector.go index d62650337..d22365896 100644 --- a/pkg/operator/clusterlink/elector/elector.go +++ b/pkg/clusterlink/clusterlink-operator/elector/elector.go @@ -13,9 +13,9 @@ import ( clientsetscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/klog/v2" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/option" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/utils" - utils2 "github.com/kosmos.io/kosmos/pkg/utils" + "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/option" + operatorutils "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/utils" + kosmosutils "github.com/kosmos.io/kosmos/pkg/utils" ) const ( @@ -30,7 +30,7 @@ func New() *ElectorInstaller { } func applyServiceAccount(opt *option.AddonOption) error { - clElectorServiceAccountBytes, err := utils.ParseTemplate(clusterlinkElectorServiceAccount, ServiceAccountReplace{ + clElectorServiceAccountBytes, err := operatorutils.ParseTemplate(clusterlinkElectorServiceAccount, ServiceAccountReplace{ Namespace: opt.GetSpecNamespace(), Name: ResourceName, }) @@ -48,7 +48,7 @@ func applyServiceAccount(opt *option.AddonOption) error { return fmt.Errorf("decode elector serviceaccount error: %v", err) } - if err := utils.CreateOrUpdateServiceAccount(opt.KubeClientSet, clElectorServiceAccount); err != nil { + if err := operatorutils.CreateOrUpdateServiceAccount(opt.KubeClientSet, clElectorServiceAccount); err != nil { return fmt.Errorf("create clusterlink agent serviceaccount error: %v", err) } @@ -58,12 +58,12 @@ func applyServiceAccount(opt *option.AddonOption) error { } func applyDeployment(opt *option.AddonOption) error { - clElectorDeploymentBytes, err := utils.ParseTemplate(clusterlinkElectorDeployment, DeploymentReplace{ + clElectorDeploymentBytes, err := operatorutils.ParseTemplate(clusterlinkElectorDeployment, DeploymentReplace{ Namespace: opt.GetSpecNamespace(), Name: ResourceName, ClusterName: opt.GetName(), ImageRepository: opt.GetImageRepository(), - ProxyConfigMapName: utils2.ProxySecretName, + ProxyConfigMapName: kosmosutils.ProxySecretName, Version: opt.Version, }) @@ -81,7 +81,7 @@ func applyDeployment(opt *option.AddonOption) error { return fmt.Errorf("decode elector deployment error: %v", err) } - if err := utils.CreateOrUpdateDeployment(opt.KubeClientSet, clElectorDeployment); err != nil { + if err := operatorutils.CreateOrUpdateDeployment(opt.KubeClientSet, clElectorDeployment); err != nil { return fmt.Errorf("create clusterlink elector deployment error: %v", err) } @@ -91,7 +91,7 @@ func applyDeployment(opt *option.AddonOption) error { } func applyClusterRole(opt *option.AddonOption) error { - clElectorClusterRoleBytes, err := utils.ParseTemplate(clusterlinkElectorClusterRole, ClusterRoleReplace{ + clElectorClusterRoleBytes, err := operatorutils.ParseTemplate(clusterlinkElectorClusterRole, ClusterRoleReplace{ Name: ResourceName, }) @@ -109,7 +109,7 @@ func applyClusterRole(opt *option.AddonOption) error { return fmt.Errorf("decode elector clusterrole error: %v", err) } - if err := utils.CreateOrUpdateClusterRole(opt.KubeClientSet, clElectorClusterRole); err != nil { + if err := operatorutils.CreateOrUpdateClusterRole(opt.KubeClientSet, clElectorClusterRole); err != nil { return fmt.Errorf("create clusterlink elector clusterrole error: %v", err) } @@ -119,7 +119,7 @@ func applyClusterRole(opt *option.AddonOption) error { } func applyClusterRoleBinding(opt *option.AddonOption) error { - clElectorClusterRoleBindingBytes, err := utils.ParseTemplate(clusterlinkElectorClusterRoleBinding, ClusterRoleBindingReplace{ + clElectorClusterRoleBindingBytes, err := operatorutils.ParseTemplate(clusterlinkElectorClusterRoleBinding, ClusterRoleBindingReplace{ Name: ResourceName, Namespace: opt.GetSpecNamespace(), }) @@ -138,7 +138,7 @@ func applyClusterRoleBinding(opt *option.AddonOption) error { return fmt.Errorf("decode elector clusterrolebinding error: %v", err) } - if err := utils.CreateOrUpdateClusterRoleBinding(opt.KubeClientSet, clElectorClusterRoleBinding); err != nil { + if err := operatorutils.CreateOrUpdateClusterRoleBinding(opt.KubeClientSet, clElectorClusterRoleBinding); err != nil { return fmt.Errorf("create clusterlink elector clusterrolebinding error: %v", err) } diff --git a/pkg/operator/clusterlink/elector/manifests.go b/pkg/clusterlink/clusterlink-operator/elector/manifests.go similarity index 100% rename from pkg/operator/clusterlink/elector/manifests.go rename to pkg/clusterlink/clusterlink-operator/elector/manifests.go diff --git a/pkg/operator/clusterlink/global/global.go b/pkg/clusterlink/clusterlink-operator/global/global.go similarity index 80% rename from pkg/operator/clusterlink/global/global.go rename to pkg/clusterlink/clusterlink-operator/global/global.go index a4137cb0b..de2691684 100644 --- a/pkg/operator/clusterlink/global/global.go +++ b/pkg/clusterlink/clusterlink-operator/global/global.go @@ -8,8 +8,8 @@ import ( clientsetscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/klog/v2" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/option" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/utils" + "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/option" + operatorutils "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/utils" ) type Installer struct { @@ -20,7 +20,7 @@ func New() *Installer { } func (i *Installer) Install(opt *option.AddonOption) error { - clNamespaceBytes, err := utils.ParseTemplate(clusterlinkNamespace, NamespaceReplace{ + clNamespaceBytes, err := operatorutils.ParseTemplate(clusterlinkNamespace, NamespaceReplace{ Namespace: opt.GetSpecNamespace(), }) @@ -38,7 +38,7 @@ func (i *Installer) Install(opt *option.AddonOption) error { return fmt.Errorf("decode namespace error: %v", err) } - if err := utils.CreateOrUpdateNamespace(opt.KubeClientSet, clNamespace); err != nil { + if err := operatorutils.CreateOrUpdateNamespace(opt.KubeClientSet, clNamespace); err != nil { return fmt.Errorf("create clusterlink namespace error: %v", err) } diff --git a/pkg/operator/clusterlink/global/manifests.go b/pkg/clusterlink/clusterlink-operator/global/manifests.go similarity index 100% rename from pkg/operator/clusterlink/global/manifests.go rename to pkg/clusterlink/clusterlink-operator/global/manifests.go diff --git a/pkg/operator/clusterlink/install.go b/pkg/clusterlink/clusterlink-operator/install.go similarity index 60% rename from pkg/operator/clusterlink/install.go rename to pkg/clusterlink/clusterlink-operator/install.go index 315df7d41..e5003b334 100644 --- a/pkg/operator/clusterlink/install.go +++ b/pkg/clusterlink/clusterlink-operator/install.go @@ -1,14 +1,14 @@ -package clusterlink +package clusterlink_operator import ( "k8s.io/klog/v2" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/agent" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/elector" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/global" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/manager" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/option" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/proxy" + "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/agent" + "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/elector" + "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/global" + "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/manager" + "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/option" + "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/proxy" ) type AddonInstaller interface { diff --git a/pkg/operator/clusterlink/manager/manager.go b/pkg/clusterlink/clusterlink-operator/manager/manager.go similarity index 80% rename from pkg/operator/clusterlink/manager/manager.go rename to pkg/clusterlink/clusterlink-operator/manager/manager.go index cf54dae52..bd701b250 100644 --- a/pkg/operator/clusterlink/manager/manager.go +++ b/pkg/clusterlink/clusterlink-operator/manager/manager.go @@ -13,9 +13,9 @@ import ( clientsetscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/klog/v2" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/option" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/utils" - utils2 "github.com/kosmos.io/kosmos/pkg/utils" + "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/option" + operatorutils "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/utils" + kosmosutils "github.com/kosmos.io/kosmos/pkg/utils" ) type ManagerInstaller struct { @@ -30,7 +30,7 @@ const ( ) func applyServiceAccount(opt *option.AddonOption) error { - clCtrManagerServiceAccountBytes, err := utils.ParseTemplate(clusterlinkManagerServiceAccount, ServiceAccountReplace{ + clCtrManagerServiceAccountBytes, err := operatorutils.ParseTemplate(clusterlinkManagerServiceAccount, ServiceAccountReplace{ Namespace: opt.GetSpecNamespace(), Name: ResourceName, }) @@ -44,7 +44,7 @@ func applyServiceAccount(opt *option.AddonOption) error { return fmt.Errorf("decode controller-manager serviceaccount error: %v", err) } - if err := utils.CreateOrUpdateServiceAccount(opt.KubeClientSet, clCtrManagerServiceAccount); err != nil { + if err := operatorutils.CreateOrUpdateServiceAccount(opt.KubeClientSet, clCtrManagerServiceAccount); err != nil { return fmt.Errorf("create clusterlink agent serviceaccount error: %v", err) } @@ -54,10 +54,10 @@ func applyServiceAccount(opt *option.AddonOption) error { } func applyDeployment(opt *option.AddonOption) error { - clCtrManagerDeploymentBytes, err := utils.ParseTemplate(clusterlinkManagerDeployment, DeploymentReplace{ + clCtrManagerDeploymentBytes, err := operatorutils.ParseTemplate(clusterlinkManagerDeployment, DeploymentReplace{ Namespace: opt.GetSpecNamespace(), Name: ResourceName, - ProxyConfigMapName: utils2.ProxySecretName, + ProxyConfigMapName: kosmosutils.ProxySecretName, ClusterName: opt.GetName(), ImageRepository: opt.GetImageRepository(), Version: opt.Version, @@ -77,7 +77,7 @@ func applyDeployment(opt *option.AddonOption) error { return fmt.Errorf("decode controller-manager deployment error: %v", err) } - if err := utils.CreateOrUpdateDeployment(opt.KubeClientSet, clCtrManagerDeployment); err != nil { + if err := operatorutils.CreateOrUpdateDeployment(opt.KubeClientSet, clCtrManagerDeployment); err != nil { return fmt.Errorf("create clusterlink controller-manager deployment error: %v", err) } @@ -87,7 +87,7 @@ func applyDeployment(opt *option.AddonOption) error { } func applyClusterRole(opt *option.AddonOption) error { - clCtrManagerClusterRoleBytes, err := utils.ParseTemplate(clusterlinkManagerClusterRole, ClusterRoleReplace{ + clCtrManagerClusterRoleBytes, err := operatorutils.ParseTemplate(clusterlinkManagerClusterRole, ClusterRoleReplace{ Name: ResourceName, }) @@ -105,7 +105,7 @@ func applyClusterRole(opt *option.AddonOption) error { return fmt.Errorf("decode controller-manager clusterrole error: %v", err) } - if err := utils.CreateOrUpdateClusterRole(opt.KubeClientSet, clCtrManagerClusterRole); err != nil { + if err := operatorutils.CreateOrUpdateClusterRole(opt.KubeClientSet, clCtrManagerClusterRole); err != nil { return fmt.Errorf("create clusterlink controller-manager clusterrole error: %v", err) } @@ -115,7 +115,7 @@ func applyClusterRole(opt *option.AddonOption) error { } func applyClusterRoleBinding(opt *option.AddonOption) error { - clCtrManagerClusterRoleBindingBytes, err := utils.ParseTemplate(clusterlinkManagerClusterRoleBinding, ClusterRoleBindingReplace{ + clCtrManagerClusterRoleBindingBytes, err := operatorutils.ParseTemplate(clusterlinkManagerClusterRoleBinding, ClusterRoleBindingReplace{ Name: ResourceName, Namespace: opt.GetSpecNamespace(), }) @@ -134,7 +134,7 @@ func applyClusterRoleBinding(opt *option.AddonOption) error { return fmt.Errorf("decode controller-manager clusterrolebinding error: %v", err) } - if err := utils.CreateOrUpdateClusterRoleBinding(opt.KubeClientSet, clCtrManagerClusterRoleBinding); err != nil { + if err := operatorutils.CreateOrUpdateClusterRoleBinding(opt.KubeClientSet, clCtrManagerClusterRoleBinding); err != nil { return fmt.Errorf("create clusterlink controller-manager clusterrolebinding error: %v", err) } diff --git a/pkg/operator/clusterlink/manager/manifests.go b/pkg/clusterlink/clusterlink-operator/manager/manifests.go similarity index 100% rename from pkg/operator/clusterlink/manager/manifests.go rename to pkg/clusterlink/clusterlink-operator/manager/manifests.go diff --git a/pkg/operator/operator_controller.go b/pkg/clusterlink/clusterlink-operator/operator_controller.go similarity index 93% rename from pkg/operator/operator_controller.go rename to pkg/clusterlink/clusterlink-operator/operator_controller.go index 7d6364378..43d05fa40 100644 --- a/pkg/operator/operator_controller.go +++ b/pkg/clusterlink/clusterlink-operator/operator_controller.go @@ -1,4 +1,4 @@ -package operator +package clusterlink_operator import ( "context" @@ -16,11 +16,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" - cmdOptions "github.com/kosmos.io/kosmos/cmd/operator/app/options" + cmdOptions "github.com/kosmos.io/kosmos/cmd/clusterlink/clusterlink-operator/app/options" "github.com/kosmos.io/kosmos/pkg/apis/kosmos/v1alpha1" + "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/option" lister "github.com/kosmos.io/kosmos/pkg/generated/listers/kosmos/v1alpha1" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/option" "github.com/kosmos.io/kosmos/pkg/utils" ) @@ -74,7 +73,7 @@ func (r *Reconciler) syncCluster(cluster *v1alpha1.Cluster) (reconcile.Result, e return reconcile.Result{Requeue: true}, err } - if err := clusterlink.Install(opt); err != nil { + if err := Install(opt); err != nil { klog.Error(err) return reconcile.Result{Requeue: true}, err } @@ -92,7 +91,7 @@ func (r *Reconciler) removeCluster(cluster *v1alpha1.Cluster) (reconcile.Result, klog.Error(err) return reconcile.Result{Requeue: true}, err } - if err := clusterlink.Uninstall(opt); err != nil { + if err := Uninstall(opt); err != nil { klog.Error(err) return reconcile.Result{Requeue: true}, err } diff --git a/pkg/operator/clusterlink/option/option.go b/pkg/clusterlink/clusterlink-operator/option/option.go similarity index 100% rename from pkg/operator/clusterlink/option/option.go rename to pkg/clusterlink/clusterlink-operator/option/option.go diff --git a/pkg/operator/clusterlink/proxy/manifests.go b/pkg/clusterlink/clusterlink-operator/proxy/manifests.go similarity index 100% rename from pkg/operator/clusterlink/proxy/manifests.go rename to pkg/clusterlink/clusterlink-operator/proxy/manifests.go diff --git a/pkg/operator/clusterlink/proxy/proxy.go b/pkg/clusterlink/clusterlink-operator/proxy/proxy.go similarity index 81% rename from pkg/operator/clusterlink/proxy/proxy.go rename to pkg/clusterlink/clusterlink-operator/proxy/proxy.go index b4acfa946..4d7af4b8b 100644 --- a/pkg/operator/clusterlink/proxy/proxy.go +++ b/pkg/clusterlink/clusterlink-operator/proxy/proxy.go @@ -14,9 +14,9 @@ import ( "k8s.io/client-go/tools/clientcmd" "k8s.io/klog/v2" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/option" - "github.com/kosmos.io/kosmos/pkg/operator/clusterlink/utils" - utils2 "github.com/kosmos.io/kosmos/pkg/utils" + "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/option" + operatorutils "github.com/kosmos.io/kosmos/pkg/clusterlink/clusterlink-operator/utils" + kosmosutils "github.com/kosmos.io/kosmos/pkg/utils" ) type ProxyInstaller struct { @@ -48,7 +48,7 @@ func applySecret(opt *option.AddonOption) error { } secret := &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ - Name: utils2.ProxySecretName, + Name: kosmosutils.ProxySecretName, Namespace: opt.GetSpecNamespace(), }, Data: map[string][]byte{ @@ -56,7 +56,7 @@ func applySecret(opt *option.AddonOption) error { }, } - if err := utils.CreateOrUpdateSecret(opt.KubeClientSet, secret); err != nil { + if err := operatorutils.CreateOrUpdateSecret(opt.KubeClientSet, secret); err != nil { return fmt.Errorf("create clusterlink agent secret error: %v", err) } @@ -64,7 +64,7 @@ func applySecret(opt *option.AddonOption) error { } func applyService(opt *option.AddonOption) error { - proxyServiceBytes, err := utils.ParseTemplate(clusterlinkProxyService, ServiceReplace{ + proxyServiceBytes, err := operatorutils.ParseTemplate(clusterlinkProxyService, ServiceReplace{ Namespace: opt.GetSpecNamespace(), Name: ResourceName, }) @@ -78,7 +78,7 @@ func applyService(opt *option.AddonOption) error { return fmt.Errorf("decode controller-proxy service error: %v", err) } - if err := utils.CreateOrUpdateService(opt.KubeClientSet, proxyService); err != nil { + if err := operatorutils.CreateOrUpdateService(opt.KubeClientSet, proxyService); err != nil { return fmt.Errorf("create clusterlink-proxy service error: %v", err) } @@ -88,10 +88,10 @@ func applyService(opt *option.AddonOption) error { } func applyDeployment(opt *option.AddonOption) error { - proxyDeploymentBytes, err := utils.ParseTemplate(clusterlinkProxyDeployment, DeploymentReplace{ + proxyDeploymentBytes, err := operatorutils.ParseTemplate(clusterlinkProxyDeployment, DeploymentReplace{ Namespace: opt.GetSpecNamespace(), Name: ResourceName, - ControlPanelSecretName: utils2.ControlPanelSecretName, + ControlPanelSecretName: kosmosutils.ControlPanelSecretName, ImageRepository: opt.GetImageRepository(), Version: opt.Version, }) @@ -106,7 +106,7 @@ func applyDeployment(opt *option.AddonOption) error { return fmt.Errorf("decode clusterlink-proxy deployment error: %v", err) } - if err := utils.CreateOrUpdateDeployment(opt.KubeClientSet, proxyDeployment); err != nil { + if err := operatorutils.CreateOrUpdateDeployment(opt.KubeClientSet, proxyDeployment); err != nil { return fmt.Errorf("create controller-proxy deployment error: %v", err) } diff --git a/pkg/operator/clusterlink/utils/idempotency.go b/pkg/clusterlink/clusterlink-operator/utils/idempotency.go similarity index 100% rename from pkg/operator/clusterlink/utils/idempotency.go rename to pkg/clusterlink/clusterlink-operator/utils/idempotency.go diff --git a/pkg/operator/clusterlink/utils/template.go b/pkg/clusterlink/clusterlink-operator/utils/template.go similarity index 100% rename from pkg/operator/clusterlink/utils/template.go rename to pkg/clusterlink/clusterlink-operator/utils/template.go diff --git a/pkg/kosmosctl/install/install.go b/pkg/kosmosctl/install/install.go index 47d46a12d..fae738b5a 100644 --- a/pkg/kosmosctl/install/install.go +++ b/pkg/kosmosctl/install/install.go @@ -482,7 +482,7 @@ func (o *CommandInstallOptions) runClustertree() error { } func (o *CommandInstallOptions) createOperator() error { - klog.Info("Start creating Kosmos-Operator...") + klog.Info("Start creating ClusterLink-Operator...") operatorDeploy, err := util.GenerateDeployment(manifest.KosmosOperatorDeployment, manifest.DeploymentReplace{ Namespace: o.Namespace, Version: o.Version, diff --git a/pkg/kosmosctl/manifest/manifest_clusterrolebindings.go b/pkg/kosmosctl/manifest/manifest_clusterrolebindings.go index 1c000f674..40086c3a8 100644 --- a/pkg/kosmosctl/manifest/manifest_clusterrolebindings.go +++ b/pkg/kosmosctl/manifest/manifest_clusterrolebindings.go @@ -48,7 +48,7 @@ subjects: name: clusterlink-controller-manager namespace: {{ .Namespace }} - kind: ServiceAccount - name: kosmos-operator + name: clusterlink-operator namespace: {{ .Namespace }} ` diff --git a/pkg/kosmosctl/manifest/manifest_deployments.go b/pkg/kosmosctl/manifest/manifest_deployments.go index 864e6e1cf..3df1c76d9 100644 --- a/pkg/kosmosctl/manifest/manifest_deployments.go +++ b/pkg/kosmosctl/manifest/manifest_deployments.go @@ -40,7 +40,7 @@ spec: apiVersion: apps/v1 kind: Deployment metadata: - name: kosmos-operator + name: clusterlink-operator namespace: {{ .Namespace }} labels: app: operator @@ -54,7 +54,7 @@ spec: labels: app: operator spec: - serviceAccountName: kosmos-operator + serviceAccountName: clusterlink-operator affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: @@ -69,11 +69,11 @@ spec: topologyKey: kubernetes.io/hostname containers: - name: operator - image: {{ .ImageRepository }}/kosmos-operator:{{ .Version }} + image: {{ .ImageRepository }}/clusterlink-operator:{{ .Version }} imagePullPolicy: IfNotPresent command: - - kosmos-operator - - --controlpanelconfig=/etc/kosmos-operator/kubeconfig + - clusterlink-operator + - --controlpanelconfig=/etc/clusterlink-operator/kubeconfig resources: limits: memory: 200Mi @@ -87,7 +87,7 @@ spec: - name: USE_PROXY value: "{{ .UseProxy }}" volumeMounts: - - mountPath: /etc/kosmos-operator + - mountPath: /etc/clusterlink-operator name: proxy-config readOnly: true volumes: diff --git a/pkg/kosmosctl/manifest/manifest_serviceaccounts.go b/pkg/kosmosctl/manifest/manifest_serviceaccounts.go index a23318507..c47bee5d9 100644 --- a/pkg/kosmosctl/manifest/manifest_serviceaccounts.go +++ b/pkg/kosmosctl/manifest/manifest_serviceaccounts.go @@ -13,7 +13,7 @@ metadata: apiVersion: v1 kind: ServiceAccount metadata: - name: kosmos-operator + name: clusterlink-operator namespace: {{ .Namespace }} ` diff --git a/pkg/kosmosctl/uninstall/uninstall.go b/pkg/kosmosctl/uninstall/uninstall.go index a64c9089d..543fd90f0 100644 --- a/pkg/kosmosctl/uninstall/uninstall.go +++ b/pkg/kosmosctl/uninstall/uninstall.go @@ -296,7 +296,7 @@ func (o *CommandUninstallOptions) runClusterlink() error { } } } else { - klog.Info("Kosmos-Clustertree is still running, skip uninstall Kosmos-Operator.") + klog.Info("Kosmos-Clustertree is still running, skip uninstall Clusterlink-Operator.") } klog.Info("Clusterlink uninstalled.") @@ -428,7 +428,7 @@ func (o *CommandUninstallOptions) runClustertree() error { } } } else { - klog.Info("Kosmos-Clusterlink is still running, skip uninstall Kosmos-Operator.") + klog.Info("Kosmos-Clusterlink is still running, skip uninstall Clusterlink-Operator.") } klog.Info("Clustertree uninstalled.") diff --git a/pkg/utils/constants.go b/pkg/utils/constants.go index 2ff95ea82..26a3bc5ca 100644 --- a/pkg/utils/constants.go +++ b/pkg/utils/constants.go @@ -23,7 +23,7 @@ var ( const ( ClusterTreeClusterManager = "ghcr.io/kosmos-io/clustertree-cluster-manager" - ClusterLinkOperator = "ghcr.io/kosmos-io/kosmos-operator" + ClusterLinkOperator = "ghcr.io/kosmos-io/clusterlink-operator" ClusterLinkAgent = "ghcr.io/kosmos-io/clusterlink-agent" ClusterLinkNetworkManager = "ghcr.io/kosmos-io/clusterlink-network-manager" ClusterLinkControllerManager = "ghcr.io/kosmos-io/clusterlink-controller-manager"