Skip to content

Commit

Permalink
Merge pull request #2150 from pixiake/master
Browse files Browse the repository at this point in the history
upgrade containerd, runc and calico version
  • Loading branch information
ks-ci-bot authored Mar 1, 2024
2 parents c965c05 + cd60d9e commit 078db05
Show file tree
Hide file tree
Showing 7 changed files with 269 additions and 1,196 deletions.
6 changes: 3 additions & 3 deletions cmd/kk/apis/kubekey/v1alpha2/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ const (
DefaultEtcdPort = "2379"
DefaultDockerVersion = "24.0.9"
DefaultCriDockerdVersion = "0.3.10"
DefaultContainerdVersion = "1.7.12"
DefaultRuncVersion = "v1.1.11"
DefaultContainerdVersion = "1.7.13"
DefaultRuncVersion = "v1.1.12"
DefaultCrictlVersion = "v1.29.0"
DefaultKubeVersion = "v1.23.15"
DefaultCalicoVersion = "v3.26.1"
DefaultCalicoVersion = "v3.27.2"
DefaultFlannelVersion = "v0.21.3"
DefaultFlannelCniPluginVersion = "v1.1.2"
DefaultCniVersion = "v1.2.0"
Expand Down
84 changes: 5 additions & 79 deletions cmd/kk/pkg/plugins/network/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package network

import (
"path/filepath"
"strings"

versionutil "k8s.io/apimachinery/pkg/util/version"

Expand Down Expand Up @@ -93,63 +92,15 @@ func deployMultus(d *DeployNetworkPluginModule) []task.Interface {
}

func deployCalico(d *DeployNetworkPluginModule) []task.Interface {
generateCalicoOld := &task.RemoteTask{
Name: "GenerateCalico",
Desc: "Generate calico",
Hosts: d.Runtime.GetHostsByRole(common.Master),
Prepare: &prepare.PrepareCollection{
new(common.OnlyFirstMaster),
new(OldK8sVersion),
},
Action: &action.Template{
Template: templates.CalicoOld,
Dst: filepath.Join(common.KubeConfigDir, templates.CalicoOld.Name()),
Data: util.Data{
"KubePodsCIDR": d.KubeConf.Cluster.Network.KubePodsCIDR,
"CalicoCniImage": images.GetImage(d.Runtime, d.KubeConf, "calico-cni").ImageName(),
"CalicoNodeImage": images.GetImage(d.Runtime, d.KubeConf, "calico-node").ImageName(),
"CalicoFlexvolImage": images.GetImage(d.Runtime, d.KubeConf, "calico-flexvol").ImageName(),
"CalicoControllersImage": images.GetImage(d.Runtime, d.KubeConf, "calico-kube-controllers").ImageName(),
"TyphaEnabled": len(d.Runtime.GetHostsByRole(common.K8s)) > 50 || d.KubeConf.Cluster.Network.Calico.Typha(),
"VethMTU": d.KubeConf.Cluster.Network.Calico.VethMTU,
"NodeCidrMaskSize": d.KubeConf.Cluster.Kubernetes.NodeCidrMaskSize,
"IPIPMode": d.KubeConf.Cluster.Network.Calico.IPIPMode,
"VXLANMode": d.KubeConf.Cluster.Network.Calico.VXLANMode,
},
},
Parallel: true,
}

generateCalicoNew := &task.RemoteTask{
generateCalicoManifests := &task.RemoteTask{
Name: "GenerateCalico",
Desc: "Generate calico",
Hosts: d.Runtime.GetHostsByRole(common.Master),
Prepare: &prepare.PrepareCollection{
new(common.OnlyFirstMaster),
&OldK8sVersion{Not: true},
},
Action: &action.Template{
Template: templates.CalicoNew,
Dst: filepath.Join(common.KubeConfigDir, templates.CalicoNew.Name()),
Data: util.Data{
"KubePodsV4CIDR": strings.Split(d.KubeConf.Cluster.Network.KubePodsCIDR, ",")[0],
"KubePodsV6CIDR": GetKubePodsV6CIDR(d),
"CalicoCniImage": images.GetImage(d.Runtime, d.KubeConf, "calico-cni").ImageName(),
"CalicoNodeImage": images.GetImage(d.Runtime, d.KubeConf, "calico-node").ImageName(),
"CalicoFlexvolImage": images.GetImage(d.Runtime, d.KubeConf, "calico-flexvol").ImageName(),
"CalicoControllersImage": images.GetImage(d.Runtime, d.KubeConf, "calico-kube-controllers").ImageName(),
"CalicoTyphaImage": images.GetImage(d.Runtime, d.KubeConf, "calico-typha").ImageName(),
"TyphaEnabled": len(d.Runtime.GetHostsByRole(common.K8s)) > 50 || d.KubeConf.Cluster.Network.Calico.Typha(),
"VethMTU": d.KubeConf.Cluster.Network.Calico.VethMTU,
"NodeCidrMaskSize": d.KubeConf.Cluster.Kubernetes.NodeCidrMaskSize,
"IPIPMode": d.KubeConf.Cluster.Network.Calico.IPIPMode,
"VXLANMode": d.KubeConf.Cluster.Network.Calico.VXLANMode,
"ConatinerManagerIsIsula": d.KubeConf.Cluster.Kubernetes.ContainerManager == "isula",
"IPV4POOLNATOUTGOING": d.KubeConf.Cluster.Network.Calico.EnableIPV4POOL_NAT_OUTGOING(),
"DefaultIPPOOL": d.KubeConf.Cluster.Network.Calico.EnableDefaultIPPOOL(),
"IPv6Support": GetKubeIPv6Support(d),
},
},
Action: new(GenerateCalicoManifests),
Parallel: true,
}

Expand All @@ -163,35 +114,10 @@ func deployCalico(d *DeployNetworkPluginModule) []task.Interface {
Retry: 5,
}

if K8sVersionAtLeast(d.KubeConf.Cluster.Kubernetes.Version, "v1.16.0") {
return []task.Interface{
generateCalicoNew,
deploy,
}
} else {
return []task.Interface{
generateCalicoOld,
deploy,
}
}
}

func GetKubeIPv6Support(d *DeployNetworkPluginModule) bool {
IPv6Support := false
kubePodsCIDR := strings.Split(d.KubeConf.Cluster.Network.KubePodsCIDR, ",")
if len(kubePodsCIDR)==2 {
IPv6Support = true
}
return IPv6Support
}

func GetKubePodsV6CIDR(d *DeployNetworkPluginModule) string {
kubePodsV6CIDR := ""
kubePodsCIDR := strings.Split(d.KubeConf.Cluster.Network.KubePodsCIDR, ",")
if len(kubePodsCIDR)==2 {
kubePodsV6CIDR = kubePodsCIDR[1]
return []task.Interface{
generateCalicoManifests,
deploy,
}
return kubePodsV6CIDR
}

func deployFlannel(d *DeployNetworkPluginModule) []task.Interface {
Expand Down
55 changes: 53 additions & 2 deletions cmd/kk/pkg/plugins/network/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ package network
import (
"embed"
"fmt"
"github.com/pkg/errors"
"io"
"os"
"path/filepath"
"strings"
"text/template"
"time"

"github.com/pkg/errors"

"github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2"
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common"
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/action"
Expand All @@ -35,7 +37,7 @@ import (
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/network/templates"
)

//go:embed cilium-1.11.7.tgz hybridnet-0.6.6.tgz
//go:embed cilium-1.11.7.tgz hybridnet-0.6.6.tgz templates/calico.tmpl

var f embed.FS

Expand Down Expand Up @@ -425,3 +427,52 @@ func (d *DeployHybridnet) Execute(runtime connector.Runtime) error {
}
return nil
}

type GenerateCalicoManifests struct {
common.KubeAction
}

func (g *GenerateCalicoManifests) Execute(runtime connector.Runtime) error {
calicoContent, err := f.ReadFile("templates/calico.tmpl")
if err != nil {
return err
}
calico := template.Must(template.New("network-plugin.yaml").Parse(string(calicoContent)))

IPv6Support := false
kubePodsV6CIDR := ""
kubePodsCIDR := strings.Split(g.KubeConf.Cluster.Network.KubePodsCIDR, ",")
if len(kubePodsCIDR) == 2 {
IPv6Support = true
kubePodsV6CIDR = kubePodsCIDR[1]
}

templateAction := action.Template{
Template: calico,
Dst: filepath.Join(common.KubeConfigDir, calico.Name()),
Data: util.Data{
"KubePodsV4CIDR": strings.Split(g.KubeConf.Cluster.Network.KubePodsCIDR, ",")[0],
"KubePodsV6CIDR": kubePodsV6CIDR,
"CalicoCniImage": images.GetImage(runtime, g.KubeConf, "calico-cni").ImageName(),
"CalicoNodeImage": images.GetImage(runtime, g.KubeConf, "calico-node").ImageName(),
"CalicoFlexvolImage": images.GetImage(runtime, g.KubeConf, "calico-flexvol").ImageName(),
"CalicoControllersImage": images.GetImage(runtime, g.KubeConf, "calico-kube-controllers").ImageName(),
"CalicoTyphaImage": images.GetImage(runtime, g.KubeConf, "calico-typha").ImageName(),
"TyphaEnabled": len(runtime.GetHostsByRole(common.K8s)) > 50 || g.KubeConf.Cluster.Network.Calico.Typha(),
"VethMTU": g.KubeConf.Cluster.Network.Calico.VethMTU,
"NodeCidrMaskSize": g.KubeConf.Cluster.Kubernetes.NodeCidrMaskSize,
"IPIPMode": g.KubeConf.Cluster.Network.Calico.IPIPMode,
"VXLANMode": g.KubeConf.Cluster.Network.Calico.VXLANMode,
"ConatinerManagerIsIsula": g.KubeConf.Cluster.Kubernetes.ContainerManager == "isula",
"IPV4POOLNATOUTGOING": g.KubeConf.Cluster.Network.Calico.EnableIPV4POOL_NAT_OUTGOING(),
"DefaultIPPOOL": g.KubeConf.Cluster.Network.Calico.EnableDefaultIPPOOL(),
"IPv6Support": IPv6Support,
},
}
templateAction.Init(nil, nil)
if err := templateAction.Execute(runtime); err != nil {
return err
}

return nil
}
Loading

0 comments on commit 078db05

Please sign in to comment.