mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-25 17:12:50 +00:00
feat: support to download binaries from cn zone
Signed-off-by: 24sama <jacksama@foxmail.com>
This commit is contained in:
parent
602abbca8a
commit
0e3da08951
|
|
@ -33,6 +33,10 @@ const (
|
|||
|
||||
// KKClusterSpec defines the desired state of KKCluster
|
||||
type KKClusterSpec struct {
|
||||
// ZONE is the zone of the KKCluster where can get the binaries.
|
||||
// If you have problem to access https://storage.googleapis.com, you can set "zone: cn".
|
||||
ZONE string `json:"zone,omitempty"`
|
||||
|
||||
// Nodes represents the information about the nodes available to the cluster
|
||||
Nodes Nodes `json:"nodes"`
|
||||
|
||||
|
|
|
|||
|
|
@ -276,6 +276,11 @@ spec:
|
|||
- namespaceOverride
|
||||
- privateRegistry
|
||||
type: object
|
||||
zone:
|
||||
description: 'ZONE is the zone of the KKCluster where can get the
|
||||
binaries. If you have problem to access https://storage.googleapis.com,
|
||||
you can set "zone: cn".'
|
||||
type: string
|
||||
required:
|
||||
- nodes
|
||||
type: object
|
||||
|
|
|
|||
|
|
@ -303,6 +303,11 @@ spec:
|
|||
- namespaceOverride
|
||||
- privateRegistry
|
||||
type: object
|
||||
zone:
|
||||
description: 'ZONE is the zone of the KKCluster where can
|
||||
get the binaries. If you have problem to access https://storage.googleapis.com,
|
||||
you can set "zone: cn".'
|
||||
type: string
|
||||
required:
|
||||
- nodes
|
||||
type: object
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: manager
|
||||
imagePullPolicy: Always
|
||||
imagePullPolicy: IfNotPresent
|
||||
|
|
@ -31,7 +31,6 @@ import (
|
|||
"github.com/kubesphere/kubekey/exp/cluster-api-provider-kubekey/pkg/scope"
|
||||
)
|
||||
|
||||
// todo: every phase reconcile method needs to handle a timeout case.
|
||||
func (r *KKInstanceReconciler) reconcilePing(ctx context.Context, instanceScope *scope.InstanceScope) error {
|
||||
instanceScope.Info("Reconcile ping")
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ type ClusterScoper interface {
|
|||
KubernetesClusterName() string
|
||||
// RootFs is the cluster scope rootfs
|
||||
RootFs() rootfs.Interface
|
||||
// Zone returns the cluster zone.
|
||||
Zone() string
|
||||
// PatchObject persists the cluster configuration and status.
|
||||
PatchObject() error
|
||||
// Close closes the current scope persisting the cluster configuration and status.
|
||||
|
|
|
|||
|
|
@ -21,7 +21,10 @@ import (
|
|||
)
|
||||
|
||||
type Interface interface {
|
||||
// ClusterRootFsDir returns the rootfs directory of the cluster.
|
||||
ClusterRootFsDir() string
|
||||
// HostRootFsDir returns the rootfs directory of the host.
|
||||
HostRootFsDir(host string) string
|
||||
// Fs returns the filesystem interface.
|
||||
Fs() filesystem.Interface
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,10 +214,16 @@ func (s *ClusterScope) ControllerName() string {
|
|||
return s.controllerName
|
||||
}
|
||||
|
||||
// RootFs returns the CAPKK rootfs interface.
|
||||
func (s *ClusterScope) RootFs() rootfs.Interface {
|
||||
return s.rootFs
|
||||
}
|
||||
|
||||
// Zone returns the KKCluster binaries zone.
|
||||
func (s *ClusterScope) Zone() string {
|
||||
return s.KKCluster.Spec.ZONE
|
||||
}
|
||||
|
||||
// ControlPlaneLoadBalancer returns the KKLoadBalancerSpec.
|
||||
func (s *ClusterScope) ControlPlaneLoadBalancer() *infrav1.KKLoadBalancerSpec {
|
||||
return s.KKCluster.Spec.ControlPlaneLoadBalancer
|
||||
|
|
|
|||
|
|
@ -67,7 +67,8 @@ func NewInstanceScope(params InstanceScopeParams) (*InstanceScope, error) {
|
|||
}
|
||||
|
||||
if params.Logger == nil {
|
||||
log := klogr.New()
|
||||
log := klogr.New().WithValues("cluster", params.Cluster.Name, "machine", params.Machine.Name,
|
||||
"kkInstance", params.KKInstance.Name)
|
||||
params.Logger = &log
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,11 +55,14 @@ func (s *Service) DownloadAll(timeout time.Duration) error {
|
|||
}
|
||||
|
||||
for _, b := range binaries {
|
||||
b.SetZone(s.scope.Zone())
|
||||
needGet := true
|
||||
if b.LocalExist() && b.CompareChecksum() == nil {
|
||||
needGet = false
|
||||
}
|
||||
if needGet {
|
||||
s.instanceScope.V(4).Info("download binary", "binary", b.Name(),
|
||||
"version", b.Version(), "url", b.Url())
|
||||
if err := b.Get(timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,11 +125,14 @@ func (s *ContainerdService) Get(timeout time.Duration) error {
|
|||
}
|
||||
|
||||
for _, b := range binaries {
|
||||
b.SetZone(s.scope.Zone())
|
||||
needGet := true
|
||||
if b.LocalExist() && b.CompareChecksum() == nil {
|
||||
needGet = false
|
||||
}
|
||||
if needGet {
|
||||
s.instanceScope.V(4).Info("download binary", "binary", b.Name(),
|
||||
"version", b.Version(), "url", b.Url())
|
||||
if err := b.Get(timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ type Binary struct {
|
|||
version string
|
||||
arch string
|
||||
url string
|
||||
cnURL string
|
||||
checksum checksum.Interface
|
||||
}
|
||||
|
||||
|
|
@ -53,6 +54,16 @@ func (b *Binary) Version() string {
|
|||
return b.version
|
||||
}
|
||||
|
||||
func (b *Binary) Url() string {
|
||||
return b.url
|
||||
}
|
||||
|
||||
func (b *Binary) SetZone(zone string) {
|
||||
if zone == "cn" {
|
||||
b.url = b.cnURL
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Binary) Get(timeout time.Duration) error {
|
||||
//todo: should not to skip TLS verify
|
||||
client := &getter.HttpGetter{
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
ContainerdName = "containerd-%s-linux-%s.tar.gz"
|
||||
ContainerdID = "containerd"
|
||||
ContainerdDownloadURLTmpl = "https://github.com/containerd/containerd/releases/download/v%s/containerd-%s-linux-%s.tar.gz"
|
||||
//ContainerdDownloadURLTmpl = "https://kubernetes-release.pek3b.qingstor.com/containerd/containerd/releases/download/v%s/containerd-%s-linux-%s.tar.gz"
|
||||
ContainerdName = "containerd-%s-linux-%s.tar.gz"
|
||||
ContainerdID = "containerd"
|
||||
ContainerdDownloadURLTmpl = "https://github.com/containerd/containerd/releases/download/v%s/containerd-%s-linux-%s.tar.gz"
|
||||
ContainerdDownloadURLTmplCN = "https://kubernetes-release.pek3b.qingstor.com/containerd/containerd/releases/download/v%s/containerd-%s-linux-%s.tar.gz"
|
||||
)
|
||||
|
||||
func NewContainerd(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Binary, error) {
|
||||
|
|
@ -54,6 +54,7 @@ func NewContainerd(sshClient ssh.Interface, rootFs rootfs.Interface, version, ar
|
|||
version,
|
||||
arch,
|
||||
fmt.Sprintf(ContainerdDownloadURLTmpl, version, version, arch),
|
||||
fmt.Sprintf(ContainerdDownloadURLTmplCN, version, version, arch),
|
||||
internal,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
CrictlName = "crictl-%s-linux-%s.tar.gz"
|
||||
CrictlID = "crictl"
|
||||
CrictlDownloadURLTmpl = "https://github.com/kubernetes-sigs/cri-tools/releases/download/%s/crictl-%s-linux-%s.tar.gz"
|
||||
//CrictlDownloadURLTmpl = "https://kubernetes-release.pek3b.qingstor.com/cri-tools/releases/download/%s/crictl-%s-linux-%s.tar.gz"
|
||||
CrictlName = "crictl-%s-linux-%s.tar.gz"
|
||||
CrictlID = "crictl"
|
||||
CrictlDownloadURLTmpl = "https://github.com/kubernetes-sigs/cri-tools/releases/download/%s/crictl-%s-linux-%s.tar.gz"
|
||||
CrictlDownloadURLTmplCN = "https://kubernetes-release.pek3b.qingstor.com/cri-tools/releases/download/%s/crictl-%s-linux-%s.tar.gz"
|
||||
)
|
||||
|
||||
func NewCrictl(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Binary, error) {
|
||||
|
|
@ -54,6 +54,7 @@ func NewCrictl(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch s
|
|||
version,
|
||||
arch,
|
||||
fmt.Sprintf(CrictlDownloadURLTmpl, version, version, arch),
|
||||
fmt.Sprintf(CrictlDownloadURLTmplCN, version, version, arch),
|
||||
internal,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,11 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
DockerName = "docker-%s.tgz"
|
||||
DockerID = "docker"
|
||||
DockerDownloadURLTmpl = "https://download.docker.com/linux/static/stable/%s/docker-%s.tgz"
|
||||
DockerDefaultVersion = "20.10.8"
|
||||
DockerName = "docker-%s.tgz"
|
||||
DockerID = "docker"
|
||||
DockerDownloadURLTmpl = "https://download.docker.com/linux/static/stable/%s/docker-%s.tgz"
|
||||
DockerDownloadURLTmplCN = "https://mirrors.aliyun.com/docker-ce/linux/static/stable/%s/docker-%s.tgz"
|
||||
DockerDefaultVersion = "20.10.8"
|
||||
)
|
||||
|
||||
func NewDocker(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Binary, error) {
|
||||
|
|
@ -55,6 +56,7 @@ func NewDocker(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch s
|
|||
version,
|
||||
arch,
|
||||
fmt.Sprintf(DockerDownloadURLTmpl, util.ArchAlias(arch), version),
|
||||
fmt.Sprintf(DockerDownloadURLTmplCN, util.ArchAlias(arch), version),
|
||||
internal,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,10 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
KubeadmName = "kubeadm"
|
||||
KubeadmID = "kubeadm"
|
||||
KubeadmDownloadURLTmpl = "https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubeadm"
|
||||
KubeadmName = "kubeadm"
|
||||
KubeadmID = "kubeadm"
|
||||
KubeadmDownloadURLTmpl = "https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubeadm"
|
||||
KubeadmDownloadURLTmplCN = "https://kubernetes-release.pek3b.qingstor.com/release/%s/bin/linux/%s/kubeadm"
|
||||
)
|
||||
|
||||
func NewKubeadm(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Binary, error) {
|
||||
|
|
@ -53,6 +54,7 @@ func NewKubeadm(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch
|
|||
version,
|
||||
arch,
|
||||
fmt.Sprintf(KubeadmDownloadURLTmpl, version, arch),
|
||||
fmt.Sprintf(KubeadmDownloadURLTmplCN, version, arch),
|
||||
internal,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
KubecniName = "cni-plugins-linux-%s-%s.tgz"
|
||||
KubecniID = "kubecni"
|
||||
KubecniDownloadURLTmpl = "https://github.com/containernetworking/plugins/releases/download/%s/cni-plugins-linux-%s-%s.tgz"
|
||||
//KubecniDownloadURLTmpl = "https://containernetworking.pek3b.qingstor.com/plugins/releases/download/%s/cni-plugins-linux-%s-%s.tgz"
|
||||
KubecniDefaultVersion = "v0.9.1"
|
||||
KubecniName = "cni-plugins-linux-%s-%s.tgz"
|
||||
KubecniID = "kubecni"
|
||||
KubecniDownloadURLTmpl = "https://github.com/containernetworking/plugins/releases/download/%s/cni-plugins-linux-%s-%s.tgz"
|
||||
KubecniDownloadURLTmplCN = "https://containernetworking.pek3b.qingstor.com/plugins/releases/download/%s/cni-plugins-linux-%s-%s.tgz"
|
||||
KubecniDefaultVersion = "v0.9.1"
|
||||
)
|
||||
|
||||
func NewKubecni(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Binary, error) {
|
||||
|
|
@ -55,6 +55,7 @@ func NewKubecni(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch
|
|||
version,
|
||||
arch,
|
||||
fmt.Sprintf(KubecniDownloadURLTmpl, version, arch, version),
|
||||
fmt.Sprintf(KubecniDownloadURLTmplCN, version, arch, version),
|
||||
internal,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,10 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
KubectlName = "kubectl"
|
||||
KubectlID = "kubectl"
|
||||
KubectlDownloadURLTmpl = "https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubectl"
|
||||
KubectlName = "kubectl"
|
||||
KubectlID = "kubectl"
|
||||
KubectlDownloadURLTmpl = "https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubectl"
|
||||
KubectlDownloadURLTmplCN = "https://kubernetes-release.pek3b.qingstor.com/release/%s/bin/linux/%s/kubectl"
|
||||
)
|
||||
|
||||
func NewKubectl(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Binary, error) {
|
||||
|
|
@ -53,6 +54,7 @@ func NewKubectl(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch
|
|||
version,
|
||||
arch,
|
||||
fmt.Sprintf(KubectlDownloadURLTmpl, version, arch),
|
||||
fmt.Sprintf(KubectlDownloadURLTmplCN, version, arch),
|
||||
internal,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,10 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
KubeletName = "kubelet"
|
||||
KubeletID = "kubelet"
|
||||
KubeletDownloadURLTmpl = "https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubelet"
|
||||
KubeletName = "kubelet"
|
||||
KubeletID = "kubelet"
|
||||
KubeletDownloadURLTmpl = "https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubelet"
|
||||
KubeletDownloadURLTmplCN = "https://kubernetes-release.pek3b.qingstor.com/release/%s/bin/linux/%s/kubelet"
|
||||
)
|
||||
|
||||
func NewKubelet(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Binary, error) {
|
||||
|
|
@ -53,6 +54,7 @@ func NewKubelet(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch
|
|||
version,
|
||||
arch,
|
||||
fmt.Sprintf(KubeletDownloadURLTmpl, version, arch),
|
||||
fmt.Sprintf(KubeletDownloadURLTmplCN, version, arch),
|
||||
internal,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
RuncName = "runc.%s"
|
||||
RuncID = "runc"
|
||||
RuncDownloadURLTmpl = "https://github.com/opencontainers/runc/releases/download/%s/runc.%s"
|
||||
//RuncDownloadURLTmpl = "https://kubernetes-release.pek3b.qingstor.com/opencontainers/runc/releases/download/%s/runc.%s"
|
||||
RuncDefaultVersion = "v1.1.1"
|
||||
RuncName = "runc.%s"
|
||||
RuncID = "runc"
|
||||
RuncDownloadURLTmpl = "https://github.com/opencontainers/runc/releases/download/%s/runc.%s"
|
||||
RuncDownloadURLTmplCN = "https://kubernetes-release.pek3b.qingstor.com/opencontainers/runc/releases/download/%s/runc.%s"
|
||||
RuncDefaultVersion = "v1.1.1"
|
||||
)
|
||||
|
||||
func NewRunc(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Binary, error) {
|
||||
|
|
@ -55,6 +55,7 @@ func NewRunc(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch str
|
|||
version,
|
||||
arch,
|
||||
fmt.Sprintf(RuncDownloadURLTmpl, version, arch),
|
||||
fmt.Sprintf(RuncDownloadURLTmplCN, version, arch),
|
||||
internal,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ type Binary interface {
|
|||
ID() string
|
||||
Arch() string
|
||||
Version() string
|
||||
Url() string
|
||||
SetZone(zone string)
|
||||
Get(timeout time.Duration) error
|
||||
CompareChecksum() error
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ variables:
|
|||
SERVICE_CIDRS: "10.233.0.0/18"
|
||||
POD_CIDRS: "10.233.64.0/18"
|
||||
SERVICE_DOMAIN: "cluster.local"
|
||||
KKZONE: "cn"
|
||||
USER_NAME: "ubuntu"
|
||||
PASSWORD: "Qcloud@123"
|
||||
INSTANCE01_IP: 172.31.50.190
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ kind: KKCluster
|
|||
metadata:
|
||||
name: '${CLUSTER_NAME}'
|
||||
spec:
|
||||
zone: '${KKZONE}'
|
||||
nodes:
|
||||
auth:
|
||||
user: '${USER_NAME}'
|
||||
|
|
|
|||
Loading…
Reference in New Issue