Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(platform): update k8s 1.19.7 support #1070

Merged
merged 5 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/docker/tools/provider-res/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations under the License.

IMAGE = provider-res
VERSION = v1.18.3-3
VERSION = v1.19.7-1
REGISTRY_PREFIX ?= tkestack

COMMON_SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
Expand Down
2 changes: 1 addition & 1 deletion build/docker/tools/tke-installer/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set -o pipefail
REGISTRY_PREFIX=${REGISTRY_PREFIX:-tkestack}
BUILDER=${BUILDER:-default}
VERSION=${VERSION:-$(git describe --dirty --always --tags | sed 's/-/./g')}
PROVIDER_RES_VERSION=v1.18.3-3
PROVIDER_RES_VERSION=v1.19.7-1
K8S_VERSION=${PROVIDER_RES_VERSION%-*}
DOCKER_VERSION=19.03.14
OSS=(linux)
Expand Down
2 changes: 1 addition & 1 deletion cmd/setup-env/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func main() {
env := os.Environ()
env = append(env, fmt.Sprintf("ARCHS=%s", strings.Join(spec.Archs, " ")))
env = append(env, fmt.Sprintf("OSS=%s", strings.Join(spec.OSs, " ")))
env = append(env, fmt.Sprintf("K8S_VERSIONS=%s", strings.Join(spec.K8sValidVersionsWithV, " ")))
env = append(env, fmt.Sprintf("K8S_VERSIONS=%s", strings.Join(spec.K8sVersionsWithV, " ")))
env = append(env, fmt.Sprintf("DOCKER_VERSIONS=%s", strings.Join(spec.DockerVersions, " ")))
env = append(env, fmt.Sprintf("CNI_PLUGINS_VERSIONS=%s", strings.Join(spec.CNIPluginsVersions, " ")))
env = append(env, fmt.Sprintf("NVIDIA_DRIVER_VERSIONS=%s", strings.Join(spec.NvidiaDriverVersions, " ")))
Expand Down
2 changes: 1 addition & 1 deletion cmd/tke-installer/app/installer/images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ var components = Components{
Busybox: containerregistry.Image{Name: "busybox", Tag: "1.31.1"},
InfluxDB: containerregistry.Image{Name: "influxdb", Tag: "1.7.9"},

ProviderRes: containerregistry.Image{Name: "provider-res", Tag: "v1.18.3-3"},
ProviderRes: containerregistry.Image{Name: "provider-res", Tag: "v1.19.7-1"},

TKEAuthAPI: containerregistry.Image{Name: "tke-auth-api", Tag: Version},
TKEAuthController: containerregistry.Image{Name: "tke-auth-controller", Tag: Version},
Expand Down
2 changes: 1 addition & 1 deletion cmd/tke-installer/app/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2461,7 +2461,7 @@ func (t *TKE) patchPlatformVersion(ctx context.Context) error {
return nil
}

versionsByte, err := json.Marshal(spec.K8sValidVersions)
versionsByte, err := json.Marshal(spec.K8sVersions)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/tke-installer/app/installer/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (t *TKE) getLatestProviderResTag(ctx context.Context) (tag string, err erro
if err != nil {
return "", err
}
if len(k8sValidVersions) > len(spec.K8sValidVersions) {
if len(k8sValidVersions) > len(spec.K8sVersions) {
return k8sValidVersions[len(k8sValidVersions)-1], nil
}
return images.Get().ProviderRes.Tag, nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/tke-installer/app/installer/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (t *TKE) updateTKEPlatformController(ctx context.Context) error {
case result < 0:
return errors.Errorf("can't upgrade, platform's version %s is higher than installer's version %s", tkeVersion, spec.TKEVersion)
case result == 0:
if len(k8sValidVersions) == len(spec.K8sValidVersions) {
if len(k8sValidVersions) == len(spec.K8sVersions) {
return errors.Errorf("can't upgrade, platform's version %s is equal to installer's version %s, please prepare your custom upgrade images before upgrade", tkeVersion, spec.TKEVersion)
}
depl.Spec.Template.Spec.InitContainers[0].Image = containerregistry.GetImagePrefix(images.Get().ProviderRes.Name + ":" + k8sValidVersions[len(k8sValidVersions)-1])
Expand Down
11 changes: 11 additions & 0 deletions pkg/platform/provider/baremetal/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,17 @@ func (p *Provider) clusterMachineIPs(c *v1.Cluster) []string {
return ips
}

func (p *Provider) EnsureCorrectCoreDNSConfig(ctx context.Context, c *v1.Cluster) error {
if c.Status.Phase == platformv1.ClusterUpscaling {
return nil
}
clientset, err := c.ClientsetForBootstrap()
if err != nil {
return err
}
return apiclient.RemoveUnsupportedCoreDNSProperty(ctx, clientset)
}

func (p *Provider) EnsureJoinPhasePreflight(ctx context.Context, c *v1.Cluster) error {
machines := map[bool][]platformv1.ClusterMachine{
true: c.Spec.ScalingMachines,
Expand Down
2 changes: 2 additions & 0 deletions pkg/platform/provider/baremetal/cluster/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func NewProvider() (*Provider, error) {
p.EnsureKubeadmInitPhaseAddon,

p.EnsureGalaxy,
p.EnsureCorrectCoreDNSConfig,

p.EnsureJoinPhasePreflight,
p.EnsureJoinPhaseControlPlanePrepare,
Expand Down Expand Up @@ -144,6 +145,7 @@ func NewProvider() (*Provider, error) {
UpgradeHandlers: []clusterprovider.Handler{
p.EnsurePreClusterUpgradeHook,
p.EnsureUpgradeControlPlaneNode,
p.EnsureCorrectCoreDNSConfig,
p.EnsurePostClusterUpgradeHook,
},
ScaleDownHandlers: []clusterprovider.Handler{
Expand Down
2 changes: 1 addition & 1 deletion pkg/platform/provider/baremetal/images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var kubecomponetNames = []string{"kube-apiserver", "kube-controller-manager", "k
var components = Components{
ETCD: containerregistry.Image{Name: "etcd", Tag: "v3.4.7"},
CoreDNS: containerregistry.Image{Name: "coredns", Tag: "1.6.7"},
Pause: containerregistry.Image{Name: "pause", Tag: "3.1"},
Pause: containerregistry.Image{Name: "pause", Tag: "3.2"},
NvidiaDevicePlugin: containerregistry.Image{Name: "nvidia-device-plugin", Tag: "1.0.0-beta4"},
Keepalived: containerregistry.Image{Name: "keepalived", Tag: "2.0.16-r0"},

Expand Down
1 change: 1 addition & 0 deletions pkg/platform/provider/baremetal/phases/galaxy/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ metadata:
data:
00-galaxy.conf: |
{
"name": "galaxy-sdn",
"type": "galaxy-sdn",
"capabilities": {"portMappings": true},
"cniVersion": "0.2.0"
Expand Down
2 changes: 1 addition & 1 deletion pkg/platform/provider/baremetal/res/res.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var (
}
KubernetesNode = Package{
Name: "kubernetes-node",
Versions: spec.K8sValidVersionsWithV,
Versions: spec.K8sVersionsWithV,
}
NvidiaDriver = Package{
Name: "NVIDIA",
Expand Down
7 changes: 1 addition & 6 deletions pkg/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,10 @@ var (
OSs = []string{"linux"}

K8sVersionConstraint = ">= 1.10"
K8sVersions = []string{"1.18.3", "1.17.13", "1.16.9"}
K8sVersions = []string{"1.19.7", "1.18.3", "1.17.13"}
K8sVersionsWithV = funk.Map(K8sVersions, func(s string) string {
return "v" + s
}).([]string)
// K8sValidVersions for backward compatibility.
K8sValidVersions = append(K8sVersions, []string{"1.16.6", "1.14.10"}...)
K8sValidVersionsWithV = funk.Map(K8sValidVersions, func(s string) string {
return "v" + s
}).([]string)

DockerVersions = []string{"19.03.14"}
CNIPluginsVersions = []string{"v0.8.6"}
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/apiclient/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestPullImageWithPod(t *testing.T) {
Containers: []corev1.Container{
{
Name: "test",
Image: "tkestack/pause:3.1",
Image: "tkestack/pause:3.2",
},
},
},
Expand Down
19 changes: 19 additions & 0 deletions pkg/util/apiclient/idempotency.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"io/ioutil"
"math"
"path/filepath"
"regexp"
"strings"
"time"

Expand Down Expand Up @@ -676,3 +677,21 @@ func GetNodeIPV6Label(ip string) string {
lableipv6Tail := fmt.Sprintf("%s=%s", LabelMachineIPV6Tail, strings.Replace(ip[splitLength:], ":", "a", -1))
return lableipv6Head + "," + lableipv6Tail
}

// RemoveUnsupportedCoreDNSProperty will remove unsupported property for old version coreDNS,
// more information please check https://github.com/coredns/coredns/issues/4362
func RemoveUnsupportedCoreDNSProperty(ctx context.Context, client clientset.Interface) error {
cm, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(ctx, "coredns", metav1.GetOptions{})
if err != nil {
return err
}
re, err := regexp.Compile(`\s*max_concurrent\s*\w+`)
if err != nil {
return errors.Wrap(err, "unable to remove unsupported coreDNS property")
}
cm.Data["Corefile"] = re.ReplaceAllString(cm.Data["Corefile"], "")
if _, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Update(ctx, cm, metav1.UpdateOptions{}); err != nil {
return errors.Wrap(err, "unable to remove unsupported coreDNS property")
}
return nil
}