Skip to content

Commit

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

* Update guest.go

(cherry picked from commit 9488cdc)
Signed-off-by: cuisongliu <[email protected]>

Co-authored-by: fengxsong <[email protected]>
  • Loading branch information
cuisongliu and fengxsong authored Aug 31, 2023
1 parent d27f4fb commit 6cd5d78
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"
"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.NewData(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), runtime.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 6cd5d78

Please sign in to comment.