Skip to content

Commit

Permalink
feat(installer): patch k8s versions (#913)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo Ryu committed Nov 17, 2020
1 parent 45b2fcd commit 251eb03
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cmd/tke-installer/app/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
k8stypes "k8s.io/apimachinery/pkg/types"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -206,6 +207,10 @@ func (t *TKE) initSteps() {
Name: "Create global cluster",
Func: t.createGlobalCluster,
},
{
Name: "Patch k8s version in cluster info",
Func: t.patchK8sValidVersions,
},
{
Name: "Write kubeconfig",
Func: t.writeKubeconfig,
Expand Down Expand Up @@ -2419,3 +2424,21 @@ func (t *TKE) writeKubeconfig(ctx context.Context) error {
_ = os.MkdirAll("/root/.kube", 0755)
return ioutil.WriteFile("/root/.kube/config", data, 0644)
}

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),
},
}
patchByte, err := json.Marshal(patchData)
if err != nil {
return err
}
_, err = t.globalClient.CoreV1().ConfigMaps("kube-public").Patch(ctx, "cluster-info", k8stypes.MergePatchType, patchByte, metav1.PatchOptions{})
return err
}

0 comments on commit 251eb03

Please sign in to comment.