Skip to content

Commit

Permalink
feat(platform): remove save third party registry
Browse files Browse the repository at this point in the history
  • Loading branch information
leonarliu committed Dec 1, 2020
1 parent e492b68 commit 607a0ea
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 57 deletions.
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" /app/bin/tke-installer $@
docker run $OPTIONS "tkestack/tke-installer-${ARCH}:$VERSION" $@

echo "Step.5 start tke-installer [ok]"
}
Expand Down
28 changes: 0 additions & 28 deletions cmd/tke-installer/app/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,6 @@ func (t *TKE) initSteps() {
}...)
}

if t.Para.Config.Registry.ThirdPartyRegistry != nil {
t.steps = append(t.steps, []types.Handler{
{
Name: "Save third party registry info",
Func: t.saveThirdPartyRegistryInfo,
},
}...)
}

t.steps = append(t.steps, []types.Handler{
{
Name: "Execute post install hook",
Expand Down Expand Up @@ -2467,22 +2458,3 @@ func (t *TKE) patchPlatformVersion(ctx context.Context) error {
_, err = t.globalClient.CoreV1().ConfigMaps("kube-public").Patch(ctx, "cluster-info", k8stypes.MergePatchType, patchByte, metav1.PatchOptions{})
return err
}

func (t *TKE) saveThirdPartyRegistryInfo(ctx context.Context) error {
if t.Para.Config.Registry.ThirdPartyRegistry == nil {
return errors.New("No third party registry info")
}
thirdPartyRegistryByte, err := json.Marshal(*t.Para.Config.Registry.ThirdPartyRegistry)
if err != nil {
return err
}
thirdPartyRegistryCm := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: thirdPartyRegistryCmName,
Namespace: t.namespace,
},
Data: map[string]string{},
}
thirdPartyRegistryCm.Data[thirdPartyRegistryCmKey] = string(thirdPartyRegistryByte)
return apiclient.CreateOrUpdateConfigMap(ctx, t.globalClient, thirdPartyRegistryCm)
}
34 changes: 6 additions & 28 deletions cmd/tke-installer/app/installer/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package installer

import (
"context"
"encoding/json"
"fmt"
"os/exec"
"time"
Expand All @@ -47,10 +46,8 @@ import (
)

const (
registryCmName = "tke-registry-api"
registryCmKey = "tke-registry-config.yaml"
thirdPartyRegistryCmName = "tke-thirdparty-registry"
thirdPartyRegistryCmKey = "tke-thirdparty-registry.json"
registryCmName = "tke-registry-api"
registryCmKey = "tke-registry-config.yaml"
)

func (t *TKE) upgradeSteps() {
Expand Down Expand Up @@ -185,10 +182,10 @@ func (t *TKE) prepareForUpgrade(ctx context.Context) error {
err = t.loadRegistry(ctx)
if err != nil {
if apierrors.IsNotFound(err) {
t.log.Infof("No %s, try to load third party registry", registryCmName)
err = t.loadThirdPartyRegistry(ctx)
if err != nil {
return err
t.log.Infof("Not found %s", registryCmName)
if t.Para.Config.Registry.ThirdPartyRegistry == nil {
t.log.Infof("Not found third party registry")
t.Para.Config.Registry.ThirdPartyRegistry = &types.ThirdPartyRegistry{}
}
} else {
return err
Expand Down Expand Up @@ -218,25 +215,6 @@ func (t *TKE) loadRegistry(ctx context.Context) error {
return nil
}

func (t *TKE) loadThirdPartyRegistry(ctx context.Context) error {
thirdPartyRegistryConfig := &types.ThirdPartyRegistry{}
thirdPartyRegistryCm, err := t.globalClient.CoreV1().ConfigMaps(t.namespace).Get(ctx, thirdPartyRegistryCmName, metav1.GetOptions{})
if err != nil {
if apierrors.IsNotFound(err) {
t.log.Infof("Not found %s", thirdPartyRegistryCmName)
t.Para.Config.Registry.ThirdPartyRegistry = thirdPartyRegistryConfig
return nil
}
return err
}
err = json.Unmarshal([]byte(thirdPartyRegistryCm.Data[thirdPartyRegistryCmKey]), thirdPartyRegistryConfig)
if err != nil {
return err
}
t.Para.Config.Registry.ThirdPartyRegistry = thirdPartyRegistryConfig
return nil
}

func (t *TKE) loginRegistryForUpgrade(ctx context.Context) error {
containerregistry.Init(t.Para.Config.Registry.Domain(), t.Para.Config.Registry.Namespace())
cmd := exec.Command("docker", "login",
Expand Down

0 comments on commit 607a0ea

Please sign in to comment.