Skip to content

Commit

Permalink
fix: remove copying kubeconfig file (labring#3809)
Browse files Browse the repository at this point in the history
* fix: remove copying kubeconfig file

* Update guest.go
  • Loading branch information
fengxsong committed Aug 31, 2023
1 parent d129911 commit 9488cdc
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions pkg/guest/guest.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,15 @@ package guest
import (
"context"
"fmt"
"path/filepath"
"strings"

"golang.org/x/sync/errgroup"

"github.com/labring/sealos/fork/golang/expansion"
"github.com/labring/sealos/pkg/constants"
"github.com/labring/sealos/pkg/env"
"github.com/labring/sealos/pkg/runtime/types"
"github.com/labring/sealos/pkg/ssh"
v2 "github.com/labring/sealos/pkg/types/v1beta1"
fileutil "github.com/labring/sealos/pkg/utils/file"
"github.com/labring/sealos/pkg/utils/maps"
stringsutil "github.com/labring/sealos/pkg/utils/strings"
)
Expand All @@ -45,23 +42,6 @@ func NewGuestManager() (Interface, error) {
}

func (d *Default) Apply(cluster *v2.Cluster, mounts []v2.MountImage, targetHosts []string) error {
kubeConfig := filepath.Join(constants.GetHomeDir(), ".kube", "config")
if !fileutil.IsExist(kubeConfig) {
adminFile := constants.NewPathResolver(cluster.Name).AdminFile()
data, err := fileutil.ReadAll(adminFile)
if err != nil {
return fmt.Errorf("read admin.conf error in guest: %w", err)
}
master0IP := cluster.GetMaster0IP()
outData := strings.ReplaceAll(string(data), types.DefaultAPIServerDomain, master0IP)
if err = fileutil.WriteFile(kubeConfig, []byte(outData)); err != nil {
return err
}
defer func() {
_ = fileutil.CleanFiles(kubeConfig)
}()
}

envWrapper := env.NewEnvProcessor(cluster)
execer := ssh.NewSSHByCluster(cluster, true)

Expand Down

0 comments on commit 9488cdc

Please sign in to comment.