Skip to content

Commit

Permalink
Revert "feat(installer): support upgrade through installer (tkestack#939
Browse files Browse the repository at this point in the history
)"

This reverts commit 2e1e884.
  • Loading branch information
Pavle Lee committed Dec 16, 2020
1 parent 067e286 commit f5a8771
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 371 deletions.
2 changes: 1 addition & 1 deletion build/docker/tools/tke-installer/init_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tailNum=$((tailNum +1))
tail -n +${tailNum} "${me}" >package.tgz || die
tar -zxf package.tgz || die

./install.sh $@ || die
./install.sh || die
cd "${cwd}" || die
exit 0

Expand Down
2 changes: 1 addition & 1 deletion build/docker/tools/tke-installer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function clean_old_data() {
function start_installer() {
echo "Step.5 start tke-installer [doing]"

docker run $OPTIONS "tkestack/tke-installer-${ARCH}:$VERSION" $@
docker run $OPTIONS "tkestack/tke-installer-${ARCH}:$VERSION"

echo "Step.5 start tke-installer [ok]"
}
Expand Down
12 changes: 0 additions & 12 deletions cmd/tke-installer/app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ type Config struct {
Force bool
SyncProjectsWithNamespaces bool
Replicas int
Upgrade bool
Kubeconfig string
RegistryUsername string
RegistryPassword string
RegistryDomain string
RegistryNamespace string
}

// CreateConfigFromOptions creates a running configuration instance based
Expand All @@ -54,11 +48,5 @@ func CreateConfigFromOptions(serverName string, opts *options.Options) (*Config,
Force: *opts.Force,
SyncProjectsWithNamespaces: *opts.SyncProjectsWithNamespaces,
Replicas: *opts.Replicas,
Upgrade: *opts.Upgrade,
Kubeconfig: *opts.Kubeconfig,
RegistryUsername: *opts.RegistryUsername,
RegistryPassword: *opts.RegistryPassword,
RegistryDomain: *opts.RegistryDomain,
RegistryNamespace: *opts.RegistryNamespace,
}, nil
}
55 changes: 15 additions & 40 deletions cmd/tke-installer/app/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,14 @@ func New(config *config.Config) *TKE {
c.docker.Stderr = c.log

if !config.Force {
err = c.loadTKEData()
data, err := ioutil.ReadFile(constants.ClusterFile)
if err == nil {
log.Infof("read %q success", constants.ClusterFile)
err = json.Unmarshal(data, c)
if err != nil {
log.Warnf("load tke data error:%s", err)
}
log.Infof("load tke data success")
c.isFromRestore = true
c.progress.Status = types.StatusDoing
}
Expand All @@ -151,20 +157,6 @@ func New(config *config.Config) *TKE {
return c
}

func (t *TKE) loadTKEData() error {
data, err := ioutil.ReadFile(constants.ClusterFile)
if err == nil {
t.log.Infof("read %q success", constants.ClusterFile)
err = json.Unmarshal(data, t)
if err != nil {
t.log.Infof("load tke data error:%s", err)
} else {
log.Infof("load tke data success")
}
}
return err
}

func (t *TKE) initSteps() {
t.steps = append(t.steps, []types.Handler{
{
Expand Down Expand Up @@ -216,8 +208,8 @@ func (t *TKE) initSteps() {
Func: t.createGlobalCluster,
},
{
Name: "Patch platform versions in cluster info",
Func: t.patchPlatformVersion,
Name: "Patch k8s version in cluster info",
Func: t.patchK8sValidVersions,
},
{
Name: "Write kubeconfig",
Expand Down Expand Up @@ -472,15 +464,6 @@ func (t *TKE) runWithUI() error {

restful.Filter(globalLogging)

if t.Config.Upgrade {
err := t.prepareForUpgrade(context.Background())
if err != nil {
return err
}
t.do()
return nil
}

if t.isFromRestore {
go t.do()
}
Expand Down Expand Up @@ -970,22 +953,15 @@ func (t *TKE) do() {
start := time.Now()
ctx := t.log.WithContext(context.Background())

var taskType string
if t.Config.Upgrade {
taskType = "upgrade"
t.upgradeSteps()
} else {
taskType = "install"
containerregistry.Init(t.Para.Config.Registry.Domain(), t.Para.Config.Registry.Namespace())
t.initSteps()
}
containerregistry.Init(t.Para.Config.Registry.Domain(), t.Para.Config.Registry.Namespace())
t.initSteps()

if t.Step == 0 {
t.log.Infof("===>starting %s task", taskType)
t.log.Info("===>starting install task")
t.progress.Status = types.StatusDoing
}

if !t.Config.Upgrade && t.runAfterClusterReady() {
if t.runAfterClusterReady() {
t.initDataForDeployTKE()
}

Expand Down Expand Up @@ -1044,7 +1020,7 @@ func (t *TKE) do() {
}
t.progress.Servers = append(t.progress.Servers, t.servers...)

t.log.Infof("===>%s task [Sucesss] [%fs]", taskType, time.Since(start).Seconds())
t.log.Infof("===>install task [Sucesss] [%fs]", time.Since(start).Seconds())
}

func (t *TKE) runAfterClusterReady() bool {
Expand Down Expand Up @@ -2449,15 +2425,14 @@ func (t *TKE) writeKubeconfig(ctx context.Context) error {
return ioutil.WriteFile("/root/.kube/config", data, 0644)
}

func (t *TKE) patchPlatformVersion(ctx context.Context) error {
func (t *TKE) patchK8sValidVersions(ctx context.Context) error {
versionsByte, err := json.Marshal(spec.K8sValidVersions)
if err != nil {
return err
}
patchData := map[string]interface{}{
"data": map[string]interface{}{
"k8sValidVersions": string(versionsByte),
"tkeVersion": spec.TKEVersion,
},
}
patchByte, err := json.Marshal(patchData)
Expand Down
20 changes: 0 additions & 20 deletions cmd/tke-installer/app/installer/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ type OIDCAuth struct {
type Registry struct {
TKERegistry *TKERegistry `json:"tke,omitempty"`
ThirdPartyRegistry *ThirdPartyRegistry `json:"thirdParty,omitempty"`
UserInputRegistry UserInputRegistry `json:"userInputRegistry,omitempty"`
}

type Audit struct {
Expand All @@ -88,39 +87,27 @@ type ElasticSearch struct {
}

func (r *Registry) Domain() string {
if r.UserInputRegistry.Domain != "" {
return r.UserInputRegistry.Domain
}
if r.ThirdPartyRegistry != nil { // first use third party when both set
return r.ThirdPartyRegistry.Domain
}
return r.TKERegistry.Domain
}

func (r *Registry) Namespace() string {
if r.UserInputRegistry.Namespace != "" {
return r.UserInputRegistry.Namespace
}
if r.ThirdPartyRegistry != nil {
return r.ThirdPartyRegistry.Namespace
}
return r.TKERegistry.Namespace
}

func (r *Registry) Username() string {
if r.UserInputRegistry.Username != "" {
return r.UserInputRegistry.Username
}
if r.ThirdPartyRegistry != nil {
return r.ThirdPartyRegistry.Username
}
return r.TKERegistry.Username
}

func (r *Registry) Password() []byte {
if len(r.UserInputRegistry.Password) != 0 {
return r.UserInputRegistry.Password
}
if r.ThirdPartyRegistry != nil {
return r.ThirdPartyRegistry.Password
}
Expand Down Expand Up @@ -151,13 +138,6 @@ type ThirdPartyRegistry struct {
Password []byte `json:"password"`
}

type UserInputRegistry struct {
Domain string `json:"domain"`
Namespace string `json:"namespace"`
Username string `json:"username"`
Password []byte `json:"password"`
}

type Business struct {
}

Expand Down
Loading

0 comments on commit f5a8771

Please sign in to comment.