mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
google object storage is supported
Signed-off-by: pixiake <guofeng@yunify.com>
This commit is contained in:
parent
fc5405ce1d
commit
266cf0ab2b
|
|
@ -14,7 +14,7 @@ RUN git clone https://github.com/kubesphere/helm-charts.git
|
|||
ADD ./ /workspace
|
||||
# Build
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o kk cmd/kk/main.go
|
||||
|
||||
# Build the manager image
|
||||
FROM debian:stable
|
||||
|
|
@ -31,5 +31,6 @@ WORKDIR /home/kubekey
|
|||
COPY --from=builder /workspace/helm-charts/src/main/nfs-client-provisioner /home/kubekey/addons/nfs-client-provisioner
|
||||
COPY --from=builder /workspace/helm-charts/src/test/ks-installer /home/kubekey/addons/ks-installer
|
||||
COPY --from=builder /workspace/manager /home/kubekey
|
||||
COPY --from=builder /workspace/kk /home/kubekey
|
||||
|
||||
|
||||
RUN ln -snf /home/kubekey/manager /home/kubekey/kk
|
||||
|
|
|
|||
6
Makefile
6
Makefile
|
|
@ -107,17 +107,17 @@ binary:
|
|||
-e CGO_ENABLED=0 \
|
||||
-e GO111MODULE=on \
|
||||
-w /usr/src/myapp golang:1.14 \
|
||||
go build -ldflags '$(LDFLAGS)' -v -o output/linux/amd64/kk ./main.go # linux
|
||||
go build -ldflags '$(LDFLAGS)' -v -o output/linux/amd64/kk ./cmd/kk/main.go # linux
|
||||
sha256sum output/linux/amd64/kk || shasum -a 256 output/linux/amd64/kk
|
||||
|
||||
docker run --rm \
|
||||
-v $(shell pwd):/usr/src/myapp \
|
||||
-e GOOS=linux \cd out
|
||||
-e GOOS=linux \
|
||||
-e GOARCH=arm64 \
|
||||
-e CGO_ENABLED=0 \
|
||||
-e GO111MODULE=on \
|
||||
-w /usr/src/myapp golang:1.14 \
|
||||
go build -ldflags '$(LDFLAGS)' -v -o output/linux/arm64/kk ./main.go # linux
|
||||
go build -ldflags '$(LDFLAGS)' -v -o output/linux/arm64/kk ./cmd/kk/main.go # linux
|
||||
sha256sum output/linux/arm64/kk || shasum -a 256 output/linux/arm64/kk
|
||||
|
||||
# build the binary file of kk
|
||||
|
|
|
|||
|
|
@ -105,6 +105,8 @@ Quick Start is for `all-in-one` installation which is a good start to get famili
|
|||
|
||||
##### Command
|
||||
|
||||
> If you have problem to access `https://storage.googleapis.com`, execute first `export KKZONE=cn`.
|
||||
|
||||
```shell script
|
||||
./kk create cluster [--with-kubernetes version] [--with-kubesphere version]
|
||||
```
|
||||
|
|
@ -133,6 +135,8 @@ Quick Start is for `all-in-one` installation which is a good start to get famili
|
|||
|
||||
You have more control to customize parameters or create a multi-node cluster using the advanced installation. Specifically, create a cluster by specifying a configuration file.
|
||||
|
||||
> If you have problem to access `https://storage.googleapis.com`, execute first `export KKZONE=cn`.
|
||||
|
||||
1. First, create an example configuration file
|
||||
|
||||
```shell script
|
||||
|
|
|
|||
|
|
@ -107,6 +107,8 @@ KubeKey 可以同时安装 Kubernetes 和 KubeSphere。根据 KubeSphere 所安
|
|||
|
||||
##### 命令
|
||||
|
||||
> 如果无法访问 `https://storage.googleapis.com`, 请先执行 `export KKZONE=cn`.
|
||||
|
||||
```shell script
|
||||
./kk create cluster [--with-kubernetes version] [--with-kubesphere version]
|
||||
```
|
||||
|
|
@ -135,6 +137,8 @@ KubeKey 可以同时安装 Kubernetes 和 KubeSphere。根据 KubeSphere 所安
|
|||
|
||||
您可以使用高级安装来控制自定义参数或创建多节点群集。具体来说,通过指定配置文件来创建集群。
|
||||
|
||||
> 如果无法访问 `https://storage.googleapis.com`, 请先执行 `export KKZONE=cn`.
|
||||
|
||||
1. 首先,创建一个示例配置文件
|
||||
|
||||
```shell script
|
||||
|
|
|
|||
4
build.sh
4
build.sh
|
|
@ -24,10 +24,10 @@ LDFLAGS="-X github.com/kubesphere/kubekey/version.version=${VERSION}
|
|||
if [ -n "$1" ]; then
|
||||
if [ "$1" == "-p" ] || [ "$1" == "--proxy" ]; then
|
||||
# Using the most trusted Go module proxy in China
|
||||
docker run --rm -e GO111MODULE=on -e GOPROXY=https://goproxy.cn -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.14.7 go build -ldflags "$LDFLAGS" -v -o output/kk ./main.go
|
||||
docker run --rm -e GO111MODULE=on -e GOPROXY=https://goproxy.cn -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.14.7 go build -ldflags "$LDFLAGS" -v -o output/kk ./cmd/kk/main.go
|
||||
else
|
||||
echo "The option should be '-p' or '--proxy'"
|
||||
fi
|
||||
else
|
||||
docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.14.7 go build -ldflags "$LDFLAGS" -v -o output/kk ./main.go
|
||||
docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.14.7 go build -ldflags "$LDFLAGS" -v -o output/kk ./cmd/kk/main.go
|
||||
fi
|
||||
|
|
|
|||
14
main.go
14
main.go
|
|
@ -19,15 +19,11 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
kubekeycontroller "github.com/kubesphere/kubekey/controllers/kubekey"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/kubesphere/kubekey/cmd"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||
"os"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log/zap"
|
||||
|
||||
|
|
@ -48,14 +44,6 @@ func init() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
// This is fork flow of kk (aka kubekey)
|
||||
// Please see also cmd/kk/main.go as an another main entry-point of kk
|
||||
// In order to keep compatible, just remain the following code lines
|
||||
if strings.Contains(os.Args[0], "kk") {
|
||||
cmd.Execute()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
var metricsAddr string
|
||||
var enableLeaderElection bool
|
||||
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
|
||||
|
|
|
|||
|
|
@ -30,31 +30,41 @@ import (
|
|||
)
|
||||
|
||||
func FilesDownloadHttp(mgr *manager.Manager, filepath, version, arch string) error {
|
||||
kkzone := os.Getenv("KKZONE")
|
||||
kubeadm := files.KubeBinary{Name: "kubeadm", Arch: arch, Version: version}
|
||||
kubelet := files.KubeBinary{Name: "kubelet", Arch: arch, Version: version}
|
||||
kubectl := files.KubeBinary{Name: "kubectl", Arch: arch, Version: version}
|
||||
kubecni := files.KubeBinary{Name: "kubecni", Arch: arch, Version: kubekeyapiv1alpha1.DefaultCniVersion}
|
||||
helm := files.KubeBinary{Name: "helm", Arch: arch, Version: kubekeyapiv1alpha1.DefaultHelmVersion}
|
||||
|
||||
kubeadm.Url = fmt.Sprintf("https://kubernetes-release.pek3b.qingstor.com/release/%s/bin/linux/%s/kubeadm", kubeadm.Version, kubeadm.Arch)
|
||||
kubelet.Url = fmt.Sprintf("https://kubernetes-release.pek3b.qingstor.com/release/%s/bin/linux/%s/kubelet", kubelet.Version, kubelet.Arch)
|
||||
kubectl.Url = fmt.Sprintf("https://kubernetes-release.pek3b.qingstor.com/release/%s/bin/linux/%s/kubectl", kubectl.Version, kubectl.Arch)
|
||||
kubecni.Url = fmt.Sprintf("https://containernetworking.pek3b.qingstor.com/plugins/releases/download/%s/cni-plugins-linux-%s-%s.tgz", kubecni.Version, kubecni.Arch, kubecni.Version)
|
||||
helm.Url = fmt.Sprintf("https://kubernetes-helm.pek3b.qingstor.com/linux-%s/%s/helm", helm.Arch, helm.Version)
|
||||
|
||||
kubeadm.Path = fmt.Sprintf("%s/kubeadm", filepath)
|
||||
kubelet.Path = fmt.Sprintf("%s/kubelet", filepath)
|
||||
kubectl.Path = fmt.Sprintf("%s/kubectl", filepath)
|
||||
kubecni.Path = fmt.Sprintf("%s/cni-plugins-linux-%s-%s.tgz", filepath, arch, kubekeyapiv1alpha1.DefaultCniVersion)
|
||||
helm.Path = fmt.Sprintf("%s/helm", filepath)
|
||||
|
||||
kubeadm.GetCmd = fmt.Sprintf("curl -o %s %s", kubeadm.Path, kubeadm.Url)
|
||||
kubelet.GetCmd = fmt.Sprintf("curl -o %s %s", kubelet.Path, kubelet.Url)
|
||||
kubectl.GetCmd = fmt.Sprintf("curl -o %s %s", kubectl.Path, kubectl.Url)
|
||||
kubecni.GetCmd = fmt.Sprintf("curl -o %s %s", kubecni.Path, kubecni.Url)
|
||||
helm.GetCmd = fmt.Sprintf("curl -o %s %s", helm.Path, helm.Url)
|
||||
if kkzone == "cn" {
|
||||
kubeadm.Url = fmt.Sprintf("https://kubernetes-release.pek3b.qingstor.com/release/%s/bin/linux/%s/kubeadm", kubeadm.Version, kubeadm.Arch)
|
||||
kubelet.Url = fmt.Sprintf("https://kubernetes-release.pek3b.qingstor.com/release/%s/bin/linux/%s/kubelet", kubelet.Version, kubelet.Arch)
|
||||
kubectl.Url = fmt.Sprintf("https://kubernetes-release.pek3b.qingstor.com/release/%s/bin/linux/%s/kubectl", kubectl.Version, kubectl.Arch)
|
||||
kubecni.Url = fmt.Sprintf("https://containernetworking.pek3b.qingstor.com/plugins/releases/download/%s/cni-plugins-linux-%s-%s.tgz", kubecni.Version, kubecni.Arch, kubecni.Version)
|
||||
helm.Url = fmt.Sprintf("https://kubernetes-helm.pek3b.qingstor.com/linux-%s/%s/helm", helm.Arch, helm.Version)
|
||||
helm.GetCmd = fmt.Sprintf("curl -o %s %s", helm.Path, helm.Url)
|
||||
} else {
|
||||
kubeadm.Url = fmt.Sprintf("https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubeadm", kubeadm.Version, kubeadm.Arch)
|
||||
kubelet.Url = fmt.Sprintf("https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubelet", kubelet.Version, kubelet.Arch)
|
||||
kubectl.Url = fmt.Sprintf("https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/%s/kubectl", kubectl.Version, kubectl.Arch)
|
||||
kubecni.Url = fmt.Sprintf("https://github.com/containernetworking/plugins/releases/download/%s/cni-plugins-linux-%s-%s.tgz", kubecni.Version, kubecni.Arch, kubecni.Version)
|
||||
helm.Url = fmt.Sprintf("https://get.helm.sh/helm-%s-linux-%s.tar.gz", helm.Version, helm.Arch)
|
||||
helm.GetCmd = fmt.Sprintf("curl -o %s/helm-%s-linux-%s.tar.gz %s && cd %s && tar -zxf helm-%s-linux-%s.tar.gz && mv linux-%s/helm . && rm -rf *linux-%s*", filepath, helm.Version, helm.Arch, helm.Url, filepath, helm.Version, helm.Arch, helm.Arch, helm.Arch)
|
||||
}
|
||||
|
||||
binaries := []files.KubeBinary{kubeadm, kubelet, kubectl, kubecni, helm}
|
||||
kubeadm.GetCmd = fmt.Sprintf("curl -L -o %s %s", kubeadm.Path, kubeadm.Url)
|
||||
kubelet.GetCmd = fmt.Sprintf("curl -L -o %s %s", kubelet.Path, kubelet.Url)
|
||||
kubectl.GetCmd = fmt.Sprintf("curl -L -o %s %s", kubectl.Path, kubectl.Url)
|
||||
kubecni.GetCmd = fmt.Sprintf("curl -L -o %s %s", kubecni.Path, kubecni.Url)
|
||||
|
||||
binaries := []files.KubeBinary{kubeadm, kubelet, kubectl, helm, kubecni}
|
||||
|
||||
for _, binary := range binaries {
|
||||
mgr.Logger.Infoln(fmt.Sprintf("Downloading %s ...", binary.Name))
|
||||
|
|
@ -62,7 +72,7 @@ func FilesDownloadHttp(mgr *manager.Manager, filepath, version, arch string) err
|
|||
for i := 5; i > 0; i-- {
|
||||
if output, err := exec.Command("/bin/sh", "-c", binary.GetCmd).CombinedOutput(); err != nil {
|
||||
fmt.Println(string(output))
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to download %s binary", binary.Name))
|
||||
return errors.New(fmt.Sprintf("Failed to download %s binary: %s", binary.Name, binary.GetCmd))
|
||||
}
|
||||
|
||||
if err := SHA256Check(binary, version); err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue