From a63889ed3ccbf63798873875306e6132c1547191 Mon Sep 17 00:00:00 2001 From: sophon Date: Tue, 30 May 2023 19:35:46 +0800 Subject: [PATCH 01/44] feat: support create kubernetes cluster (#3459) --- Makefile | 18 +- go.mod | 52 +++- go.sum | 278 ++++++++++++++---- internal/cli/cmd/cli.go | 3 + internal/cli/cmd/infrastructure/create.go | 252 ++++++++++++++++ internal/cli/cmd/infrastructure/infras.go | 35 +++ .../cli/cmd/infrastructure/infras_test.go | 46 +++ internal/cli/cmd/infrastructure/kubernetes.go | 81 +++++ .../cli/cmd/infrastructure/loader_adapter.go | 113 +++++++ .../cmd/infrastructure/loader_adapter_test.go | 74 +++++ internal/cli/cmd/infrastructure/suit_test.go | 32 ++ .../cli/cmd/infrastructure/tasks/module.go | 104 +++++++ .../cli/cmd/infrastructure/tasks/prepare.go | 47 +++ .../cli/cmd/infrastructure/tasks/tasks.go | 131 +++++++++ .../template/kubekey_cluster_template.tpl | 69 +++++ internal/cli/cmd/infrastructure/type.go | 44 +++ .../template/kubekey_cluster_template.cue | 71 +++++ 17 files changed, 1369 insertions(+), 81 deletions(-) create mode 100644 internal/cli/cmd/infrastructure/create.go create mode 100644 internal/cli/cmd/infrastructure/infras.go create mode 100644 internal/cli/cmd/infrastructure/infras_test.go create mode 100644 internal/cli/cmd/infrastructure/kubernetes.go create mode 100644 internal/cli/cmd/infrastructure/loader_adapter.go create mode 100644 internal/cli/cmd/infrastructure/loader_adapter_test.go create mode 100644 internal/cli/cmd/infrastructure/suit_test.go create mode 100644 internal/cli/cmd/infrastructure/tasks/module.go create mode 100644 internal/cli/cmd/infrastructure/tasks/prepare.go create mode 100644 internal/cli/cmd/infrastructure/tasks/tasks.go create mode 100644 internal/cli/cmd/infrastructure/template/kubekey_cluster_template.tpl create mode 100644 internal/cli/cmd/infrastructure/type.go create mode 100644 internal/cli/create/template/kubekey_cluster_template.cue diff --git a/Makefile b/Makefile index ef804b6c3ca..d55292ac2dd 100644 --- a/Makefile +++ b/Makefile @@ -67,6 +67,8 @@ LD_FLAGS="-s -w -X main.version=v${VERSION} -X main.buildDate=`date -u +'%Y-%m-% local : ARCH ?= $(shell go env GOOS)-$(shell go env GOARCH) ARCH ?= linux-amd64 +# build tags +BUILD_TAGS="containers_image_openpgp" TAG_LATEST ?= false @@ -160,7 +162,7 @@ fmt: ## Run go fmt against code. .PHONY: vet vet: ## Run go vet against code. - GOOS=$(GOOS) $(GO) vet -mod=mod ./... + GOOS=$(GOOS) $(GO) vet -tags $(BUILD_TAGS) -mod=mod ./... .PHONY: cue-fmt cue-fmt: cuetool ## Run cue fmt against code. @@ -265,7 +267,7 @@ CLI_LD_FLAGS ="-s -w \ -X github.com/apecloud/kubeblocks/version.DefaultKubeBlocksVersion=$(VERSION)" bin/kbcli.%: test-go-generate ## Cross build bin/kbcli.$(OS).$(ARCH). - GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) CGO_ENABLED=0 $(GO) build -ldflags=${CLI_LD_FLAGS} -o $@ cmd/cli/main.go + GOOS=$(word 2,$(subst ., ,$@)) GOARCH=$(word 3,$(subst ., ,$@)) CGO_ENABLED=0 $(GO) build -tags $(BUILD_TAGS) -ldflags=${CLI_LD_FLAGS} -o $@ cmd/cli/main.go .PHONY: kbcli-fast kbcli-fast: OS=$(shell $(GO) env GOOS) @@ -296,7 +298,7 @@ api-doc: ## generate API reference manual. .PHONY: manager manager: cue-fmt generate manager-go-generate test-go-generate build-checks ## Build manager binary. - $(GO) build -ldflags=${LD_FLAGS} -o bin/manager ./cmd/manager/main.go + $(GO) build -tags $(BUILD_TAGS) -ldflags=${LD_FLAGS} -o bin/manager ./cmd/manager/main.go CERT_ROOT_CA ?= $(WEBHOOK_CERT_DIR)/rootCA.key .PHONY: webhook-cert @@ -331,26 +333,26 @@ endif .PHONY: install install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. - ($(KUSTOMIZE) build config/crd | kubectl replace -f -) || ($(KUSTOMIZE) build config/crd | kubectl create -f -) + ($(KUSTOMIZE) build -tags $(BUILD_TAGS) config/crd | kubectl replace -f -) || ($(KUSTOMIZE) build config/crd | kubectl create -f -) .PHONY: uninstall uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. - $(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f - + $(KUSTOMIZE) build -tags $(BUILD_TAGS) config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f - .PHONY: deploy deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} - $(KUSTOMIZE) build config/default | kubectl apply -f - + $(KUSTOMIZE) build -tags $(BUILD_TAGS) config/default | kubectl apply -f - .PHONY: dry-run dry-run: manifests kustomize ## Dry-run deploy job. cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} mkdir -p dry-run - $(KUSTOMIZE) build config/default > dry-run/manifests.yaml + $(KUSTOMIZE) build -tags $(BUILD_TAGS) config/default > dry-run/manifests.yaml .PHONY: undeploy undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. - $(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f - + $(KUSTOMIZE) build -tags $(BUILD_TAGS) config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f - ##@ Contributor diff --git a/go.mod b/go.mod index d9ebb470544..3855dd4560d 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/dapr/kit v0.0.3 github.com/docker/cli v20.10.24+incompatible github.com/docker/docker v20.10.24+incompatible - github.com/docker/go-connections v0.4.0 + github.com/docker/go-connections v0.4.1-0.20190612165340-fd1b1942c4d5 github.com/evanphx/json-patch v5.6.0+incompatible github.com/fatih/color v1.14.1 github.com/fsnotify/fsnotify v1.6.0 @@ -47,6 +47,7 @@ require ( github.com/k3d-io/k3d/v5 v5.4.4 github.com/kubernetes-csi/external-snapshotter/client/v3 v3.0.0 github.com/kubernetes-csi/external-snapshotter/client/v6 v6.2.0 + github.com/kubesphere/kubekey/v3 v3.0.7 github.com/leaanthony/debme v1.2.1 github.com/manifoldco/promptui v0.9.0 github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 @@ -126,6 +127,8 @@ require ( github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect + github.com/VividCortex/ewma v1.2.0 // indirect + github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect github.com/acomagu/bufpipe v1.0.3 // indirect github.com/ahmetalpbalkan/go-cursor v0.0.0-20131010032410-8136607ea412 // indirect github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a // indirect @@ -133,6 +136,7 @@ require ( github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect github.com/benbjohnson/clock v1.3.0 // indirect + github.com/aws/aws-sdk-go v1.44.180 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bhmj/xpression v0.9.1 // indirect @@ -153,9 +157,12 @@ require ( github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/cyberphone/json-canonicalization v0.0.0-20220623050100-57a0ce2678a7 // indirect github.com/cyphar/filepath-securejoin v0.2.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/daviddengcn/go-colortext v1.0.0 // indirect + github.com/deckarep/golang-set v1.8.0 // indirect + github.com/deislabs/oras v0.9.0 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dimchansky/utfbom v1.1.1 // indirect github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2 // indirect @@ -171,6 +178,7 @@ require ( github.com/emicklei/go-restful/v3 v3.9.0 // indirect github.com/emicklei/proto v1.6.15 // indirect github.com/emirpasic/gods v1.18.1 // indirect + github.com/estesp/manifest-tool/v2 v2.0.3 // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect github.com/fasthttp/router v1.4.12 // indirect @@ -185,11 +193,19 @@ require ( github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect + github.com/go-openapi/analysis v0.21.4 // indirect + github.com/go-openapi/errors v0.20.3 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.1 // indirect + github.com/go-openapi/loads v0.21.2 // indirect + github.com/go-openapi/runtime v0.24.1 // indirect + github.com/go-openapi/spec v0.20.7 // indirect + github.com/go-openapi/strfmt v0.21.3 // indirect github.com/go-openapi/swag v0.22.3 // indirect + github.com/go-openapi/validate v0.22.0 // indirect github.com/go-redis/redis/v7 v7.4.1 // indirect - github.com/go-test/deep v1.0.8 // indirect + github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect + github.com/go-test/deep v1.1.0 // indirect github.com/gobwas/glob v0.2.3 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -202,6 +218,7 @@ require ( github.com/google/btree v1.0.1 // indirect github.com/google/cel-go v0.12.6 // indirect github.com/google/gnostic v0.6.9 // indirect + github.com/google/go-containerregistry v0.12.1 // indirect github.com/google/go-intervals v0.0.2 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect @@ -217,17 +234,16 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-getter v1.7.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect - github.com/hashicorp/go-uuid v1.0.2 // indirect + github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/terraform-json v0.15.0 // indirect - github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect github.com/huandu/xstrings v1.3.3 // indirect github.com/imdario/mergo v0.3.13 // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect @@ -240,18 +256,22 @@ require ( github.com/jcmturner/gofork v1.0.0 // indirect github.com/jcmturner/gokrb5/v8 v8.4.2 // indirect github.com/jcmturner/rpc/v2 v2.0.3 // indirect - github.com/jhump/protoreflect v1.13.0 // indirect + github.com/jhump/protoreflect v1.14.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmoiron/sqlx v1.3.5 // indirect - github.com/jonboulle/clockwork v0.2.2 // indirect + github.com/jonboulle/clockwork v0.3.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/klauspost/compress v1.15.15 // indirect github.com/klauspost/pgzip v1.2.6-0.20220930104621-17e8dac29df8 // indirect github.com/kopia/kopia v0.10.7 // indirect + github.com/kr/fs v0.1.0 // indirect github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect + github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible // indirect + github.com/lestrrat-go/strftime v1.0.5 // indirect + github.com/letsencrypt/boulder v0.0.0-20221109233200-85aa52084eaf // indirect github.com/lib/pq v1.10.7 // indirect github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect github.com/lithammer/dedent v1.1.0 // indirect @@ -280,6 +300,7 @@ require ( github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/modood/table v0.0.0-20220527013332-8d47e76dad33 // indirect github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect github.com/morikuni/aec v1.0.0 // indirect @@ -287,6 +308,7 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d // indirect + github.com/oklog/ulid v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/runc v1.1.5 // indirect github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect @@ -297,7 +319,9 @@ require ( github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pierrec/lz4 v2.6.1+incompatible // indirect github.com/pjbgf/sha1cd v0.2.3 // indirect + github.com/pkg/sftp v1.13.5 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect + github.com/proglottis/gpgme v0.1.3 // indirect github.com/prometheus/client_golang v1.14.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.37.0 // indirect @@ -305,6 +329,7 @@ require ( github.com/prometheus/statsd_exporter v0.22.3 // indirect github.com/protocolbuffers/txtpbfmt v0.0.0-20201118171849-f6a6b3f636fc // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect + github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 // indirect github.com/rivo/uniseg v0.4.3 // indirect github.com/robfig/cron/v3 v3.0.1 // indirect github.com/rubenv/sql-migrate v1.2.0 // indirect @@ -312,18 +337,24 @@ require ( github.com/segmentio/ksuid v1.0.4 // indirect github.com/sergi/go-diff v1.2.0 // indirect github.com/shopspring/decimal v1.2.0 // indirect + github.com/sigstore/fulcio v1.0.0 // indirect + github.com/sigstore/rekor v1.0.1 // indirect + github.com/sigstore/sigstore v1.5.1 // indirect github.com/skeema/knownhosts v1.1.0 // indirect github.com/soheilhy/cmux v0.1.5 // indirect github.com/sony/gobreaker v0.4.2-0.20210216022020-dd874f9dd33b // indirect github.com/spf13/afero v1.9.3 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980 // indirect github.com/stoewer/go-strcase v1.2.0 // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/subosito/gotenv v1.4.2 // indirect github.com/sylabs/sif/v2 v2.9.0 // indirect github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect github.com/tchap/go-patricia v2.3.0+incompatible // indirect + github.com/theupdateframework/go-tuf v0.5.2-0.20221207161717-9cb61d6e65f5 // indirect github.com/theupdateframework/notary v0.7.0 // indirect + github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect github.com/tj/go-spin v1.1.0 // indirect github.com/tklauser/go-sysconf v0.3.11 // indirect github.com/tklauser/numcpus v0.6.0 // indirect @@ -331,6 +362,7 @@ require ( github.com/ulikunitz/xz v0.5.11 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/vbatts/tar-split v0.11.2 // indirect + github.com/vbauerster/mpb/v7 v7.5.3 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/stringprep v1.0.3 // indirect @@ -348,6 +380,7 @@ require ( go.etcd.io/etcd/client/v2 v2.305.6 // indirect go.etcd.io/etcd/pkg/v3 v3.5.6 // indirect go.etcd.io/etcd/raft/v3 v3.5.6 // indirect + go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.35.0 // indirect go.opentelemetry.io/otel v1.12.0 // indirect @@ -376,9 +409,10 @@ require ( google.golang.org/genproto v0.0.0-20230104163317-caabf589fcbf // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect + gopkg.in/square/go-jose.v2 v2.6.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6 // indirect + inet.af/netaddr v0.0.0-20220617031823-097006376321 // indirect k8s.io/apiserver v0.26.1 // indirect k8s.io/component-helpers v0.26.0 // indirect oras.land/oras-go v1.2.2 // indirect @@ -390,6 +424,8 @@ require ( ) replace ( + github.com/docker/distribution => github.com/docker/distribution v2.8.2+incompatible + github.com/docker/docker => github.com/moby/moby v20.10.14+incompatible github.com/spf13/afero => github.com/spf13/afero v1.2.2 go.opentelemetry.io/otel => go.opentelemetry.io/otel v1.10.0 go.opentelemetry.io/otel/trace => go.opentelemetry.io/otel/trace v1.10.0 diff --git a/go.sum b/go.sum index bad490f78ea..51802bf7026 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,5 @@ bazil.org/fuse v0.0.0-20160811212531-371fbbdaa898/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8= +bitbucket.org/creachadair/shell v0.0.7 h1:Z96pB6DkSb7F3Y3BBnJeOZH2gazyMTWlvecSD4vDqfk= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -196,8 +197,7 @@ github.com/14rcole/gopopulate v0.0.0-20180821133914-b175b219e774 h1:SCbEWT58NSt7 github.com/AdhityaRamadhanus/fasthttpcors v0.0.0-20170121111917-d4c07198763a h1:XVdatQFSP2YhJGjqLLIfW8QBk4loz/SCe/PxkXDiW+s= github.com/AdhityaRamadhanus/fasthttpcors v0.0.0-20170121111917-d4c07198763a/go.mod h1:C0A1KeiVHs+trY6gUTPhhGammbrZ30ZfXRW/nuT7HLw= github.com/Azure/azure-pipeline-go v0.2.3 h1:7U9HBg1JFK3jHl5qmo4CTZKFTVgMwdFHMVtCdfBE21U= -github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/azure-sdk-for-go v65.0.0+incompatible h1:HzKLt3kIwMm4KeJYTdx9EbjRYTySD/t8i1Ee/W5EGXw= +github.com/Azure/azure-sdk-for-go v67.3.0+incompatible h1:QEvenaO+Y9ShPeCWsSAtolzVUcb0T0tPeek5TDsovuM= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.3 h1:8LoU8N2lIUzkmstvwXvVfniMZlFbesfT2AmA1aqvRr8= github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0 h1:Px2UA+2RvSSvv+RvJNuUB6n7rs5Wsel4dXLe90Um2n4= @@ -205,20 +205,19 @@ github.com/Azure/azure-storage-blob-go v0.14.0 h1:1BCg74AmVdYwO3dlKwtFU1V0wU2PZd github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/Azure/go-autorest v10.8.1+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest v0.9.6/go.mod h1:/FALq9T/kS7b5J5qsQ+RSTUdAmGFqi0vUdVNNx8q630= github.com/Azure/go-autorest/autorest v0.11.1/go.mod h1:JFgpikqFJ/MleTTxwepExTKnFUKKszPS8UavbQYUMuw= -github.com/Azure/go-autorest/autorest v0.11.27 h1:F3R3q42aWytozkV8ihzcgMO4OA4cuqr3bNlsEuF6//A= +github.com/Azure/go-autorest/autorest v0.11.28 h1:ndAExarwr5Y+GaHE6VCaY1kyS/HwwGGyuimVhWsHOEM= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= github.com/Azure/go-autorest/autorest/adal v0.8.2/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= github.com/Azure/go-autorest/autorest/adal v0.9.0/go.mod h1:/c022QCutn2P7uY+/oQWWNcK9YU+MH96NgK+jErpbcg= github.com/Azure/go-autorest/autorest/adal v0.9.5/go.mod h1:B7KF7jKIeC9Mct5spmyCB/A8CG/sEz1vwIRGv/bbw7A= -github.com/Azure/go-autorest/autorest/adal v0.9.18 h1:kLnPsRjzZZUF3K5REu/Kc+qMQrvuza2bwSnNdhmzLfQ= +github.com/Azure/go-autorest/autorest/adal v0.9.21 h1:jjQnVFXPfekaqb8vIsv2G1lxshoW+oGv4MDlhRtnYZk= github.com/Azure/go-autorest/autorest/azure/auth v0.5.11 h1:P6bYXFoao05z5uhOQzbC3Qd8JqF3jUoocoTeIxkp2cA= -github.com/Azure/go-autorest/autorest/azure/cli v0.4.5 h1:0W/yGmFdTIT77fvdlGZ0LMISoLHFJ7Tx4U0yeB+uFs4= +github.com/Azure/go-autorest/autorest/azure/cli v0.4.6 h1:w77/uPk80ZET2F+AfQExZyEWtn+0Rk/uw17m9fv5Ajc= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= @@ -292,13 +291,16 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs= -github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= github.com/Shopify/sarama v1.30.0 h1:TOZL6r37xJBDEMLx4yjB77jxbZYXPaDow08TSK6vIL0= github.com/Shopify/sarama v1.30.0/go.mod h1:zujlQQx1kzHsh4jfV1USnptCQrHAEZ2Hk8fTKCulPVs= github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae h1:ePgznFqEG1v3AjMklnK8H7BSc++FDSo7xfK9K7Af+0Y= github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae/go.mod h1:/cvHQkZ1fst0EmZnA5dFtiQdWCNCFYzb+uE2vqVgvx0= github.com/StudioSol/set v1.0.0 h1:G27J71la+Da08WidabBkoRrvPLTa4cdCn0RjvyJ5WKQ= github.com/StudioSol/set v1.0.0/go.mod h1:hIUNZPo6rEGF43RlPXHq7Fjmf+HkVJBqAjtK7Z9LoIU= +github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow= +github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4= +github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= +github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agrea/ptr v0.0.0-20180711073057-77a518d99b7b h1:WMhlIaJkDgEQSVJQM06YV+cYUl1r5OY5//ijMXJNqtA= @@ -329,24 +331,25 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/authzed/controller-idioms v0.7.0 h1:HhNMUBb8hJzYqY3mhen3B2AC5nsIem3fBe0tC/AAOHo= github.com/authzed/controller-idioms v0.7.0/go.mod h1:0B/PmqCguKv8b3azSMF+HdyKpKr2o3UAZ5eo12Ze8Fo= -github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= -github.com/aws/aws-sdk-go v1.44.122 h1:p6mw01WBaNpbdP2xrisz5tIkcNwzj/HysobNoaAHjgo= github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= +github.com/aws/aws-sdk-go v1.44.180 h1:VLZuAHI9fa/3WME5JjpVjcPCNfpGHVMiHx8sLHWhMgI= +github.com/aws/aws-sdk-go v1.44.180/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20150223135152-b965b613227f/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= +github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bhmj/jsonslice v1.1.2 h1:Lzen2S9iG3HsESpiIAnTM7Obs1QiTz83ZXa5YrpTTWI= github.com/bhmj/jsonslice v1.1.2/go.mod h1:O3ZoA0zdEefdbk1dkU5aWPOA36zQhhS/HV6RQFLTlnU= @@ -364,19 +367,16 @@ github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2y github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/briandowns/spinner v1.23.0 h1:alDF2guRWqa/FOZZYWjlMIx2L6H0wyewPxo/CH4Pt2A= github.com/briandowns/spinner v1.23.0/go.mod h1:rPG4gmXeN3wQV/TsAY4w8lPdIM6RX3yqeBQJSrbXjuE= -github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= -github.com/bshuster-repo/logrus-logstash-hook v1.0.0 h1:e+C0SB5R1pu//O4MQ3f9cFuPGoOVeF2fE4Og9otCc70= +github.com/bshuster-repo/logrus-logstash-hook v1.0.2 h1:JYRWo+QGnQdedgshosug9hxpPYTB9oJ1ZZD3fY31alU= github.com/bsm/ginkgo/v2 v2.5.0 h1:aOAnND1T40wEdAtkGSkvSICWeQ8L3UASX7YVCqQx+eQ= github.com/bsm/gomega v1.20.0 h1:JhAwLmtRzXFTx2AkALSLa8ijZafntmhSoU63Ok18Uq8= github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= -github.com/bugsnag/bugsnag-go v1.0.5-0.20150529004307-13fd6b8acda0 h1:s7+5BfS4WFJoVF9pnB8kBk03S7pZXRdKamnV0FOl5Sc= github.com/bugsnag/bugsnag-go v1.0.5-0.20150529004307-13fd6b8acda0/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= -github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b h1:otBG+dV+YK+Soembjv71DPz3uX/V/6MMlSyD9JBQ6kQ= +github.com/bugsnag/bugsnag-go v2.1.2+incompatible h1:E7dor84qzwUO8KdCM68CZwq9QOSR7HXlLx3Wj5vui2s= github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50= -github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXer/kZD8Ri1aaunCxIEsOst1BVJswV0o= github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= +github.com/bugsnag/panicwrap v1.3.4 h1:A6sXFtDGsgU/4BLf5JT0o5uYg3EeKgGx3Sfs+/uk3pU= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/bxcodec/faker v2.0.1+incompatible h1:P0KUpUw5w6WJXwrPfv35oc91i4d8nf40Nwln+M/+faA= github.com/c9s/goprocinfo v0.0.0-20170724085704-0010a05ce49f h1:tRk+aBit+q3oqnj/1mF5HHhP2yxJM2lSa0afOJxQ3nE= @@ -388,6 +388,7 @@ github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInq github.com/cenkalti/backoff/v4 v4.2.0 h1:HN5dHm3WBOgndBH6E8V0q2jIYIR3s9yglV8k/+MN3u4= github.com/cenkalti/backoff/v4 v4.2.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/census-instrumentation/opencensus-proto v0.3.0 h1:t/LhUZLVitR1Ow2YOnduCsavhwFUklBMoGVYUCqmCqk= github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054 h1:uH66TXeswKn5PW5zdZ39xEwfS9an067BirqA+P4QaLI= github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= @@ -431,12 +432,14 @@ github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUK github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4 h1:hzAQntlaYRkVSFEfj9OTWlVV1H155FMD8BTKktLv0QI= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490 h1:KwaoQzs/WeUxxJqiJsZ4euOly1Az/IgZXXSxlD/UBNk= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd/v2 v2.0.1 h1:y1Rh3tEU89D+7Tgbw+lp52T6p/GJLpDmNvr10UWqLTE= github.com/cockroachdb/apd/v2 v2.0.1/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= @@ -576,6 +579,8 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/cyberphone/json-canonicalization v0.0.0-20220623050100-57a0ce2678a7 h1:vU+EP9ZuFUCYE0NYLwTSob+3LNEJATzNfP/DC7SWGWI= +github.com/cyberphone/json-canonicalization v0.0.0-20220623050100-57a0ce2678a7/go.mod h1:uzvlm1mxhHkdfqitSA92i7Se+S9ksOn3a3qmv/kyOCw= github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/cyphar/filepath-securejoin v0.2.3 h1:YX6ebbZCZP7VkM3scTTokDgBL2TY741X51MTk3ycuNI= github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= @@ -596,10 +601,12 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/daviddengcn/go-colortext v1.0.0 h1:ANqDyC0ys6qCSvuEK7l3g5RaehL/Xck9EX8ATG8oKsE= github.com/daviddengcn/go-colortext v1.0.0/go.mod h1:zDqEI5NVUop5QPpVJUxE9UO10hRnmkD5G4Pmri9+m4c= +github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= +github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= +github.com/deislabs/oras v0.9.0 h1:R6PRN3bTruUjHcGKgdteurzbpsCxwf3XJCLsxLFyBuU= +github.com/deislabs/oras v0.9.0/go.mod h1:QXnMi3+eEm/rkgGT6L+Lt0TT2WLA7pOzuk7tZIsUhFM= github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/denisenkom/go-mssqldb v0.9.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= -github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= -github.com/dgrijalva/jwt-go v0.0.0-20170104182250-a601269ab70c/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= @@ -608,25 +615,20 @@ github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE= github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2 h1:aBfCb7iqHmDEIp6fBvC/hQUddQfg+3qdYjwzaiP9Hnc= github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2/go.mod h1:WHNsWjnIn2V1LYOrME7e8KxSeKunYHsxEm4am0BUtcI= -github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= github.com/docker/cli v0.0.0-20191017083524-a8ff7f821017/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v20.10.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/cli v20.10.24+incompatible h1:vfV+1kv9yD0/cpL6wWY9cE+Y9J8hL/NqJDGob0B3RVw= github.com/docker/cli v20.10.24+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY= -github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/docker v20.10.24+incompatible h1:Ugvxm7a8+Gz6vqQYQQ2W7GYq5EUPaAiuPgIfVyI3dYE= -github.com/docker/docker v20.10.24+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.6.3/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y= github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c/go.mod h1:CADgU4DSXK5QUlFslkQu2yW2TKzFZcXq/leZfM0UH5Q= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-connections v0.4.1-0.20190612165340-fd1b1942c4d5 h1:2o8D0hdBky229bNnc7a8bAZkeVMpH4qsp2Rmt4g/+Zk= +github.com/docker/go-connections v0.4.1-0.20190612165340-fd1b1942c4d5/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-events v0.0.0-20170721190031-9461782956ad/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ+oDZB4KHQFypsfjYlq/C4rfL7D3g8= github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= @@ -636,7 +638,6 @@ github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHz github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= @@ -671,9 +672,13 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1 h1:xvqufLtNVwAhN8NMyWklVgxnWohi+wtMGQMhtxexlm0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v0.6.2 h1:JiO+kJTpmYGjEodY7O1Zk8oZcNz1+f30UtwtXoFUPzE= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= +github.com/estesp/manifest-tool/v2 v2.0.3 h1:F9HMOqcXvtW+8drQB+BjNRU/+bLXOwCfj3mbjqQC2Ns= +github.com/estesp/manifest-tool/v2 v2.0.3/go.mod h1:Suh+tbKQvKHcs4Vltzy8gwZk1y9eSRI635gT4gFw5Ss= github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ= github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= @@ -682,6 +687,9 @@ github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJ github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d h1:105gxyaGwCFad8crR9dcMQWvV9Hvulu6hwUh4tWPJnM= github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4= +github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a h1:yDWHCSQ40h88yih2JAcL6Ls/kVkSE8GFACTGVnMPruw= +github.com/facebookgo/limitgroup v0.0.0-20150612190941-6abd8d71ec01 h1:IeaD1VDVBPlx3viJT9Md8if8IxxJnO+x0JCGb054heg= +github.com/facebookgo/muster v0.0.0-20150708232844-fd3d7953fd52 h1:a4DFiKFJiDRGFD1qIcqGLX/WlUMD9dyLSLDt+9QZgt8= github.com/fasthttp/router v1.4.12 h1:QEgK+UKARaC1bAzJgnIhdUMay6nwp+YFq6VGPlyKN1o= github.com/fasthttp/router v1.4.12/go.mod h1:41Qdc4Z4T2pWVVtATHCnoUnOtxdBoeKEYJTXhHwbxCQ= github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8= @@ -704,9 +712,10 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA= +github.com/fullstorydev/grpcurl v1.8.6 h1:WylAwnPauJIofYSHqqMTC1eEfUIzqzevXyogBxnQquo= github.com/fvbommel/sortorder v1.0.2 h1:mV4o8B2hKboCdkJm+a7uX/SIpZob4JzUpc5GGnM45eo= github.com/fvbommel/sortorder v1.0.2/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0= -github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= +github.com/garyburd/redigo v1.6.3 h1:HCeeRluvAgMusMomi1+6Y5dmFOdYV/JzoRrrbFlkGIc= github.com/getsentry/raven-go v0.2.0 h1:no+xWJRb5ZI7eE8TWgIq1jLulQiIoLG0IfYxv5JYMGs= github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -734,7 +743,6 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gorp/gorp/v3 v3.0.2 h1:ULqJXIekoqMx29FI5ekXXFoH1dT2Vc8UhnRzBg+Emz4= github.com/go-gorp/gorp/v3 v3.0.2/go.mod h1:BJ3q1ejpV8cVALtcXvXaXyTOlMmJhWDxTmncaR6rwBY= -github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= @@ -757,23 +765,53 @@ github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A= github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-openapi/analysis v0.21.2/go.mod h1:HZwRk4RRisyG8vx2Oe6aqeSQcoxRp47Xkp3+K6q+LdY= +github.com/go-openapi/analysis v0.21.4 h1:ZDFLvSNxpDaomuCueM0BlSXxpANBlFYiBvr+GXrvIHc= +github.com/go-openapi/analysis v0.21.4/go.mod h1:4zQ35W4neeZTqh3ol0rv/O8JBbka9QyAgQRPp9y3pfo= +github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= +github.com/go-openapi/errors v0.19.9/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= +github.com/go-openapi/errors v0.20.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= +github.com/go-openapi/errors v0.20.3 h1:rz6kiC84sqNQoqrtulzaL/VERgkoCyB6WdEkc2ujzUc= +github.com/go-openapi/errors v0.20.3/go.mod h1:Z3FlZ4I8jEGxjUK+bugx3on2mIAk4txuAOhlsB1FSgk= github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= +github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= +github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= github.com/go-openapi/jsonreference v0.20.1 h1:FBLnyygC4/IZZr893oiomc9XaghoveYTrLC1F86HID8= github.com/go-openapi/jsonreference v0.20.1/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/loads v0.21.1/go.mod h1:/DtAMXXneXFjbQMGEtbamCZb+4x7eGwkvZCvBmwUG+g= +github.com/go-openapi/loads v0.21.2 h1:r2a/xFIYeZ4Qd2TnGpWDIQNcP80dIaZgf704za8enro= +github.com/go-openapi/loads v0.21.2/go.mod h1:Jq58Os6SSGz0rzh62ptiu8Z31I+OTHqmULx5e/gJbNw= +github.com/go-openapi/runtime v0.24.1 h1:Sml5cgQKGYQHF+M7yYSHaH1eOjvTykrddTE/KtQVjqo= +github.com/go-openapi/runtime v0.24.1/go.mod h1:AKurw9fNre+h3ELZfk6ILsfvPN+bvvlaU/M9q/r9hpk= github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= +github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= +github.com/go-openapi/spec v0.20.6/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= +github.com/go-openapi/spec v0.20.7 h1:1Rlu/ZrOCCob0n+JKKJAWhNWMPW8bOZRg8FJaY+0SKI= +github.com/go-openapi/spec v0.20.7/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= +github.com/go-openapi/strfmt v0.21.0/go.mod h1:ZRQ409bWMj+SOgXofQAGTIo2Ebu72Gs+WaRADcS5iNg= +github.com/go-openapi/strfmt v0.21.1/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k= +github.com/go-openapi/strfmt v0.21.2/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k= +github.com/go-openapi/strfmt v0.21.3 h1:xwhj5X6CjXEZZHMWy1zKJxvW9AfHC9pkyUjLvHtKG7o= +github.com/go-openapi/strfmt v0.21.3/go.mod h1:k+RzNO0Da+k3FrrynSNN8F7n/peCmQQqbbXjtDfvmGg= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/validate v0.21.0/go.mod h1:rjnrwK57VJ7A8xqfpAOEKRH8yQSGUriMu5/zuPSQ1hg= +github.com/go-openapi/validate v0.22.0 h1:b0QecH6VslW/TxtpKgzpO1SNG7GU2FsaqKdP1E2T50Y= +github.com/go-openapi/validate v0.22.0/go.mod h1:rjnrwK57VJ7A8xqfpAOEKRH8yQSGUriMu5/zuPSQ1hg= github.com/go-redis/redis/v7 v7.4.1 h1:PASvf36gyUpr2zdOUS/9Zqc80GbM+9BDyiJSJDDOrTI= github.com/go-redis/redis/v7 v7.4.1/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg= github.com/go-redis/redismock/v9 v9.0.2 h1:1X51FovN18M9GXBdbi5xWiXoFPXAijdLdvA7VrYjoVA= @@ -785,16 +823,41 @@ github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= -github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= +github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= +github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= +github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= +github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= +github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= +github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= +github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= +github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= +github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= +github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= +github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= +github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= +github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= +github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= +github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= github.com/gobuffalo/logger v1.0.6 h1:nnZNpxYo0zx+Aj9RfMPBm+x9zAU2OayFh/xrAWi34HU= github.com/gobuffalo/logger v1.0.6/go.mod h1:J31TBEHR1QLV2683OXTAItYIg8pv2JMHnF/quuAbMjs= +github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= github.com/gobuffalo/packd v1.0.1 h1:U2wXfRr4E9DH8IdsDLlRFwTZTK7hLfq9qT/QHXGVe/0= github.com/gobuffalo/packd v1.0.1/go.mod h1:PP2POP3p3RXGz7Jh6eYEf93S7vA2za6xM7QT85L4+VY= +github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= +github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/packr/v2 v2.8.3 h1:xE1yzvnO56cUC0sTpKR3DIbxZgB54AftTFMhB2XEWlY= github.com/gobuffalo/packr/v2 v2.8.3/go.mod h1:0SahksCVcx4IMnigTjiFuyldmTrdTctXsOdiU5KwbKc= +github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= @@ -807,6 +870,7 @@ github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godror/godror v0.24.2/go.mod h1:wZv/9vPiUib6tkoDl+AZ/QLf5YZgMravZ7jxH2eQWAE= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0= github.com/gogo/googleapis v1.2.0/go.mod h1:Njal3psf3qN6dwBtQfUmBZh2ybovJ0tlu3o/AC7HYjU= github.com/gogo/googleapis v1.4.0/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -878,8 +942,8 @@ github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= github.com/google/cel-go v0.12.6 h1:kjeKudqV0OygrAqA9fX6J55S8gj+Jre2tckIm5RoG4M= github.com/google/cel-go v0.12.6/go.mod h1:Jk7ljRzLBhkmiAwBoUxB1sZSCVBAzkqPF25olK/iRDw= -github.com/google/certificate-transparency-go v1.0.10-0.20180222191210-5ab67e519c93 h1:jc2UWq7CbdszqeH6qu1ougXMIUBfSy8Pbh/anURYbGI= github.com/google/certificate-transparency-go v1.0.10-0.20180222191210-5ab67e519c93/go.mod h1:QeJfpSbVSfYc7RgB3gJFj9cbuQMMchQxrWXz8Ruopmg= +github.com/google/certificate-transparency-go v1.1.3 h1:WEb38wcTe0EuAvg7USzgklnOjjnlMaahYO3faaqnCn8= github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0= github.com/google/gnostic v0.6.9/go.mod h1:Nm8234We1lq6iB9OmlgNv3nH91XLLVZHCDayfA3xq+E= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -899,6 +963,8 @@ github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-containerregistry v0.5.1/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0= +github.com/google/go-containerregistry v0.12.1 h1:W1mzdNUTx4Zla4JaixCRLhORcR7G6KxE5hHl5fkPsp8= +github.com/google/go-containerregistry v0.12.1/go.mod h1:sdIK+oHQO7B93xI8UweYdl887YhuIwg9vz8BSLH3+8k= github.com/google/go-intervals v0.0.2 h1:FGrVEiUnTRKR8yE04qzXYaJMtnIYqobR5QbblK3ixcM= github.com/google/go-intervals v0.0.2/go.mod h1:MkaR3LNRfeKLPmqgJYs4E66z5InYjmCjbbr4TQlcT6Y= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -929,6 +995,7 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLe github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= +github.com/google/trillian v1.5.0 h1:I5pIN18bKlXtlj1Tk919rQ3mWBU2BzNNR6JhLISGMB4= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -953,12 +1020,11 @@ github.com/googleapis/gax-go/v2 v2.7.0 h1:IcsPKeInNvYi7eqSaDjiZqDDKu5rsmunY0Y1Yu github.com/googleapis/gax-go/v2 v2.7.0/go.mod h1:TEop28CZZQ2y+c0VxMUmu1lV+fQx57QpBWsYpwqHJx8= github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg= github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= @@ -985,8 +1051,9 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 h1:BZHcxBETFHIdVyhyEfOvn/RdU/QGdLI4y34qQGjGWO0= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 h1:lLT7ZLSzGLI08vc9cpd+tYmNWjdKDqyr/2L+f6U12Fk= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= @@ -1009,7 +1076,7 @@ github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1: github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.4.3 h1:DXmvivbWD5qdiBts9TpBC7BYL1Aia5sxbRgQB+v6UZM= +github.com/hashicorp/go-plugin v1.4.6 h1:MDV3UrKQBM3du3G7MApDGvOsMYy3JQJ4exhSoKBAeVA= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= @@ -1017,8 +1084,9 @@ github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerX github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= +github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= @@ -1038,8 +1106,9 @@ github.com/hashicorp/terraform-exec v0.18.0 h1:BJa6/Fhxnb0zvsEGqUrFSybcnhAiBVSUg github.com/hashicorp/terraform-exec v0.18.0/go.mod h1:6PMRgg0Capig5Fn0zW9/+WM3vQsdwotwa8uxDVzLpHE= github.com/hashicorp/terraform-json v0.15.0 h1:/gIyNtR6SFw6h5yzlbDbACyGvIhKtQi8mTsbkNd79lE= github.com/hashicorp/terraform-json v0.15.0/go.mod h1:+L1RNzjDU5leLFZkHTFTbJXaoqUC6TqXlFgDoOXrtvk= -github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= -github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= +github.com/honeycombio/beeline-go v1.10.0 h1:cUDe555oqvw8oD76BQJ8alk7FP0JZ/M/zXpNvOEDLDc= +github.com/honeycombio/libhoney-go v1.16.0 h1:kPpqoz6vbOzgp7jC6SR7SkNj7rua7rgxvznI6M3KdHc= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= @@ -1089,26 +1158,27 @@ github.com/jhump/gopoet v0.0.0-20190322174617-17282ff210b3/go.mod h1:me9yfT6IJSl github.com/jhump/gopoet v0.1.0/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI= github.com/jhump/goprotoc v0.5.0/go.mod h1:VrbvcYrQOrTi3i0Vf+m+oqQWk9l72mjkJCYo7UvLHRQ= github.com/jhump/protoreflect v1.11.0/go.mod h1:U7aMIjN0NWq9swDP7xDdoMfRHb35uiuTd3Z9nFXJf5E= -github.com/jhump/protoreflect v1.13.0 h1:zrrZqa7JAc2YGgPSzZZkmUXJ5G6NRPdxOg/9t7ISImA= -github.com/jhump/protoreflect v1.13.0/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI= +github.com/jhump/protoreflect v1.14.0 h1:MBbQK392K3u8NTLbKOCIi3XdI+y+c6yt5oMq0X3xviw= +github.com/jhump/protoreflect v1.14.0/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI= github.com/jinzhu/gorm v0.0.0-20170222002820-5409931a1bb8 h1:CZkYfurY6KGhVtlalI4QwQ6T0Cu6iuY3e0x5RLu96WE= github.com/jinzhu/gorm v0.0.0-20170222002820-5409931a1bb8/go.mod h1:Vla75njaFJ8clLU1W44h34PjIkijhjHIYnZxMqCdxqo= github.com/jinzhu/inflection v0.0.0-20170102125226-1c35d901db3d h1:jRQLvyVGL+iVtDElaEIDdKwpPqUIZJfzkNLV34htpEc= github.com/jinzhu/inflection v0.0.0-20170102125226-1c35d901db3d/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/jmhodges/clock v0.0.0-20160418191101-880ee4c33548 h1:dYTbLf4m0a5u0KLmPfB6mgxbcV7588bOCx79hxa5Sr4= github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= +github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg= +github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= @@ -1120,12 +1190,16 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/k3d-io/k3d/v5 v5.4.4 h1:txQNPNhxuSDRU1+dN9wDjliQp9DslK76gVplqWjQDjg= github.com/k3d-io/k3d/v5 v5.4.4/go.mod h1:+eDAoEC4G3bJ4daG2h68kY+L4mCkV7GU4TTGXhfSk0c= +github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA= +github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= +github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw= github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= @@ -1153,6 +1227,8 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxv github.com/kopia/kopia v0.10.7 h1:6s0ZIZW3Ge2ozzefddASy7CIUadp/5tF9yCDKQfAKKI= github.com/kopia/kopia v0.10.7/go.mod h1:0d9THPD+jwomPcXvPbCdmLyX6phQVP7AqcCcDEajfNA= github.com/kortschak/utter v1.0.1/go.mod h1:vSmSjbyrlKjjsL71193LmzBOKgwePk9DH6uFaWHIInc= +github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -1169,6 +1245,8 @@ github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0 h1:nHHjmvjitIiyP github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0/go.mod h1:YBCo4DoEeDndqvAn6eeu0vWM7QdXmHEeI9cFWplmBys= github.com/kubernetes-csi/external-snapshotter/client/v6 v6.2.0 h1:cMM5AB37e9aRGjErygVT6EuBPB6s5a+l95OPERmSlVM= github.com/kubernetes-csi/external-snapshotter/client/v6 v6.2.0/go.mod h1:VQVLCPGDX5l6V5PezjlDXLa+SpCbWSVU7B16cFWVVeE= +github.com/kubesphere/kubekey/v3 v3.0.7 h1:yJn9F6ByGh2oBRYk68WkrNzCTOYEra5OtZz1NK/5KZk= +github.com/kubesphere/kubekey/v3 v3.0.7/go.mod h1:PyNlP30B6LSjpu2VUpbBbdqgk309gNojBBUh+1X6UiM= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= @@ -1180,6 +1258,14 @@ github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oO github.com/leaanthony/debme v1.2.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA= github.com/leaanthony/slicer v1.5.0 h1:aHYTN8xbCCLxJmkNKiLB6tgcMARl4eWmH9/F+S/0HtY= github.com/leaanthony/slicer v1.5.0/go.mod h1:FwrApmf8gOrpzEWM2J/9Lh79tyq8KTX5AzRtwV7m4AY= +github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8= +github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is= +github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkLibYKgg+SwmyFU9dF2hn6MdTj4= +github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA= +github.com/lestrrat-go/strftime v1.0.5 h1:A7H3tT8DhTz8u65w+JRpiBxM4dINQhUXAZnhBa2xeOE= +github.com/lestrrat-go/strftime v1.0.5/go.mod h1:E1nN3pCbtMSu1yjSVeyuRFVm/U0xoR76fd03sz+Qz4g= +github.com/letsencrypt/boulder v0.0.0-20221109233200-85aa52084eaf h1:ndns1qx/5dL43g16EQkPV/i8+b3l5bYQwLeoSBe7tS8= +github.com/letsencrypt/boulder v0.0.0-20221109233200-85aa52084eaf/go.mod h1:aGkAgvWY/IUcVFfuly53REpfv5edu25oij+qHRFaraA= github.com/lib/pq v0.0.0-20150723085316-0dad96c0b94f/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= @@ -1205,17 +1291,18 @@ github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= github.com/markbates/errx v1.1.0 h1:QDFeR+UP95dO12JgW+tgi2UVfo0V8YBHiUIOaeBPiEI= github.com/markbates/errx v1.1.0/go.mod h1:PLa46Oex9KNbVDZhKel8v1OT7hD5JZ2eI7AHhA0wswc= +github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= github.com/markbates/oncer v1.0.0 h1:E83IaVAHygyndzPimgUYJjbshhDTALZyXxvk9FOlQRY= github.com/markbates/oncer v1.0.0/go.mod h1:Z59JA581E9GP6w96jai+TGqafHPW+cPfRxz2aSZ0mcI= github.com/markbates/safe v1.0.1 h1:yjZkbvRM6IzKj9tlu/zMJLS0n/V351OZWRnF3QfaUxI= github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= -github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= @@ -1284,15 +1371,18 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu github.com/mitchellh/mapstructure v0.0.0-20150613213606-2caf8efc9366/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 h1:BpfhmLKZf+SjVanKKhCgf3bg+511DmU9eDQTen7LLbY= github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= +github.com/moby/moby v20.10.14+incompatible h1:J47P0p+O49F3au8QyE34dE/qXz571kcVmsbx8bvEuS0= +github.com/moby/moby v20.10.14+incompatible/go.mod h1:fDXVQ6+S340veQPv35CzDahGBmHsiclFwfEygB/TWMc= github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/moby/sys/mount v0.3.0 h1:bXZYMmq7DBQPwHRxH/MG+u9+XF90ZOwoXpHTOznMGp0= @@ -1313,6 +1403,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/modood/table v0.0.0-20220527013332-8d47e76dad33 h1:T5IbS9C1G2zeHb6eBy6OfIvj5tfQB23kGFpewCJuGDg= +github.com/modood/table v0.0.0-20220527013332-8d47e76dad33/go.mod h1:41qyXVI5QH9/ObyPj27CGCVau5v/njfc3Gjj7yzr0HQ= github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/2gBQ3RWajuToeY6ZtZTIKv2v7ThUy5KKusIT0yc0= github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= @@ -1330,16 +1422,17 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A= -github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d h1:x3S6kxmy49zXVVyhcnrFqxvNVCBPb2KZ9hV2RBdS840= github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= +github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= +github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v0.0.0-20151202141238-7f8ab55aaf3b/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -1372,7 +1465,6 @@ github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQ github.com/opencontainers/go-digest v1.0.0-rc1.0.20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= @@ -1401,18 +1493,21 @@ github.com/opencontainers/selinux v1.10.2 h1:NFy2xCsjn7+WspbfZkUd5zyVeisV7VFbPSP github.com/opencontainers/selinux v1.10.2/go.mod h1:cARutUbaUrlRClyvxOICCgKixCs6L05aUsohzA3EkHQ= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/openzipkin/zipkin-go v0.4.0 h1:CtfRrOVZtbDj8rt1WXjklw0kqqJQwICrCKmlfUuBUUw= github.com/openzipkin/zipkin-go v0.4.0/go.mod h1:4c3sLeE8xjNqehmF5RpAFLPLJxXscc0R4l6Zg0P1tTQ= github.com/ostreedev/ostree-go v0.0.0-20210805093236-719684c64e4f h1:/UDgs8FGMqwnHagNDPGOlts35QkhAZ8by3DR7nMih7M= github.com/ostreedev/ostree-go v0.0.0-20210805093236-719684c64e4f/go.mod h1:J6OG6YJVEWopen4avK3VNQSnALmmjvniMmni/YFYAwc= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= +github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI= github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= @@ -1425,6 +1520,8 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18= +github.com/pkg/sftp v1.13.5 h1:a3RLUqkyjYRtBTZJZ1VRrKbN3zhuPLlUc3sphVz81go= +github.com/pkg/sftp v1.13.5/go.mod h1:wHDZ0IZX6JcBYRK1TH9bcVq8G7TLpVHYIGJRFnmPfxg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= @@ -1434,7 +1531,8 @@ github.com/poy/onpar v0.0.0-20190519213022-ee068f8ea4d1 h1:oL4IBbcqwhhNWh31bjOX8 github.com/poy/onpar v0.0.0-20190519213022-ee068f8ea4d1/go.mod h1:nSbFQvMj97ZyhFRSJYtut+msi4sOY6zJDGCdSc+/rZU= github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= -github.com/prometheus/client_golang v0.0.0-20180209125602-c332b6f63c06/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/proglottis/gpgme v0.1.3 h1:Crxx0oz4LKB3QXc5Ea0J19K/3ICfy3ftr5exgUK1AU0= +github.com/proglottis/gpgme v0.1.3/go.mod h1:fPbW/EZ0LvwQtH8Hy7eixhp1eF3G39dtx7GUN+0Gmy0= github.com/prometheus/client_golang v0.9.0-pre1.0.20180209125602-c332b6f63c06/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= @@ -1494,6 +1592,8 @@ github.com/replicatedhq/termui/v3 v3.1.1-0.20200811145416-f40076d26851 h1:eRlNDH github.com/replicatedhq/termui/v3 v3.1.1-0.20200811145416-f40076d26851/go.mod h1:JDxG6+uubnk9/BZ2yUsyAJJwlptjrnmB2MPF5d2Xe/8= github.com/replicatedhq/troubleshoot v0.57.0 h1:m9B31Mhgiz4Lwz+W4RvFkqhfYZLCwAqRPUwiwmSAAps= github.com/replicatedhq/troubleshoot v0.57.0/go.mod h1:R5VdixzaBXfWLbP9mcLuZKs/bDCyGGS4+vFtKGWs9xE= +github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo= +github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= @@ -1501,6 +1601,8 @@ github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= @@ -1536,10 +1638,17 @@ github.com/shirou/gopsutil/v3 v3.23.1/go.mod h1:NN6mnm5/0k8jw4cBfCnJtr5L7ErOTg18 github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sigstore/fulcio v1.0.0 h1:hBZW6qg9GXTtCX8jOg1hmyjYLrmsEKZGeMwAbW3XNEg= +github.com/sigstore/fulcio v1.0.0/go.mod h1:j4MzLxX/Be0rHYh3JF2dgMorkWGzEMHBqIHwFU8I/Rw= +github.com/sigstore/rekor v1.0.1 h1:rcESXSNkAPRWFYZel9rarspdvneET60F2ngNkadi89c= +github.com/sigstore/rekor v1.0.1/go.mod h1:ecTKdZWGWqE1pl3U1m1JebQJLU/hSjD9vYHOmHQ7w4g= +github.com/sigstore/sigstore v1.5.1 h1:iUou0QJW8eQKMUkTXbFyof9ZOblDtfaW2Sn2+QI8Tcs= +github.com/sigstore/sigstore v1.5.1/go.mod h1:3i6UTWVNtFwOtbgG63FZZNID4vO9KcO8AszIJlaNI8k= github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= @@ -1549,9 +1658,10 @@ github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0 github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/skeema/knownhosts v1.1.0 h1:Wvr9V0MxhjRbl3f9nMnKnFfiWTJmtECJ9Njkea3ysW0= github.com/skeema/knownhosts v1.1.0/go.mod h1:sKFq3RD6/TKZkSWn8boUbDC7Qkgcv+8XXijpFO6roag= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= @@ -1569,6 +1679,7 @@ github.com/spf13/cobra v0.0.1/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3 github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= +github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= @@ -1590,6 +1701,7 @@ github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5q github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU= github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA= +github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980 h1:lIOOHPEbXzO3vnmx2gok1Tfs31Q8GQqKLc8vVqyQq/I= github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8= github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= @@ -1626,10 +1738,14 @@ github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I= github.com/tchap/go-patricia v2.3.0+incompatible h1:GkY4dP3cEfEASBPPkWd+AmjYxhmDkqO9/zg7R0lSQRs= github.com/tchap/go-patricia v2.3.0+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I= +github.com/theupdateframework/go-tuf v0.5.2-0.20221207161717-9cb61d6e65f5 h1:s+Yvt6bzRwHljSE7j6DLBDcfpZEdBhrvLgOUmd8f7ZM= +github.com/theupdateframework/go-tuf v0.5.2-0.20221207161717-9cb61d6e65f5/go.mod h1:Le8NAjvDJK1vmLgpVYr4AR1Tqam/b/mTdQyTy37UJDA= github.com/theupdateframework/notary v0.7.0 h1:QyagRZ7wlSpjT5N2qQAh/pN+DVqgekv4DzbAiAiEL3c= github.com/theupdateframework/notary v0.7.0/go.mod h1:c9DRxcmhHmVLDay4/2fUYdISnHqbFDGRSlXPO0AhYWw= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 h1:e/5i7d4oYZ+C1wj2THlRK+oAhjeS/TRQwMfkIuet3w0= +github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399/go.mod h1:LdwHTNJT99C5fTAzDz0ud328OgXz+gierycbcIx2fRs= github.com/tj/go-spin v1.1.0 h1:lhdWZsvImxvZ3q1C5OIB7d72DuOwP4O2NdBg9PyzNds= github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4= github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM= @@ -1640,6 +1756,7 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1 github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 h1:uruHq4dN7GR16kFc5fp3d1RIYzJW5onx8Ybykw2YQFA= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/transparency-dev/merkle v0.0.1 h1:T9/9gYB8uZl7VOJIhdwjALeRWlxUxSfDEysjfmx+L9E= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= @@ -1649,6 +1766,7 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli v1.22.7 h1:aXiFAgRugfJ27UFDsGJ9DB2FvTC73hlVXFSqq5bo9eU= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= @@ -1658,15 +1776,21 @@ github.com/valyala/fasthttp v1.41.0/go.mod h1:f6VbjjoI3z1NDOZOv17o6RvtRSWxC77seB github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/vbatts/tar-split v0.11.2 h1:Via6XqJr0hceW4wff3QRzD5gAk/tatMw/4ZA7cTlIME= github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI= +github.com/vbauerster/mpb/v7 v7.5.3 h1:BkGfmb6nMrrBQDFECR/Q7RkKCw7ylMetCb4079CGs4w= +github.com/vbauerster/mpb/v7 v7.5.3/go.mod h1:i+h4QY6lmLvBNK2ah1fSreiw3ajskRlBp9AhY/PnuOE= github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho= github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= +github.com/vmihailenco/msgpack v3.3.3+incompatible h1:wapg9xDUZDzGCNFlwc5SqI1rvcciqcxEHac4CYj89xI= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= +github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= +github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmware-tanzu/velero v1.10.1 h1:6WYOolZIygHb8FOZtpp8vCqCuy5Mk3qBF1S65L5cjuo= github.com/vmware-tanzu/velero v1.10.1/go.mod h1:N0J+j8xGSmanGpy1zCRMH2DMGPpwkUj9EZIUXfOlanY= github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= @@ -1706,12 +1830,9 @@ github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= -github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43 h1:+lm10QQTNSBd8DVTNGHx7o/IKu9HYDvLMffDhbyLccI= -github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= -github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50 h1:hlE8//ciYMztlGpl/VA+Zm1AcTPHYkHJPbHqE6WJUXE= -github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= -github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f h1:ERexzlUfuTvpE74urLSbIQW0Z/6hF9t8U4NsJLaioAY= -github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= +github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940 h1:p7OofyZ509h8DmPLh8Hn+EIIZm/xYhdZHJ9GnXHdr6U= +github.com/yvasiyarov/gorelic v0.0.7 h1:4DTF1WOM2ZZS/xMOkTFBOcb6XiHu/PKn3rVo6dbewQE= +github.com/yvasiyarov/newrelic_platform_go v0.0.0-20160601141957-9c099fbc30e9 h1:AsFN8kXcCVkUFHyuzp1FtYbzp1nCO/H6+1uPSGEyPzM= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= @@ -1725,6 +1846,7 @@ go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= +go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489 h1:1JFLBqwIgdyHN1ZtgjTBwO+blA6gVOmZurpiMEsETKo= go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/api/v3 v3.5.6 h1:Cy2qx3npLcYqTKqGJzMypnMv2tiRyifZJ17BlWIWA7A= @@ -1737,15 +1859,25 @@ go.etcd.io/etcd/client/v2 v2.305.6 h1:fIDR0p4KMjw01MJMfUIDWdQbjo06PD6CeYM5z4EHLi go.etcd.io/etcd/client/v2 v2.305.6/go.mod h1:BHha8XJGe8vCIBfWBpbBLVZ4QjOIlfoouvOwydu63E0= go.etcd.io/etcd/client/v3 v3.5.6 h1:coLs69PWCXE9G4FKquzNaSHrRyMCAXwF+IX1tAPVO8E= go.etcd.io/etcd/client/v3 v3.5.6/go.mod h1:f6GRinRMCsFVv9Ht42EyY7nfsVGwrNO0WEoS2pRKzQk= +go.etcd.io/etcd/etcdctl/v3 v3.5.4 h1:LVFzhocId7Vb8SqK3YanpW0rKjlvtkN80ShJpcBDDZk= +go.etcd.io/etcd/etcdutl/v3 v3.5.4 h1:TeQGkpXMGnQ+Tgn/dB5yuADyeSZatehBBy6XXSxnO7U= go.etcd.io/etcd/pkg/v3 v3.5.6 h1:k1GZrGrfMHy5/cg2bxNGsmLTFisatyhDYCFLRuaavWg= go.etcd.io/etcd/pkg/v3 v3.5.6/go.mod h1:qATwUzDb6MLyGWq2nUj+jwXqZJcxkCuabh0P7Cuff3k= go.etcd.io/etcd/raft/v3 v3.5.6 h1:tOmx6Ym6rn2GpZOrvTGJZciJHek6RnC3U/zNInzIN50= go.etcd.io/etcd/raft/v3 v3.5.6/go.mod h1:wL8kkRGx1Hp8FmZUuHfL3K2/OaGIDaXGr1N7i2G07J0= go.etcd.io/etcd/server/v3 v3.5.6 h1:RXuwaB8AMiV62TqcqIt4O4bG8NWjsxOkDJVT3MZI5Ds= go.etcd.io/etcd/server/v3 v3.5.6/go.mod h1:6/Gfe8XTGXQJgLYQ65oGKMfPivb2EASLUSMSWN9Sroo= +go.etcd.io/etcd/tests/v3 v3.5.4 h1:wiYG8vbDwZO2UatQE9Z3GIv2z52jGg5DvEkTDXm090c= +go.etcd.io/etcd/v3 v3.5.4 h1:IWyDYI27KTWKGv1OS0Hzysr6514E6e7qfRUVpzr4YFQ= +go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= +go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= +go.mongodb.org/mongo-driver v1.8.3/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= +go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8= go.mongodb.org/mongo-driver v1.11.1 h1:QP0znIRTuL0jf1oBQoAoM0C6ZJfBK4kx0Uumtv1A7w8= go.mongodb.org/mongo-driver v1.11.1/go.mod h1:s7p5vEtfbeR1gYi6pnj3c3/urpbLv2T5Sfd6Rp2HBB8= go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk= +go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 h1:CCriYyAfq1Br1aIYettdHZTy8mBTIPo7We18TuO/bak= +go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -1812,6 +1944,7 @@ go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= go4.org/intern v0.0.0-20211027215823-ae77deb06f29 h1:UXLjNohABv4S58tHmeuIZDO6e3mHpW2Dx33gaNt03LE= go4.org/intern v0.0.0-20211027215823-ae77deb06f29/go.mod h1:cS2ma+47FKrLPdXFpr7CuxiTW3eyJbWew4qx0qtQWDA= go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E= +go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E= go4.org/unsafe/assume-no-moving-gc v0.0.0-20230221090011-e4bae7ad2296 h1:QJ/xcIANMLApehfgPCHnfK1hZiaMmbaTVmPv7DAoTbo= go4.org/unsafe/assume-no-moving-gc v0.0.0-20230221090011-e4bae7ad2296/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E= golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1821,6 +1954,7 @@ golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -1835,10 +1969,13 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= @@ -1906,7 +2043,6 @@ golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190619014844-b5b0513f8c1b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1941,6 +2077,7 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -1999,6 +2136,7 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -2021,14 +2159,16 @@ golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190514135907-3a4b5fb9f71f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190522044717-8097e1b27ff5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190524152521-dbbf3f1254d4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -2095,6 +2235,7 @@ golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -2136,6 +2277,7 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -2183,9 +2325,13 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= @@ -2257,7 +2403,6 @@ golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3j golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= gomodules.xyz/jsonpatch/v2 v2.2.0 h1:4pT439QV83L+G9FkcCriY6EkpcK6r6bK+A5FBUMI7qY= gomodules.xyz/jsonpatch/v2 v2.2.0/go.mod h1:WXp+iVDkoLQqPudfQ9GBlwB2eZ5DKOnjQZCYdOS8GPY= -google.golang.org/api v0.0.0-20160322025152-9bf6e6e569ff/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -2317,7 +2462,6 @@ google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCID google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/cloud v0.0.0-20151119220103-975617b05ea8/go.mod h1:0H1ncTHf11KCFhTc/+EFRbzSCOZx+VUbRMk55Yv5MYk= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -2427,7 +2571,6 @@ google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= google.golang.org/genproto v0.0.0-20230104163317-caabf589fcbf h1:/JqRexUvugu6JURQ0O7RfV1EnvgrOxUV4tSjuAv0Sr0= google.golang.org/genproto v0.0.0-20230104163317-caabf589fcbf/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.0.5/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -2490,10 +2633,10 @@ google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175 google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/alexcesaro/statsd.v2 v2.0.0 h1:FXkZSCZIH17vLCO5sO2UucTHsH9pc+17F6pl3JVCwMc= gopkg.in/cenkalti/backoff.v2 v2.2.1 h1:eJ9UAg01/HIHG987TwxvnzK2MgxXq97YY6rYDpY9aII= gopkg.in/cenkalti/backoff.v2 v2.2.1/go.mod h1:S0QdOvT2AlerfSBkp0O+dk+bbIMaNbEmVk876gPCthU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20141024133853-64131543e789/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20160105164936-4f90aeace3a2/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -2502,6 +2645,7 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/cheggaaa/pb.v1 v1.0.28 h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= @@ -2519,6 +2663,8 @@ gopkg.in/rethinkdb/rethinkdb-go.v6 v6.2.1/go.mod h1:WbjuEoo1oadwzQ4apSDU+JTvmllE gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= +gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= +gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= @@ -2534,6 +2680,7 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= @@ -2553,8 +2700,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6 h1:acCzuUSQ79tGsM/O50VRFySfMm19IoMKL+sZztZkCxw= -inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6/go.mod h1:y3MGhcFMlh0KZPMuXXow8mpjxxAk3yoDNsp4cQz54i8= +inet.af/netaddr v0.0.0-20220617031823-097006376321 h1:B4dC8ySKTQXasnjDTMsoCMf1sQG4WsMej0WXaHxunmU= +inet.af/netaddr v0.0.0-20220617031823-097006376321/go.mod h1:OIezDfdzOgFhuw4HuWapWq2e9l0H9tK4F1j+ETRtF3k= k8s.io/api v0.19.0/go.mod h1:I1K45XlvTrDjmj5LoM5LuP/KYrhWbjUKT/SoPG0qTjw= k8s.io/api v0.20.1/go.mod h1:KqwcCVogGxQY3nBlRpwt+wpAMF/KjaCc7RpywacvqUo= k8s.io/api v0.20.4/go.mod h1:++lNL1AJMkDymriNniQsWRkMDzRaX2Y/POTUi8yvqYQ= @@ -2630,6 +2777,7 @@ oras.land/oras-go v1.2.2/go.mod h1:Apa81sKoZPpP7CDciE006tSZ0x3Q3+dOoBcMZ/aNxvw= periph.io/x/host/v3 v3.8.0 h1:T5ojZ2wvnZHGPS4h95N2ZpcCyHnsvH3YRZ1UUUiv5CQ= periph.io/x/host/v3 v3.8.0/go.mod h1:rzOLH+2g9bhc6pWZrkCrmytD4igwQ2vxFw6Wn6ZOlLY= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/letsencrypt v0.0.3 h1:H7xDfhkaFFSYEJlKeq38RwX2jYcnTeHuDQyT+mMNMwM= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.14/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= diff --git a/internal/cli/cmd/cli.go b/internal/cli/cmd/cli.go index fe99c0c7df4..1740343410c 100644 --- a/internal/cli/cmd/cli.go +++ b/internal/cli/cmd/cli.go @@ -36,6 +36,8 @@ import ( utilcomp "k8s.io/kubectl/pkg/util/completion" "k8s.io/kubectl/pkg/util/templates" + infras "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure" + "github.com/apecloud/kubeblocks/internal/cli/cmd/addon" "github.com/apecloud/kubeblocks/internal/cli/cmd/alert" "github.com/apecloud/kubeblocks/internal/cli/cmd/bench" @@ -183,6 +185,7 @@ A Command Line Interface for KubeBlocks`, fault.NewFaultCmd(f, ioStreams), builder.NewBuilderCmd(f, ioStreams), report.NewReportCmd(f, ioStreams), + infras.NewInfraCmd(ioStreams), ) filters := []string{"options"} diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go new file mode 100644 index 00000000000..03ae9225123 --- /dev/null +++ b/internal/cli/cmd/infrastructure/create.go @@ -0,0 +1,252 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package infrastructure + +import ( + "fmt" + "os" + "os/user" + "path/filepath" + "strings" + + "github.com/StudioSol/set" + kubekeyapiv1alpha2 "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/connector" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/pipeline" + "github.com/spf13/cobra" + "k8s.io/apimachinery/pkg/util/rand" + "k8s.io/cli-runtime/pkg/genericclioptions" + + "github.com/apecloud/kubeblocks/internal/cli/util" + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" + "github.com/apecloud/kubeblocks/internal/configuration/container" +) + +type clusterOptions struct { + IOStreams genericclioptions.IOStreams + + timeout int64 + userName string + password string + privateKey string + privateKeyPath string + + clusterName string + nodes []string + version string + criType string + cluster Cluster + debug bool + + enablePullImage bool + autoRenewCerts bool + securityEnhancement bool +} + +const ( + defaultVersion = "v1.26.1" + defaultDownloadURL = "curl -L -o %s %s" +) + +var createExamples = ` +` + +func (o *clusterOptions) Complete() error { + if o.clusterName == "" { + o.clusterName = "kubeblocks-" + rand.String(6) + fmt.Printf("The cluster name is not set, auto generate cluster name: %s\n", o.clusterName) + } + if o.userName == "" { + currentUser, err := user.Current() + if err != nil { + return err + } + o.userName = currentUser.Username + fmt.Printf("The user is not set, use current user %s\n", o.userName) + } + if o.privateKey == "" { + home, err := os.UserHomeDir() + if err != nil { + return err + } + if o.privateKeyPath == "" && o.password == "" { + o.privateKeyPath = filepath.Join(home, ".ssh", "id_rsa") + } + if strings.HasPrefix(o.privateKeyPath, "~/") { + o.privateKeyPath = filepath.Join(home, o.privateKeyPath[2:]) + } + } + if len(o.nodes) == 0 { + return cfgcore.MakeError("The list of machines where kubernetes is installed must be specified.") + } + o.cluster.Nodes = make([]ClusterNode, len(o.nodes)) + for i, node := range o.nodes { + fields := strings.SplitN(node, ":", 3) + if len(fields) < 2 { + return cfgcore.MakeError("The node format is incorrect, require: [name:address:internalAddress].") + } + n := ClusterNode{ + Name: fields[0], + Address: fields[1], + InternalAddress: fields[1], + } + if len(fields) == 3 { + n.InternalAddress = fields[2] + } + o.cluster.Nodes[i] = n + } + return nil +} + +func (o *clusterOptions) Validate() error { + checkFn := func(n string) bool { + for _, node := range o.cluster.Nodes { + if node.Name == n { + return true + } + } + return false + } + validateNodes := func(nodes []string) error { + sets := set.NewLinkedHashSetString() + for _, node := range nodes { + if !checkFn(node) { + return cfgcore.MakeError("node %s is not exist!", node) + } + if sets.InArray(node) { + return cfgcore.MakeError("node %s is repeat!", node) + } + sets.Add(node) + } + return nil + } + if o.userName == "" { + return cfgcore.MakeError("user name is empty") + } + if o.privateKey == "" && o.privateKeyPath != "" { + if _, err := os.Stat(o.privateKeyPath); err != nil { + return err + } + b, err := os.ReadFile(o.privateKeyPath) + if err != nil { + return err + } + o.privateKey = string(b) + } + if len(o.cluster.ETCD) == 0 || len(o.cluster.Master) == 0 || len(o.cluster.Worker) == 0 { + return cfgcore.MakeError("etcd, master or worker is empty") + } + if err := validateNodes(o.cluster.ETCD); err != nil { + return err + } + if err := validateNodes(o.cluster.Master); err != nil { + return err + } + if err := validateNodes(o.cluster.Worker); err != nil { + return err + } + return nil +} + +func (o *clusterOptions) Run() error { + updateClusterHosts := func(cluster *kubekeyapiv1alpha2.ClusterSpec, runtime *common.KubeRuntime) { + hostSet := set.NewLinkedHashSetString() + for _, role := range cluster.GroupHosts() { + for _, host := range role { + if host.IsRole(common.Master) || host.IsRole(common.Worker) { + host.SetRole(common.K8s) + } + if !hostSet.InArray(host.GetName()) { + hostSet.Add(host.GetName()) + runtime.BaseRuntime.AppendHost(host) + runtime.BaseRuntime.AppendRoleMap(host) + } + } + } + } + + cluster, err := createClusterWithOptions(buildTemplateParams(o)) + if err != nil { + return err + } + runtime := &common.KubeRuntime{ + BaseRuntime: connector.NewBaseRuntime(o.clusterName, connector.NewDialer(), o.debug, false), + Cluster: cluster, + ClusterName: o.clusterName, + Arg: common.Argument{ + DownloadCommand: func(path, url string) string { + // this is an extension point for downloading tools, for example users can set the timeout, proxy or retry under + // some poor network environment. Or users even can choose another cli, it might be wget. + // perhaps we should have a build-in download function instead of totally rely on the external one + return fmt.Sprintf(defaultDownloadURL, path, url) + }, + }, + } + updateClusterHosts(cluster, runtime) + + pipeline := pipeline.Pipeline{ + Name: "CreateCluster", + Modules: NewCreateK8sClusterForKubeblocks(o), + Runtime: runtime, + } + if err := pipeline.Start(); err != nil { + return err + } + fmt.Fprintf(o.IOStreams.Out, "Kubernetes Installation is complete.\n\n") + return nil +} + +func NewCreateKubernetesCmd(streams genericclioptions.IOStreams) *cobra.Command { + o := &clusterOptions{ + IOStreams: streams, + } + cmd := &cobra.Command{ + Use: "create", + Short: "create kubernetes cluster.", + Example: createExamples, + Run: func(cmd *cobra.Command, args []string) { + util.CheckErr(o.Complete()) + util.CheckErr(o.Validate()) + util.CheckErr(o.Run()) + }, + } + o.buildCreateInfraFlags(cmd) + return cmd +} + +func (o *clusterOptions) buildCreateInfraFlags(cmd *cobra.Command) { + cmd.Flags().StringVarP(&o.clusterName, "name", "", "", "Specify kubernetes cluster name") + cmd.Flags().StringVarP(&o.version, "version", "", defaultVersion, fmt.Sprintf("Specify install kubernetes version. default version is %s", defaultVersion)) + cmd.Flags().StringVarP(&o.criType, "container-runtime", "", string(container.ContainerdType), "Specify kubernetes container runtime. default is containerd") + cmd.Flags().StringSliceVarP(&o.nodes, "nodes", "", nil, "List of machines on which kubernetes is installed. [require]") + cmd.Flags().BoolVarP(&o.debug, "debug", "", false, "set debug mode") + + // for user + cmd.Flags().StringVarP(&o.userName, "user", "u", "", "Specify the account to access the remote server. [require]") + cmd.Flags().Int64VarP(&o.timeout, "timeout", "t", 30, "Specify the ssh timeout.[option]") + cmd.Flags().StringVarP(&o.password, "password", "p", "", "Specify the password for the account to execute sudo. [option]") + cmd.Flags().StringVarP(&o.privateKey, "private-key", "", "", "The PrimaryKey for ssh to the remote machine. [option]") + cmd.Flags().StringVarP(&o.privateKeyPath, "private-key-path", "", "", "Specify the file PrimaryKeyPath of ssh to the remote machine. default ~/.ssh/id_rsa.") + + cmd.Flags().StringSliceVarP(&o.cluster.ETCD, "etcd", "", nil, "Specify etcd nodes") + cmd.Flags().StringSliceVarP(&o.cluster.Master, "master", "", nil, "Specify master nodes") + cmd.Flags().StringSliceVarP(&o.cluster.Worker, "worker", "", nil, "Specify worker nodes") +} diff --git a/internal/cli/cmd/infrastructure/infras.go b/internal/cli/cmd/infrastructure/infras.go new file mode 100644 index 00000000000..8b784bf3eb8 --- /dev/null +++ b/internal/cli/cmd/infrastructure/infras.go @@ -0,0 +1,35 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package infrastructure + +import ( + "github.com/spf13/cobra" + "k8s.io/cli-runtime/pkg/genericclioptions" +) + +// NewInfraCmd for builder functions +func NewInfraCmd(streams genericclioptions.IOStreams) *cobra.Command { + cmd := &cobra.Command{ + Use: "infra", + Short: "infra command", + } + cmd.AddCommand(NewCreateKubernetesCmd(streams)) + return cmd +} diff --git a/internal/cli/cmd/infrastructure/infras_test.go b/internal/cli/cmd/infrastructure/infras_test.go new file mode 100644 index 00000000000..4efb8357a4d --- /dev/null +++ b/internal/cli/cmd/infrastructure/infras_test.go @@ -0,0 +1,46 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package infrastructure + +import ( + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + "k8s.io/cli-runtime/pkg/genericclioptions" + cmdtesting "k8s.io/kubectl/pkg/cmd/testing" +) + +var _ = Describe("kubeblock infra", func() { + var streams genericclioptions.IOStreams + var tf *cmdtesting.TestFactory + + BeforeEach(func() { + streams, _, _, _ = genericclioptions.NewTestIOStreams() + }) + + AfterEach(func() { + tf.Cleanup() + }) + + It("command should succeed", func() { + cmd := NewInfraCmd(streams) + Expect(cmd).ShouldNot(BeNil()) + }) +}) diff --git a/internal/cli/cmd/infrastructure/kubernetes.go b/internal/cli/cmd/infrastructure/kubernetes.go new file mode 100644 index 00000000000..1bf83c823d6 --- /dev/null +++ b/internal/cli/cmd/infrastructure/kubernetes.go @@ -0,0 +1,81 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package infrastructure + +import ( + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/binaries" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/confirm" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/precheck" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/certs" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/container" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/module" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/etcd" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/filesystem" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/images" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/kubernetes" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/dns" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/network" +) + +func NewCreateK8sClusterForKubeblocks(o *clusterOptions) []module.Module { + // TODO: add a new module to check if the cluster is already installed + return []module.Module{ + &precheck.GreetingsModule{}, + &tasks.CheckNodeArchitectureModule{}, + &precheck.NodePreCheckModule{}, + // install kubekey required packages + &tasks.InstallDependenciesModule{}, + &precheck.NodePreCheckModule{}, + &confirm.InstallConfirmModule{}, + // &os.RepositoryModule{Skip: !runtime.Arg.InstallPackages}, + &binaries.NodeBinariesModule{}, + &os.ConfigureOSModule{}, + // &customscripts.CustomScriptsModule{Phase: "PreInstall", Scripts: runtime.Cluster.System.PreInstall}, + &kubernetes.StatusModule{}, + &container.InstallContainerModule{}, + &images.PullModule{Skip: !o.enablePullImage}, + &etcd.PreCheckModule{}, + &etcd.CertsModule{}, + &etcd.InstallETCDBinaryModule{}, + &etcd.ConfigureModule{}, + &etcd.BackupModule{}, + &kubernetes.InstallKubeBinariesModule{}, + // init kubeVip on first master + // &loadbalancer.KubevipModule{}, + &kubernetes.InitKubernetesModule{}, + &dns.ClusterDNSModule{}, + &kubernetes.StatusModule{}, + &kubernetes.JoinNodesModule{}, + // deploy kubeVip on other masters + // &loadbalancer.KubevipModule{}, + // &loadbalancer.HaproxyModule{}, + &network.DeployNetworkPluginModule{}, + &kubernetes.ConfigureKubernetesModule{}, + &filesystem.ChownModule{}, + &certs.AutoRenewCertsModule{Skip: !o.autoRenewCerts}, + &kubernetes.SecurityEnhancementModule{Skip: !o.securityEnhancement}, + &kubernetes.SaveKubeConfigModule{}, + &plugins.DeployPluginsModule{}, + // &customscripts.CustomScriptsModule{Phase: "PostInstall", Scripts: runtime.Cluster.System.PostInstall}, + } +} diff --git a/internal/cli/cmd/infrastructure/loader_adapter.go b/internal/cli/cmd/infrastructure/loader_adapter.go new file mode 100644 index 00000000000..d2916c97369 --- /dev/null +++ b/internal/cli/cmd/infrastructure/loader_adapter.go @@ -0,0 +1,113 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package infrastructure + +import ( + "bufio" + "embed" + "encoding/json" + "strings" + + kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" + "github.com/leaanthony/debme" + "k8s.io/apimachinery/pkg/util/yaml" + + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" + "github.com/apecloud/kubeblocks/internal/gotemplate" +) + +var ( + //go:embed template/* + cueTemplate embed.FS +) + +func newKubeKeyClusterTemplate(templateName string) (string, error) { + tmplFs, _ := debme.FS(cueTemplate, "template") + if tmlBytes, err := tmplFs.ReadFile(templateName); err != nil { + return "", err + } else { + return string(tmlBytes), nil + } +} + +func createClusterWithOptions(values *gotemplate.TplValues) (*kubekeyapiv1alpha2.ClusterSpec, error) { + const tplFile = "kubekey_cluster_template.tpl" + yamlTemplate, err := newKubeKeyClusterTemplate(tplFile) + if err != nil { + return nil, err + } + + tpl := gotemplate.NewTplEngine(values, nil, "ClusterTemplate", nil, nil) + rendered, err := tpl.Render(yamlTemplate) + if err != nil { + return nil, err + } + + var ret map[string]interface{} + cluster := kubekeyapiv1alpha2.Cluster{} + content, err := yaml.NewYAMLReader(bufio.NewReader(strings.NewReader(rendered))).Read() + if err != nil { + return nil, cfgcore.WrapError(err, "failed to read the cluster yaml") + } + err = yaml.Unmarshal(content, &ret) + if err != nil { + return nil, cfgcore.WrapError(err, "failed to unmarshal the cluster yaml") + } + + contentToJson, err := yaml.ToJSON(content) + if err != nil { + return nil, cfgcore.WrapError(err, "Unable to convert configuration to json") + } + if err := json.Unmarshal(contentToJson, &cluster); err != nil { + return nil, cfgcore.WrapError(err, "failed to unmarshal the cluster") + } + return &cluster.Spec, nil +} + +const ( + builtinClusterNameObject = "Name" + builtinTimeoutObject = "Timeout" + builtinClusterVersionObject = "Version" + builtinCRITypeObject = "CRIType" + builtinUserObject = "User" + builtinPasswordObject = "Password" + builtinPrivateKeyObject = "PrivateKey" + builtinHostsObject = "Hosts" + builtinRoleGroupsObject = "RoleGroups" +) + +func buildTemplateParams(o *clusterOptions) *gotemplate.TplValues { + return &gotemplate.TplValues{ + builtinClusterNameObject: o.clusterName, + builtinClusterVersionObject: o.version, + builtinCRITypeObject: o.criType, + builtinUserObject: o.userName, + builtinPasswordObject: o.password, + builtinPrivateKeyObject: o.privateKey, + builtinHostsObject: o.cluster.Nodes, + builtinTimeoutObject: o.timeout, + builtinRoleGroupsObject: gotemplate.TplValues{ + common.ETCD: o.cluster.ETCD, + common.Master: o.cluster.Master, + common.Worker: o.cluster.Worker, + }, + } +} diff --git a/internal/cli/cmd/infrastructure/loader_adapter_test.go b/internal/cli/cmd/infrastructure/loader_adapter_test.go new file mode 100644 index 00000000000..131922ff5e3 --- /dev/null +++ b/internal/cli/cmd/infrastructure/loader_adapter_test.go @@ -0,0 +1,74 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package infrastructure + +import ( + "testing" + + kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" + + "github.com/apecloud/kubeblocks/internal/configuration/container" +) + +func TestCreateClusterWithOptions(t *testing.T) { + tests := []struct { + name string + args *clusterOptions + want *kubekeyapiv1alpha2.ClusterSpec + wantErr bool + }{{ + name: "generateClusterTest", + args: &clusterOptions{ + clusterName: "for_test", + version: defaultVersion, + criType: string(container.ContainerdType), + userName: "test", + password: "test", + cluster: Cluster{ + Nodes: []ClusterNode{ + { + Name: "node1", + Address: "127.0.0.1", + InternalAddress: "127.0.0.1", + }, { + Name: "node2", + Address: "127.0.0.2", + InternalAddress: "127.0.0.2", + }, + }, + ETCD: []string{"node1"}, + Master: []string{"node1"}, + Worker: []string{"node2"}, + }, + }, + }} + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := createClusterWithOptions(buildTemplateParams(tt.args)) + if (err != nil) != tt.wantErr { + t.Errorf("createClusterWithOptions() error = %v, wantErr %v", err, tt.wantErr) + return + } + if got == nil { + t.Errorf("createClusterWithOptions() got = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/internal/cli/cmd/infrastructure/suit_test.go b/internal/cli/cmd/infrastructure/suit_test.go new file mode 100644 index 00000000000..10f1ace770b --- /dev/null +++ b/internal/cli/cmd/infrastructure/suit_test.go @@ -0,0 +1,32 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package infrastructure + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestAppp(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Infra Cmd Test Suite") +} diff --git a/internal/cli/cmd/infrastructure/tasks/module.go b/internal/cli/cmd/infrastructure/tasks/module.go new file mode 100644 index 00000000000..4d82765d003 --- /dev/null +++ b/internal/cli/cmd/infrastructure/tasks/module.go @@ -0,0 +1,104 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package tasks + +import ( + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/confirm" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/logger" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task" + + "github.com/mitchellh/mapstructure" +) + +type InstallDependenciesModule struct { + common.KubeModule +} + +func (i *InstallDependenciesModule) isNotReadyHosts() []connector.Host { + hosts := make([]connector.Host, 0) + for _, host := range i.Runtime.GetAllHosts() { + var result confirm.PreCheckResults + if v, ok := host.GetCache().Get(common.NodePreCheck); ok { + _ = mapstructure.Decode(v, &result) + if result.Socat == "" || result.Conntrack == "" || result.Ipset == "" || result.Chronyd == "" || result.Ebtables == "" { + hosts = append(hosts, host) + } + } + } + return hosts +} + +// Init install dependencies module +func (i *InstallDependenciesModule) Init() { + i.Name = "InstallDependenciesModule" + i.Desc = "install dependencies" + + hosts := i.isNotReadyHosts() + if len(hosts) == 0 { + logger.Log.Info("All hosts are ready, skip install dependencies") + return + } + + prepareOSData := &task.RemoteTask{ + Name: "GetOSData", + Desc: "Get OS release", + Hosts: i.Runtime.GetAllHosts(), + Action: new(os.GetOSData), + Parallel: true, + } + + installPkg := &task.RemoteTask{ + Name: "InstallDependenciesModule", + Desc: "check and install dependencies", + Hosts: hosts, + Action: new(InstallDependenciesTask), + Parallel: true, + } + + i.Tasks = []task.Interface{ + prepareOSData, + installPkg, + } +} + +type CheckNodeArchitectureModule struct { + common.KubeModule +} + +// Init install dependencies module +func (i *CheckNodeArchitectureModule) Init() { + i.Name = "CheckNodeArch" + i.Desc = "check and update host arch" + + prepareNodeArch := &task.RemoteTask{ + Name: "CheckNodeArch", + Desc: "check and update node arch", + Hosts: i.Runtime.GetAllHosts(), + Action: new(UpdateNodeTask), + Parallel: true, + } + + i.Tasks = []task.Interface{ + prepareNodeArch, + } +} diff --git a/internal/cli/cmd/infrastructure/tasks/prepare.go b/internal/cli/cmd/infrastructure/tasks/prepare.go new file mode 100644 index 00000000000..209ac0ae2ee --- /dev/null +++ b/internal/cli/cmd/infrastructure/tasks/prepare.go @@ -0,0 +1,47 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package tasks + +import ( + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/confirm" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" + "github.com/mitchellh/mapstructure" +) + +type DependenciesChecker struct { + common.KubePrepare +} + +func (n *DependenciesChecker) PreCheck(runtime connector.Runtime) (bool, error) { + host := runtime.RemoteHost() + + v, ok := host.GetCache().Get(common.NodePreCheck) + if !ok { + return false, nil + } + + var result confirm.PreCheckResults + if err := mapstructure.Decode(v, &result); err != nil { + return false, cfgcore.WrapError(err, "failed to decode precheck result") + } + return true, nil +} diff --git a/internal/cli/cmd/infrastructure/tasks/tasks.go b/internal/cli/cmd/infrastructure/tasks/tasks.go new file mode 100644 index 00000000000..c9944b180b4 --- /dev/null +++ b/internal/cli/cmd/infrastructure/tasks/tasks.go @@ -0,0 +1,131 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package tasks + +import ( + "fmt" + "strings" + + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" + kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/logger" + "github.com/kubesphere/kubekey/v3/util/osrelease" +) + +type InstallDependenciesTask struct { + common.KubeAction + pkg []string +} + +var dependenciesPkg = []string{"socat", "conntrack", "ipset", "ebtables", "chrony", "iptables"} + +func (i *InstallDependenciesTask) Execute(runtime connector.Runtime) (err error) { + host := runtime.RemoteHost() + release, ok := host.GetCache().Get(os.Release) + if !ok { + return cfgcore.MakeError("failed to get os release.") + } + + r := release.(*osrelease.Data) + installCommand, err := checkRepositoryInstallerCommand(r, runtime) + if err != nil { + return err + } + depPkg := strings.Join(append(i.pkg, dependenciesPkg...), " ") + stdout, err := runtime.GetRunner().SudoCmd(fmt.Sprintf("%s %s", installCommand, depPkg), true) + logger.Log.Info(stdout) + return err +} + +type UpdateNodeTask struct { + common.KubeAction +} + +func (i *UpdateNodeTask) Execute(runtime connector.Runtime) (err error) { + host := runtime.RemoteHost() + if host.GetArch() != "" { + return nil + } + + stdout, err := runtime.GetRunner().Cmd("uname -m", false) + if err != nil { + return err + } + host.SetArch(parseNodeArchitecture(stdout)) + updateClusterSpecHost(i.KubeConf.Cluster, host) + return nil +} + +func updateClusterSpecHost(clusterSpec *kubekeyapiv1alpha2.ClusterSpec, host connector.Host) { + for i := range clusterSpec.Hosts { + h := &clusterSpec.Hosts[i] + if h.Name == host.GetName() { + h.Arch = host.GetArch() + } + } +} + +func parseNodeArchitecture(stdout string) string { + switch strings.TrimSpace(stdout) { + default: + return "amd64" + case "x86_64": + return "amd64" + case "arm64", "arm": + return "arm64" + case "aarch64", "aarch32": + return "arm" + } +} + +func checkRepositoryInstallerCommand(osData *osrelease.Data, runtime connector.Runtime) (string, error) { + const ( + debianCommand = "apt install -y" + rhelCommand = "yum install -y" + ) + + isDebianCore := func() bool { + checkDeb, err := runtime.GetRunner().SudoCmd("which apt", false) + return err == nil && strings.Contains(checkDeb, "bin") + } + isRhelCore := func() bool { + checkDeb, err := runtime.GetRunner().SudoCmd("which yum", false) + return err == nil && strings.Contains(checkDeb, "bin") + } + + switch strings.ToLower(osData.ID) { + case "ubuntu", "debian": + return debianCommand, nil + case "centos", "rhel": + return rhelCommand, nil + } + + switch { + default: + return "", cfgcore.MakeError("failed to check apt or yum.") + case isRhelCore(): + return rhelCommand, nil + case isDebianCore(): + return debianCommand, nil + } +} diff --git a/internal/cli/cmd/infrastructure/template/kubekey_cluster_template.tpl b/internal/cli/cmd/infrastructure/template/kubekey_cluster_template.tpl new file mode 100644 index 00000000000..8fdd053e4a2 --- /dev/null +++ b/internal/cli/cmd/infrastructure/template/kubekey_cluster_template.tpl @@ -0,0 +1,69 @@ +apiVersion: kubekey.kubesphere.io/v1alpha2 +kind: Cluster +metadata: + name: {{ $.Name }} +spec: + hosts: + {{- range $.Hosts }} + - name: {{ .Name }} + address: {{ .Address }} + internalAddress: {{ .InternalAddress }} + user: {{ $.User }} + password: {{ $.Password }} + privateKey: {{ $.PrivateKey | quote }} + timeout: {{ $.Timeout }} + {{- end }} + roleGroups: + {{- $roles := keys $.RoleGroups }} + {{- range $roles }} + {{- $nodes := get $.RoleGroups . }} + {{ . }}: + {{- range $nodes }} + - {{ . }} + {{- end }} + {{- end }} + controlPlaneEndpoint: + domain: lb.api-service.local + {{- $address := ""}} + {{- if hasKey $.RoleGroups "master" }} + {{- $mName := index (get $.RoleGroups "master") 0 }} + {{- range $.Hosts }} + {{- if eq .Name $mName }} + {{- $address = .InternalAddress }} + {{- end }} + {{- end }} + {{- end }} + {{- if eq $address "" }} + {{- failed "require control address." }} + {{- end }} + address: {{ $address }} + port: 6443 + kubernetes: + nodelocaldns: false + dnsDomain: cluster.local + version: {{ $.Version }} + clusterName: {{ $.Name }} + {{- $criType := "containerd" }} + nodeCidrMaskSize: 24 + proxyMode: ipvs + {{- if eq $criType "containerd" }} + containerRuntimeEndpoint: "unix:///run/containerd/containerd.sock" + {{- end }} + {{- if $.CRIType }} + {{ $criType = $.CRIType }} + {{- end }} + containerManager: {{ $criType }} + etcd: + backupDir: /var/backups/kube_etcd + backupPeriod: 1800 + keepBackupNumber: 6 + backupScript: /usr/local/bin/kube-scripts + {{- if hasKey $.RoleGroups "etcd" }} + type: kubekey + {{- else }} + type: kubeadm + {{- end }} + network: + plugin: calico + kubePodsCIDR: 10.233.64.0/18 + kubeServiceCIDR: 10.233.0.0/18 \ No newline at end of file diff --git a/internal/cli/cmd/infrastructure/type.go b/internal/cli/cmd/infrastructure/type.go new file mode 100644 index 00000000000..df12c3eb36d --- /dev/null +++ b/internal/cli/cmd/infrastructure/type.go @@ -0,0 +1,44 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package infrastructure + +type Cluster struct { + User ClusterUser + Nodes []ClusterNode + + ETCD []string `json:"etcd"` + Master []string `json:"master"` + Worker []string `json:"worker"` +} + +type ClusterNode struct { + Name string `json:"name"` + Address string `json:"address"` + InternalAddress string `json:"internalAddress"` +} + +type ClusterUser struct { + // user name + Name string `json:"name"` + // sudo password + Password string `json:"password"` + // ssh privateKey + PrivateKey string `json:"privateKey"` +} diff --git a/internal/cli/create/template/kubekey_cluster_template.cue b/internal/cli/create/template/kubekey_cluster_template.cue new file mode 100644 index 00000000000..c67231ce34e --- /dev/null +++ b/internal/cli/create/template/kubekey_cluster_template.cue @@ -0,0 +1,71 @@ +// Copyright (C) 2022-2023 ApeCloud Co., Ltd +// +// This file is part of KubeBlocks project +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +options: { + name: string + user: string + + privateKey: string + hosts: [...Host] + roleGroups: {} + + version: string + criType: string + ... +} + +Host: { + name: string + address: string + internalAddress: string +} + +// required, k8s api resource content +content: { + apiVersion: "kubekey.kubesphere.io/v1alpha2" + kind: "Cluster" + metadata: { + name: options.name + } + spec: { + hosts: [ for _, h in options.hosts { + name: h.name + address: h.address + internalAddress: h.internalAddress + if options.user != "" { + user: options.user + } + if options.privateKey != "" { + privateKey: options.privateKey + } + }] + roleGroups: options.roleGroups + controlPlaneEndpoint: + domain: "lb.kubesphere.local" + port: 6443 + kubernetes: + version: options.version + clusterName: options.name + autoRenewCerts: true + if options.criType != "" { + containerManager: options.criType + } + if options.criType == "" { + containerManager: "containerd" + } + } +} From 23a7999c64163a3b9ecd8a65f46dddfb5d1e68f9 Mon Sep 17 00:00:00 2001 From: sophon Date: Wed, 31 May 2023 10:25:37 +0800 Subject: [PATCH 02/44] chore: rename file --- internal/cli/cmd/infrastructure/{kubernetes.go => pipeline.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename internal/cli/cmd/infrastructure/{kubernetes.go => pipeline.go} (100%) diff --git a/internal/cli/cmd/infrastructure/kubernetes.go b/internal/cli/cmd/infrastructure/pipeline.go similarity index 100% rename from internal/cli/cmd/infrastructure/kubernetes.go rename to internal/cli/cmd/infrastructure/pipeline.go From d8dbd18c44b68cb60bec1a36fe4ac866be705810 Mon Sep 17 00:00:00 2001 From: sophon Date: Wed, 31 May 2023 15:58:22 +0800 Subject: [PATCH 03/44] fix: failed to ut --- .golangci.yaml | 3 +++ Makefile | 12 ++++++------ internal/cli/cmd/infrastructure/infras_test.go | 3 --- internal/cli/cmd/infrastructure/loader_adapter.go | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 45fd7a703a8..2e8d9c74fdb 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -11,6 +11,9 @@ run: skip-files: - "^zz_generated.*" + build-tags: + - containers_image_openpgp + output: # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" format: colored-line-number diff --git a/Makefile b/Makefile index d55292ac2dd..926c27e38f2 100644 --- a/Makefile +++ b/Makefile @@ -127,7 +127,7 @@ all: manager kbcli probe reloader ## Make all cmd binaries. .PHONY: manifests manifests: test-go-generate controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. - $(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook paths="./cmd/manager/...;./apis/...;./controllers/...;./internal/..." output:crd:artifacts:config=config/crd/bases + $(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook paths="./cmd/manager/...;./apis/...;./controllers/..." output:crd:artifacts:config=config/crd/bases @cp config/crd/bases/* $(CHART_PATH)/crds @cp config/rbac/role.yaml $(CHART_PATH)/config/rbac/role.yaml $(MAKE) client-sdk-gen @@ -182,7 +182,7 @@ golangci-lint: golangci ## Run golangci-lint against code. .PHONY: staticcheck staticcheck: staticchecktool ## Run staticcheck against code. - $(STATICCHECK) ./... + $(STATICCHECK) -tags $(BUILD_TAGS) ./... .PHONY: build-checks build-checks: generate fmt vet goimports lint-fast ## Run build checks. @@ -213,22 +213,22 @@ endif .PHONY: test-current-ctx test-current-ctx: manifests generate add-k8s-host ## Run operator controller tests with current $KUBECONFIG context. if existing k8s cluster is k3d or minikube, specify EXISTING_CLUSTER_TYPE. - USE_EXISTING_CLUSTER=true KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" $(GO) test -p 1 -coverprofile cover.out $(TEST_PACKAGES) + USE_EXISTING_CLUSTER=true KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" $(GO) test -tags $(BUILD_TAGS) -p 1 -coverprofile cover.out $(TEST_PACKAGES) .PHONY: test-fast test-fast: envtest - KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" $(GO) test -short -coverprofile cover.out $(TEST_PACKAGES) + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" $(GO) test -tags $(BUILD_TAGS) -short -coverprofile cover.out $(TEST_PACKAGES) .PHONY: test test: manifests generate test-go-generate add-k8s-host test-fast ## Run tests. if existing k8s cluster is k3d or minikube, specify EXISTING_CLUSTER_TYPE. .PHONY: race race: - KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" $(GO) test -race $(TEST_PACKAGES) + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" $(GO) test -tags $(BUILD_TAGS) -race $(TEST_PACKAGES) .PHONY: test-integration test-integration: manifests generate envtest add-k8s-host ## Run tests. if existing k8s cluster is k3d or minikube, specify EXISTING_CLUSTER_TYPE. - KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" $(GO) test ./test/integration + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" $(GO) test -tags $(BUILD_TAGS) ./test/integration .PHONY: test-delve test-delve: manifests generate envtest ## Run tests. diff --git a/internal/cli/cmd/infrastructure/infras_test.go b/internal/cli/cmd/infrastructure/infras_test.go index 4efb8357a4d..e7307b7e189 100644 --- a/internal/cli/cmd/infrastructure/infras_test.go +++ b/internal/cli/cmd/infrastructure/infras_test.go @@ -24,19 +24,16 @@ import ( . "github.com/onsi/gomega" "k8s.io/cli-runtime/pkg/genericclioptions" - cmdtesting "k8s.io/kubectl/pkg/cmd/testing" ) var _ = Describe("kubeblock infra", func() { var streams genericclioptions.IOStreams - var tf *cmdtesting.TestFactory BeforeEach(func() { streams, _, _, _ = genericclioptions.NewTestIOStreams() }) AfterEach(func() { - tf.Cleanup() }) It("command should succeed", func() { diff --git a/internal/cli/cmd/infrastructure/loader_adapter.go b/internal/cli/cmd/infrastructure/loader_adapter.go index d2916c97369..5b1b460852a 100644 --- a/internal/cli/cmd/infrastructure/loader_adapter.go +++ b/internal/cli/cmd/infrastructure/loader_adapter.go @@ -72,11 +72,11 @@ func createClusterWithOptions(values *gotemplate.TplValues) (*kubekeyapiv1alpha2 return nil, cfgcore.WrapError(err, "failed to unmarshal the cluster yaml") } - contentToJson, err := yaml.ToJSON(content) + contentToJSON, err := yaml.ToJSON(content) if err != nil { return nil, cfgcore.WrapError(err, "Unable to convert configuration to json") } - if err := json.Unmarshal(contentToJson, &cluster); err != nil { + if err := json.Unmarshal(contentToJSON, &cluster); err != nil { return nil, cfgcore.WrapError(err, "failed to unmarshal the cluster") } return &cluster.Spec, nil From fab6dec2c66c430dcad607df0874292009f06344 Mon Sep 17 00:00:00 2001 From: sophon Date: Wed, 31 May 2023 16:09:49 +0800 Subject: [PATCH 04/44] chore: update kb depends --- internal/cli/cmd/infrastructure/create.go | 1 - internal/cli/cmd/infrastructure/pipeline.go | 2 -- internal/cli/cmd/infrastructure/tasks/module.go | 8 +++++++- internal/cli/cmd/infrastructure/tasks/tasks.go | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index 03ae9225123..0f1883f2226 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -56,7 +56,6 @@ type clusterOptions struct { cluster Cluster debug bool - enablePullImage bool autoRenewCerts bool securityEnhancement bool } diff --git a/internal/cli/cmd/infrastructure/pipeline.go b/internal/cli/cmd/infrastructure/pipeline.go index 1bf83c823d6..5a7de0a4cdf 100644 --- a/internal/cli/cmd/infrastructure/pipeline.go +++ b/internal/cli/cmd/infrastructure/pipeline.go @@ -30,7 +30,6 @@ import ( "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/module" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/etcd" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/filesystem" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/images" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/kubernetes" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/dns" @@ -53,7 +52,6 @@ func NewCreateK8sClusterForKubeblocks(o *clusterOptions) []module.Module { // &customscripts.CustomScriptsModule{Phase: "PreInstall", Scripts: runtime.Cluster.System.PreInstall}, &kubernetes.StatusModule{}, &container.InstallContainerModule{}, - &images.PullModule{Skip: !o.enablePullImage}, &etcd.PreCheckModule{}, &etcd.CertsModule{}, &etcd.InstallETCDBinaryModule{}, diff --git a/internal/cli/cmd/infrastructure/tasks/module.go b/internal/cli/cmd/infrastructure/tasks/module.go index 4d82765d003..3b64d08c675 100644 --- a/internal/cli/cmd/infrastructure/tasks/module.go +++ b/internal/cli/cmd/infrastructure/tasks/module.go @@ -40,7 +40,13 @@ func (i *InstallDependenciesModule) isNotReadyHosts() []connector.Host { var result confirm.PreCheckResults if v, ok := host.GetCache().Get(common.NodePreCheck); ok { _ = mapstructure.Decode(v, &result) - if result.Socat == "" || result.Conntrack == "" || result.Ipset == "" || result.Chronyd == "" || result.Ebtables == "" { + if result.Socat == "" || + result.Conntrack == "" || + result.Curl == "" || + result.Ipset == "" || + result.Chronyd == "" || + result.Ipvsadm == "" || + result.Ebtables == "" { hosts = append(hosts, host) } } diff --git a/internal/cli/cmd/infrastructure/tasks/tasks.go b/internal/cli/cmd/infrastructure/tasks/tasks.go index c9944b180b4..4347cd50f45 100644 --- a/internal/cli/cmd/infrastructure/tasks/tasks.go +++ b/internal/cli/cmd/infrastructure/tasks/tasks.go @@ -37,7 +37,7 @@ type InstallDependenciesTask struct { pkg []string } -var dependenciesPkg = []string{"socat", "conntrack", "ipset", "ebtables", "chrony", "iptables"} +var dependenciesPkg = []string{"socat", "conntrack", "ipset", "ebtables", "chrony", "iptables", "curl", "ipvsadm"} func (i *InstallDependenciesTask) Execute(runtime connector.Runtime) (err error) { host := runtime.RemoteHost() From fca9a159faf2f04e284e04db25e3c642ffc9d6aa Mon Sep 17 00:00:00 2001 From: sophon Date: Wed, 31 May 2023 16:12:27 +0800 Subject: [PATCH 05/44] chore: update kbcli-doc --- Makefile | 4 +- docs/user_docs/cli/cli.md | 7 +++ docs/user_docs/cli/kbcli.md | 1 + docs/user_docs/cli/kbcli_infra.md | 43 ++++++++++++++++ docs/user_docs/cli/kbcli_infra_create.md | 65 ++++++++++++++++++++++++ 5 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 docs/user_docs/cli/kbcli_infra.md create mode 100644 docs/user_docs/cli/kbcli_infra_create.md diff --git a/Makefile b/Makefile index 926c27e38f2..83237a435af 100644 --- a/Makefile +++ b/Makefile @@ -285,9 +285,7 @@ clean-kbcli: ## Clean bin/kbcli*. .PHONY: kbcli-doc kbcli-doc: generate test-go-generate ## generate CLI command reference manual. - $(GO) run ./hack/docgen/cli/main.go ./docs/user_docs/cli - - + $(GO) run -tags $(BUILD_TAGS) ./hack/docgen/cli/main.go ./docs/user_docs/cli .PHONY: api-doc api-doc: ## generate API reference manual. diff --git a/docs/user_docs/cli/cli.md b/docs/user_docs/cli/cli.md index c4c1548ccf1..136d2155cf4 100644 --- a/docs/user_docs/cli/cli.md +++ b/docs/user_docs/cli/cli.md @@ -136,6 +136,13 @@ Inject faults to pod. * [kbcli fault time](kbcli_fault_time.md) - Clock skew failure. +## [infra](kbcli_infra.md) + +infra command + +* [kbcli infra create](kbcli_infra_create.md) - create kubernetes cluster. + + ## [kubeblocks](kbcli_kubeblocks.md) KubeBlocks operation commands. diff --git a/docs/user_docs/cli/kbcli.md b/docs/user_docs/cli/kbcli.md index 848ce3e9946..664f1fadd27 100644 --- a/docs/user_docs/cli/kbcli.md +++ b/docs/user_docs/cli/kbcli.md @@ -64,6 +64,7 @@ kbcli [flags] * [kbcli clusterversion](kbcli_clusterversion.md) - ClusterVersion command. * [kbcli dashboard](kbcli_dashboard.md) - List and open the KubeBlocks dashboards. * [kbcli fault](kbcli_fault.md) - Inject faults to pod. +* [kbcli infra](kbcli_infra.md) - infra command * [kbcli kubeblocks](kbcli_kubeblocks.md) - KubeBlocks operation commands. * [kbcli migration](kbcli_migration.md) - Data migration between two data sources. * [kbcli options](kbcli_options.md) - Print the list of flags inherited by all commands. diff --git a/docs/user_docs/cli/kbcli_infra.md b/docs/user_docs/cli/kbcli_infra.md new file mode 100644 index 00000000000..03f64d298de --- /dev/null +++ b/docs/user_docs/cli/kbcli_infra.md @@ -0,0 +1,43 @@ +--- +title: kbcli infra +--- + +infra command + +### Options + +``` + -h, --help help for infra +``` + +### Options inherited from parent commands + +``` + --as string Username to impersonate for the operation. User could be a regular user or a service account in a namespace. + --as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups. + --as-uid string UID to impersonate for the operation. + --cache-dir string Default cache directory (default "$HOME/.kube/cache") + --certificate-authority string Path to a cert file for the certificate authority + --client-certificate string Path to a client certificate file for TLS + --client-key string Path to a client key file for TLS + --cluster string The name of the kubeconfig cluster to use + --context string The name of the kubeconfig context to use + --disable-compression If true, opt-out of response compression for all requests to the server + --insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure + --kubeconfig string Path to the kubeconfig file to use for CLI requests. + --match-server-version Require server version to match client version + -n, --namespace string If present, the namespace scope for this CLI request + --request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0") + -s, --server string The address and port of the Kubernetes API server + --tls-server-name string Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used + --token string Bearer token for authentication to the API server + --user string The name of the kubeconfig user to use +``` + +### SEE ALSO + + +* [kbcli infra create](kbcli_infra_create.md) - create kubernetes cluster. + +#### Go Back to [CLI Overview](cli.md) Homepage. + diff --git a/docs/user_docs/cli/kbcli_infra_create.md b/docs/user_docs/cli/kbcli_infra_create.md new file mode 100644 index 00000000000..174a85190bb --- /dev/null +++ b/docs/user_docs/cli/kbcli_infra_create.md @@ -0,0 +1,65 @@ +--- +title: kbcli infra create +--- + +create kubernetes cluster. + +``` +kbcli infra create [flags] +``` + +### Examples + +``` + + +``` + +### Options + +``` + --container-runtime string Specify kubernetes container runtime. default is containerd (default "containerd") + --debug set debug mode + --etcd strings Specify etcd nodes + -h, --help help for create + --master strings Specify master nodes + --name string Specify kubernetes cluster name + --nodes strings List of machines on which kubernetes is installed. [require] + -p, --password string Specify the password for the account to execute sudo. [option] + --private-key string The PrimaryKey for ssh to the remote machine. [option] + --private-key-path string Specify the file PrimaryKeyPath of ssh to the remote machine. default ~/.ssh/id_rsa. + -t, --timeout int Specify the ssh timeout.[option] (default 30) + -u, --user string Specify the account to access the remote server. [require] + --version string Specify install kubernetes version. default version is v1.26.1 (default "v1.26.1") + --worker strings Specify worker nodes +``` + +### Options inherited from parent commands + +``` + --as string Username to impersonate for the operation. User could be a regular user or a service account in a namespace. + --as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups. + --as-uid string UID to impersonate for the operation. + --cache-dir string Default cache directory (default "$HOME/.kube/cache") + --certificate-authority string Path to a cert file for the certificate authority + --client-certificate string Path to a client certificate file for TLS + --client-key string Path to a client key file for TLS + --cluster string The name of the kubeconfig cluster to use + --context string The name of the kubeconfig context to use + --disable-compression If true, opt-out of response compression for all requests to the server + --insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure + --kubeconfig string Path to the kubeconfig file to use for CLI requests. + --match-server-version Require server version to match client version + -n, --namespace string If present, the namespace scope for this CLI request + --request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0") + -s, --server string The address and port of the Kubernetes API server + --tls-server-name string Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used + --token string Bearer token for authentication to the API server +``` + +### SEE ALSO + +* [kbcli infra](kbcli_infra.md) - infra command + +#### Go Back to [CLI Overview](cli.md) Homepage. + From a268e560f03ce488e3e519a2f06338b218c14b5e Mon Sep 17 00:00:00 2001 From: sophon Date: Mon, 5 Jun 2023 10:56:59 +0800 Subject: [PATCH 06/44] migrate template to kubeblocks --- .../cli/cmd/infrastructure/builder/builder.go | 83 +++++++ .../template/containerd.config.toml.tpl | 78 +++++++ .../builder/template/containerd.service.tpl | 26 +++ .../builder/template/crictl.yaml.tpl | 5 + .../builder/template/init_os.sh.tpl | 148 ++++++++++++ .../template/kubekey_cluster.tpl} | 0 .../infrastructure/builder/template_task.go | 55 +++++ internal/cli/cmd/infrastructure/create.go | 36 +-- .../cli/cmd/infrastructure/loader_adapter.go | 53 +---- .../cmd/infrastructure/loader_adapter_test.go | 7 +- internal/cli/cmd/infrastructure/pipeline.go | 17 +- .../cli/cmd/infrastructure/tasks/constant.go | 39 ++++ .../cli/cmd/infrastructure/tasks/dependent.go | 220 ++++++++++++++++++ .../cli/cmd/infrastructure/tasks/download.go | 79 +++++++ .../cmd/infrastructure/tasks/kubernetes.go | 127 ++++++++++ .../cli/cmd/infrastructure/tasks/module.go | 110 --------- .../cli/cmd/infrastructure/tasks/prepare.go | 47 ---- .../cli/cmd/infrastructure/tasks/tasks.go | 3 +- .../cmd/infrastructure/{ => types}/type.go | 12 +- 19 files changed, 911 insertions(+), 234 deletions(-) create mode 100644 internal/cli/cmd/infrastructure/builder/builder.go create mode 100644 internal/cli/cmd/infrastructure/builder/template/containerd.config.toml.tpl create mode 100644 internal/cli/cmd/infrastructure/builder/template/containerd.service.tpl create mode 100644 internal/cli/cmd/infrastructure/builder/template/crictl.yaml.tpl create mode 100644 internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl rename internal/cli/cmd/infrastructure/{template/kubekey_cluster_template.tpl => builder/template/kubekey_cluster.tpl} (100%) create mode 100644 internal/cli/cmd/infrastructure/builder/template_task.go create mode 100644 internal/cli/cmd/infrastructure/tasks/constant.go create mode 100644 internal/cli/cmd/infrastructure/tasks/dependent.go create mode 100644 internal/cli/cmd/infrastructure/tasks/download.go create mode 100644 internal/cli/cmd/infrastructure/tasks/kubernetes.go delete mode 100644 internal/cli/cmd/infrastructure/tasks/module.go delete mode 100644 internal/cli/cmd/infrastructure/tasks/prepare.go rename internal/cli/cmd/infrastructure/{ => types}/type.go (84%) diff --git a/internal/cli/cmd/infrastructure/builder/builder.go b/internal/cli/cmd/infrastructure/builder/builder.go new file mode 100644 index 00000000000..203c2a5ebc8 --- /dev/null +++ b/internal/cli/cmd/infrastructure/builder/builder.go @@ -0,0 +1,83 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package builder + +import ( + "bufio" + "embed" + "encoding/json" + "strings" + + "github.com/leaanthony/debme" + "k8s.io/apimachinery/pkg/util/yaml" + + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" + "github.com/apecloud/kubeblocks/internal/gotemplate" +) + +var ( + //go:embed template/* + cueTemplate embed.FS +) + +func newBuildTemplate(templateName string) (string, error) { + tmplFs, _ := debme.FS(cueTemplate, "template") + if tmlBytes, err := tmplFs.ReadFile(templateName); err != nil { + return "", err + } else { + return string(tmlBytes), nil + } +} + +func BuildFromTemplate(values *gotemplate.TplValues, templateName string) (string, error) { + tpl, err := newBuildTemplate(templateName) + if err != nil { + return "", err + } + + engine := gotemplate.NewTplEngine(values, nil, templateName, nil, nil) + rendered, err := engine.Render(tpl) + if err != nil { + return "", err + } + return rendered, nil +} + +func BuildResourceFromYaml[T any](obj T, bYaml string) (*T, error) { + var ret map[string]interface{} + + content, err := yaml.NewYAMLReader(bufio.NewReader(strings.NewReader(bYaml))).Read() + if err != nil { + return nil, cfgcore.WrapError(err, "failed to read the cluster yaml") + } + err = yaml.Unmarshal(content, &ret) + if err != nil { + return nil, cfgcore.WrapError(err, "failed to unmarshal the cluster yaml") + } + + contentToJSON, err := yaml.ToJSON(content) + if err != nil { + return nil, cfgcore.WrapError(err, "Unable to convert configuration to json") + } + if err := json.Unmarshal(contentToJSON, &obj); err != nil { + return nil, cfgcore.WrapError(err, "failed to unmarshal the cluster") + } + return &obj, nil +} diff --git a/internal/cli/cmd/infrastructure/builder/template/containerd.config.toml.tpl b/internal/cli/cmd/infrastructure/builder/template/containerd.config.toml.tpl new file mode 100644 index 00000000000..c5e8b55b08c --- /dev/null +++ b/internal/cli/cmd/infrastructure/builder/template/containerd.config.toml.tpl @@ -0,0 +1,78 @@ +version = 2 +{{- if .DataRoot }} +root = {{ .DataRoot }} +{{ else }} +root = "/var/lib/containerd" +{{- end }} +state = "/run/containerd" + +[grpc] + address = "/run/containerd/containerd.sock" + uid = 0 + gid = 0 + max_recv_message_size = 16777216 + max_send_message_size = 16777216 + +[ttrpc] + address = "" + uid = 0 + gid = 0 + +[debug] + address = "" + uid = 0 + gid = 0 + level = "" + +[metrics] + address = "" + grpc_histogram = false + +[cgroup] + path = "" + +[timeouts] + "io.containerd.timeout.shim.cleanup" = "5s" + "io.containerd.timeout.shim.load" = "5s" + "io.containerd.timeout.shim.shutdown" = "3s" + "io.containerd.timeout.task.state" = "2s" + +[plugins] + [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc] + runtime_type = "io.containerd.runc.v2" + [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] + SystemdCgroup = true + [plugins."io.containerd.grpc.v1.cri"] + sandbox_image = "{{ .SandBoxImage }}" + [plugins."io.containerd.grpc.v1.cri".cni] + bin_dir = "/opt/cni/bin" + conf_dir = "/etc/cni/net.d" + max_conf_num = 1 + conf_template = "" + [plugins."io.containerd.grpc.v1.cri".registry] + [plugins."io.containerd.grpc.v1.cri".registry.mirrors] + {{- if .Mirrors }} + [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"] + endpoint = [{{ .Mirrors }}, "https://registry-1.docker.io"] + {{ else }} + [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"] + endpoint = ["https://registry-1.docker.io"] + {{- end}} + {{- range $value := .InsecureRegistries }} + [plugins."io.containerd.grpc.v1.cri".registry.mirrors."{{$value}}"] + endpoint = ["http://{{$value}}"] + {{- end}} + + {{- if .Auths }} + [plugins."io.containerd.grpc.v1.cri".registry.configs] + {{- range $repo, $entry := .Auths }} + [plugins."io.containerd.grpc.v1.cri".registry.configs."{{$repo}}".auth] + username = "{{$entry.Username}}" + password = "{{$entry.Password}}" + [plugins."io.containerd.grpc.v1.cri".registry.configs."{{$repo}}".tls] + ca_file = "{{$entry.CAFile}}" + cert_file = "{{$entry.CertFile}}" + key_file = "{{$entry.KeyFile}}" + insecure_skip_verify = {{$entry.SkipTLSVerify}} + {{- end}} + {{- end}} \ No newline at end of file diff --git a/internal/cli/cmd/infrastructure/builder/template/containerd.service.tpl b/internal/cli/cmd/infrastructure/builder/template/containerd.service.tpl new file mode 100644 index 00000000000..bb65fafafe4 --- /dev/null +++ b/internal/cli/cmd/infrastructure/builder/template/containerd.service.tpl @@ -0,0 +1,26 @@ +[Unit] +Description=containerd container runtime +Documentation=https://containerd.io +After=network.target local-fs.target + +[Service] +ExecStartPre=-/sbin/modprobe overlay +ExecStart=/usr/bin/containerd + +Type=notify +Delegate=yes +KillMode=process +Restart=always +RestartSec=5 +# Having non-zero Limit*s causes performance problems due to accounting overhead +# in the kernel. We recommend using cgroups to do container-local accounting. +LimitNPROC=infinity +LimitCORE=infinity +LimitNOFILE=1048576 +# Comment TasksMax if your systemd version does not supports it. +# Only systemd 226 and above support this version. +TasksMax=infinity +OOMScoreAdjust=-999 + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/internal/cli/cmd/infrastructure/builder/template/crictl.yaml.tpl b/internal/cli/cmd/infrastructure/builder/template/crictl.yaml.tpl new file mode 100644 index 00000000000..236bb88f5fd --- /dev/null +++ b/internal/cli/cmd/infrastructure/builder/template/crictl.yaml.tpl @@ -0,0 +1,5 @@ +runtime-endpoint: {{ .Endpoint }} +image-endpoint: {{ .Endpoint }} +timeout: 5 +debug: false +pull-image-on-create: false \ No newline at end of file diff --git a/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl b/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl new file mode 100644 index 00000000000..350c95f9cd5 --- /dev/null +++ b/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl @@ -0,0 +1,148 @@ +#!/usr/bin/env bash + +function swap_off() { + echo "swap off..." + swapoff -a + sed -i /^[^#]*swap*/s/^/\#/g /etc/fstab + + # clean cache + echo 3 > /proc/sys/vm/drop_caches +} + +function selinux_off() { + echo "selinux off..." + setenforce 0 + echo "enforce: $(getenforce)" + + if [ -f /etc/selinux/config ]; then + sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config + fi +} + + +function replace_in_file() { + local filename="${1:?filename is required}" + local match_regex="${2:?match regex is required}" + local substitute_regex="${3:?substitute regex is required}" + local posix_regex=${4:-true} + + local result + + # Use a non-printable character as a 'sed' delimiter to avoid issues + local -r del=$'\001' + if [[ $posix_regex = true ]]; then + result="$(sed -E "s${del}${match_regex}${del}${substitute_regex}${del}g" "$filename")" + else + result="$(sed "s${del}${match_regex}${del}${substitute_regex}${del}g" "$filename")" + fi + echo "$result" > "$filename" +} + +function sysctl_set_property() { + local -r property="${1:?missing property}" + local -r value="${2:?missing value}" + local -r conf_file="/etc/sysctl.conf" + if grep -qE "^#*\s*${property}" "$conf_file" >/dev/null; then + replace_in_file "$conf_file" "^#*\s*${property}\s*=.*" "${property} = ${value}" false + else + echo "${property} = '${value}'" >>"$conf_file" + fi +} + +function set_network() { + echo "set network..." + + sysctl_set_property "net.ipv4.tcp_tw_recycle" "0" + sysctl_set_property "net.ipv4.ip_forward" "1" + sysctl_set_property "net.bridge.bridge-nf-call-arptables" "1" + sysctl_set_property "net.bridge.bridge-nf-call-ip6tables" "1" + sysctl_set_property "net.bridge.bridge-nf-call-iptables" "1" + sysctl_set_property "net.ipv4.ip_local_reserved_ports" "30000-32767" +} + +function firewall_off() { + echo "firewall off..." + systemctl stop firewalld 1>/dev/null 2>/dev/null + systemctl disable firewalld 1>/dev/null 2>/dev/null + systemctl stop ufw 1>/dev/null 2>/dev/null + systemctl disable ufw 1>/dev/null 2>/dev/null +} + + +echo 'vm.max_map_count = 262144' >> /etc/sysctl.conf +echo 'vm.swappiness = 1' >> /etc/sysctl.conf +echo 'fs.inotify.max_user_instances = 524288' >> /etc/sysctl.conf +echo 'kernel.pid_max = 65535' >> /etc/sysctl.conf + + +#See https://imroc.io/posts/kubernetes/troubleshooting-with-kubernetes-network/ +sed -r -i "s@#{0,}?net.ipv4.tcp_tw_recycle ?= ?(0|1)@net.ipv4.tcp_tw_recycle = 0@g" /etc/sysctl.conf + +sed -r -i "s@#{0,}?net.ipv4.ip_forward ?= ?(0|1)@net.ipv4.ip_forward = 1@g" /etc/sysctl.conf +sed -r -i "s@#{0,}?net.bridge.bridge-nf-call-arptables ?= ?(0|1)@net.bridge.bridge-nf-call-arptables = 1@g" /etc/sysctl.conf +sed -r -i "s@#{0,}?net.bridge.bridge-nf-call-ip6tables ?= ?(0|1)@net.bridge.bridge-nf-call-ip6tables = 1@g" /etc/sysctl.conf +sed -r -i "s@#{0,}?net.bridge.bridge-nf-call-iptables ?= ?(0|1)@net.bridge.bridge-nf-call-iptables = 1@g" /etc/sysctl.conf +sed -r -i "s@#{0,}?net.ipv4.ip_local_reserved_ports ?= ?([0-9]{1,}-{0,1},{0,1}){1,}@net.ipv4.ip_local_reserved_ports = 30000-32767@g" /etc/sysctl.conf +sed -r -i "s@#{0,}?vm.max_map_count ?= ?([0-9]{1,})@vm.max_map_count = 262144@g" /etc/sysctl.conf +sed -r -i "s@#{0,}?vm.swappiness ?= ?([0-9]{1,})@vm.swappiness = 1@g" /etc/sysctl.conf +sed -r -i "s@#{0,}?fs.inotify.max_user_instances ?= ?([0-9]{1,})@fs.inotify.max_user_instances = 524288@g" /etc/sysctl.conf +sed -r -i "s@#{0,}?kernel.pid_max ?= ?([0-9]{1,})@kernel.pid_max = 65535@g" /etc/sysctl.conf + +tmpfile="$$.tmp" +awk ' !x[$0]++{print > "'$tmpfile'"}' /etc/sysctl.conf +mv $tmpfile /etc/sysctl.conf + + +modinfo br_netfilter > /dev/null 2>&1 +if [ $? -eq 0 ]; then + modprobe br_netfilter + mkdir -p /etc/modules-load.d + echo 'br_netfilter' > /etc/modules-load.d/kubekey-br_netfilter.conf +fi + +modinfo overlay > /dev/null 2>&1 +if [ $? -eq 0 ]; then + modprobe overlay + echo 'overlay' >> /etc/modules-load.d/kubekey-br_netfilter.conf +fi + +modprobe ip_vs +modprobe ip_vs_rr +modprobe ip_vs_wrr +modprobe ip_vs_sh + +cat > /etc/modules-load.d/kube_proxy-ipvs.conf << EOF +ip_vs +ip_vs_rr +ip_vs_wrr +ip_vs_sh +EOF + +modprobe nf_conntrack_ipv4 1>/dev/null 2>/dev/null +if [ $? -eq 0 ]; then + echo 'nf_conntrack_ipv4' > /etc/modules-load.d/kube_proxy-ipvs.conf +else + modprobe nf_conntrack + echo 'nf_conntrack' > /etc/modules-load.d/kube_proxy-ipvs.conf +fi +sysctl -p + +sed -i ':a;$!{N;ba};s@# kubekey hosts BEGIN.*# kubekey hosts END@@' /etc/hosts +sed -i '/^$/N;/\n$/N;//D' /etc/hosts + +cat >>/etc/hosts</dev/null 2>&1 || true +update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy >/dev/null 2>&1 || true +update-alternatives --set arptables /usr/sbin/arptables-legacy >/dev/null 2>&1 || true +update-alternatives --set ebtables /usr/sbin/ebtables-legacy >/dev/null 2>&1 || true + +ulimit -u 65535 +ulimit -n 65535 diff --git a/internal/cli/cmd/infrastructure/template/kubekey_cluster_template.tpl b/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl similarity index 100% rename from internal/cli/cmd/infrastructure/template/kubekey_cluster_template.tpl rename to internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl diff --git a/internal/cli/cmd/infrastructure/builder/template_task.go b/internal/cli/cmd/infrastructure/builder/template_task.go new file mode 100644 index 00000000000..eaf7d5d1cc9 --- /dev/null +++ b/internal/cli/cmd/infrastructure/builder/template_task.go @@ -0,0 +1,55 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package builder + +import ( + "path/filepath" + + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/action" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/util" + + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" + "github.com/apecloud/kubeblocks/internal/gotemplate" +) + +type Template struct { + action.BaseAction + Template string + Dst string + Values gotemplate.TplValues +} + +func (t *Template) Execute(runtime connector.Runtime) error { + templateStr, err := BuildFromTemplate(&t.Values, t.Template) + if err != nil { + return cfgcore.WrapError(err, "failed to render template %s", t.Template) + } + + fileName := filepath.Join(runtime.GetHostWorkDir(), t.Template) + if err := util.WriteFile(fileName, []byte(templateStr)); err != nil { + return cfgcore.WrapError(err, "failed to write file %s", fileName) + } + + if err := runtime.GetRunner().SudoScp(fileName, t.Dst); err != nil { + return cfgcore.WrapError(err, "failed to scp file %s to remote %s", fileName, t.Dst) + } + return nil +} diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index 0f1883f2226..2e34bd3e36a 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -27,6 +27,8 @@ import ( "strings" "github.com/StudioSol/set" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" kubekeyapiv1alpha2 "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/connector" @@ -42,6 +44,7 @@ import ( type clusterOptions struct { IOStreams genericclioptions.IOStreams + version types.InfraVersionInfo timeout int64 userName string @@ -51,20 +54,14 @@ type clusterOptions struct { clusterName string nodes []string - version string criType string - cluster Cluster + cluster types.Cluster debug bool autoRenewCerts bool securityEnhancement bool } -const ( - defaultVersion = "v1.26.1" - defaultDownloadURL = "curl -L -o %s %s" -) - var createExamples = ` ` @@ -96,13 +93,13 @@ func (o *clusterOptions) Complete() error { if len(o.nodes) == 0 { return cfgcore.MakeError("The list of machines where kubernetes is installed must be specified.") } - o.cluster.Nodes = make([]ClusterNode, len(o.nodes)) + o.cluster.Nodes = make([]types.ClusterNode, len(o.nodes)) for i, node := range o.nodes { fields := strings.SplitN(node, ":", 3) if len(fields) < 2 { return cfgcore.MakeError("The node format is incorrect, require: [name:address:internalAddress].") } - n := ClusterNode{ + n := types.ClusterNode{ Name: fields[0], Address: fields[1], InternalAddress: fields[1], @@ -190,14 +187,6 @@ func (o *clusterOptions) Run() error { BaseRuntime: connector.NewBaseRuntime(o.clusterName, connector.NewDialer(), o.debug, false), Cluster: cluster, ClusterName: o.clusterName, - Arg: common.Argument{ - DownloadCommand: func(path, url string) string { - // this is an extension point for downloading tools, for example users can set the timeout, proxy or retry under - // some poor network environment. Or users even can choose another cli, it might be wget. - // perhaps we should have a build-in download function instead of totally rely on the external one - return fmt.Sprintf(defaultDownloadURL, path, url) - }, - }, } updateClusterHosts(cluster, runtime) @@ -217,6 +206,7 @@ func NewCreateKubernetesCmd(streams genericclioptions.IOStreams) *cobra.Command o := &clusterOptions{ IOStreams: streams, } + o.setDefaultVersion() cmd := &cobra.Command{ Use: "create", Short: "create kubernetes cluster.", @@ -233,7 +223,7 @@ func NewCreateKubernetesCmd(streams genericclioptions.IOStreams) *cobra.Command func (o *clusterOptions) buildCreateInfraFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&o.clusterName, "name", "", "", "Specify kubernetes cluster name") - cmd.Flags().StringVarP(&o.version, "version", "", defaultVersion, fmt.Sprintf("Specify install kubernetes version. default version is %s", defaultVersion)) + cmd.Flags().StringVarP(&o.version.KubernetesVersion, "version", "", o.version.KubernetesVersion, fmt.Sprintf("Specify install kubernetes version. default version is %s", o.version.KubernetesVersion)) cmd.Flags().StringVarP(&o.criType, "container-runtime", "", string(container.ContainerdType), "Specify kubernetes container runtime. default is containerd") cmd.Flags().StringSliceVarP(&o.nodes, "nodes", "", nil, "List of machines on which kubernetes is installed. [require]") cmd.Flags().BoolVarP(&o.debug, "debug", "", false, "set debug mode") @@ -249,3 +239,13 @@ func (o *clusterOptions) buildCreateInfraFlags(cmd *cobra.Command) { cmd.Flags().StringSliceVarP(&o.cluster.Master, "master", "", nil, "Specify master nodes") cmd.Flags().StringSliceVarP(&o.cluster.Worker, "worker", "", nil, "Specify worker nodes") } + +func (o *clusterOptions) setDefaultVersion() { + o.version.KubernetesVersion = tasks.DefaultK8sVersion + o.version.EtcdVersion = tasks.DefaultEtcdVersion + o.version.ContainerVersion = tasks.DefaultContainerdVersion + o.version.HelmVersion = tasks.DefaultHelmVersion + o.version.CRICtlVersion = tasks.DefaultCRICtlVersion + o.version.CniVersion = tasks.DefaultCniVersion + o.version.RuncVersion = tasks.DefaultRuncVersion +} diff --git a/internal/cli/cmd/infrastructure/loader_adapter.go b/internal/cli/cmd/infrastructure/loader_adapter.go index 5b1b460852a..b240c16eff5 100644 --- a/internal/cli/cmd/infrastructure/loader_adapter.go +++ b/internal/cli/cmd/infrastructure/loader_adapter.go @@ -20,65 +20,26 @@ along with this program. If not, see . package infrastructure import ( - "bufio" - "embed" - "encoding/json" - "strings" - kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" - "github.com/leaanthony/debme" - "k8s.io/apimachinery/pkg/util/yaml" - cfgcore "github.com/apecloud/kubeblocks/internal/configuration" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" "github.com/apecloud/kubeblocks/internal/gotemplate" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" ) -var ( - //go:embed template/* - cueTemplate embed.FS -) - -func newKubeKeyClusterTemplate(templateName string) (string, error) { - tmplFs, _ := debme.FS(cueTemplate, "template") - if tmlBytes, err := tmplFs.ReadFile(templateName); err != nil { - return "", err - } else { - return string(tmlBytes), nil - } -} +var ReplicaSetSignature = func(_ kubekeyapiv1alpha2.Cluster, _ any) {} func createClusterWithOptions(values *gotemplate.TplValues) (*kubekeyapiv1alpha2.ClusterSpec, error) { - const tplFile = "kubekey_cluster_template.tpl" - yamlTemplate, err := newKubeKeyClusterTemplate(tplFile) + const tplFile = "kubekey_cluster.tpl" + rendered, err := builder.BuildFromTemplate(values, tplFile) if err != nil { return nil, err } - tpl := gotemplate.NewTplEngine(values, nil, "ClusterTemplate", nil, nil) - rendered, err := tpl.Render(yamlTemplate) + cluster, err := builder.BuildResourceFromYaml(kubekeyapiv1alpha2.Cluster{}, rendered) if err != nil { return nil, err } - - var ret map[string]interface{} - cluster := kubekeyapiv1alpha2.Cluster{} - content, err := yaml.NewYAMLReader(bufio.NewReader(strings.NewReader(rendered))).Read() - if err != nil { - return nil, cfgcore.WrapError(err, "failed to read the cluster yaml") - } - err = yaml.Unmarshal(content, &ret) - if err != nil { - return nil, cfgcore.WrapError(err, "failed to unmarshal the cluster yaml") - } - - contentToJSON, err := yaml.ToJSON(content) - if err != nil { - return nil, cfgcore.WrapError(err, "Unable to convert configuration to json") - } - if err := json.Unmarshal(contentToJSON, &cluster); err != nil { - return nil, cfgcore.WrapError(err, "failed to unmarshal the cluster") - } return &cluster.Spec, nil } @@ -97,7 +58,7 @@ const ( func buildTemplateParams(o *clusterOptions) *gotemplate.TplValues { return &gotemplate.TplValues{ builtinClusterNameObject: o.clusterName, - builtinClusterVersionObject: o.version, + builtinClusterVersionObject: o.version.KubernetesVersion, builtinCRITypeObject: o.criType, builtinUserObject: o.userName, builtinPasswordObject: o.password, diff --git a/internal/cli/cmd/infrastructure/loader_adapter_test.go b/internal/cli/cmd/infrastructure/loader_adapter_test.go index 131922ff5e3..7740c4b42aa 100644 --- a/internal/cli/cmd/infrastructure/loader_adapter_test.go +++ b/internal/cli/cmd/infrastructure/loader_adapter_test.go @@ -22,6 +22,7 @@ package infrastructure import ( "testing" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" "github.com/apecloud/kubeblocks/internal/configuration/container" @@ -37,12 +38,12 @@ func TestCreateClusterWithOptions(t *testing.T) { name: "generateClusterTest", args: &clusterOptions{ clusterName: "for_test", - version: defaultVersion, + version: types.InfraVersionInfo{}, criType: string(container.ContainerdType), userName: "test", password: "test", - cluster: Cluster{ - Nodes: []ClusterNode{ + cluster: types.Cluster{ + Nodes: []types.ClusterNode{ { Name: "node1", Address: "127.0.0.1", diff --git a/internal/cli/cmd/infrastructure/pipeline.go b/internal/cli/cmd/infrastructure/pipeline.go index 5a7de0a4cdf..17b3484c6e0 100644 --- a/internal/cli/cmd/infrastructure/pipeline.go +++ b/internal/cli/cmd/infrastructure/pipeline.go @@ -20,10 +20,6 @@ along with this program. If not, see . package infrastructure import ( - "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/binaries" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/confirm" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/precheck" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/certs" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/container" @@ -34,6 +30,8 @@ import ( "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/dns" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/network" + + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" ) func NewCreateK8sClusterForKubeblocks(o *clusterOptions) []module.Module { @@ -44,14 +42,17 @@ func NewCreateK8sClusterForKubeblocks(o *clusterOptions) []module.Module { &precheck.NodePreCheckModule{}, // install kubekey required packages &tasks.InstallDependenciesModule{}, - &precheck.NodePreCheckModule{}, - &confirm.InstallConfirmModule{}, + // &precheck.NodePreCheckModule{}, + // &confirm.InstallConfirmModule{}, // &os.RepositoryModule{Skip: !runtime.Arg.InstallPackages}, - &binaries.NodeBinariesModule{}, - &os.ConfigureOSModule{}, + // &binaries.NodeBinariesModule{}, + &tasks.PrepareK8sBinariesModule{BinaryVersion: o.version}, + &tasks.ConfigureOSModule{}, + // &os.ConfigureOSModule{}, // &customscripts.CustomScriptsModule{Phase: "PreInstall", Scripts: runtime.Cluster.System.PreInstall}, &kubernetes.StatusModule{}, &container.InstallContainerModule{}, + &tasks.InstallCRIModule{}, &etcd.PreCheckModule{}, &etcd.CertsModule{}, &etcd.InstallETCDBinaryModule{}, diff --git a/internal/cli/cmd/infrastructure/tasks/constant.go b/internal/cli/cmd/infrastructure/tasks/constant.go new file mode 100644 index 00000000000..f5894b6a4e7 --- /dev/null +++ b/internal/cli/cmd/infrastructure/tasks/constant.go @@ -0,0 +1,39 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package tasks + +const ( + ContainerdService = "containerd.service.tpl" + ContainerdConfig = "containerd.config.toml.tpl" + CRICtlConfig = "crictl.yaml.tpl" + ConfigureOSScripts = "init_os.sh.tpl" + + ContainerdServiceInstallPath = "/etc/systemd/system/containerd.service" + ContainerdConfigInstallPath = "/etc/containerd/config.toml" + CRICtlConfigInstallPath = "/etc/crictl.yaml" + + DefaultK8sVersion = "v1.26.5" // https://github.com/kubernetes/kubernetes/releases/tag/v1.26.5 + DefaultEtcdVersion = "v3.4.26" // https://github.com/etcd-io/etcd/releases/tag/v3.4.26 + DefaultCRICtlVersion = "v1.26.0" // https://github.com/kubernetes-sigs/cri-tools/releases/tag/v1.26.0 + DefaultHelmVersion = "v3.12.0" // https://github.com/helm/helm/releases + DefaultContainerdVersion = "v1.7.2" // https://github.com/containerd/containerd/releases + DefaultRuncVersion = "v1.1.7" // https://github.com/opencontainers/runc/releases + DefaultCniVersion = "v1.3.0" // https://github.com/containernetworking/plugins/releases +) diff --git a/internal/cli/cmd/infrastructure/tasks/dependent.go b/internal/cli/cmd/infrastructure/tasks/dependent.go new file mode 100644 index 00000000000..0bc3b462fb9 --- /dev/null +++ b/internal/cli/cmd/infrastructure/tasks/dependent.go @@ -0,0 +1,220 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package tasks + +import ( + "github.com/apecloud/kubeblocks/internal/gotemplate" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/confirm" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/container" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/container/templates" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/logger" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/prepare" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/images" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/kubernetes" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/registry" + "github.com/mitchellh/mapstructure" + + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" +) + +type InstallDependenciesModule struct { + common.KubeModule +} + +func (i *InstallDependenciesModule) isNotReadyHosts() []connector.Host { + hosts := make([]connector.Host, 0) + for _, host := range i.Runtime.GetAllHosts() { + var result confirm.PreCheckResults + if v, ok := host.GetCache().Get(common.NodePreCheck); ok { + _ = mapstructure.Decode(v, &result) + if result.Socat == "" || + result.Conntrack == "" || + result.Curl == "" || + result.Ipset == "" || + result.Chronyd == "" || + result.Ipvsadm == "" || + result.Ebtables == "" { + hosts = append(hosts, host) + } + } + } + return hosts +} + +// Init install dependencies module +func (i *InstallDependenciesModule) Init() { + i.Name = "InstallDependenciesModule" + i.Desc = "install dependencies" + + hosts := i.isNotReadyHosts() + if len(hosts) == 0 { + logger.Log.Info("All hosts are ready, skip install dependencies") + return + } + + i.Tasks = []task.Interface{ + &task.RemoteTask{ + Name: "GetOSData", + Desc: "Get OS release", + Hosts: i.Runtime.GetAllHosts(), + Action: new(os.GetOSData), + Parallel: true, + }, + &task.RemoteTask{ + Name: "InstallDependenciesModule", + Desc: "check and install dependencies", + Hosts: hosts, + Action: new(InstallDependenciesTask), + Parallel: true, + }, + } +} + +type CheckNodeArchitectureModule struct { + common.KubeModule +} + +// Init install dependencies module +func (i *CheckNodeArchitectureModule) Init() { + i.Name = "CheckNodeArch" + i.Desc = "check and update host arch" + i.Tasks = []task.Interface{ + &task.RemoteTask{ + Name: "CheckNodeArch", + Desc: "check and update node arch", + Hosts: i.Runtime.GetAllHosts(), + Action: new(UpdateNodeTask), + Parallel: true, + }, + } +} + +type InstallCRIModule struct { + common.KubeModule +} + +func (i *InstallCRIModule) Init() { + i.Name = "InstallContainerModule" + i.Desc = "Install container manager" + + syncContainerd := &task.RemoteTask{ + Name: "SyncContainerd", + Desc: "Sync containerd binaries", + Hosts: i.Runtime.GetHostsByRole(common.K8s), + Prepare: &prepare.PrepareCollection{ + &kubernetes.NodeInCluster{Not: true}, + &container.ContainerdExist{Not: true}, + }, + Action: new(container.SyncContainerd), + Parallel: true, + Retry: 2, + } + + syncCrictlBinaries := &task.RemoteTask{ + Name: "SyncCrictlBinaries", + Desc: "Sync crictl binaries", + Hosts: i.Runtime.GetHostsByRole(common.K8s), + Prepare: &prepare.PrepareCollection{ + &kubernetes.NodeInCluster{Not: true}, + &container.CrictlExist{Not: true}, + }, + Action: new(container.SyncCrictlBinaries), + Parallel: true, + Retry: 2, + } + + generateContainerdService := &task.RemoteTask{ + Name: "GenerateContainerdService", + Desc: "Generate containerd service", + Hosts: i.Runtime.GetHostsByRole(common.K8s), + Prepare: &prepare.PrepareCollection{ + &kubernetes.NodeInCluster{Not: true}, + &container.ContainerdExist{Not: true}, + }, + Action: &builder.Template{ + Template: ContainerdService, + Dst: ContainerdServiceInstallPath, + }, + Parallel: true, + } + + generateContainerdConfig := &task.RemoteTask{ + Name: "GenerateContainerdConfig", + Desc: "Generate containerd config", + Hosts: i.Runtime.GetHostsByRole(common.K8s), + Prepare: &prepare.PrepareCollection{ + &kubernetes.NodeInCluster{Not: true}, + &container.ContainerdExist{Not: true}, + }, + Action: &builder.Template{ + Template: ContainerdConfig, + Dst: ContainerdConfigInstallPath, + Values: gotemplate.TplValues{ + "Mirrors": templates.Mirrors(i.KubeConf), + "InsecureRegistries": i.KubeConf.Cluster.Registry.InsecureRegistries, + "SandBoxImage": images.GetImage(i.Runtime, i.KubeConf, "pause").ImageName(), + "Auths": registry.DockerRegistryAuthEntries(i.KubeConf.Cluster.Registry.Auths), + "DataRoot": templates.DataRoot(i.KubeConf), + }}, + Parallel: true, + } + + generateCrictlConfig := &task.RemoteTask{ + Name: "GenerateCrictlConfig", + Desc: "Generate crictl config", + Hosts: i.Runtime.GetHostsByRole(common.K8s), + Prepare: &prepare.PrepareCollection{ + &kubernetes.NodeInCluster{Not: true}, + &container.ContainerdExist{Not: true}, + }, + Action: &builder.Template{ + Template: CRICtlConfig, + Dst: CRICtlConfigInstallPath, + Values: gotemplate.TplValues{ + "Endpoint": i.KubeConf.Cluster.Kubernetes.ContainerRuntimeEndpoint, + }}, + Parallel: true, + } + + enableContainerd := &task.RemoteTask{ + Name: "EnableContainerd", + Desc: "Enable containerd", + Hosts: i.Runtime.GetHostsByRole(common.K8s), + Prepare: &prepare.PrepareCollection{ + &kubernetes.NodeInCluster{Not: true}, + &container.ContainerdExist{Not: true}, + }, + Action: new(container.EnableContainerd), + Parallel: true, + } + + i.Tasks = []task.Interface{ + syncContainerd, + syncCrictlBinaries, + generateContainerdService, + generateContainerdConfig, + generateCrictlConfig, + enableContainerd, + } +} diff --git a/internal/cli/cmd/infrastructure/tasks/download.go b/internal/cli/cmd/infrastructure/tasks/download.go new file mode 100644 index 00000000000..8e2c3d26db3 --- /dev/null +++ b/internal/cli/cmd/infrastructure/tasks/download.go @@ -0,0 +1,79 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package tasks + +import ( + "fmt" + "os" + + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/logger" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/util" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/files" + + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" +) + +const ( + defaultDownloadURL = "curl -L -o %s %s" +) + +func downloadKubernetesBinaryWithArch(downloadPath string, arch string, binaryVersion types.InfraVersionInfo) (map[string]*files.KubeBinary, error) { + downloadCommand := func(path, url string) string { + return fmt.Sprintf(defaultDownloadURL, path, url) + } + + binaries := []*files.KubeBinary{ + files.NewKubeBinary("etcd", arch, binaryVersion.EtcdVersion, downloadPath, downloadCommand), + files.NewKubeBinary("kubeadm", arch, binaryVersion.KubernetesVersion, downloadPath, downloadCommand), + files.NewKubeBinary("kubelet", arch, binaryVersion.KubernetesVersion, downloadPath, downloadCommand), + files.NewKubeBinary("kubectl", arch, binaryVersion.KubernetesVersion, downloadPath, downloadCommand), + files.NewKubeBinary("kubecni", arch, binaryVersion.CniVersion, downloadPath, downloadCommand), + files.NewKubeBinary("helm", arch, binaryVersion.HelmVersion, downloadPath, downloadCommand), + // for containerd + files.NewKubeBinary("crictl", arch, binaryVersion.CRICtlVersion, downloadPath, downloadCommand), + files.NewKubeBinary("containerd", arch, binaryVersion.ContainerVersion, downloadPath, downloadCommand), + files.NewKubeBinary("runc", arch, binaryVersion.RuncVersion, downloadPath, downloadCommand), + } + + binariesMap := make(map[string]*files.KubeBinary) + for _, binary := range binaries { + if err := binary.CreateBaseDir(); err != nil { + return nil, cfgcore.WrapError(err, "failed to create file %s base dir.", binary.FileName) + } + logger.Log.Messagef(common.LocalHost, "downloading %s %s %s ...", arch, binary.ID, binary.Version) + + binariesMap[binary.ID] = binary + if util.IsExist(binary.Path()) { + if err := binary.SHA256Check(); err != nil { + _ = os.Remove(binary.Path()) + } else { + logger.Log.Messagef(common.LocalHost, "%s is existed", binary.ID) + continue + } + } + if err := binary.Download(); err != nil { + return nil, cfgcore.WrapError(err, "failed to download %s binary: %s", binary.ID, binary.GetCmd()) + } + } + + return binariesMap, nil +} diff --git a/internal/cli/cmd/infrastructure/tasks/kubernetes.go b/internal/cli/cmd/infrastructure/tasks/kubernetes.go new file mode 100644 index 00000000000..8e798ee0acc --- /dev/null +++ b/internal/cli/cmd/infrastructure/tasks/kubernetes.go @@ -0,0 +1,127 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package tasks + +import ( + "path/filepath" + + "github.com/StudioSol/set" + "github.com/apecloud/kubeblocks/internal/gotemplate" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os/templates" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task" + + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" +) + +type PrepareK8sBinariesModule struct { + common.KubeModule + + // kubernetes version + BinaryVersion types.InfraVersionInfo +} + +type ConfigureOSModule struct { + common.KubeModule +} + +func (p *PrepareK8sBinariesModule) Init() { + p.Name = "PrepareK8sBinariesModule" + p.Desc = "Download installation binaries for kubernetes" + + p.Tasks = []task.Interface{ + &task.LocalTask{ + Name: "DownloadBinaries", + Desc: "Download installation binaries", + Action: &DownloadKubernetesBinary{BinaryVersion: p.BinaryVersion}, + }} +} + +func (c *ConfigureOSModule) Init() { + c.Name = "ConfigureOSModule" + c.Desc = "Init os dependencies" + c.Tasks = []task.Interface{ + &task.RemoteTask{ + Name: "GetOSData", + Desc: "Get OS release", + Hosts: c.Runtime.GetAllHosts(), + Action: new(os.GetOSData), + Parallel: true, + }, + &task.RemoteTask{ + Name: "InitOS", + Desc: "Prepare to init OS", + Hosts: c.Runtime.GetAllHosts(), + Action: new(os.NodeConfigureOS), + Parallel: true, + }, + &task.RemoteTask{ + Name: "GenerateScript", + Desc: "Generate init os script", + Hosts: c.Runtime.GetAllHosts(), + Action: &builder.Template{ + Template: ConfigureOSScripts, + Dst: filepath.Join(common.KubeScriptDir, "initOS.sh"), + Values: gotemplate.TplValues{ + "Hosts": templates.GenerateHosts(c.Runtime, c.KubeConf), + }}, + Parallel: true, + }, + &task.RemoteTask{ + Name: "ExecScript", + Desc: "Exec init os script", + Hosts: c.Runtime.GetAllHosts(), + Action: new(os.NodeExecScript), + Parallel: true, + }, + &task.RemoteTask{ + Name: "ConfigureNtpServer", + Desc: "configure the ntp server for each node", + Hosts: c.Runtime.GetAllHosts(), + Prepare: new(os.NodeConfigureNtpCheck), + Action: new(os.NodeConfigureNtpServer), + Parallel: true, + }, + } +} + +type DownloadKubernetesBinary struct { + common.KubeAction + BinaryVersion types.InfraVersionInfo +} + +func (d *DownloadKubernetesBinary) Execute(runtime connector.Runtime) error { + archSet := set.NewLinkedHashSetString() + for _, host := range runtime.GetAllHosts() { + archSet.Add(host.GetArch()) + } + + for _, arch := range archSet.AsSlice() { + binariesMap, err := downloadKubernetesBinaryWithArch(runtime.GetWorkDir(), arch, d.BinaryVersion) + if err != nil { + return err + } + d.PipelineCache.Set(common.KubeBinaries+"-"+arch, binariesMap) + } + return nil +} diff --git a/internal/cli/cmd/infrastructure/tasks/module.go b/internal/cli/cmd/infrastructure/tasks/module.go deleted file mode 100644 index 3b64d08c675..00000000000 --- a/internal/cli/cmd/infrastructure/tasks/module.go +++ /dev/null @@ -1,110 +0,0 @@ -/* -Copyright (C) 2022-2023 ApeCloud Co., Ltd - -This file is part of KubeBlocks project - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . -*/ - -package tasks - -import ( - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/confirm" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/logger" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task" - - "github.com/mitchellh/mapstructure" -) - -type InstallDependenciesModule struct { - common.KubeModule -} - -func (i *InstallDependenciesModule) isNotReadyHosts() []connector.Host { - hosts := make([]connector.Host, 0) - for _, host := range i.Runtime.GetAllHosts() { - var result confirm.PreCheckResults - if v, ok := host.GetCache().Get(common.NodePreCheck); ok { - _ = mapstructure.Decode(v, &result) - if result.Socat == "" || - result.Conntrack == "" || - result.Curl == "" || - result.Ipset == "" || - result.Chronyd == "" || - result.Ipvsadm == "" || - result.Ebtables == "" { - hosts = append(hosts, host) - } - } - } - return hosts -} - -// Init install dependencies module -func (i *InstallDependenciesModule) Init() { - i.Name = "InstallDependenciesModule" - i.Desc = "install dependencies" - - hosts := i.isNotReadyHosts() - if len(hosts) == 0 { - logger.Log.Info("All hosts are ready, skip install dependencies") - return - } - - prepareOSData := &task.RemoteTask{ - Name: "GetOSData", - Desc: "Get OS release", - Hosts: i.Runtime.GetAllHosts(), - Action: new(os.GetOSData), - Parallel: true, - } - - installPkg := &task.RemoteTask{ - Name: "InstallDependenciesModule", - Desc: "check and install dependencies", - Hosts: hosts, - Action: new(InstallDependenciesTask), - Parallel: true, - } - - i.Tasks = []task.Interface{ - prepareOSData, - installPkg, - } -} - -type CheckNodeArchitectureModule struct { - common.KubeModule -} - -// Init install dependencies module -func (i *CheckNodeArchitectureModule) Init() { - i.Name = "CheckNodeArch" - i.Desc = "check and update host arch" - - prepareNodeArch := &task.RemoteTask{ - Name: "CheckNodeArch", - Desc: "check and update node arch", - Hosts: i.Runtime.GetAllHosts(), - Action: new(UpdateNodeTask), - Parallel: true, - } - - i.Tasks = []task.Interface{ - prepareNodeArch, - } -} diff --git a/internal/cli/cmd/infrastructure/tasks/prepare.go b/internal/cli/cmd/infrastructure/tasks/prepare.go deleted file mode 100644 index 209ac0ae2ee..00000000000 --- a/internal/cli/cmd/infrastructure/tasks/prepare.go +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright (C) 2022-2023 ApeCloud Co., Ltd - -This file is part of KubeBlocks project - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . -*/ - -package tasks - -import ( - cfgcore "github.com/apecloud/kubeblocks/internal/configuration" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/confirm" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" - "github.com/mitchellh/mapstructure" -) - -type DependenciesChecker struct { - common.KubePrepare -} - -func (n *DependenciesChecker) PreCheck(runtime connector.Runtime) (bool, error) { - host := runtime.RemoteHost() - - v, ok := host.GetCache().Get(common.NodePreCheck) - if !ok { - return false, nil - } - - var result confirm.PreCheckResults - if err := mapstructure.Decode(v, &result); err != nil { - return false, cfgcore.WrapError(err, "failed to decode precheck result") - } - return true, nil -} diff --git a/internal/cli/cmd/infrastructure/tasks/tasks.go b/internal/cli/cmd/infrastructure/tasks/tasks.go index 4347cd50f45..4cc6a41ef9f 100644 --- a/internal/cli/cmd/infrastructure/tasks/tasks.go +++ b/internal/cli/cmd/infrastructure/tasks/tasks.go @@ -23,13 +23,14 @@ import ( "fmt" "strings" - cfgcore "github.com/apecloud/kubeblocks/internal/configuration" kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/logger" "github.com/kubesphere/kubekey/v3/util/osrelease" + + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" ) type InstallDependenciesTask struct { diff --git a/internal/cli/cmd/infrastructure/type.go b/internal/cli/cmd/infrastructure/types/type.go similarity index 84% rename from internal/cli/cmd/infrastructure/type.go rename to internal/cli/cmd/infrastructure/types/type.go index df12c3eb36d..f57066cf299 100644 --- a/internal/cli/cmd/infrastructure/type.go +++ b/internal/cli/cmd/infrastructure/types/type.go @@ -17,7 +17,17 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package infrastructure +package types + +type InfraVersionInfo struct { + KubernetesVersion string + EtcdVersion string + ContainerVersion string + CRICtlVersion string + RuncVersion string + CniVersion string + HelmVersion string +} type Cluster struct { User ClusterUser From 8c9b761d773464f8f24aa7e8d2b829e3b0b07df3 Mon Sep 17 00:00:00 2001 From: sophon-zt Date: Mon, 5 Jun 2023 03:01:54 +0000 Subject: [PATCH 07/44] chore: auto update cli doc changes --- docs/user_docs/cli/kbcli_infra_create.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user_docs/cli/kbcli_infra_create.md b/docs/user_docs/cli/kbcli_infra_create.md index 174a85190bb..e912528c81d 100644 --- a/docs/user_docs/cli/kbcli_infra_create.md +++ b/docs/user_docs/cli/kbcli_infra_create.md @@ -30,7 +30,7 @@ kbcli infra create [flags] --private-key-path string Specify the file PrimaryKeyPath of ssh to the remote machine. default ~/.ssh/id_rsa. -t, --timeout int Specify the ssh timeout.[option] (default 30) -u, --user string Specify the account to access the remote server. [require] - --version string Specify install kubernetes version. default version is v1.26.1 (default "v1.26.1") + --version string Specify install kubernetes version. default version is v1.26.5 (default "v1.26.5") --worker strings Specify worker nodes ``` From 2a72247735e90c03494d94f69cce74f5939f09ce Mon Sep 17 00:00:00 2001 From: sophon Date: Mon, 5 Jun 2023 18:19:33 +0800 Subject: [PATCH 08/44] adjust init os scripts --- .../template/containerd.config.toml.tpl | 69 ++------ .../builder/template/init_os.sh.tpl | 160 +++++++++--------- internal/cli/cmd/infrastructure/create.go | 4 +- .../cli/cmd/infrastructure/loader_adapter.go | 2 +- .../cmd/infrastructure/loader_adapter_test.go | 3 +- internal/cli/cmd/infrastructure/pipeline.go | 3 +- .../cli/cmd/infrastructure/tasks/constant.go | 2 +- .../cli/cmd/infrastructure/tasks/dependent.go | 2 +- .../cli/cmd/infrastructure/tasks/download.go | 16 +- .../cmd/infrastructure/tasks/kubernetes.go | 6 +- .../cli/cmd/infrastructure/tasks/utils.go | 111 ++++++++++++ 11 files changed, 231 insertions(+), 147 deletions(-) create mode 100644 internal/cli/cmd/infrastructure/tasks/utils.go diff --git a/internal/cli/cmd/infrastructure/builder/template/containerd.config.toml.tpl b/internal/cli/cmd/infrastructure/builder/template/containerd.config.toml.tpl index c5e8b55b08c..170c38f7f87 100644 --- a/internal/cli/cmd/infrastructure/builder/template/containerd.config.toml.tpl +++ b/internal/cli/cmd/infrastructure/builder/template/containerd.config.toml.tpl @@ -13,66 +13,31 @@ state = "/run/containerd" max_recv_message_size = 16777216 max_send_message_size = 16777216 -[ttrpc] - address = "" - uid = 0 - gid = 0 - -[debug] - address = "" - uid = 0 - gid = 0 - level = "" - [metrics] address = "" grpc_histogram = false -[cgroup] - path = "" - [timeouts] "io.containerd.timeout.shim.cleanup" = "5s" "io.containerd.timeout.shim.load" = "5s" "io.containerd.timeout.shim.shutdown" = "3s" "io.containerd.timeout.task.state" = "2s" -[plugins] - [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc] - runtime_type = "io.containerd.runc.v2" - [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] - SystemdCgroup = true - [plugins."io.containerd.grpc.v1.cri"] - sandbox_image = "{{ .SandBoxImage }}" - [plugins."io.containerd.grpc.v1.cri".cni] - bin_dir = "/opt/cni/bin" - conf_dir = "/etc/cni/net.d" - max_conf_num = 1 - conf_template = "" - [plugins."io.containerd.grpc.v1.cri".registry] - [plugins."io.containerd.grpc.v1.cri".registry.mirrors] - {{- if .Mirrors }} - [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"] - endpoint = [{{ .Mirrors }}, "https://registry-1.docker.io"] - {{ else }} - [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"] - endpoint = ["https://registry-1.docker.io"] - {{- end}} - {{- range $value := .InsecureRegistries }} - [plugins."io.containerd.grpc.v1.cri".registry.mirrors."{{$value}}"] - endpoint = ["http://{{$value}}"] - {{- end}} +[plugins."io.containerd.grpc.v1.cri".containerd] +default_runtime_name = "runc" + +[plugins."io.containerd.grpc.v1.cri"] +sandbox_image = "{{ .SandBoxImage }}" + +[plugins."io.containerd.grpc.v1.cri".registry] +config_path = "/etc/containerd/certs.d:/etc/docker/certs.d" + +[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc] +runtime_type = "io.containerd.runc.v2" + +[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] +SystemdCgroup = true - {{- if .Auths }} - [plugins."io.containerd.grpc.v1.cri".registry.configs] - {{- range $repo, $entry := .Auths }} - [plugins."io.containerd.grpc.v1.cri".registry.configs."{{$repo}}".auth] - username = "{{$entry.Username}}" - password = "{{$entry.Password}}" - [plugins."io.containerd.grpc.v1.cri".registry.configs."{{$repo}}".tls] - ca_file = "{{$entry.CAFile}}" - cert_file = "{{$entry.CertFile}}" - key_file = "{{$entry.KeyFile}}" - insecure_skip_verify = {{$entry.SkipTLSVerify}} - {{- end}} - {{- end}} \ No newline at end of file +[plugins."io.containerd.grpc.v1.cri".cni] +bin_dir = "/opt/cni/bin" +conf_dir = "/etc/cni/net.d" diff --git a/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl b/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl index 350c95f9cd5..4393f2cf578 100644 --- a/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl +++ b/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl @@ -7,6 +7,7 @@ function swap_off() { # clean cache echo 3 > /proc/sys/vm/drop_caches + echo } function selinux_off() { @@ -17,8 +18,17 @@ function selinux_off() { if [ -f /etc/selinux/config ]; then sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config fi + echo } +function firewalld_off() { + echo "firewall off..." + systemctl stop firewalld.service 1>/dev/null 2>&1 + systemctl disable firewalld.service 1>/dev/null 2>&1 + systemctl stop ufw 1>/dev/null 2>&1 + systemctl disable ufw 1>/dev/null 2>&1 + echo +} function replace_in_file() { local filename="${1:?filename is required}" @@ -27,8 +37,6 @@ function replace_in_file() { local posix_regex=${4:-true} local result - - # Use a non-printable character as a 'sed' delimiter to avoid issues local -r del=$'\001' if [[ $posix_regex = true ]]; then result="$(sed -E "s${del}${match_regex}${del}${substitute_regex}${del}g" "$filename")" @@ -38,111 +46,103 @@ function replace_in_file() { echo "$result" > "$filename" } -function sysctl_set_property() { - local -r property="${1:?missing property}" +function sysctl_set_keyvalue() { + local -r key="${1:?missing key}" local -r value="${2:?missing value}" - local -r conf_file="/etc/sysctl.conf" - if grep -qE "^#*\s*${property}" "$conf_file" >/dev/null; then - replace_in_file "$conf_file" "^#*\s*${property}\s*=.*" "${property} = ${value}" false + local -r conf_file="${3:-"/etc/sysctl.conf"}" + if grep -qE "^#*\s*${key}" "$conf_file" >/dev/null; then + replace_in_file "$conf_file" "^#*\s*${key}\s*=.*" "${key} = ${value}" else - echo "${property} = '${value}'" >>"$conf_file" + echo "${key} = ${value}" >>"$conf_file" fi } function set_network() { echo "set network..." - sysctl_set_property "net.ipv4.tcp_tw_recycle" "0" - sysctl_set_property "net.ipv4.ip_forward" "1" - sysctl_set_property "net.bridge.bridge-nf-call-arptables" "1" - sysctl_set_property "net.bridge.bridge-nf-call-ip6tables" "1" - sysctl_set_property "net.bridge.bridge-nf-call-iptables" "1" - sysctl_set_property "net.ipv4.ip_local_reserved_ports" "30000-32767" -} + sysctl_set_keyvalue "net.ipv4.tcp_tw_recycle" "0" + sysctl_set_keyvalue "net.ipv4.ip_forward" "1" + sysctl_set_keyvalue "net.bridge.bridge-nf-call-arptables" "1" + sysctl_set_keyvalue "net.bridge.bridge-nf-call-ip6tables" "1" + sysctl_set_keyvalue "net.bridge.bridge-nf-call-iptables" "1" + sysctl_set_keyvalue "net.ipv4.ip_local_reserved_ports" "30000-32767" -function firewall_off() { - echo "firewall off..." - systemctl stop firewalld 1>/dev/null 2>/dev/null - systemctl disable firewalld 1>/dev/null 2>/dev/null - systemctl stop ufw 1>/dev/null 2>/dev/null - systemctl disable ufw 1>/dev/null 2>/dev/null + echo } +function common_os_setting() { + swap_off + selinux_off + firewalld_off + set_network +} -echo 'vm.max_map_count = 262144' >> /etc/sysctl.conf -echo 'vm.swappiness = 1' >> /etc/sysctl.conf -echo 'fs.inotify.max_user_instances = 524288' >> /etc/sysctl.conf -echo 'kernel.pid_max = 65535' >> /etc/sysctl.conf - - -#See https://imroc.io/posts/kubernetes/troubleshooting-with-kubernetes-network/ -sed -r -i "s@#{0,}?net.ipv4.tcp_tw_recycle ?= ?(0|1)@net.ipv4.tcp_tw_recycle = 0@g" /etc/sysctl.conf - -sed -r -i "s@#{0,}?net.ipv4.ip_forward ?= ?(0|1)@net.ipv4.ip_forward = 1@g" /etc/sysctl.conf -sed -r -i "s@#{0,}?net.bridge.bridge-nf-call-arptables ?= ?(0|1)@net.bridge.bridge-nf-call-arptables = 1@g" /etc/sysctl.conf -sed -r -i "s@#{0,}?net.bridge.bridge-nf-call-ip6tables ?= ?(0|1)@net.bridge.bridge-nf-call-ip6tables = 1@g" /etc/sysctl.conf -sed -r -i "s@#{0,}?net.bridge.bridge-nf-call-iptables ?= ?(0|1)@net.bridge.bridge-nf-call-iptables = 1@g" /etc/sysctl.conf -sed -r -i "s@#{0,}?net.ipv4.ip_local_reserved_ports ?= ?([0-9]{1,}-{0,1},{0,1}){1,}@net.ipv4.ip_local_reserved_ports = 30000-32767@g" /etc/sysctl.conf -sed -r -i "s@#{0,}?vm.max_map_count ?= ?([0-9]{1,})@vm.max_map_count = 262144@g" /etc/sysctl.conf -sed -r -i "s@#{0,}?vm.swappiness ?= ?([0-9]{1,})@vm.swappiness = 1@g" /etc/sysctl.conf -sed -r -i "s@#{0,}?fs.inotify.max_user_instances ?= ?([0-9]{1,})@fs.inotify.max_user_instances = 524288@g" /etc/sysctl.conf -sed -r -i "s@#{0,}?kernel.pid_max ?= ?([0-9]{1,})@kernel.pid_max = 65535@g" /etc/sysctl.conf - -tmpfile="$$.tmp" -awk ' !x[$0]++{print > "'$tmpfile'"}' /etc/sysctl.conf -mv $tmpfile /etc/sysctl.conf +function install_hosts() { + sed -i ':a;$!{N;ba};s@# kubeblocks hosts BEGIN.*# kubeblocks hosts END@@' /etc/hosts + sed -i '/^$/N;/\n$/N;//D' /etc/hosts + cat >>/etc/hosts< /dev/null 2>&1 -if [ $? -eq 0 ]; then - modprobe br_netfilter - mkdir -p /etc/modules-load.d - echo 'br_netfilter' > /etc/modules-load.d/kubekey-br_netfilter.conf -fi +function install_netfilter() { + modinfo br_netfilter > /dev/null 2>&1 + if [ $? -eq 0 ]; then + modprobe br_netfilter + mkdir -p /etc/modules-load.d + echo 'br_netfilter' > /etc/modules-load.d/kubekey-br_netfilter.conf + fi -modinfo overlay > /dev/null 2>&1 -if [ $? -eq 0 ]; then - modprobe overlay - echo 'overlay' >> /etc/modules-load.d/kubekey-br_netfilter.conf -fi + modinfo overlay > /dev/null 2>&1 + if [ $? -eq 0 ]; then + modprobe overlay + echo 'overlay' >> /etc/modules-load.d/kubekey-br_netfilter.conf + fi +} -modprobe ip_vs -modprobe ip_vs_rr -modprobe ip_vs_wrr -modprobe ip_vs_sh +function install_ipvs() { + modprobe ip_vs + modprobe ip_vs_rr + modprobe ip_vs_wrr + modprobe ip_vs_sh -cat > /etc/modules-load.d/kube_proxy-ipvs.conf << EOF + cat > /etc/modules-load.d/kube_proxy-ipvs.conf << EOF ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh EOF -modprobe nf_conntrack_ipv4 1>/dev/null 2>/dev/null -if [ $? -eq 0 ]; then - echo 'nf_conntrack_ipv4' > /etc/modules-load.d/kube_proxy-ipvs.conf -else - modprobe nf_conntrack - echo 'nf_conntrack' > /etc/modules-load.d/kube_proxy-ipvs.conf -fi -sysctl -p + modprobe nf_conntrack_ipv4 1>/dev/null 2>/dev/null + if [ $? -eq 0 ]; then + echo 'nf_conntrack_ipv4' > /etc/modules-load.d/kube_proxy-ipvs.conf + else + modprobe nf_conntrack + echo 'nf_conntrack' > /etc/modules-load.d/kube_proxy-ipvs.conf + fi +} -sed -i ':a;$!{N;ba};s@# kubekey hosts BEGIN.*# kubekey hosts END@@' /etc/hosts -sed -i '/^$/N;/\n$/N;//D' /etc/hosts +# install_netfilter +# install_ipvs +install_hosts +common_os_setting -cat >>/etc/hosts</dev/null 2>&1 || true -update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy >/dev/null 2>&1 || true -update-alternatives --set arptables /usr/sbin/arptables-legacy >/dev/null 2>&1 || true -update-alternatives --set ebtables /usr/sbin/ebtables-legacy >/dev/null 2>&1 || true +# update-alternatives --set iptables /usr/sbin/iptables-legacy >/dev/null 2>&1 || true +# update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy >/dev/null 2>&1 || true +# update-alternatives --set arptables /usr/sbin/arptables-legacy >/dev/null 2>&1 || true +# update-alternatives --set ebtables /usr/sbin/ebtables-legacy >/dev/null 2>&1 || true ulimit -u 65535 ulimit -n 65535 diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index 2e34bd3e36a..c47e6453003 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -27,8 +27,6 @@ import ( "strings" "github.com/StudioSol/set" - "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" - "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" kubekeyapiv1alpha2 "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/connector" @@ -37,6 +35,8 @@ import ( "k8s.io/apimachinery/pkg/util/rand" "k8s.io/cli-runtime/pkg/genericclioptions" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" "github.com/apecloud/kubeblocks/internal/cli/util" cfgcore "github.com/apecloud/kubeblocks/internal/configuration" "github.com/apecloud/kubeblocks/internal/configuration/container" diff --git a/internal/cli/cmd/infrastructure/loader_adapter.go b/internal/cli/cmd/infrastructure/loader_adapter.go index b240c16eff5..82cf2d0c9b6 100644 --- a/internal/cli/cmd/infrastructure/loader_adapter.go +++ b/internal/cli/cmd/infrastructure/loader_adapter.go @@ -21,10 +21,10 @@ package infrastructure import ( kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" "github.com/apecloud/kubeblocks/internal/gotemplate" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" ) var ReplicaSetSignature = func(_ kubekeyapiv1alpha2.Cluster, _ any) {} diff --git a/internal/cli/cmd/infrastructure/loader_adapter_test.go b/internal/cli/cmd/infrastructure/loader_adapter_test.go index 7740c4b42aa..c678a2b4563 100644 --- a/internal/cli/cmd/infrastructure/loader_adapter_test.go +++ b/internal/cli/cmd/infrastructure/loader_adapter_test.go @@ -22,9 +22,10 @@ package infrastructure import ( "testing" - "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" + "github.com/apecloud/kubeblocks/internal/configuration/container" ) diff --git a/internal/cli/cmd/infrastructure/pipeline.go b/internal/cli/cmd/infrastructure/pipeline.go index 17b3484c6e0..14b1c081c2d 100644 --- a/internal/cli/cmd/infrastructure/pipeline.go +++ b/internal/cli/cmd/infrastructure/pipeline.go @@ -22,7 +22,6 @@ package infrastructure import ( "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/precheck" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/certs" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/container" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/module" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/etcd" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/filesystem" @@ -51,7 +50,7 @@ func NewCreateK8sClusterForKubeblocks(o *clusterOptions) []module.Module { // &os.ConfigureOSModule{}, // &customscripts.CustomScriptsModule{Phase: "PreInstall", Scripts: runtime.Cluster.System.PreInstall}, &kubernetes.StatusModule{}, - &container.InstallContainerModule{}, + // &container.InstallContainerModule{}, &tasks.InstallCRIModule{}, &etcd.PreCheckModule{}, &etcd.CertsModule{}, diff --git a/internal/cli/cmd/infrastructure/tasks/constant.go b/internal/cli/cmd/infrastructure/tasks/constant.go index f5894b6a4e7..5b514c11a8e 100644 --- a/internal/cli/cmd/infrastructure/tasks/constant.go +++ b/internal/cli/cmd/infrastructure/tasks/constant.go @@ -33,7 +33,7 @@ const ( DefaultEtcdVersion = "v3.4.26" // https://github.com/etcd-io/etcd/releases/tag/v3.4.26 DefaultCRICtlVersion = "v1.26.0" // https://github.com/kubernetes-sigs/cri-tools/releases/tag/v1.26.0 DefaultHelmVersion = "v3.12.0" // https://github.com/helm/helm/releases - DefaultContainerdVersion = "v1.7.2" // https://github.com/containerd/containerd/releases DefaultRuncVersion = "v1.1.7" // https://github.com/opencontainers/runc/releases DefaultCniVersion = "v1.3.0" // https://github.com/containernetworking/plugins/releases + DefaultContainerdVersion = "1.7.2" // https://github.com/containerd/containerd/releases ) diff --git a/internal/cli/cmd/infrastructure/tasks/dependent.go b/internal/cli/cmd/infrastructure/tasks/dependent.go index 0bc3b462fb9..fd202c452f6 100644 --- a/internal/cli/cmd/infrastructure/tasks/dependent.go +++ b/internal/cli/cmd/infrastructure/tasks/dependent.go @@ -20,7 +20,6 @@ along with this program. If not, see . package tasks import ( - "github.com/apecloud/kubeblocks/internal/gotemplate" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/confirm" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" @@ -36,6 +35,7 @@ import ( "github.com/mitchellh/mapstructure" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" + "github.com/apecloud/kubeblocks/internal/gotemplate" ) type InstallDependenciesModule struct { diff --git a/internal/cli/cmd/infrastructure/tasks/download.go b/internal/cli/cmd/infrastructure/tasks/download.go index 8e2c3d26db3..ad83f1b7744 100644 --- a/internal/cli/cmd/infrastructure/tasks/download.go +++ b/internal/cli/cmd/infrastructure/tasks/download.go @@ -22,6 +22,7 @@ package tasks import ( "fmt" "os" + "os/exec" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/logger" @@ -59,21 +60,28 @@ func downloadKubernetesBinaryWithArch(downloadPath string, arch string, binaryVe if err := binary.CreateBaseDir(); err != nil { return nil, cfgcore.WrapError(err, "failed to create file %s base dir.", binary.FileName) } - logger.Log.Messagef(common.LocalHost, "downloading %s %s %s ...", arch, binary.ID, binary.Version) + logger.Log.Messagef(common.LocalHost, "downloading %s %s %s ...", arch, binary.ID, binary.Version) binariesMap[binary.ID] = binary if util.IsExist(binary.Path()) { - if err := binary.SHA256Check(); err != nil { + if err := checkSha256sum(binary); err != nil { + logger.Log.Messagef(common.LocalHost, "failed to check %s sha256, error: %v", binary.ID, err) _ = os.Remove(binary.Path()) } else { logger.Log.Messagef(common.LocalHost, "%s is existed", binary.ID) continue } } - if err := binary.Download(); err != nil { + if err := download(binary); err != nil { return nil, cfgcore.WrapError(err, "failed to download %s binary: %s", binary.ID, binary.GetCmd()) } } - return binariesMap, nil } + +func download(binary *files.KubeBinary) error { + if err := runCommand(exec.Command("/bin/sh", "-c", binary.GetCmd())); err != nil { + return err + } + return writeSha256sum(binary) +} diff --git a/internal/cli/cmd/infrastructure/tasks/kubernetes.go b/internal/cli/cmd/infrastructure/tasks/kubernetes.go index 8e798ee0acc..e1738e3e355 100644 --- a/internal/cli/cmd/infrastructure/tasks/kubernetes.go +++ b/internal/cli/cmd/infrastructure/tasks/kubernetes.go @@ -23,7 +23,6 @@ import ( "path/filepath" "github.com/StudioSol/set" - "github.com/apecloud/kubeblocks/internal/gotemplate" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os/templates" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" @@ -32,6 +31,7 @@ import ( "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" + "github.com/apecloud/kubeblocks/internal/gotemplate" ) type PrepareK8sBinariesModule struct { @@ -51,7 +51,7 @@ func (p *PrepareK8sBinariesModule) Init() { p.Tasks = []task.Interface{ &task.LocalTask{ - Name: "DownloadBinaries", + Name: "PrepareK8sBinaries", Desc: "Download installation binaries", Action: &DownloadKubernetesBinary{BinaryVersion: p.BinaryVersion}, }} @@ -69,7 +69,7 @@ func (c *ConfigureOSModule) Init() { Parallel: true, }, &task.RemoteTask{ - Name: "InitOS", + Name: "SetHostName", Desc: "Prepare to init OS", Hosts: c.Runtime.GetAllHosts(), Action: new(os.NodeConfigureOS), diff --git a/internal/cli/cmd/infrastructure/tasks/utils.go b/internal/cli/cmd/infrastructure/tasks/utils.go new file mode 100644 index 00000000000..f144cd4d2db --- /dev/null +++ b/internal/cli/cmd/infrastructure/tasks/utils.go @@ -0,0 +1,111 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package tasks + +import ( + "crypto/sha256" + "errors" + "fmt" + "io" + "os" + "os/exec" + "strings" + + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/common" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/logger" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/util" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/files" + + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" +) + +func runCommand(cmd *exec.Cmd) error { + logger.Log.Messagef(common.LocalHost, "Running: %s", cmd.String()) + stdout, err := cmd.StdoutPipe() + if err != nil { + return err + } + cmd.Stderr = cmd.Stdout + if err = cmd.Start(); err != nil { + return err + } + + // read from stdout + for { + tmp := make([]byte, 1024) + _, err := stdout.Read(tmp) + fmt.Print(string(tmp)) + if errors.Is(err, io.EOF) { + break + } else if err != nil { + logger.Log.Errorln(err) + break + } + } + return cmd.Wait() +} + +func getSha256sumFile(binary *files.KubeBinary) string { + return fmt.Sprintf("%s.sum.%s", binary.Path(), "sha256") +} + +func checkSha256sum(binary *files.KubeBinary) error { + checksumFile := getSha256sumFile(binary) + if !util.IsExist(checksumFile) { + return cfgcore.MakeError("checksum file %s is not exist", checksumFile) + } + + checksum, err := calSha256sum(binary.Path()) + if err != nil { + return err + } + + data, err := os.ReadFile(checksumFile) + if err != nil { + return err + } + if strings.TrimSpace(string(data)) == checksum { + return nil + } + return cfgcore.MakeError("checksum of %s is not match, [%s] vs [%s]", binary.ID, string(data), checksum) +} + +func calSha256sum(path string) (string, error) { + file, err := os.Open(path) + if err != nil { + return "", err + } + defer file.Close() + + data, err := io.ReadAll(file) + if err != nil { + return "", err + } + return fmt.Sprintf("%x", sha256.Sum256(data)), nil +} + +func writeSha256sum(binary *files.KubeBinary) error { + checksumFile := getSha256sumFile(binary) + sum, err := calSha256sum(binary.Path()) + if err != nil { + return err + } + return util.WriteFile(checksumFile, []byte(sum)) +} From 02be71a49c824d1835716f1ef054a4289dc7861c Mon Sep 17 00:00:00 2001 From: sophon Date: Tue, 6 Jun 2023 14:30:07 +0800 Subject: [PATCH 09/44] add template --- .../builder/template/containerd.config.toml.tpl | 5 +++++ .../builder/template/containerd.service.tpl | 2 +- .../infrastructure/builder/template/init_os.sh.tpl | 12 ++++++------ .../builder/template/kubekey_cluster.tpl | 4 ++-- internal/cli/cmd/infrastructure/create.go | 12 +++++++----- internal/cli/cmd/infrastructure/pipeline.go | 7 +++---- internal/cli/cmd/infrastructure/tasks/constant.go | 2 ++ internal/cli/cmd/infrastructure/tasks/dependent.go | 10 +++------- 8 files changed, 29 insertions(+), 25 deletions(-) diff --git a/internal/cli/cmd/infrastructure/builder/template/containerd.config.toml.tpl b/internal/cli/cmd/infrastructure/builder/template/containerd.config.toml.tpl index 170c38f7f87..b4af2c0bf37 100644 --- a/internal/cli/cmd/infrastructure/builder/template/containerd.config.toml.tpl +++ b/internal/cli/cmd/infrastructure/builder/template/containerd.config.toml.tpl @@ -13,6 +13,9 @@ state = "/run/containerd" max_recv_message_size = 16777216 max_send_message_size = 16777216 +[debug] + level = "info" + [metrics] address = "" grpc_histogram = false @@ -27,6 +30,8 @@ state = "/run/containerd" default_runtime_name = "runc" [plugins."io.containerd.grpc.v1.cri"] +stream_server_address = "127.0.0.1" +max_container_log_line_size = 262144 sandbox_image = "{{ .SandBoxImage }}" [plugins."io.containerd.grpc.v1.cri".registry] diff --git a/internal/cli/cmd/infrastructure/builder/template/containerd.service.tpl b/internal/cli/cmd/infrastructure/builder/template/containerd.service.tpl index bb65fafafe4..d5af236df2f 100644 --- a/internal/cli/cmd/infrastructure/builder/template/containerd.service.tpl +++ b/internal/cli/cmd/infrastructure/builder/template/containerd.service.tpl @@ -16,7 +16,7 @@ RestartSec=5 # in the kernel. We recommend using cgroups to do container-local accounting. LimitNPROC=infinity LimitCORE=infinity -LimitNOFILE=1048576 +LimitNOFILE=infinity # Comment TasksMax if your systemd version does not supports it. # Only systemd 226 and above support this version. TasksMax=infinity diff --git a/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl b/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl index 4393f2cf578..4bac9857d40 100644 --- a/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl +++ b/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl @@ -127,8 +127,8 @@ EOF fi } -# install_netfilter -# install_ipvs +install_netfilter +install_ipvs install_hosts common_os_setting @@ -139,10 +139,10 @@ sysctl_set_keyvalue "kernel.pid_max" "65535" sysctl -p # Make sure the iptables utility doesn't use the nftables backend. -# update-alternatives --set iptables /usr/sbin/iptables-legacy >/dev/null 2>&1 || true -# update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy >/dev/null 2>&1 || true -# update-alternatives --set arptables /usr/sbin/arptables-legacy >/dev/null 2>&1 || true -# update-alternatives --set ebtables /usr/sbin/ebtables-legacy >/dev/null 2>&1 || true +update-alternatives --set iptables /usr/sbin/iptables-legacy >/dev/null 2>&1 || true +update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy >/dev/null 2>&1 || true +update-alternatives --set arptables /usr/sbin/arptables-legacy >/dev/null 2>&1 || true +update-alternatives --set ebtables /usr/sbin/ebtables-legacy >/dev/null 2>&1 || true ulimit -u 65535 ulimit -n 65535 diff --git a/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl b/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl index 8fdd053e4a2..f2a5c34bd2f 100644 --- a/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl +++ b/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl @@ -23,7 +23,7 @@ spec: {{- end }} {{- end }} controlPlaneEndpoint: - domain: lb.api-service.local + domain: lb.apiservice.local {{- $address := ""}} {{- if hasKey $.RoleGroups "master" }} {{- $mName := index (get $.RoleGroups "master") 0 }} @@ -64,6 +64,6 @@ spec: type: kubeadm {{- end }} network: - plugin: calico + plugin: cilium kubePodsCIDR: 10.233.64.0/18 kubeServiceCIDR: 10.233.0.0/18 \ No newline at end of file diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index c47e6453003..6bc65a929f0 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -52,11 +52,12 @@ type clusterOptions struct { privateKey string privateKeyPath string - clusterName string - nodes []string - criType string - cluster types.Cluster - debug bool + clusterName string + nodes []string + criType string + cluster types.Cluster + debug bool + sandBoxImage string autoRenewCerts bool securityEnhancement bool @@ -232,6 +233,7 @@ func (o *clusterOptions) buildCreateInfraFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&o.userName, "user", "u", "", "Specify the account to access the remote server. [require]") cmd.Flags().Int64VarP(&o.timeout, "timeout", "t", 30, "Specify the ssh timeout.[option]") cmd.Flags().StringVarP(&o.password, "password", "p", "", "Specify the password for the account to execute sudo. [option]") + cmd.Flags().StringVarP(&o.password, "sandbox-image", "", tasks.DefaultSandBoxImage, "Specified image will not be used by the cri. [option]") cmd.Flags().StringVarP(&o.privateKey, "private-key", "", "", "The PrimaryKey for ssh to the remote machine. [option]") cmd.Flags().StringVarP(&o.privateKeyPath, "private-key-path", "", "", "Specify the file PrimaryKeyPath of ssh to the remote machine. default ~/.ssh/id_rsa.") diff --git a/internal/cli/cmd/infrastructure/pipeline.go b/internal/cli/cmd/infrastructure/pipeline.go index 14b1c081c2d..b34a9143757 100644 --- a/internal/cli/cmd/infrastructure/pipeline.go +++ b/internal/cli/cmd/infrastructure/pipeline.go @@ -26,7 +26,6 @@ import ( "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/etcd" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/filesystem" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/kubernetes" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/dns" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/network" @@ -51,7 +50,7 @@ func NewCreateK8sClusterForKubeblocks(o *clusterOptions) []module.Module { // &customscripts.CustomScriptsModule{Phase: "PreInstall", Scripts: runtime.Cluster.System.PreInstall}, &kubernetes.StatusModule{}, // &container.InstallContainerModule{}, - &tasks.InstallCRIModule{}, + &tasks.InstallCRIModule{SandBoxImage: o.sandBoxImage}, &etcd.PreCheckModule{}, &etcd.CertsModule{}, &etcd.InstallETCDBinaryModule{}, @@ -72,8 +71,8 @@ func NewCreateK8sClusterForKubeblocks(o *clusterOptions) []module.Module { &filesystem.ChownModule{}, &certs.AutoRenewCertsModule{Skip: !o.autoRenewCerts}, &kubernetes.SecurityEnhancementModule{Skip: !o.securityEnhancement}, - &kubernetes.SaveKubeConfigModule{}, - &plugins.DeployPluginsModule{}, + // &kubernetes.SaveKubeConfigModule{}, + // &plugins.DeployPluginsModule{}, // &customscripts.CustomScriptsModule{Phase: "PostInstall", Scripts: runtime.Cluster.System.PostInstall}, } } diff --git a/internal/cli/cmd/infrastructure/tasks/constant.go b/internal/cli/cmd/infrastructure/tasks/constant.go index 5b514c11a8e..c06f1d7e369 100644 --- a/internal/cli/cmd/infrastructure/tasks/constant.go +++ b/internal/cli/cmd/infrastructure/tasks/constant.go @@ -29,6 +29,8 @@ const ( ContainerdConfigInstallPath = "/etc/containerd/config.toml" CRICtlConfigInstallPath = "/etc/crictl.yaml" + DefaultSandBoxImage = "k8s.gcr.io/pause:3.8" + DefaultK8sVersion = "v1.26.5" // https://github.com/kubernetes/kubernetes/releases/tag/v1.26.5 DefaultEtcdVersion = "v3.4.26" // https://github.com/etcd-io/etcd/releases/tag/v3.4.26 DefaultCRICtlVersion = "v1.26.0" // https://github.com/kubernetes-sigs/cri-tools/releases/tag/v1.26.0 diff --git a/internal/cli/cmd/infrastructure/tasks/dependent.go b/internal/cli/cmd/infrastructure/tasks/dependent.go index fd202c452f6..3914546d12a 100644 --- a/internal/cli/cmd/infrastructure/tasks/dependent.go +++ b/internal/cli/cmd/infrastructure/tasks/dependent.go @@ -29,9 +29,7 @@ import ( "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/logger" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/prepare" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/images" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/kubernetes" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/registry" "github.com/mitchellh/mapstructure" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" @@ -112,6 +110,7 @@ func (i *CheckNodeArchitectureModule) Init() { type InstallCRIModule struct { common.KubeModule + SandBoxImage string } func (i *InstallCRIModule) Init() { @@ -171,11 +170,8 @@ func (i *InstallCRIModule) Init() { Template: ContainerdConfig, Dst: ContainerdConfigInstallPath, Values: gotemplate.TplValues{ - "Mirrors": templates.Mirrors(i.KubeConf), - "InsecureRegistries": i.KubeConf.Cluster.Registry.InsecureRegistries, - "SandBoxImage": images.GetImage(i.Runtime, i.KubeConf, "pause").ImageName(), - "Auths": registry.DockerRegistryAuthEntries(i.KubeConf.Cluster.Registry.Auths), - "DataRoot": templates.DataRoot(i.KubeConf), + "SandBoxImage": i.SandBoxImage, + "DataRoot": templates.DataRoot(i.KubeConf), }}, Parallel: true, } From 4664520dc96e3c146382a233cb63e8856b6e2041 Mon Sep 17 00:00:00 2001 From: sophon Date: Tue, 6 Jun 2023 17:21:48 +0800 Subject: [PATCH 10/44] add delete cluster command --- .../builder/template/kubekey_cluster.tpl | 2 +- internal/cli/cmd/infrastructure/cluster.go | 206 ++++++++++++++++++ internal/cli/cmd/infrastructure/create.go | 172 ++------------- internal/cli/cmd/infrastructure/delete.go | 111 ++++++++++ internal/cli/cmd/infrastructure/infras.go | 1 + .../cli/cmd/infrastructure/loader_adapter.go | 2 +- .../cmd/infrastructure/loader_adapter_test.go | 45 ++-- internal/cli/cmd/infrastructure/pipeline.go | 17 +- 8 files changed, 377 insertions(+), 179 deletions(-) create mode 100644 internal/cli/cmd/infrastructure/cluster.go create mode 100644 internal/cli/cmd/infrastructure/delete.go diff --git a/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl b/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl index f2a5c34bd2f..94236f92850 100644 --- a/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl +++ b/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl @@ -49,7 +49,7 @@ spec: {{- if eq $criType "containerd" }} containerRuntimeEndpoint: "unix:///run/containerd/containerd.sock" {{- end }} - {{- if $.CRIType }} + {{- if hasKey . "CRIType" }} {{ $criType = $.CRIType }} {{- end }} containerManager: {{ $criType }} diff --git a/internal/cli/cmd/infrastructure/cluster.go b/internal/cli/cmd/infrastructure/cluster.go new file mode 100644 index 00000000000..34c1c772d5f --- /dev/null +++ b/internal/cli/cmd/infrastructure/cluster.go @@ -0,0 +1,206 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package infrastructure + +import ( + "fmt" + "os" + "os/user" + "path/filepath" + "strings" + + "github.com/StudioSol/set" + "github.com/apecloud/kubeblocks/internal/cli/printer" + "github.com/apecloud/kubeblocks/internal/cli/util/prompt" + kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" + "github.com/spf13/cobra" + "golang.org/x/exp/slices" + "k8s.io/apimachinery/pkg/util/rand" + "k8s.io/cli-runtime/pkg/genericclioptions" + + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" +) + +type clusterOptions struct { + IOStreams genericclioptions.IOStreams + + clusterName string + nodes []string + cluster types.Cluster + + timeout int64 + userName string + password string + privateKey string + privateKeyPath string +} + +func buildCommonFlags(cmd *cobra.Command, o *clusterOptions) { + cmd.Flags().StringVarP(&o.clusterName, "name", "", "", "Specify kubernetes cluster name") + cmd.Flags().StringSliceVarP(&o.nodes, "nodes", "", nil, "List of machines on which kubernetes is installed. [require]") + + // for user + cmd.Flags().StringVarP(&o.userName, "user", "u", "", "Specify the account to access the remote server. [require]") + cmd.Flags().Int64VarP(&o.timeout, "timeout", "t", 30, "Specify the ssh timeout.[option]") + cmd.Flags().StringVarP(&o.password, "password", "p", "", "Specify the password for the account to execute sudo. [option]") + cmd.Flags().StringVarP(&o.password, "sandbox-image", "", tasks.DefaultSandBoxImage, "Specified image will not be used by the cri. [option]") + cmd.Flags().StringVarP(&o.privateKey, "private-key", "", "", "The PrimaryKey for ssh to the remote machine. [option]") + cmd.Flags().StringVarP(&o.privateKeyPath, "private-key-path", "", "", "Specify the file PrimaryKeyPath of ssh to the remote machine. default ~/.ssh/id_rsa.") + + cmd.Flags().StringSliceVarP(&o.cluster.ETCD, "etcd", "", nil, "Specify etcd nodes") + cmd.Flags().StringSliceVarP(&o.cluster.Master, "master", "", nil, "Specify master nodes") + cmd.Flags().StringSliceVarP(&o.cluster.Worker, "worker", "", nil, "Specify worker nodes") +} + +func (o *clusterOptions) Complete() error { + if o.clusterName == "" { + o.clusterName = "kubeblocks-" + rand.String(6) + fmt.Printf("The cluster name is not set, auto generate cluster name: %s\n", o.clusterName) + } + + if o.userName == "" { + currentUser, err := user.Current() + if err != nil { + return err + } + o.userName = currentUser.Username + fmt.Printf("The user is not set, use current user %s\n", o.userName) + } + if o.privateKey == "" { + home, err := os.UserHomeDir() + if err != nil { + return err + } + if o.privateKeyPath == "" && o.password == "" { + o.privateKeyPath = filepath.Join(home, ".ssh", "id_rsa") + } + if strings.HasPrefix(o.privateKeyPath, "~/") { + o.privateKeyPath = filepath.Join(home, o.privateKeyPath[2:]) + } + } + if len(o.nodes) == 0 { + return cfgcore.MakeError("The list of machines where kubernetes is installed must be specified.") + } + o.cluster.Nodes = make([]types.ClusterNode, len(o.nodes)) + for i, node := range o.nodes { + fields := strings.SplitN(node, ":", 3) + if len(fields) < 2 { + return cfgcore.MakeError("The node format is incorrect, require: [name:address:internalAddress].") + } + n := types.ClusterNode{ + Name: fields[0], + Address: fields[1], + InternalAddress: fields[1], + } + if len(fields) == 3 { + n.InternalAddress = fields[2] + } + o.cluster.Nodes[i] = n + } + return nil +} + +func (o *clusterOptions) Validate() error { + checkFn := func(n string) bool { + for _, node := range o.cluster.Nodes { + if node.Name == n { + return true + } + } + return false + } + validateNodes := func(nodes []string) error { + sets := set.NewLinkedHashSetString() + for _, node := range nodes { + if !checkFn(node) { + return cfgcore.MakeError("node %s is not exist!", node) + } + if sets.InArray(node) { + return cfgcore.MakeError("node %s is repeat!", node) + } + sets.Add(node) + } + return nil + } + if o.userName == "" { + return cfgcore.MakeError("user name is empty") + } + if o.privateKey == "" && o.privateKeyPath != "" { + if _, err := os.Stat(o.privateKeyPath); err != nil { + return err + } + b, err := os.ReadFile(o.privateKeyPath) + if err != nil { + return err + } + o.privateKey = string(b) + } + if len(o.cluster.ETCD) == 0 || len(o.cluster.Master) == 0 || len(o.cluster.Worker) == 0 { + return cfgcore.MakeError("etcd, master or worker is empty") + } + if err := validateNodes(o.cluster.ETCD); err != nil { + return err + } + if err := validateNodes(o.cluster.Master); err != nil { + return err + } + if err := validateNodes(o.cluster.Worker); err != nil { + return err + } + return nil +} + +func syncClusterNodeRole(cluster *kubekeyapiv1alpha2.ClusterSpec, runtime *common.KubeRuntime) { + hostSet := set.NewLinkedHashSetString() + for _, role := range cluster.GroupHosts() { + for _, host := range role { + if host.IsRole(common.Master) || host.IsRole(common.Worker) { + host.SetRole(common.K8s) + } + if !hostSet.InArray(host.GetName()) { + hostSet.Add(host.GetName()) + runtime.BaseRuntime.AppendHost(host) + runtime.BaseRuntime.AppendRoleMap(host) + } + } + } +} + +func (o *clusterOptions) confirm(promptStr string) (bool, error) { + const yesStr = "yes" + const noStr = "no" + + confirmStr := []string{yesStr, noStr} + printer.Warning(o.IOStreams.Out, promptStr) + input, err := prompt.NewPrompt("Please type [yes/No] to confirm:", + func(input string) error { + if !slices.Contains(confirmStr, strings.ToLower(input)) { + return fmt.Errorf("typed \"%s\" does not match \"%s\"", input, confirmStr) + } + return nil + }, o.IOStreams.In).Run() + if err != nil { + return false, err + } + return strings.ToLower(input) == yesStr, nil +} diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index 6bc65a929f0..10ca8fd48dc 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -21,41 +21,24 @@ package infrastructure import ( "fmt" - "os" - "os/user" - "path/filepath" - "strings" - "github.com/StudioSol/set" - kubekeyapiv1alpha2 "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/connector" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/pipeline" "github.com/spf13/cobra" - "k8s.io/apimachinery/pkg/util/rand" "k8s.io/cli-runtime/pkg/genericclioptions" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" "github.com/apecloud/kubeblocks/internal/cli/util" - cfgcore "github.com/apecloud/kubeblocks/internal/configuration" "github.com/apecloud/kubeblocks/internal/configuration/container" ) -type clusterOptions struct { - IOStreams genericclioptions.IOStreams - version types.InfraVersionInfo +type createOptions struct { + clusterOptions + version types.InfraVersionInfo - timeout int64 - userName string - password string - privateKey string - privateKeyPath string - - clusterName string - nodes []string criType string - cluster types.Cluster debug bool sandBoxImage string @@ -66,134 +49,30 @@ type clusterOptions struct { var createExamples = ` ` -func (o *clusterOptions) Complete() error { - if o.clusterName == "" { - o.clusterName = "kubeblocks-" + rand.String(6) - fmt.Printf("The cluster name is not set, auto generate cluster name: %s\n", o.clusterName) - } - if o.userName == "" { - currentUser, err := user.Current() - if err != nil { - return err - } - o.userName = currentUser.Username - fmt.Printf("The user is not set, use current user %s\n", o.userName) - } - if o.privateKey == "" { - home, err := os.UserHomeDir() - if err != nil { - return err - } - if o.privateKeyPath == "" && o.password == "" { - o.privateKeyPath = filepath.Join(home, ".ssh", "id_rsa") - } - if strings.HasPrefix(o.privateKeyPath, "~/") { - o.privateKeyPath = filepath.Join(home, o.privateKeyPath[2:]) - } - } - if len(o.nodes) == 0 { - return cfgcore.MakeError("The list of machines where kubernetes is installed must be specified.") - } - o.cluster.Nodes = make([]types.ClusterNode, len(o.nodes)) - for i, node := range o.nodes { - fields := strings.SplitN(node, ":", 3) - if len(fields) < 2 { - return cfgcore.MakeError("The node format is incorrect, require: [name:address:internalAddress].") - } - n := types.ClusterNode{ - Name: fields[0], - Address: fields[1], - InternalAddress: fields[1], - } - if len(fields) == 3 { - n.InternalAddress = fields[2] - } - o.cluster.Nodes[i] = n - } - return nil -} - -func (o *clusterOptions) Validate() error { - checkFn := func(n string) bool { - for _, node := range o.cluster.Nodes { - if node.Name == n { - return true - } - } - return false - } - validateNodes := func(nodes []string) error { - sets := set.NewLinkedHashSetString() - for _, node := range nodes { - if !checkFn(node) { - return cfgcore.MakeError("node %s is not exist!", node) - } - if sets.InArray(node) { - return cfgcore.MakeError("node %s is repeat!", node) - } - sets.Add(node) - } - return nil - } - if o.userName == "" { - return cfgcore.MakeError("user name is empty") - } - if o.privateKey == "" && o.privateKeyPath != "" { - if _, err := os.Stat(o.privateKeyPath); err != nil { - return err - } - b, err := os.ReadFile(o.privateKeyPath) - if err != nil { - return err - } - o.privateKey = string(b) - } - if len(o.cluster.ETCD) == 0 || len(o.cluster.Master) == 0 || len(o.cluster.Worker) == 0 { - return cfgcore.MakeError("etcd, master or worker is empty") - } - if err := validateNodes(o.cluster.ETCD); err != nil { - return err - } - if err := validateNodes(o.cluster.Master); err != nil { - return err - } - if err := validateNodes(o.cluster.Worker); err != nil { +func (o *createOptions) Run() error { + cluster, err := createClusterWithOptions(buildTemplateParams(o)) + if err != nil { return err } - return nil -} -func (o *clusterOptions) Run() error { - updateClusterHosts := func(cluster *kubekeyapiv1alpha2.ClusterSpec, runtime *common.KubeRuntime) { - hostSet := set.NewLinkedHashSetString() - for _, role := range cluster.GroupHosts() { - for _, host := range role { - if host.IsRole(common.Master) || host.IsRole(common.Worker) { - host.SetRole(common.K8s) - } - if !hostSet.InArray(host.GetName()) { - hostSet.Add(host.GetName()) - runtime.BaseRuntime.AppendHost(host) - runtime.BaseRuntime.AppendRoleMap(host) - } - } - } - } - - cluster, err := createClusterWithOptions(buildTemplateParams(o)) + yes, err := o.confirm(fmt.Sprintf("install kubernetes using version: %v", o.version.KubernetesVersion)) if err != nil { return err } + if !yes { + return nil + } + runtime := &common.KubeRuntime{ BaseRuntime: connector.NewBaseRuntime(o.clusterName, connector.NewDialer(), o.debug, false), Cluster: cluster, ClusterName: o.clusterName, } - updateClusterHosts(cluster, runtime) + syncClusterNodeRole(cluster, runtime) pipeline := pipeline.Pipeline{ Name: "CreateCluster", - Modules: NewCreateK8sClusterForKubeblocks(o), + Modules: NewCreatePipeline(o), Runtime: runtime, } if err := pipeline.Start(); err != nil { @@ -204,9 +83,10 @@ func (o *clusterOptions) Run() error { } func NewCreateKubernetesCmd(streams genericclioptions.IOStreams) *cobra.Command { - o := &clusterOptions{ - IOStreams: streams, - } + o := &createOptions{ + clusterOptions: clusterOptions{ + IOStreams: streams, + }} o.setDefaultVersion() cmd := &cobra.Command{ Use: "create", @@ -222,27 +102,15 @@ func NewCreateKubernetesCmd(streams genericclioptions.IOStreams) *cobra.Command return cmd } -func (o *clusterOptions) buildCreateInfraFlags(cmd *cobra.Command) { - cmd.Flags().StringVarP(&o.clusterName, "name", "", "", "Specify kubernetes cluster name") +func (o *createOptions) buildCreateInfraFlags(cmd *cobra.Command) { + buildCommonFlags(cmd, &o.clusterOptions) cmd.Flags().StringVarP(&o.version.KubernetesVersion, "version", "", o.version.KubernetesVersion, fmt.Sprintf("Specify install kubernetes version. default version is %s", o.version.KubernetesVersion)) cmd.Flags().StringVarP(&o.criType, "container-runtime", "", string(container.ContainerdType), "Specify kubernetes container runtime. default is containerd") - cmd.Flags().StringSliceVarP(&o.nodes, "nodes", "", nil, "List of machines on which kubernetes is installed. [require]") cmd.Flags().BoolVarP(&o.debug, "debug", "", false, "set debug mode") - // for user - cmd.Flags().StringVarP(&o.userName, "user", "u", "", "Specify the account to access the remote server. [require]") - cmd.Flags().Int64VarP(&o.timeout, "timeout", "t", 30, "Specify the ssh timeout.[option]") - cmd.Flags().StringVarP(&o.password, "password", "p", "", "Specify the password for the account to execute sudo. [option]") - cmd.Flags().StringVarP(&o.password, "sandbox-image", "", tasks.DefaultSandBoxImage, "Specified image will not be used by the cri. [option]") - cmd.Flags().StringVarP(&o.privateKey, "private-key", "", "", "The PrimaryKey for ssh to the remote machine. [option]") - cmd.Flags().StringVarP(&o.privateKeyPath, "private-key-path", "", "", "Specify the file PrimaryKeyPath of ssh to the remote machine. default ~/.ssh/id_rsa.") - - cmd.Flags().StringSliceVarP(&o.cluster.ETCD, "etcd", "", nil, "Specify etcd nodes") - cmd.Flags().StringSliceVarP(&o.cluster.Master, "master", "", nil, "Specify master nodes") - cmd.Flags().StringSliceVarP(&o.cluster.Worker, "worker", "", nil, "Specify worker nodes") } -func (o *clusterOptions) setDefaultVersion() { +func (o *createOptions) setDefaultVersion() { o.version.KubernetesVersion = tasks.DefaultK8sVersion o.version.EtcdVersion = tasks.DefaultEtcdVersion o.version.ContainerVersion = tasks.DefaultContainerdVersion diff --git a/internal/cli/cmd/infrastructure/delete.go b/internal/cli/cmd/infrastructure/delete.go new file mode 100644 index 00000000000..f3dace68829 --- /dev/null +++ b/internal/cli/cmd/infrastructure/delete.go @@ -0,0 +1,111 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package infrastructure + +import ( + "fmt" + + "github.com/apecloud/kubeblocks/internal/gotemplate" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/pipeline" + "github.com/spf13/cobra" + "k8s.io/cli-runtime/pkg/genericclioptions" + + "github.com/apecloud/kubeblocks/internal/cli/util" +) + +type deleteOptions struct { + clusterOptions + + deleteCRI bool + debug bool +} + +func (o *deleteOptions) Run() error { + cluster, err := createClusterWithOptions(&gotemplate.TplValues{ + builtinClusterNameObject: o.clusterName, + builtinUserObject: o.userName, + builtinClusterVersionObject: "0.0.0", + builtinPasswordObject: o.password, + builtinPrivateKeyObject: o.privateKey, + builtinHostsObject: o.cluster.Nodes, + builtinTimeoutObject: o.timeout, + builtinRoleGroupsObject: gotemplate.TplValues{ + common.ETCD: o.cluster.ETCD, + common.Master: o.cluster.Master, + common.Worker: o.cluster.Worker, + }, + }) + if err != nil { + return err + } + + yes, err := o.confirm(fmt.Sprintf("delete kubernetes: %s", o.clusterName)) + if err != nil { + return err + } + if !yes { + return nil + } + + runtime := &common.KubeRuntime{ + BaseRuntime: connector.NewBaseRuntime(o.clusterName, connector.NewDialer(), o.debug, false), + Cluster: cluster, + ClusterName: o.clusterName, + } + syncClusterNodeRole(cluster, runtime) + + pipeline := pipeline.Pipeline{ + Name: "DeleteCluster", + Modules: NewDeletePipeline(o), + Runtime: runtime, + } + if err := pipeline.Start(); err != nil { + return err + } + fmt.Fprintf(o.IOStreams.Out, "Kubernetes deletion is complete.\n\n") + return nil +} + +func (o *deleteOptions) buildDeleteInfraFlags(cmd *cobra.Command) { + buildCommonFlags(cmd, &o.clusterOptions) + cmd.Flags().BoolVarP(&o.debug, "debug", "", false, "set debug mode") + cmd.Flags().BoolVarP(&o.debug, "delete-cri", "", false, "delete cri") +} + +func NewDeleteKubernetesCmd(streams genericclioptions.IOStreams) *cobra.Command { + o := &deleteOptions{ + clusterOptions: clusterOptions{ + IOStreams: streams, + }} + cmd := &cobra.Command{ + Use: "delete", + Short: "delete kubernetes cluster.", + Example: createExamples, + Run: func(cmd *cobra.Command, args []string) { + util.CheckErr(o.Complete()) + util.CheckErr(o.Validate()) + util.CheckErr(o.Run()) + }, + } + o.buildDeleteInfraFlags(cmd) + return cmd +} diff --git a/internal/cli/cmd/infrastructure/infras.go b/internal/cli/cmd/infrastructure/infras.go index 8b784bf3eb8..f47465f4ee3 100644 --- a/internal/cli/cmd/infrastructure/infras.go +++ b/internal/cli/cmd/infrastructure/infras.go @@ -31,5 +31,6 @@ func NewInfraCmd(streams genericclioptions.IOStreams) *cobra.Command { Short: "infra command", } cmd.AddCommand(NewCreateKubernetesCmd(streams)) + cmd.AddCommand(NewDeleteKubernetesCmd(streams)) return cmd } diff --git a/internal/cli/cmd/infrastructure/loader_adapter.go b/internal/cli/cmd/infrastructure/loader_adapter.go index 82cf2d0c9b6..67710570db1 100644 --- a/internal/cli/cmd/infrastructure/loader_adapter.go +++ b/internal/cli/cmd/infrastructure/loader_adapter.go @@ -55,7 +55,7 @@ const ( builtinRoleGroupsObject = "RoleGroups" ) -func buildTemplateParams(o *clusterOptions) *gotemplate.TplValues { +func buildTemplateParams(o *createOptions) *gotemplate.TplValues { return &gotemplate.TplValues{ builtinClusterNameObject: o.clusterName, builtinClusterVersionObject: o.version.KubernetesVersion, diff --git a/internal/cli/cmd/infrastructure/loader_adapter_test.go b/internal/cli/cmd/infrastructure/loader_adapter_test.go index c678a2b4563..c3a1bd76c5c 100644 --- a/internal/cli/cmd/infrastructure/loader_adapter_test.go +++ b/internal/cli/cmd/infrastructure/loader_adapter_test.go @@ -22,42 +22,43 @@ package infrastructure import ( "testing" + "github.com/apecloud/kubeblocks/internal/configuration/container" kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" - - "github.com/apecloud/kubeblocks/internal/configuration/container" ) func TestCreateClusterWithOptions(t *testing.T) { tests := []struct { name string - args *clusterOptions + args *createOptions want *kubekeyapiv1alpha2.ClusterSpec wantErr bool }{{ name: "generateClusterTest", - args: &clusterOptions{ - clusterName: "for_test", - version: types.InfraVersionInfo{}, - criType: string(container.ContainerdType), - userName: "test", - password: "test", - cluster: types.Cluster{ - Nodes: []types.ClusterNode{ - { - Name: "node1", - Address: "127.0.0.1", - InternalAddress: "127.0.0.1", - }, { - Name: "node2", - Address: "127.0.0.2", - InternalAddress: "127.0.0.2", + args: &createOptions{ + version: types.InfraVersionInfo{}, + criType: string(container.ContainerdType), + clusterOptions: clusterOptions{ + clusterName: "for_test", + userName: "test", + password: "test", + cluster: types.Cluster{ + Nodes: []types.ClusterNode{ + { + Name: "node1", + Address: "127.0.0.1", + InternalAddress: "127.0.0.1", + }, { + Name: "node2", + Address: "127.0.0.2", + InternalAddress: "127.0.0.2", + }, }, + ETCD: []string{"node1"}, + Master: []string{"node1"}, + Worker: []string{"node2"}, }, - ETCD: []string{"node1"}, - Master: []string{"node1"}, - Worker: []string{"node2"}, }, }, }} diff --git a/internal/cli/cmd/infrastructure/pipeline.go b/internal/cli/cmd/infrastructure/pipeline.go index b34a9143757..3ca92250471 100644 --- a/internal/cli/cmd/infrastructure/pipeline.go +++ b/internal/cli/cmd/infrastructure/pipeline.go @@ -20,8 +20,10 @@ along with this program. If not, see . package infrastructure import ( + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/precheck" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/certs" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/container" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/module" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/etcd" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/filesystem" @@ -32,8 +34,7 @@ import ( "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" ) -func NewCreateK8sClusterForKubeblocks(o *clusterOptions) []module.Module { - // TODO: add a new module to check if the cluster is already installed +func NewCreatePipeline(o *createOptions) []module.Module { return []module.Module{ &precheck.GreetingsModule{}, &tasks.CheckNodeArchitectureModule{}, @@ -69,10 +70,20 @@ func NewCreateK8sClusterForKubeblocks(o *clusterOptions) []module.Module { &network.DeployNetworkPluginModule{}, &kubernetes.ConfigureKubernetesModule{}, &filesystem.ChownModule{}, - &certs.AutoRenewCertsModule{Skip: !o.autoRenewCerts}, + // &certs.AutoRenewCertsModule{Skip: !o.autoRenewCerts}, &kubernetes.SecurityEnhancementModule{Skip: !o.securityEnhancement}, // &kubernetes.SaveKubeConfigModule{}, // &plugins.DeployPluginsModule{}, // &customscripts.CustomScriptsModule{Phase: "PostInstall", Scripts: runtime.Cluster.System.PostInstall}, } } + +func NewDeletePipeline(o *deleteOptions) []module.Module { + return []module.Module{ + &precheck.GreetingsModule{}, + &kubernetes.ResetClusterModule{}, + &container.UninstallContainerModule{Skip: !o.deleteCRI}, + &os.ClearOSEnvironmentModule{}, + &certs.UninstallAutoRenewCertsModule{}, + } +} From a74421ffc31c4bbb999b8b0ac034d47ff36f34c7 Mon Sep 17 00:00:00 2001 From: sophon Date: Tue, 6 Jun 2023 19:35:17 +0800 Subject: [PATCH 11/44] remove useless code --- internal/cli/cmd/infrastructure/create.go | 1 - internal/cli/cmd/infrastructure/pipeline.go | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index 10ca8fd48dc..48f6c9b8e65 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -42,7 +42,6 @@ type createOptions struct { debug bool sandBoxImage string - autoRenewCerts bool securityEnhancement bool } diff --git a/internal/cli/cmd/infrastructure/pipeline.go b/internal/cli/cmd/infrastructure/pipeline.go index 3ca92250471..46a588c6d3b 100644 --- a/internal/cli/cmd/infrastructure/pipeline.go +++ b/internal/cli/cmd/infrastructure/pipeline.go @@ -39,18 +39,10 @@ func NewCreatePipeline(o *createOptions) []module.Module { &precheck.GreetingsModule{}, &tasks.CheckNodeArchitectureModule{}, &precheck.NodePreCheckModule{}, - // install kubekey required packages &tasks.InstallDependenciesModule{}, - // &precheck.NodePreCheckModule{}, - // &confirm.InstallConfirmModule{}, - // &os.RepositoryModule{Skip: !runtime.Arg.InstallPackages}, - // &binaries.NodeBinariesModule{}, &tasks.PrepareK8sBinariesModule{BinaryVersion: o.version}, &tasks.ConfigureOSModule{}, - // &os.ConfigureOSModule{}, - // &customscripts.CustomScriptsModule{Phase: "PreInstall", Scripts: runtime.Cluster.System.PreInstall}, &kubernetes.StatusModule{}, - // &container.InstallContainerModule{}, &tasks.InstallCRIModule{SandBoxImage: o.sandBoxImage}, &etcd.PreCheckModule{}, &etcd.CertsModule{}, @@ -58,23 +50,14 @@ func NewCreatePipeline(o *createOptions) []module.Module { &etcd.ConfigureModule{}, &etcd.BackupModule{}, &kubernetes.InstallKubeBinariesModule{}, - // init kubeVip on first master - // &loadbalancer.KubevipModule{}, &kubernetes.InitKubernetesModule{}, &dns.ClusterDNSModule{}, &kubernetes.StatusModule{}, &kubernetes.JoinNodesModule{}, - // deploy kubeVip on other masters - // &loadbalancer.KubevipModule{}, - // &loadbalancer.HaproxyModule{}, &network.DeployNetworkPluginModule{}, &kubernetes.ConfigureKubernetesModule{}, &filesystem.ChownModule{}, - // &certs.AutoRenewCertsModule{Skip: !o.autoRenewCerts}, &kubernetes.SecurityEnhancementModule{Skip: !o.securityEnhancement}, - // &kubernetes.SaveKubeConfigModule{}, - // &plugins.DeployPluginsModule{}, - // &customscripts.CustomScriptsModule{Phase: "PostInstall", Scripts: runtime.Cluster.System.PostInstall}, } } From 398653091ebcb80f28f463c5765141192fb71237 Mon Sep 17 00:00:00 2001 From: sophon Date: Fri, 9 Jun 2023 15:00:54 +0800 Subject: [PATCH 12/44] fix sandbox-images does not take effect --- internal/cli/cmd/infrastructure/cluster.go | 2 -- internal/cli/cmd/infrastructure/create.go | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/cli/cmd/infrastructure/cluster.go b/internal/cli/cmd/infrastructure/cluster.go index 34c1c772d5f..33b57e15497 100644 --- a/internal/cli/cmd/infrastructure/cluster.go +++ b/internal/cli/cmd/infrastructure/cluster.go @@ -36,7 +36,6 @@ import ( "k8s.io/apimachinery/pkg/util/rand" "k8s.io/cli-runtime/pkg/genericclioptions" - "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" cfgcore "github.com/apecloud/kubeblocks/internal/configuration" ) @@ -63,7 +62,6 @@ func buildCommonFlags(cmd *cobra.Command, o *clusterOptions) { cmd.Flags().StringVarP(&o.userName, "user", "u", "", "Specify the account to access the remote server. [require]") cmd.Flags().Int64VarP(&o.timeout, "timeout", "t", 30, "Specify the ssh timeout.[option]") cmd.Flags().StringVarP(&o.password, "password", "p", "", "Specify the password for the account to execute sudo. [option]") - cmd.Flags().StringVarP(&o.password, "sandbox-image", "", tasks.DefaultSandBoxImage, "Specified image will not be used by the cri. [option]") cmd.Flags().StringVarP(&o.privateKey, "private-key", "", "", "The PrimaryKey for ssh to the remote machine. [option]") cmd.Flags().StringVarP(&o.privateKeyPath, "private-key-path", "", "", "Specify the file PrimaryKeyPath of ssh to the remote machine. default ~/.ssh/id_rsa.") diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index 48f6c9b8e65..1497b3d9a33 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -49,6 +49,7 @@ var createExamples = ` ` func (o *createOptions) Run() error { + cluster, err := createClusterWithOptions(buildTemplateParams(o)) if err != nil { return err @@ -104,9 +105,9 @@ func NewCreateKubernetesCmd(streams genericclioptions.IOStreams) *cobra.Command func (o *createOptions) buildCreateInfraFlags(cmd *cobra.Command) { buildCommonFlags(cmd, &o.clusterOptions) cmd.Flags().StringVarP(&o.version.KubernetesVersion, "version", "", o.version.KubernetesVersion, fmt.Sprintf("Specify install kubernetes version. default version is %s", o.version.KubernetesVersion)) + cmd.Flags().StringVarP(&o.sandBoxImage, "sandbox-image", "", tasks.DefaultSandBoxImage, "Specified sandbox-image will not be used by the cri. [option]") cmd.Flags().StringVarP(&o.criType, "container-runtime", "", string(container.ContainerdType), "Specify kubernetes container runtime. default is containerd") cmd.Flags().BoolVarP(&o.debug, "debug", "", false, "set debug mode") - } func (o *createOptions) setDefaultVersion() { From 5f361aff509cd5a31dd455cfb118a0f9f092c231 Mon Sep 17 00:00:00 2001 From: sophon Date: Fri, 9 Jun 2023 15:15:46 +0800 Subject: [PATCH 13/44] verify kubernetes version validity --- internal/cli/cmd/infrastructure/create.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index 1497b3d9a33..b25759ce02f 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -26,11 +26,13 @@ import ( "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/pipeline" "github.com/spf13/cobra" + versionutil "k8s.io/apimachinery/pkg/util/version" "k8s.io/cli-runtime/pkg/genericclioptions" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" "github.com/apecloud/kubeblocks/internal/cli/util" + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" "github.com/apecloud/kubeblocks/internal/configuration/container" ) @@ -49,6 +51,19 @@ var createExamples = ` ` func (o *createOptions) Run() error { + const minKubernetesVersion = "v1.24.0" + + v, err := versionutil.ParseSemantic(o.version.KubernetesVersion) + if err != nil { + return err + } + c, err := v.Compare(minKubernetesVersion) + if err != nil { + return err + } + if c < 0 { + return cfgcore.MakeError("kubernetes version must be greater than %s", minKubernetesVersion) + } cluster, err := createClusterWithOptions(buildTemplateParams(o)) if err != nil { From 9e686263ac4c453a108905de7a6744324649b8a4 Mon Sep 17 00:00:00 2001 From: sophon Date: Fri, 9 Jun 2023 16:29:49 +0800 Subject: [PATCH 14/44] refactor clusterOptions --- .../builder/template/init_os.sh.tpl | 6 +- .../builder/template/kubekey_cluster.tpl | 6 +- internal/cli/cmd/infrastructure/cluster.go | 92 +++++++++++-------- internal/cli/cmd/infrastructure/delete.go | 12 +-- .../cli/cmd/infrastructure/loader_adapter.go | 14 +-- .../cmd/infrastructure/loader_adapter_test.go | 8 +- internal/cli/cmd/infrastructure/types/type.go | 7 +- .../template/kubekey_cluster_template.cue | 71 -------------- 8 files changed, 82 insertions(+), 134 deletions(-) delete mode 100644 internal/cli/create/template/kubekey_cluster_template.cue diff --git a/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl b/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl index 4bac9857d40..7bdda1eabea 100644 --- a/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl +++ b/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl @@ -65,6 +65,7 @@ function set_network() { sysctl_set_keyvalue "net.bridge.bridge-nf-call-arptables" "1" sysctl_set_keyvalue "net.bridge.bridge-nf-call-ip6tables" "1" sysctl_set_keyvalue "net.bridge.bridge-nf-call-iptables" "1" + # for node port sysctl_set_keyvalue "net.ipv4.ip_local_reserved_ports" "30000-32767" echo @@ -132,10 +133,11 @@ install_ipvs install_hosts common_os_setting +# for es/opensearch sysctl_set_keyvalue "vm.max_map_count" "262144" -sysctl_set_keyvalue "vm.swappiness" "1" +# for kubeblocks +sysctl_set_keyvalue "fs.inotify.max_user_watches" "524288" sysctl_set_keyvalue "fs.inotify.max_user_instances" "524288" -sysctl_set_keyvalue "kernel.pid_max" "65535" sysctl -p # Make sure the iptables utility doesn't use the nftables backend. diff --git a/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl b/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl index 94236f92850..ad8e2318698 100644 --- a/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl +++ b/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl @@ -8,9 +8,9 @@ spec: - name: {{ .Name }} address: {{ .Address }} internalAddress: {{ .InternalAddress }} - user: {{ $.User }} - password: {{ $.Password }} - privateKey: {{ $.PrivateKey | quote }} + user: {{ $.User.Name }} + password: {{ $.User.Password }} + privateKey: {{ $.User.PrivateKey | quote }} timeout: {{ $.Timeout }} {{- end }} roleGroups: diff --git a/internal/cli/cmd/infrastructure/cluster.go b/internal/cli/cmd/infrastructure/cluster.go index 33b57e15497..b22e4310ac7 100644 --- a/internal/cli/cmd/infrastructure/cluster.go +++ b/internal/cli/cmd/infrastructure/cluster.go @@ -27,6 +27,7 @@ import ( "strings" "github.com/StudioSol/set" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" "github.com/apecloud/kubeblocks/internal/cli/printer" "github.com/apecloud/kubeblocks/internal/cli/util/prompt" kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" @@ -41,33 +42,30 @@ import ( ) type clusterOptions struct { + types.Cluster IOStreams genericclioptions.IOStreams - clusterName string - nodes []string - cluster types.Cluster - - timeout int64 - userName string - password string - privateKey string - privateKeyPath string + clusterConfig string + clusterName string + nodes []string + timeout int64 } func buildCommonFlags(cmd *cobra.Command, o *clusterOptions) { + cmd.Flags().StringVarP(&o.clusterConfig, "config", "c", "", "Specify infra cluster config file. [option]") cmd.Flags().StringVarP(&o.clusterName, "name", "", "", "Specify kubernetes cluster name") cmd.Flags().StringSliceVarP(&o.nodes, "nodes", "", nil, "List of machines on which kubernetes is installed. [require]") // for user - cmd.Flags().StringVarP(&o.userName, "user", "u", "", "Specify the account to access the remote server. [require]") + cmd.Flags().StringVarP(&o.User.Name, "user", "u", "", "Specify the account to access the remote server. [require]") cmd.Flags().Int64VarP(&o.timeout, "timeout", "t", 30, "Specify the ssh timeout.[option]") - cmd.Flags().StringVarP(&o.password, "password", "p", "", "Specify the password for the account to execute sudo. [option]") - cmd.Flags().StringVarP(&o.privateKey, "private-key", "", "", "The PrimaryKey for ssh to the remote machine. [option]") - cmd.Flags().StringVarP(&o.privateKeyPath, "private-key-path", "", "", "Specify the file PrimaryKeyPath of ssh to the remote machine. default ~/.ssh/id_rsa.") + cmd.Flags().StringVarP(&o.User.Password, "password", "p", "", "Specify the password for the account to execute sudo. [option]") + cmd.Flags().StringVarP(&o.User.PrivateKey, "private-key", "", "", "The PrimaryKey for ssh to the remote machine. [option]") + cmd.Flags().StringVarP(&o.User.PrivateKeyPath, "private-key-path", "", "", "Specify the file PrimaryKeyPath of ssh to the remote machine. default ~/.ssh/id_rsa.") - cmd.Flags().StringSliceVarP(&o.cluster.ETCD, "etcd", "", nil, "Specify etcd nodes") - cmd.Flags().StringSliceVarP(&o.cluster.Master, "master", "", nil, "Specify master nodes") - cmd.Flags().StringSliceVarP(&o.cluster.Worker, "worker", "", nil, "Specify worker nodes") + cmd.Flags().StringSliceVarP(&o.ETCD, "etcd", "", nil, "Specify etcd nodes") + cmd.Flags().StringSliceVarP(&o.Master, "master", "", nil, "Specify master nodes") + cmd.Flags().StringSliceVarP(&o.Worker, "worker", "", nil, "Specify worker nodes") } func (o *clusterOptions) Complete() error { @@ -76,30 +74,34 @@ func (o *clusterOptions) Complete() error { fmt.Printf("The cluster name is not set, auto generate cluster name: %s\n", o.clusterName) } - if o.userName == "" { + if o.clusterConfig != "" { + return o.validateClusterConfig(o.clusterConfig) + } + + if o.User.Name == "" { currentUser, err := user.Current() if err != nil { return err } - o.userName = currentUser.Username - fmt.Printf("The user is not set, use current user %s\n", o.userName) + o.User.Name = currentUser.Username + fmt.Printf("The user is not set, use current user %s\n", o.User.Name) } - if o.privateKey == "" { + if o.User.PrivateKey == "" { home, err := os.UserHomeDir() if err != nil { return err } - if o.privateKeyPath == "" && o.password == "" { - o.privateKeyPath = filepath.Join(home, ".ssh", "id_rsa") + if o.User.PrivateKeyPath == "" && o.User.Password == "" { + o.User.PrivateKeyPath = filepath.Join(home, ".ssh", "id_rsa") } - if strings.HasPrefix(o.privateKeyPath, "~/") { - o.privateKeyPath = filepath.Join(home, o.privateKeyPath[2:]) + if strings.HasPrefix(o.User.PrivateKeyPath, "~/") { + o.User.PrivateKeyPath = filepath.Join(home, o.User.PrivateKeyPath[2:]) } } if len(o.nodes) == 0 { return cfgcore.MakeError("The list of machines where kubernetes is installed must be specified.") } - o.cluster.Nodes = make([]types.ClusterNode, len(o.nodes)) + o.Nodes = make([]types.ClusterNode, len(o.nodes)) for i, node := range o.nodes { fields := strings.SplitN(node, ":", 3) if len(fields) < 2 { @@ -113,14 +115,14 @@ func (o *clusterOptions) Complete() error { if len(fields) == 3 { n.InternalAddress = fields[2] } - o.cluster.Nodes[i] = n + o.Nodes[i] = n } return nil } func (o *clusterOptions) Validate() error { checkFn := func(n string) bool { - for _, node := range o.cluster.Nodes { + for _, node := range o.Nodes { if node.Name == n { return true } @@ -140,29 +142,29 @@ func (o *clusterOptions) Validate() error { } return nil } - if o.userName == "" { + if o.User.Name == "" { return cfgcore.MakeError("user name is empty") } - if o.privateKey == "" && o.privateKeyPath != "" { - if _, err := os.Stat(o.privateKeyPath); err != nil { + if o.User.PrivateKey == "" && o.User.PrivateKeyPath != "" { + if _, err := os.Stat(o.User.PrivateKeyPath); err != nil { return err } - b, err := os.ReadFile(o.privateKeyPath) + b, err := os.ReadFile(o.User.PrivateKeyPath) if err != nil { return err } - o.privateKey = string(b) + o.User.PrivateKey = string(b) } - if len(o.cluster.ETCD) == 0 || len(o.cluster.Master) == 0 || len(o.cluster.Worker) == 0 { + if len(o.ETCD) == 0 || len(o.Master) == 0 || len(o.Worker) == 0 { return cfgcore.MakeError("etcd, master or worker is empty") } - if err := validateNodes(o.cluster.ETCD); err != nil { + if err := validateNodes(o.ETCD); err != nil { return err } - if err := validateNodes(o.cluster.Master); err != nil { + if err := validateNodes(o.Master); err != nil { return err } - if err := validateNodes(o.cluster.Worker); err != nil { + if err := validateNodes(o.Worker); err != nil { return err } return nil @@ -202,3 +204,21 @@ func (o *clusterOptions) confirm(promptStr string) (bool, error) { } return strings.ToLower(input) == yesStr, nil } + +func (o *clusterOptions) validateClusterConfig(configFile string) error { + _, err := os.Stat(configFile) + if err != nil { + return err + } + b, err := os.ReadFile(configFile) + if err != nil { + return err + } + + c, err := builder.BuildResourceFromYaml(o.Cluster, string(b)) + if err != nil { + return err + } + o.Cluster = *c + return nil +} diff --git a/internal/cli/cmd/infrastructure/delete.go b/internal/cli/cmd/infrastructure/delete.go index f3dace68829..d4ddb3b4bd0 100644 --- a/internal/cli/cmd/infrastructure/delete.go +++ b/internal/cli/cmd/infrastructure/delete.go @@ -42,16 +42,14 @@ type deleteOptions struct { func (o *deleteOptions) Run() error { cluster, err := createClusterWithOptions(&gotemplate.TplValues{ builtinClusterNameObject: o.clusterName, - builtinUserObject: o.userName, builtinClusterVersionObject: "0.0.0", - builtinPasswordObject: o.password, - builtinPrivateKeyObject: o.privateKey, - builtinHostsObject: o.cluster.Nodes, + builtinUserObject: o.User, + builtinHostsObject: o.Nodes, builtinTimeoutObject: o.timeout, builtinRoleGroupsObject: gotemplate.TplValues{ - common.ETCD: o.cluster.ETCD, - common.Master: o.cluster.Master, - common.Worker: o.cluster.Worker, + common.ETCD: o.ETCD, + common.Master: o.Master, + common.Worker: o.Worker, }, }) if err != nil { diff --git a/internal/cli/cmd/infrastructure/loader_adapter.go b/internal/cli/cmd/infrastructure/loader_adapter.go index 67710570db1..09e0bc869fc 100644 --- a/internal/cli/cmd/infrastructure/loader_adapter.go +++ b/internal/cli/cmd/infrastructure/loader_adapter.go @@ -49,8 +49,6 @@ const ( builtinClusterVersionObject = "Version" builtinCRITypeObject = "CRIType" builtinUserObject = "User" - builtinPasswordObject = "Password" - builtinPrivateKeyObject = "PrivateKey" builtinHostsObject = "Hosts" builtinRoleGroupsObject = "RoleGroups" ) @@ -60,15 +58,13 @@ func buildTemplateParams(o *createOptions) *gotemplate.TplValues { builtinClusterNameObject: o.clusterName, builtinClusterVersionObject: o.version.KubernetesVersion, builtinCRITypeObject: o.criType, - builtinUserObject: o.userName, - builtinPasswordObject: o.password, - builtinPrivateKeyObject: o.privateKey, - builtinHostsObject: o.cluster.Nodes, + builtinUserObject: o.User, + builtinHostsObject: o.Nodes, builtinTimeoutObject: o.timeout, builtinRoleGroupsObject: gotemplate.TplValues{ - common.ETCD: o.cluster.ETCD, - common.Master: o.cluster.Master, - common.Worker: o.cluster.Worker, + common.ETCD: o.ETCD, + common.Master: o.Master, + common.Worker: o.Worker, }, } } diff --git a/internal/cli/cmd/infrastructure/loader_adapter_test.go b/internal/cli/cmd/infrastructure/loader_adapter_test.go index c3a1bd76c5c..7cc0f8813ee 100644 --- a/internal/cli/cmd/infrastructure/loader_adapter_test.go +++ b/internal/cli/cmd/infrastructure/loader_adapter_test.go @@ -41,9 +41,7 @@ func TestCreateClusterWithOptions(t *testing.T) { criType: string(container.ContainerdType), clusterOptions: clusterOptions{ clusterName: "for_test", - userName: "test", - password: "test", - cluster: types.Cluster{ + Cluster: types.Cluster{ Nodes: []types.ClusterNode{ { Name: "node1", @@ -55,6 +53,10 @@ func TestCreateClusterWithOptions(t *testing.T) { InternalAddress: "127.0.0.2", }, }, + User: types.ClusterUser{ + Name: "test", + Password: "test", + }, ETCD: []string{"node1"}, Master: []string{"node1"}, Worker: []string{"node2"}, diff --git a/internal/cli/cmd/infrastructure/types/type.go b/internal/cli/cmd/infrastructure/types/type.go index f57066cf299..668403bcec6 100644 --- a/internal/cli/cmd/infrastructure/types/type.go +++ b/internal/cli/cmd/infrastructure/types/type.go @@ -30,8 +30,8 @@ type InfraVersionInfo struct { } type Cluster struct { - User ClusterUser - Nodes []ClusterNode + User ClusterUser `json:"user"` + Nodes []ClusterNode `json:"nodes"` ETCD []string `json:"etcd"` Master []string `json:"master"` @@ -50,5 +50,6 @@ type ClusterUser struct { // sudo password Password string `json:"password"` // ssh privateKey - PrivateKey string `json:"privateKey"` + PrivateKey string `json:"privateKey"` + PrivateKeyPath string `json:"privateKeyPath"` } diff --git a/internal/cli/create/template/kubekey_cluster_template.cue b/internal/cli/create/template/kubekey_cluster_template.cue deleted file mode 100644 index c67231ce34e..00000000000 --- a/internal/cli/create/template/kubekey_cluster_template.cue +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2022-2023 ApeCloud Co., Ltd -// -// This file is part of KubeBlocks project -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -options: { - name: string - user: string - - privateKey: string - hosts: [...Host] - roleGroups: {} - - version: string - criType: string - ... -} - -Host: { - name: string - address: string - internalAddress: string -} - -// required, k8s api resource content -content: { - apiVersion: "kubekey.kubesphere.io/v1alpha2" - kind: "Cluster" - metadata: { - name: options.name - } - spec: { - hosts: [ for _, h in options.hosts { - name: h.name - address: h.address - internalAddress: h.internalAddress - if options.user != "" { - user: options.user - } - if options.privateKey != "" { - privateKey: options.privateKey - } - }] - roleGroups: options.roleGroups - controlPlaneEndpoint: - domain: "lb.kubesphere.local" - port: 6443 - kubernetes: - version: options.version - clusterName: options.name - autoRenewCerts: true - if options.criType != "" { - containerManager: options.criType - } - if options.criType == "" { - containerManager: "containerd" - } - } -} From b1b9f39782db91f237173b60032ff19dda0c7c5d Mon Sep 17 00:00:00 2001 From: sophon Date: Fri, 9 Jun 2023 16:31:03 +0800 Subject: [PATCH 15/44] update kbcli-doc --- docs/user_docs/cli/cli.md | 1 + docs/user_docs/cli/kbcli_infra.md | 1 + docs/user_docs/cli/kbcli_infra_create.md | 2 + docs/user_docs/cli/kbcli_infra_delete.md | 65 ++++++++++++++++++++++ internal/cli/cmd/infrastructure/cluster.go | 2 +- 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 docs/user_docs/cli/kbcli_infra_delete.md diff --git a/docs/user_docs/cli/cli.md b/docs/user_docs/cli/cli.md index 136d2155cf4..31099364ff8 100644 --- a/docs/user_docs/cli/cli.md +++ b/docs/user_docs/cli/cli.md @@ -141,6 +141,7 @@ Inject faults to pod. infra command * [kbcli infra create](kbcli_infra_create.md) - create kubernetes cluster. +* [kbcli infra delete](kbcli_infra_delete.md) - delete kubernetes cluster. ## [kubeblocks](kbcli_kubeblocks.md) diff --git a/docs/user_docs/cli/kbcli_infra.md b/docs/user_docs/cli/kbcli_infra.md index 03f64d298de..a7934026e4d 100644 --- a/docs/user_docs/cli/kbcli_infra.md +++ b/docs/user_docs/cli/kbcli_infra.md @@ -38,6 +38,7 @@ infra command * [kbcli infra create](kbcli_infra_create.md) - create kubernetes cluster. +* [kbcli infra delete](kbcli_infra_delete.md) - delete kubernetes cluster. #### Go Back to [CLI Overview](cli.md) Homepage. diff --git a/docs/user_docs/cli/kbcli_infra_create.md b/docs/user_docs/cli/kbcli_infra_create.md index e912528c81d..df1c301542a 100644 --- a/docs/user_docs/cli/kbcli_infra_create.md +++ b/docs/user_docs/cli/kbcli_infra_create.md @@ -18,6 +18,7 @@ kbcli infra create [flags] ### Options ``` + -c, --config string Specify infra cluster config file. [option] --container-runtime string Specify kubernetes container runtime. default is containerd (default "containerd") --debug set debug mode --etcd strings Specify etcd nodes @@ -28,6 +29,7 @@ kbcli infra create [flags] -p, --password string Specify the password for the account to execute sudo. [option] --private-key string The PrimaryKey for ssh to the remote machine. [option] --private-key-path string Specify the file PrimaryKeyPath of ssh to the remote machine. default ~/.ssh/id_rsa. + --sandbox-image string Specified sandbox-image will not be used by the cri. [option] (default "k8s.gcr.io/pause:3.8") -t, --timeout int Specify the ssh timeout.[option] (default 30) -u, --user string Specify the account to access the remote server. [require] --version string Specify install kubernetes version. default version is v1.26.5 (default "v1.26.5") diff --git a/docs/user_docs/cli/kbcli_infra_delete.md b/docs/user_docs/cli/kbcli_infra_delete.md new file mode 100644 index 00000000000..87b402cb6b1 --- /dev/null +++ b/docs/user_docs/cli/kbcli_infra_delete.md @@ -0,0 +1,65 @@ +--- +title: kbcli infra delete +--- + +delete kubernetes cluster. + +``` +kbcli infra delete [flags] +``` + +### Examples + +``` + + +``` + +### Options + +``` + -c, --config string Specify infra cluster config file. [option] + --debug set debug mode + --delete-cri delete cri + --etcd strings Specify etcd nodes + -h, --help help for delete + --master strings Specify master nodes + --name string Specify kubernetes cluster name + --nodes strings List of machines on which kubernetes is installed. [require] + -p, --password string Specify the password for the account to execute sudo. [option] + --private-key string The PrimaryKey for ssh to the remote machine. [option] + --private-key-path string Specify the file PrimaryKeyPath of ssh to the remote machine. default ~/.ssh/id_rsa. + -t, --timeout int Specify the ssh timeout.[option] (default 30) + -u, --user string Specify the account to access the remote server. [require] + --worker strings Specify worker nodes +``` + +### Options inherited from parent commands + +``` + --as string Username to impersonate for the operation. User could be a regular user or a service account in a namespace. + --as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups. + --as-uid string UID to impersonate for the operation. + --cache-dir string Default cache directory (default "$HOME/.kube/cache") + --certificate-authority string Path to a cert file for the certificate authority + --client-certificate string Path to a client certificate file for TLS + --client-key string Path to a client key file for TLS + --cluster string The name of the kubeconfig cluster to use + --context string The name of the kubeconfig context to use + --disable-compression If true, opt-out of response compression for all requests to the server + --insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure + --kubeconfig string Path to the kubeconfig file to use for CLI requests. + --match-server-version Require server version to match client version + -n, --namespace string If present, the namespace scope for this CLI request + --request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0") + -s, --server string The address and port of the Kubernetes API server + --tls-server-name string Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used + --token string Bearer token for authentication to the API server +``` + +### SEE ALSO + +* [kbcli infra](kbcli_infra.md) - infra command + +#### Go Back to [CLI Overview](cli.md) Homepage. + diff --git a/internal/cli/cmd/infrastructure/cluster.go b/internal/cli/cmd/infrastructure/cluster.go index b22e4310ac7..b5eb674180a 100644 --- a/internal/cli/cmd/infrastructure/cluster.go +++ b/internal/cli/cmd/infrastructure/cluster.go @@ -47,8 +47,8 @@ type clusterOptions struct { clusterConfig string clusterName string - nodes []string timeout int64 + nodes []string } func buildCommonFlags(cmd *cobra.Command, o *clusterOptions) { From 87b7de4b999e709198b33d645272c76e0a5c6c81 Mon Sep 17 00:00:00 2001 From: sophon Date: Tue, 13 Jun 2023 10:48:24 +0800 Subject: [PATCH 16/44] chore: add helm installer --- internal/cli/cmd/infrastructure/pipeline.go | 1 + .../cli/cmd/infrastructure/tasks/addon.go | 62 +++++++++++++++++++ internal/cli/cmd/infrastructure/types/type.go | 6 ++ 3 files changed, 69 insertions(+) create mode 100644 internal/cli/cmd/infrastructure/tasks/addon.go diff --git a/internal/cli/cmd/infrastructure/pipeline.go b/internal/cli/cmd/infrastructure/pipeline.go index 46a588c6d3b..3771c5f4f6a 100644 --- a/internal/cli/cmd/infrastructure/pipeline.go +++ b/internal/cli/cmd/infrastructure/pipeline.go @@ -58,6 +58,7 @@ func NewCreatePipeline(o *createOptions) []module.Module { &kubernetes.ConfigureKubernetesModule{}, &filesystem.ChownModule{}, &kubernetes.SecurityEnhancementModule{Skip: !o.securityEnhancement}, + &tasks.AddonsInstaller{Addons: o.Addons}, } } diff --git a/internal/cli/cmd/infrastructure/tasks/addon.go b/internal/cli/cmd/infrastructure/tasks/addon.go new file mode 100644 index 00000000000..b69f644c954 --- /dev/null +++ b/internal/cli/cmd/infrastructure/tasks/addon.go @@ -0,0 +1,62 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package tasks + +import ( + "fmt" + "path/filepath" + + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task" + + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" +) + +type AddonsInstaller struct { + common.KubeModule + Addons []types.PluginMeta +} + +type KBAddonsInstall struct { + common.KubeAction + Addons []types.PluginMeta +} + +func (a *AddonsInstaller) Init() { + a.Name = "AddonsInstaller" + a.Desc = "Install helm addons" + a.Tasks = []task.Interface{ + &task.LocalTask{ + Name: "AddonsInstaller", + Desc: "Install helm addons", + Action: &KBAddonsInstall{Addons: a.Addons}, + }} +} + +func (i *KBAddonsInstall) Execute(runtime connector.Runtime) error { + kubeConfig := filepath.Join(runtime.GetWorkDir(), fmt.Sprintf("config-%s", runtime.GetObjName())) + _ = kubeConfig + for _, addon := range i.Addons { + _ = addon + // TODO install helm install + } + return nil +} diff --git a/internal/cli/cmd/infrastructure/types/type.go b/internal/cli/cmd/infrastructure/types/type.go index 668403bcec6..b923b36a184 100644 --- a/internal/cli/cmd/infrastructure/types/type.go +++ b/internal/cli/cmd/infrastructure/types/type.go @@ -29,6 +29,10 @@ type InfraVersionInfo struct { HelmVersion string } +type PluginMeta struct { + Name string `json:"name"` +} + type Cluster struct { User ClusterUser `json:"user"` Nodes []ClusterNode `json:"nodes"` @@ -36,6 +40,8 @@ type Cluster struct { ETCD []string `json:"etcd"` Master []string `json:"master"` Worker []string `json:"worker"` + + Addons []PluginMeta `json:"addons"` } type ClusterNode struct { From 3b85da1819b5a26ec644fd710e9ae8bf16915621 Mon Sep 17 00:00:00 2001 From: sophon-zt Date: Sun, 25 Jun 2023 01:54:22 +0000 Subject: [PATCH 17/44] chore: auto update cli doc changes --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3855dd4560d..e1d696d354e 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,6 @@ require ( github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 github.com/onsi/ginkgo/v2 v2.9.1 github.com/onsi/gomega v1.27.4 - github.com/opencontainers/image-spec v1.1.0-rc2 github.com/pkg/errors v0.9.1 github.com/pmezard/go-difflib v1.0.0 github.com/redis/go-redis/v9 v9.0.1 @@ -310,6 +309,7 @@ require ( github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.1.0-rc2 // indirect github.com/opencontainers/runc v1.1.5 // indirect github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect github.com/opencontainers/selinux v1.10.2 // indirect From 9878233a819db8db442ed7014d1aee6752c8d4a6 Mon Sep 17 00:00:00 2001 From: sophon Date: Sun, 25 Jun 2023 10:44:38 +0800 Subject: [PATCH 18/44] chore: adjust roleGroup struct --- internal/cli/cmd/infrastructure/cluster.go | 14 +++++++------- internal/cli/cmd/infrastructure/delete.go | 6 +++--- internal/cli/cmd/infrastructure/loader_adapter.go | 6 +++--- .../cli/cmd/infrastructure/loader_adapter_test.go | 8 +++++--- internal/cli/cmd/infrastructure/types/type.go | 11 +++++++++-- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/internal/cli/cmd/infrastructure/cluster.go b/internal/cli/cmd/infrastructure/cluster.go index b5eb674180a..30842e37fca 100644 --- a/internal/cli/cmd/infrastructure/cluster.go +++ b/internal/cli/cmd/infrastructure/cluster.go @@ -63,9 +63,9 @@ func buildCommonFlags(cmd *cobra.Command, o *clusterOptions) { cmd.Flags().StringVarP(&o.User.PrivateKey, "private-key", "", "", "The PrimaryKey for ssh to the remote machine. [option]") cmd.Flags().StringVarP(&o.User.PrivateKeyPath, "private-key-path", "", "", "Specify the file PrimaryKeyPath of ssh to the remote machine. default ~/.ssh/id_rsa.") - cmd.Flags().StringSliceVarP(&o.ETCD, "etcd", "", nil, "Specify etcd nodes") - cmd.Flags().StringSliceVarP(&o.Master, "master", "", nil, "Specify master nodes") - cmd.Flags().StringSliceVarP(&o.Worker, "worker", "", nil, "Specify worker nodes") + cmd.Flags().StringSliceVarP(&o.RoleGroup.ETCD, "etcd", "", nil, "Specify etcd nodes") + cmd.Flags().StringSliceVarP(&o.RoleGroup.Master, "master", "", nil, "Specify master nodes") + cmd.Flags().StringSliceVarP(&o.RoleGroup.Worker, "worker", "", nil, "Specify worker nodes") } func (o *clusterOptions) Complete() error { @@ -155,16 +155,16 @@ func (o *clusterOptions) Validate() error { } o.User.PrivateKey = string(b) } - if len(o.ETCD) == 0 || len(o.Master) == 0 || len(o.Worker) == 0 { + if o.RoleGroup.IsValidate() { return cfgcore.MakeError("etcd, master or worker is empty") } - if err := validateNodes(o.ETCD); err != nil { + if err := validateNodes(o.RoleGroup.ETCD); err != nil { return err } - if err := validateNodes(o.Master); err != nil { + if err := validateNodes(o.RoleGroup.Master); err != nil { return err } - if err := validateNodes(o.Worker); err != nil { + if err := validateNodes(o.RoleGroup.Worker); err != nil { return err } return nil diff --git a/internal/cli/cmd/infrastructure/delete.go b/internal/cli/cmd/infrastructure/delete.go index d4ddb3b4bd0..03b3066d766 100644 --- a/internal/cli/cmd/infrastructure/delete.go +++ b/internal/cli/cmd/infrastructure/delete.go @@ -47,9 +47,9 @@ func (o *deleteOptions) Run() error { builtinHostsObject: o.Nodes, builtinTimeoutObject: o.timeout, builtinRoleGroupsObject: gotemplate.TplValues{ - common.ETCD: o.ETCD, - common.Master: o.Master, - common.Worker: o.Worker, + common.ETCD: o.RoleGroup.ETCD, + common.Master: o.RoleGroup.Master, + common.Worker: o.RoleGroup.Worker, }, }) if err != nil { diff --git a/internal/cli/cmd/infrastructure/loader_adapter.go b/internal/cli/cmd/infrastructure/loader_adapter.go index 09e0bc869fc..aebd3da7002 100644 --- a/internal/cli/cmd/infrastructure/loader_adapter.go +++ b/internal/cli/cmd/infrastructure/loader_adapter.go @@ -62,9 +62,9 @@ func buildTemplateParams(o *createOptions) *gotemplate.TplValues { builtinHostsObject: o.Nodes, builtinTimeoutObject: o.timeout, builtinRoleGroupsObject: gotemplate.TplValues{ - common.ETCD: o.ETCD, - common.Master: o.Master, - common.Worker: o.Worker, + common.ETCD: o.RoleGroup.ETCD, + common.Master: o.RoleGroup.Master, + common.Worker: o.RoleGroup.Worker, }, } } diff --git a/internal/cli/cmd/infrastructure/loader_adapter_test.go b/internal/cli/cmd/infrastructure/loader_adapter_test.go index 7cc0f8813ee..91847e3f83c 100644 --- a/internal/cli/cmd/infrastructure/loader_adapter_test.go +++ b/internal/cli/cmd/infrastructure/loader_adapter_test.go @@ -57,9 +57,11 @@ func TestCreateClusterWithOptions(t *testing.T) { Name: "test", Password: "test", }, - ETCD: []string{"node1"}, - Master: []string{"node1"}, - Worker: []string{"node2"}, + RoleGroup: types.RoleGroup{ + ETCD: []string{"node1"}, + Master: []string{"node1"}, + Worker: []string{"node2"}, + }, }, }, }, diff --git a/internal/cli/cmd/infrastructure/types/type.go b/internal/cli/cmd/infrastructure/types/type.go index b923b36a184..336ce34ec35 100644 --- a/internal/cli/cmd/infrastructure/types/type.go +++ b/internal/cli/cmd/infrastructure/types/type.go @@ -37,11 +37,14 @@ type Cluster struct { User ClusterUser `json:"user"` Nodes []ClusterNode `json:"nodes"` + RoleGroup RoleGroup `json:"roleGroup"` + Addons []PluginMeta `json:"addons"` +} + +type RoleGroup struct { ETCD []string `json:"etcd"` Master []string `json:"master"` Worker []string `json:"worker"` - - Addons []PluginMeta `json:"addons"` } type ClusterNode struct { @@ -59,3 +62,7 @@ type ClusterUser struct { PrivateKey string `json:"privateKey"` PrivateKeyPath string `json:"privateKeyPath"` } + +func (g RoleGroup) IsValidate() bool { + return len(g.ETCD) > 0 && len(g.Master) > 0 && len(g.Worker) > 0 +} From 2a0d192c3843e91980a88c82a551b25a7b4769e0 Mon Sep 17 00:00:00 2001 From: sophon Date: Sun, 25 Jun 2023 10:50:18 +0800 Subject: [PATCH 19/44] chore: refine the code for cluster Validate --- internal/cli/cmd/infrastructure/cluster.go | 139 ++++++++++++--------- 1 file changed, 81 insertions(+), 58 deletions(-) diff --git a/internal/cli/cmd/infrastructure/cluster.go b/internal/cli/cmd/infrastructure/cluster.go index 30842e37fca..b74af0b2005 100644 --- a/internal/cli/cmd/infrastructure/cluster.go +++ b/internal/cli/cmd/infrastructure/cluster.go @@ -27,9 +27,6 @@ import ( "strings" "github.com/StudioSol/set" - "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" - "github.com/apecloud/kubeblocks/internal/cli/printer" - "github.com/apecloud/kubeblocks/internal/cli/util/prompt" kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" "github.com/spf13/cobra" @@ -37,8 +34,12 @@ import ( "k8s.io/apimachinery/pkg/util/rand" "k8s.io/cli-runtime/pkg/genericclioptions" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" + "github.com/apecloud/kubeblocks/internal/cli/printer" + "github.com/apecloud/kubeblocks/internal/cli/util/prompt" cfgcore "github.com/apecloud/kubeblocks/internal/configuration" + cfgutil "github.com/apecloud/kubeblocks/internal/configuration/util" ) type clusterOptions struct { @@ -75,7 +76,7 @@ func (o *clusterOptions) Complete() error { } if o.clusterConfig != "" { - return o.validateClusterConfig(o.clusterConfig) + return o.fillClusterConfig(o.clusterConfig) } if o.User.Name == "" { @@ -86,17 +87,12 @@ func (o *clusterOptions) Complete() error { o.User.Name = currentUser.Username fmt.Printf("The user is not set, use current user %s\n", o.User.Name) } - if o.User.PrivateKey == "" { + if o.User.Password == "" && o.User.PrivateKey == "" && o.User.PrivateKeyPath == "" { home, err := os.UserHomeDir() if err != nil { return err } - if o.User.PrivateKeyPath == "" && o.User.Password == "" { - o.User.PrivateKeyPath = filepath.Join(home, ".ssh", "id_rsa") - } - if strings.HasPrefix(o.User.PrivateKeyPath, "~/") { - o.User.PrivateKeyPath = filepath.Join(home, o.User.PrivateKeyPath[2:]) - } + o.User.PrivateKeyPath = filepath.Join(home, ".ssh", "id_rsa") } if len(o.nodes) == 0 { return cfgcore.MakeError("The list of machines where kubernetes is installed must be specified.") @@ -121,69 +117,48 @@ func (o *clusterOptions) Complete() error { } func (o *clusterOptions) Validate() error { - checkFn := func(n string) bool { - for _, node := range o.Nodes { - if node.Name == n { - return true - } - } - return false - } - validateNodes := func(nodes []string) error { - sets := set.NewLinkedHashSetString() - for _, node := range nodes { - if !checkFn(node) { - return cfgcore.MakeError("node %s is not exist!", node) - } - if sets.InArray(node) { - return cfgcore.MakeError("node %s is repeat!", node) - } - sets.Add(node) - } - return nil - } if o.User.Name == "" { return cfgcore.MakeError("user name is empty") } - if o.User.PrivateKey == "" && o.User.PrivateKeyPath != "" { - if _, err := os.Stat(o.User.PrivateKeyPath); err != nil { - return err - } - b, err := os.ReadFile(o.User.PrivateKeyPath) - if err != nil { - return err - } - o.User.PrivateKey = string(b) + if err := validateUser(o); err != nil { + return err } - if o.RoleGroup.IsValidate() { + if !o.RoleGroup.IsValidate() { return cfgcore.MakeError("etcd, master or worker is empty") } - if err := validateNodes(o.RoleGroup.ETCD); err != nil { + if err := o.checkReplicaNode(o.RoleGroup.ETCD); err != nil { return err } - if err := validateNodes(o.RoleGroup.Master); err != nil { + if err := o.checkReplicaNode(o.RoleGroup.Master); err != nil { return err } - if err := validateNodes(o.RoleGroup.Worker); err != nil { + if err := o.checkReplicaNode(o.RoleGroup.Worker); err != nil { return err } return nil } -func syncClusterNodeRole(cluster *kubekeyapiv1alpha2.ClusterSpec, runtime *common.KubeRuntime) { - hostSet := set.NewLinkedHashSetString() - for _, role := range cluster.GroupHosts() { - for _, host := range role { - if host.IsRole(common.Master) || host.IsRole(common.Worker) { - host.SetRole(common.K8s) - } - if !hostSet.InArray(host.GetName()) { - hostSet.Add(host.GetName()) - runtime.BaseRuntime.AppendHost(host) - runtime.BaseRuntime.AppendRoleMap(host) - } +func (o *clusterOptions) checkReplicaNode(nodes []string) error { + sets := cfgutil.NewSet() + for _, node := range nodes { + if !o.hasNode(node) { + return cfgcore.MakeError("node %s is not exist!", node) } + if sets.InArray(node) { + return cfgcore.MakeError("node %s is repeat!", node) + } + sets.Add(node) } + return nil +} + +func (o *clusterOptions) hasNode(n string) bool { + for _, node := range o.Nodes { + if node.Name == n { + return true + } + } + return false } func (o *clusterOptions) confirm(promptStr string) (bool, error) { @@ -205,7 +180,7 @@ func (o *clusterOptions) confirm(promptStr string) (bool, error) { return strings.ToLower(input) == yesStr, nil } -func (o *clusterOptions) validateClusterConfig(configFile string) error { +func (o *clusterOptions) fillClusterConfig(configFile string) error { _, err := os.Stat(configFile) if err != nil { return err @@ -222,3 +197,51 @@ func (o *clusterOptions) validateClusterConfig(configFile string) error { o.Cluster = *c return nil } + +func checkAndUpdateHomeDir(user *types.ClusterUser) error { + if !strings.HasPrefix(user.PrivateKeyPath, "~/") { + return nil + } + home, err := os.UserHomeDir() + if err != nil { + return err + } + user.PrivateKeyPath = filepath.Join(home, user.PrivateKeyPath[2:]) + return nil +} + +func validateUser(o *clusterOptions) error { + if o.User.Password != "" || o.User.PrivateKey != "" { + return nil + } + if o.User.PrivateKey == "" && o.User.PrivateKeyPath != "" { + if err := checkAndUpdateHomeDir(&o.User); err != nil { + return err + } + if _, err := os.Stat(o.User.PrivateKeyPath); err != nil { + return err + } + b, err := os.ReadFile(o.User.PrivateKeyPath) + if err != nil { + return err + } + o.User.PrivateKey = string(b) + } + return nil +} + +func syncClusterNodeRole(cluster *kubekeyapiv1alpha2.ClusterSpec, runtime *common.KubeRuntime) { + hostSet := set.NewLinkedHashSetString() + for _, role := range cluster.GroupHosts() { + for _, host := range role { + if host.IsRole(common.Master) || host.IsRole(common.Worker) { + host.SetRole(common.K8s) + } + if !hostSet.InArray(host.GetName()) { + hostSet.Add(host.GetName()) + runtime.BaseRuntime.AppendHost(host) + runtime.BaseRuntime.AppendRoleMap(host) + } + } + } +} From d0e79a556e6cd30e0adea75139379b382e4cb5a6 Mon Sep 17 00:00:00 2001 From: sophon Date: Sun, 25 Jun 2023 19:53:47 +0800 Subject: [PATCH 20/44] chore: add SaveKubeConfig for saving kubeconfig --- go.mod | 2 +- internal/cli/cmd/infrastructure/create.go | 2 + internal/cli/cmd/infrastructure/pipeline.go | 52 +++++------ .../cmd/infrastructure/tasks/kubeconfig.go | 89 +++++++++++++++++++ .../cmd/infrastructure/tasks/kubernetes.go | 86 +++++++++++++++--- .../infrastructure/tasks/kubernetes_test.go | 20 +++++ 6 files changed, 208 insertions(+), 43 deletions(-) create mode 100644 internal/cli/cmd/infrastructure/tasks/kubeconfig.go create mode 100644 internal/cli/cmd/infrastructure/tasks/kubernetes_test.go diff --git a/go.mod b/go.mod index e1d696d354e..3855dd4560d 100644 --- a/go.mod +++ b/go.mod @@ -53,6 +53,7 @@ require ( github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 github.com/onsi/ginkgo/v2 v2.9.1 github.com/onsi/gomega v1.27.4 + github.com/opencontainers/image-spec v1.1.0-rc2 github.com/pkg/errors v0.9.1 github.com/pmezard/go-difflib v1.0.0 github.com/redis/go-redis/v9 v9.0.1 @@ -309,7 +310,6 @@ require ( github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.0-rc2 // indirect github.com/opencontainers/runc v1.1.5 // indirect github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect github.com/opencontainers/selinux v1.10.2 // indirect diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index b25759ce02f..141452bd3f6 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -45,6 +45,7 @@ type createOptions struct { sandBoxImage string securityEnhancement bool + outputKubeconfig string } var createExamples = ` @@ -123,6 +124,7 @@ func (o *createOptions) buildCreateInfraFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&o.sandBoxImage, "sandbox-image", "", tasks.DefaultSandBoxImage, "Specified sandbox-image will not be used by the cri. [option]") cmd.Flags().StringVarP(&o.criType, "container-runtime", "", string(container.ContainerdType), "Specify kubernetes container runtime. default is containerd") cmd.Flags().BoolVarP(&o.debug, "debug", "", false, "set debug mode") + cmd.Flags().StringVarP(&o.outputKubeconfig, "output-kubeconfig", "", tasks.GetDefaultConfig(), "Specified output kubeconfig. [option]") } func (o *createOptions) setDefaultVersion() { diff --git a/internal/cli/cmd/infrastructure/pipeline.go b/internal/cli/cmd/infrastructure/pipeline.go index 3771c5f4f6a..184e3d6cc2e 100644 --- a/internal/cli/cmd/infrastructure/pipeline.go +++ b/internal/cli/cmd/infrastructure/pipeline.go @@ -20,45 +20,41 @@ along with this program. If not, see . package infrastructure import ( + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/precheck" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/certs" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/container" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/module" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/etcd" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/filesystem" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/kubernetes" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/dns" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/network" - - "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" ) func NewCreatePipeline(o *createOptions) []module.Module { return []module.Module{ - &precheck.GreetingsModule{}, - &tasks.CheckNodeArchitectureModule{}, - &precheck.NodePreCheckModule{}, - &tasks.InstallDependenciesModule{}, - &tasks.PrepareK8sBinariesModule{BinaryVersion: o.version}, - &tasks.ConfigureOSModule{}, - &kubernetes.StatusModule{}, - &tasks.InstallCRIModule{SandBoxImage: o.sandBoxImage}, - &etcd.PreCheckModule{}, - &etcd.CertsModule{}, - &etcd.InstallETCDBinaryModule{}, - &etcd.ConfigureModule{}, - &etcd.BackupModule{}, - &kubernetes.InstallKubeBinariesModule{}, - &kubernetes.InitKubernetesModule{}, - &dns.ClusterDNSModule{}, + //&precheck.GreetingsModule{}, + //&tasks.CheckNodeArchitectureModule{}, + //&precheck.NodePreCheckModule{}, + //&tasks.InstallDependenciesModule{}, + //&tasks.PrepareK8sBinariesModule{BinaryVersion: o.version}, + //&tasks.ConfigureOSModule{}, + //&kubernetes.StatusModule{}, + //&tasks.InstallCRIModule{SandBoxImage: o.sandBoxImage}, + //&etcd.PreCheckModule{}, + //&etcd.CertsModule{}, + //&etcd.InstallETCDBinaryModule{}, + //&etcd.ConfigureModule{}, + //&etcd.BackupModule{}, + //&kubernetes.InstallKubeBinariesModule{}, + //&kubernetes.InitKubernetesModule{}, + //&dns.ClusterDNSModule{}, &kubernetes.StatusModule{}, - &kubernetes.JoinNodesModule{}, - &network.DeployNetworkPluginModule{}, - &kubernetes.ConfigureKubernetesModule{}, - &filesystem.ChownModule{}, - &kubernetes.SecurityEnhancementModule{Skip: !o.securityEnhancement}, - &tasks.AddonsInstaller{Addons: o.Addons}, + &tasks.SaveKubeConfigModule{OutputKubeconfig: o.outputKubeconfig}, + //&kubernetes.JoinNodesModule{}, + //&network.DeployNetworkPluginModule{}, + //&kubernetes.ConfigureKubernetesModule{}, + //&filesystem.ChownModule{}, + //&kubernetes.SecurityEnhancementModule{Skip: !o.securityEnhancement}, + //&tasks.AddonsInstaller{Addons: o.Addons}, } } diff --git a/internal/cli/cmd/infrastructure/tasks/kubeconfig.go b/internal/cli/cmd/infrastructure/tasks/kubeconfig.go new file mode 100644 index 00000000000..2776c6bd052 --- /dev/null +++ b/internal/cli/cmd/infrastructure/tasks/kubeconfig.go @@ -0,0 +1,89 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package tasks + +import ( + "fmt" + "os" + "time" + + "github.com/apecloud/kubeblocks/internal/cli/util" + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" + "k8s.io/client-go/tools/clientcmd" + clientcmdapi "k8s.io/client-go/tools/clientcmd/api" +) + +func kubeconfigMerge(newKubeConfig *clientcmdapi.Config, existingKubeConfig *clientcmdapi.Config, outPath string) error { + // merge clusters + for k, v := range newKubeConfig.Clusters { + if _, ok := existingKubeConfig.Clusters[k]; ok { + return cfgcore.MakeError("Cluster '%s' already exists in target KubeConfig", k) + } + existingKubeConfig.Clusters[k] = v + } + + // merge auth + for k, v := range newKubeConfig.AuthInfos { + if _, ok := existingKubeConfig.AuthInfos[k]; ok { + return cfgcore.MakeError("AuthInfo '%s' already exists in target KubeConfig", k) + } + existingKubeConfig.AuthInfos[k] = v + } + + // merge contexts + for k, v := range newKubeConfig.Contexts { + if _, ok := existingKubeConfig.Contexts[k]; ok { + return cfgcore.MakeError("Context '%s' already exists in target KubeConfig", k) + } + existingKubeConfig.Contexts[k] = v + } + + existingKubeConfig.CurrentContext = newKubeConfig.CurrentContext + return kubeconfigWrite(existingKubeConfig, outPath) +} + +func kubeconfigWrite(config *clientcmdapi.Config, path string) error { + tempPath := fmt.Sprintf("%s.kb_%s", path, time.Now().Format("20060102_150405.000000")) + if err := clientcmd.WriteToFile(*config, tempPath); err != nil { + return cfgcore.WrapError(err, "failed to write merged kubeconfig to temporary file '%s'", tempPath) + } + + // Move temporary file over existing KubeConfig + if err := os.Rename(tempPath, path); err != nil { + return cfgcore.WrapError(err, "failed to overwrite existing KubeConfig '%s' with new kubeconfig '%s'", path, tempPath) + } + return nil +} + +func GetDefaultConfig() string { + defaultKubeConfigLoadingRules := clientcmd.NewDefaultClientConfigLoadingRules() + kcFile := defaultKubeConfigLoadingRules.GetDefaultFilename() + if kcFile == "" { + kcFile = util.GetKubeconfigDir() + } + return kcFile +} + +func kubeconfigLoad(kcFile string) (*clientcmdapi.Config, error) { + if _, err := os.Stat(kcFile); err == nil { + return clientcmd.LoadFromFile(kcFile) + } + return nil, nil +} diff --git a/internal/cli/cmd/infrastructure/tasks/kubernetes.go b/internal/cli/cmd/infrastructure/tasks/kubernetes.go index e1738e3e355..58aaca66b44 100644 --- a/internal/cli/cmd/infrastructure/tasks/kubernetes.go +++ b/internal/cli/cmd/infrastructure/tasks/kubernetes.go @@ -20,18 +20,24 @@ along with this program. If not, see . package tasks import ( + "fmt" "path/filepath" + "strings" "github.com/StudioSol/set" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" + "github.com/apecloud/kubeblocks/internal/gotemplate" + kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os/templates" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task" - - "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" - "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" - "github.com/apecloud/kubeblocks/internal/gotemplate" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/kubernetes" + "k8s.io/client-go/tools/clientcmd" + clientcmdapi "k8s.io/client-go/tools/clientcmd/api" ) type PrepareK8sBinariesModule struct { @@ -45,6 +51,12 @@ type ConfigureOSModule struct { common.KubeModule } +type SaveKubeConfigModule struct { + common.KubeModule + + OutputKubeconfig string +} + func (p *PrepareK8sBinariesModule) Init() { p.Name = "PrepareK8sBinariesModule" p.Desc = "Download installation binaries for kubernetes" @@ -93,16 +105,19 @@ func (c *ConfigureOSModule) Init() { Hosts: c.Runtime.GetAllHosts(), Action: new(os.NodeExecScript), Parallel: true, - }, - &task.RemoteTask{ - Name: "ConfigureNtpServer", - Desc: "configure the ntp server for each node", - Hosts: c.Runtime.GetAllHosts(), - Prepare: new(os.NodeConfigureNtpCheck), - Action: new(os.NodeConfigureNtpServer), - Parallel: true, - }, - } + }} +} + +func (p *SaveKubeConfigModule) Init() { + p.Name = "SaveKubeConfigModule" + p.Desc = "Save kube config to local file" + + p.Tasks = []task.Interface{ + &task.LocalTask{ + Name: "SaveKubeConfig", + Desc: "Save kube config to local file", + Action: &SaveKubeConfig{outputKubeconfig: p.OutputKubeconfig}, + }} } type DownloadKubernetesBinary struct { @@ -125,3 +140,46 @@ func (d *DownloadKubernetesBinary) Execute(runtime connector.Runtime) error { } return nil } + +type SaveKubeConfig struct { + common.KubeAction + + outputKubeconfig string +} + +func (c *SaveKubeConfig) Execute(runtime connector.Runtime) error { + master := runtime.GetHostsByRole(common.Master)[0] + + status, ok := c.PipelineCache.Get(common.ClusterStatus) + if !ok { + return cfgcore.MakeError("failed to get kubernetes status.") + } + cluster := status.(*kubernetes.KubernetesStatus) + kubeConfigStr := cluster.KubeConfig + kc, err := clientcmd.Load([]byte(kubeConfigStr)) + if err != nil { + return err + } + updateClusterAPIServer(kc, master, c.KubeConf.Cluster.ControlPlaneEndpoint) + kcFile := GetDefaultConfig() + existingKC, err := kubeconfigLoad(kcFile) + if err != nil { + return err + } + if c.outputKubeconfig == "" { + c.outputKubeconfig = kcFile + } + if existingKC != nil { + return kubeconfigMerge(kc, existingKC, c.outputKubeconfig) + } + return kubeconfigWrite(kc, c.outputKubeconfig) +} + +func updateClusterAPIServer(kc *clientcmdapi.Config, master connector.Host, endpoint kubekeyapiv1alpha2.ControlPlaneEndpoint) { + cpePrefix := fmt.Sprintf("https://%s:", endpoint.Domain) + for _, cluster := range kc.Clusters { + if strings.HasPrefix(cluster.Server, cpePrefix) { + cluster.Server = fmt.Sprintf("https://%s:%d", master.GetAddress(), endpoint.Port) + } + } +} diff --git a/internal/cli/cmd/infrastructure/tasks/kubernetes_test.go b/internal/cli/cmd/infrastructure/tasks/kubernetes_test.go new file mode 100644 index 00000000000..c26042f49b6 --- /dev/null +++ b/internal/cli/cmd/infrastructure/tasks/kubernetes_test.go @@ -0,0 +1,20 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package tasks From 0530a38aad088070add6b33584bf056ff55e6f85 Mon Sep 17 00:00:00 2001 From: sophon Date: Sun, 25 Jun 2023 20:14:04 +0800 Subject: [PATCH 21/44] chore: delete commented code --- internal/cli/cmd/infrastructure/pipeline.go | 51 +++++++++++---------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/internal/cli/cmd/infrastructure/pipeline.go b/internal/cli/cmd/infrastructure/pipeline.go index 184e3d6cc2e..8415394a088 100644 --- a/internal/cli/cmd/infrastructure/pipeline.go +++ b/internal/cli/cmd/infrastructure/pipeline.go @@ -20,41 +20,46 @@ along with this program. If not, see . package infrastructure import ( - "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/precheck" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/certs" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/container" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/module" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/etcd" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/filesystem" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/kubernetes" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/dns" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/network" + + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" ) func NewCreatePipeline(o *createOptions) []module.Module { return []module.Module{ - //&precheck.GreetingsModule{}, - //&tasks.CheckNodeArchitectureModule{}, - //&precheck.NodePreCheckModule{}, - //&tasks.InstallDependenciesModule{}, - //&tasks.PrepareK8sBinariesModule{BinaryVersion: o.version}, - //&tasks.ConfigureOSModule{}, - //&kubernetes.StatusModule{}, - //&tasks.InstallCRIModule{SandBoxImage: o.sandBoxImage}, - //&etcd.PreCheckModule{}, - //&etcd.CertsModule{}, - //&etcd.InstallETCDBinaryModule{}, - //&etcd.ConfigureModule{}, - //&etcd.BackupModule{}, - //&kubernetes.InstallKubeBinariesModule{}, - //&kubernetes.InitKubernetesModule{}, - //&dns.ClusterDNSModule{}, + &precheck.GreetingsModule{}, + &tasks.CheckNodeArchitectureModule{}, + &precheck.NodePreCheckModule{}, + &tasks.InstallDependenciesModule{}, + &tasks.PrepareK8sBinariesModule{BinaryVersion: o.version}, + &tasks.ConfigureOSModule{}, + &kubernetes.StatusModule{}, + &tasks.InstallCRIModule{SandBoxImage: o.sandBoxImage}, + &etcd.PreCheckModule{}, + &etcd.CertsModule{}, + &etcd.InstallETCDBinaryModule{}, + &etcd.ConfigureModule{}, + &etcd.BackupModule{}, + &kubernetes.InstallKubeBinariesModule{}, + &kubernetes.InitKubernetesModule{}, + &dns.ClusterDNSModule{}, &kubernetes.StatusModule{}, &tasks.SaveKubeConfigModule{OutputKubeconfig: o.outputKubeconfig}, - //&kubernetes.JoinNodesModule{}, - //&network.DeployNetworkPluginModule{}, - //&kubernetes.ConfigureKubernetesModule{}, - //&filesystem.ChownModule{}, - //&kubernetes.SecurityEnhancementModule{Skip: !o.securityEnhancement}, - //&tasks.AddonsInstaller{Addons: o.Addons}, + &kubernetes.JoinNodesModule{}, + &network.DeployNetworkPluginModule{}, + &kubernetes.ConfigureKubernetesModule{}, + &filesystem.ChownModule{}, + &kubernetes.SecurityEnhancementModule{Skip: !o.securityEnhancement}, + &tasks.AddonsInstaller{Addons: o.Addons}, } } From c363f64e88e066fa152951bf3571d12cd5a1d634 Mon Sep 17 00:00:00 2001 From: sophon-zt Date: Sun, 25 Jun 2023 12:19:02 +0000 Subject: [PATCH 22/44] chore: auto update cli doc changes --- docs/user_docs/cli/kbcli_infra_create.md | 1 + go.mod | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/user_docs/cli/kbcli_infra_create.md b/docs/user_docs/cli/kbcli_infra_create.md index df1c301542a..56d153b6506 100644 --- a/docs/user_docs/cli/kbcli_infra_create.md +++ b/docs/user_docs/cli/kbcli_infra_create.md @@ -26,6 +26,7 @@ kbcli infra create [flags] --master strings Specify master nodes --name string Specify kubernetes cluster name --nodes strings List of machines on which kubernetes is installed. [require] + --output-kubeconfig string Specified output kubeconfig. [option] (default "/home/runner/.kube/config") -p, --password string Specify the password for the account to execute sudo. [option] --private-key string The PrimaryKey for ssh to the remote machine. [option] --private-key-path string Specify the file PrimaryKeyPath of ssh to the remote machine. default ~/.ssh/id_rsa. diff --git a/go.mod b/go.mod index 3855dd4560d..e1d696d354e 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,6 @@ require ( github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 github.com/onsi/ginkgo/v2 v2.9.1 github.com/onsi/gomega v1.27.4 - github.com/opencontainers/image-spec v1.1.0-rc2 github.com/pkg/errors v0.9.1 github.com/pmezard/go-difflib v1.0.0 github.com/redis/go-redis/v9 v9.0.1 @@ -310,6 +309,7 @@ require ( github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.1.0-rc2 // indirect github.com/opencontainers/runc v1.1.5 // indirect github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect github.com/opencontainers/selinux v1.10.2 // indirect From e5e7d8b6e2b91b084463c3a75bd2dbdbdb57b453 Mon Sep 17 00:00:00 2001 From: sophon Date: Sun, 25 Jun 2023 21:01:19 +0800 Subject: [PATCH 23/44] chore: chore: refine code for addon --- .../{tasks/constant.go => constant/const.go} | 2 +- internal/cli/cmd/infrastructure/create.go | 17 +++--- internal/cli/cmd/infrastructure/pipeline.go | 51 ++++++++--------- .../cli/cmd/infrastructure/tasks/addon.go | 17 +++++- .../cli/cmd/infrastructure/tasks/dependent.go | 13 +++-- .../cli/cmd/infrastructure/tasks/download.go | 7 ++- .../cmd/infrastructure/tasks/kubernetes.go | 12 ++-- internal/cli/cmd/infrastructure/types/type.go | 21 ++++++- .../{tasks/utils.go => utils/checksum.go} | 36 +----------- .../infrastructure/utils/command_wrapper.go | 56 +++++++++++++++++++ .../cmd/infrastructure/utils/helm_wrapper.go | 38 +++++++++++++ .../cmd/infrastructure/utils/yaml_wrapper.go | 34 +++++++++++ 12 files changed, 216 insertions(+), 88 deletions(-) rename internal/cli/cmd/infrastructure/{tasks/constant.go => constant/const.go} (99%) rename internal/cli/cmd/infrastructure/{tasks/utils.go => utils/checksum.go} (72%) create mode 100644 internal/cli/cmd/infrastructure/utils/command_wrapper.go create mode 100644 internal/cli/cmd/infrastructure/utils/helm_wrapper.go create mode 100644 internal/cli/cmd/infrastructure/utils/yaml_wrapper.go diff --git a/internal/cli/cmd/infrastructure/tasks/constant.go b/internal/cli/cmd/infrastructure/constant/const.go similarity index 99% rename from internal/cli/cmd/infrastructure/tasks/constant.go rename to internal/cli/cmd/infrastructure/constant/const.go index c06f1d7e369..25c2c5ebba5 100644 --- a/internal/cli/cmd/infrastructure/tasks/constant.go +++ b/internal/cli/cmd/infrastructure/constant/const.go @@ -17,7 +17,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package tasks +package constant const ( ContainerdService = "containerd.service.tpl" diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index 141452bd3f6..4aec11abe84 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -29,6 +29,7 @@ import ( versionutil "k8s.io/apimachinery/pkg/util/version" "k8s.io/cli-runtime/pkg/genericclioptions" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/constant" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" "github.com/apecloud/kubeblocks/internal/cli/util" @@ -121,18 +122,18 @@ func NewCreateKubernetesCmd(streams genericclioptions.IOStreams) *cobra.Command func (o *createOptions) buildCreateInfraFlags(cmd *cobra.Command) { buildCommonFlags(cmd, &o.clusterOptions) cmd.Flags().StringVarP(&o.version.KubernetesVersion, "version", "", o.version.KubernetesVersion, fmt.Sprintf("Specify install kubernetes version. default version is %s", o.version.KubernetesVersion)) - cmd.Flags().StringVarP(&o.sandBoxImage, "sandbox-image", "", tasks.DefaultSandBoxImage, "Specified sandbox-image will not be used by the cri. [option]") + cmd.Flags().StringVarP(&o.sandBoxImage, "sandbox-image", "", constant.DefaultSandBoxImage, "Specified sandbox-image will not be used by the cri. [option]") cmd.Flags().StringVarP(&o.criType, "container-runtime", "", string(container.ContainerdType), "Specify kubernetes container runtime. default is containerd") cmd.Flags().BoolVarP(&o.debug, "debug", "", false, "set debug mode") cmd.Flags().StringVarP(&o.outputKubeconfig, "output-kubeconfig", "", tasks.GetDefaultConfig(), "Specified output kubeconfig. [option]") } func (o *createOptions) setDefaultVersion() { - o.version.KubernetesVersion = tasks.DefaultK8sVersion - o.version.EtcdVersion = tasks.DefaultEtcdVersion - o.version.ContainerVersion = tasks.DefaultContainerdVersion - o.version.HelmVersion = tasks.DefaultHelmVersion - o.version.CRICtlVersion = tasks.DefaultCRICtlVersion - o.version.CniVersion = tasks.DefaultCniVersion - o.version.RuncVersion = tasks.DefaultRuncVersion + o.version.KubernetesVersion = constant.DefaultK8sVersion + o.version.EtcdVersion = constant.DefaultEtcdVersion + o.version.ContainerVersion = constant.DefaultContainerdVersion + o.version.HelmVersion = constant.DefaultHelmVersion + o.version.CRICtlVersion = constant.DefaultCRICtlVersion + o.version.CniVersion = constant.DefaultCniVersion + o.version.RuncVersion = constant.DefaultRuncVersion } diff --git a/internal/cli/cmd/infrastructure/pipeline.go b/internal/cli/cmd/infrastructure/pipeline.go index 8415394a088..0912ea9af20 100644 --- a/internal/cli/cmd/infrastructure/pipeline.go +++ b/internal/cli/cmd/infrastructure/pipeline.go @@ -20,45 +20,40 @@ along with this program. If not, see . package infrastructure import ( + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/precheck" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/certs" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/container" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/module" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/etcd" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/filesystem" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/kubernetes" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/dns" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/network" - - "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" ) func NewCreatePipeline(o *createOptions) []module.Module { return []module.Module{ - &precheck.GreetingsModule{}, - &tasks.CheckNodeArchitectureModule{}, - &precheck.NodePreCheckModule{}, - &tasks.InstallDependenciesModule{}, - &tasks.PrepareK8sBinariesModule{BinaryVersion: o.version}, - &tasks.ConfigureOSModule{}, - &kubernetes.StatusModule{}, - &tasks.InstallCRIModule{SandBoxImage: o.sandBoxImage}, - &etcd.PreCheckModule{}, - &etcd.CertsModule{}, - &etcd.InstallETCDBinaryModule{}, - &etcd.ConfigureModule{}, - &etcd.BackupModule{}, - &kubernetes.InstallKubeBinariesModule{}, - &kubernetes.InitKubernetesModule{}, - &dns.ClusterDNSModule{}, + //&precheck.GreetingsModule{}, + //&tasks.CheckNodeArchitectureModule{}, + //&precheck.NodePreCheckModule{}, + //&tasks.InstallDependenciesModule{}, + //&tasks.PrepareK8sBinariesModule{BinaryVersion: o.version}, + //&tasks.ConfigureOSModule{}, + //&kubernetes.StatusModule{}, + //&tasks.InstallCRIModule{SandBoxImage: o.sandBoxImage}, + //&etcd.PreCheckModule{}, + //&etcd.CertsModule{}, + //&etcd.InstallETCDBinaryModule{}, + //&etcd.ConfigureModule{}, + //&etcd.BackupModule{}, + //&kubernetes.InstallKubeBinariesModule{}, + //&kubernetes.InitKubernetesModule{}, + //&dns.ClusterDNSModule{}, &kubernetes.StatusModule{}, - &tasks.SaveKubeConfigModule{OutputKubeconfig: o.outputKubeconfig}, - &kubernetes.JoinNodesModule{}, - &network.DeployNetworkPluginModule{}, - &kubernetes.ConfigureKubernetesModule{}, - &filesystem.ChownModule{}, - &kubernetes.SecurityEnhancementModule{Skip: !o.securityEnhancement}, + //&tasks.SaveKubeConfigModule{OutputKubeconfig: o.outputKubeconfig}, + //&kubernetes.JoinNodesModule{}, + //&network.DeployNetworkPluginModule{}, + //&kubernetes.ConfigureKubernetesModule{}, + //&filesystem.ChownModule{}, + //&kubernetes.SecurityEnhancementModule{Skip: !o.securityEnhancement}, &tasks.AddonsInstaller{Addons: o.Addons}, } } diff --git a/internal/cli/cmd/infrastructure/tasks/addon.go b/internal/cli/cmd/infrastructure/tasks/addon.go index b69f644c954..d2883d57a44 100644 --- a/internal/cli/cmd/infrastructure/tasks/addon.go +++ b/internal/cli/cmd/infrastructure/tasks/addon.go @@ -23,11 +23,13 @@ import ( "fmt" "path/filepath" + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/utils" ) type AddonsInstaller struct { @@ -53,10 +55,19 @@ func (a *AddonsInstaller) Init() { func (i *KBAddonsInstall) Execute(runtime connector.Runtime) error { kubeConfig := filepath.Join(runtime.GetWorkDir(), fmt.Sprintf("config-%s", runtime.GetObjName())) - _ = kubeConfig + var installer utils.Installer for _, addon := range i.Addons { - _ = addon - // TODO install helm install + switch { + case addon.Sources.Chart != nil: + installer = utils.NewHelmInstaller(*addon.Sources.Chart, kubeConfig) + case addon.Sources.Yaml != nil: + installer = utils.NewYamlInstaller(*addon.Sources.Yaml, kubeConfig) + default: + return cfgcore.MakeError("addon source not supported: addon: %v", addon) + } + if err := installer.Install(addon.Name, addon.Namespace); err != nil { + return err + } } return nil } diff --git a/internal/cli/cmd/infrastructure/tasks/dependent.go b/internal/cli/cmd/infrastructure/tasks/dependent.go index 3914546d12a..30204fa604d 100644 --- a/internal/cli/cmd/infrastructure/tasks/dependent.go +++ b/internal/cli/cmd/infrastructure/tasks/dependent.go @@ -33,6 +33,7 @@ import ( "github.com/mitchellh/mapstructure" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/constant" "github.com/apecloud/kubeblocks/internal/gotemplate" ) @@ -152,8 +153,8 @@ func (i *InstallCRIModule) Init() { &container.ContainerdExist{Not: true}, }, Action: &builder.Template{ - Template: ContainerdService, - Dst: ContainerdServiceInstallPath, + Template: constant.ContainerdService, + Dst: constant.ContainerdServiceInstallPath, }, Parallel: true, } @@ -167,8 +168,8 @@ func (i *InstallCRIModule) Init() { &container.ContainerdExist{Not: true}, }, Action: &builder.Template{ - Template: ContainerdConfig, - Dst: ContainerdConfigInstallPath, + Template: constant.ContainerdConfig, + Dst: constant.ContainerdConfigInstallPath, Values: gotemplate.TplValues{ "SandBoxImage": i.SandBoxImage, "DataRoot": templates.DataRoot(i.KubeConf), @@ -185,8 +186,8 @@ func (i *InstallCRIModule) Init() { &container.ContainerdExist{Not: true}, }, Action: &builder.Template{ - Template: CRICtlConfig, - Dst: CRICtlConfigInstallPath, + Template: constant.CRICtlConfig, + Dst: constant.CRICtlConfigInstallPath, Values: gotemplate.TplValues{ "Endpoint": i.KubeConf.Cluster.Kubernetes.ContainerRuntimeEndpoint, }}, diff --git a/internal/cli/cmd/infrastructure/tasks/download.go b/internal/cli/cmd/infrastructure/tasks/download.go index ad83f1b7744..913a88a217a 100644 --- a/internal/cli/cmd/infrastructure/tasks/download.go +++ b/internal/cli/cmd/infrastructure/tasks/download.go @@ -30,6 +30,7 @@ import ( "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/files" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" + kbutils "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/utils" cfgcore "github.com/apecloud/kubeblocks/internal/configuration" ) @@ -64,7 +65,7 @@ func downloadKubernetesBinaryWithArch(downloadPath string, arch string, binaryVe logger.Log.Messagef(common.LocalHost, "downloading %s %s %s ...", arch, binary.ID, binary.Version) binariesMap[binary.ID] = binary if util.IsExist(binary.Path()) { - if err := checkSha256sum(binary); err != nil { + if err := kbutils.CheckSha256sum(binary); err != nil { logger.Log.Messagef(common.LocalHost, "failed to check %s sha256, error: %v", binary.ID, err) _ = os.Remove(binary.Path()) } else { @@ -80,8 +81,8 @@ func downloadKubernetesBinaryWithArch(downloadPath string, arch string, binaryVe } func download(binary *files.KubeBinary) error { - if err := runCommand(exec.Command("/bin/sh", "-c", binary.GetCmd())); err != nil { + if err := kbutils.RunCommand(exec.Command("/bin/sh", "-c", binary.GetCmd())); err != nil { return err } - return writeSha256sum(binary) + return kbutils.WriteSha256sum(binary) } diff --git a/internal/cli/cmd/infrastructure/tasks/kubernetes.go b/internal/cli/cmd/infrastructure/tasks/kubernetes.go index 58aaca66b44..30a1bae87b8 100644 --- a/internal/cli/cmd/infrastructure/tasks/kubernetes.go +++ b/internal/cli/cmd/infrastructure/tasks/kubernetes.go @@ -25,10 +25,6 @@ import ( "strings" "github.com/StudioSol/set" - "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" - "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" - cfgcore "github.com/apecloud/kubeblocks/internal/configuration" - "github.com/apecloud/kubeblocks/internal/gotemplate" kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os/templates" @@ -38,6 +34,12 @@ import ( "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/kubernetes" "k8s.io/client-go/tools/clientcmd" clientcmdapi "k8s.io/client-go/tools/clientcmd/api" + + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/builder" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/constant" + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" + "github.com/apecloud/kubeblocks/internal/gotemplate" ) type PrepareK8sBinariesModule struct { @@ -92,7 +94,7 @@ func (c *ConfigureOSModule) Init() { Desc: "Generate init os script", Hosts: c.Runtime.GetAllHosts(), Action: &builder.Template{ - Template: ConfigureOSScripts, + Template: constant.ConfigureOSScripts, Dst: filepath.Join(common.KubeScriptDir, "initOS.sh"), Values: gotemplate.TplValues{ "Hosts": templates.GenerateHosts(c.Runtime, c.KubeConf), diff --git a/internal/cli/cmd/infrastructure/types/type.go b/internal/cli/cmd/infrastructure/types/type.go index 336ce34ec35..ddfbb3be5d4 100644 --- a/internal/cli/cmd/infrastructure/types/type.go +++ b/internal/cli/cmd/infrastructure/types/type.go @@ -30,7 +30,26 @@ type InfraVersionInfo struct { } type PluginMeta struct { - Name string `json:"name"` + Name string `json:"name,omitempty"` + Namespace string `json:"namespace,omitempty"` + Sources PluginSources `json:"sources,omitempty"` +} + +type PluginSources struct { + Chart *HelmChart `json:"chart,omitempty"` + Yaml *Yaml `json:"yaml,omitempty"` +} + +type HelmChart struct { + Name string `json:"name,omitempty"` + Version string `json:"version,omitempty"` + Repo string `json:"repo,omitempty"` + Path string `json:"path,omitempty"` + Values []string `json:"values,omitempty"` +} + +type Yaml struct { + Path []string `json:"path,omitempty"` } type Cluster struct { diff --git a/internal/cli/cmd/infrastructure/tasks/utils.go b/internal/cli/cmd/infrastructure/utils/checksum.go similarity index 72% rename from internal/cli/cmd/infrastructure/tasks/utils.go rename to internal/cli/cmd/infrastructure/utils/checksum.go index f144cd4d2db..3305293198e 100644 --- a/internal/cli/cmd/infrastructure/tasks/utils.go +++ b/internal/cli/cmd/infrastructure/utils/checksum.go @@ -17,56 +17,26 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package tasks +package utils import ( "crypto/sha256" - "errors" "fmt" "io" "os" - "os/exec" "strings" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/common" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/logger" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/util" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/files" cfgcore "github.com/apecloud/kubeblocks/internal/configuration" ) -func runCommand(cmd *exec.Cmd) error { - logger.Log.Messagef(common.LocalHost, "Running: %s", cmd.String()) - stdout, err := cmd.StdoutPipe() - if err != nil { - return err - } - cmd.Stderr = cmd.Stdout - if err = cmd.Start(); err != nil { - return err - } - - // read from stdout - for { - tmp := make([]byte, 1024) - _, err := stdout.Read(tmp) - fmt.Print(string(tmp)) - if errors.Is(err, io.EOF) { - break - } else if err != nil { - logger.Log.Errorln(err) - break - } - } - return cmd.Wait() -} - func getSha256sumFile(binary *files.KubeBinary) string { return fmt.Sprintf("%s.sum.%s", binary.Path(), "sha256") } -func checkSha256sum(binary *files.KubeBinary) error { +func CheckSha256sum(binary *files.KubeBinary) error { checksumFile := getSha256sumFile(binary) if !util.IsExist(checksumFile) { return cfgcore.MakeError("checksum file %s is not exist", checksumFile) @@ -101,7 +71,7 @@ func calSha256sum(path string) (string, error) { return fmt.Sprintf("%x", sha256.Sum256(data)), nil } -func writeSha256sum(binary *files.KubeBinary) error { +func WriteSha256sum(binary *files.KubeBinary) error { checksumFile := getSha256sumFile(binary) sum, err := calSha256sum(binary.Path()) if err != nil { diff --git a/internal/cli/cmd/infrastructure/utils/command_wrapper.go b/internal/cli/cmd/infrastructure/utils/command_wrapper.go new file mode 100644 index 00000000000..a732a47621c --- /dev/null +++ b/internal/cli/cmd/infrastructure/utils/command_wrapper.go @@ -0,0 +1,56 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package utils + +import ( + "errors" + "fmt" + "io" + "os/exec" + + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/common" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/logger" +) + +func RunCommand(cmd *exec.Cmd) error { + logger.Log.Messagef(common.LocalHost, "Running: %s", cmd.String()) + stdout, err := cmd.StdoutPipe() + if err != nil { + return err + } + cmd.Stderr = cmd.Stdout + if err = cmd.Start(); err != nil { + return err + } + + // read from stdout + for { + tmp := make([]byte, 1024) + _, err := stdout.Read(tmp) + fmt.Print(string(tmp)) + if errors.Is(err, io.EOF) { + break + } else if err != nil { + logger.Log.Errorln(err) + break + } + } + return cmd.Wait() +} diff --git a/internal/cli/cmd/infrastructure/utils/helm_wrapper.go b/internal/cli/cmd/infrastructure/utils/helm_wrapper.go new file mode 100644 index 00000000000..8fdee5679ed --- /dev/null +++ b/internal/cli/cmd/infrastructure/utils/helm_wrapper.go @@ -0,0 +1,38 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package utils + +import "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" + +type Installer interface { + Install(name, ns string) error +} + +type HelmInstallHelper struct { +} + +func (h *HelmInstallHelper) Install(name, ns string) error { + //TODO implement me + panic("implement me") +} + +func NewHelmInstaller(chart types.HelmChart, kubeconfig string) Installer { + return &HelmInstallHelper{} +} diff --git a/internal/cli/cmd/infrastructure/utils/yaml_wrapper.go b/internal/cli/cmd/infrastructure/utils/yaml_wrapper.go new file mode 100644 index 00000000000..860a9bbd767 --- /dev/null +++ b/internal/cli/cmd/infrastructure/utils/yaml_wrapper.go @@ -0,0 +1,34 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package utils + +import "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" + +type YamlInstallHelper struct { +} + +func (y *YamlInstallHelper) Install(name, ns string) error { + //TODO implement me + panic("implement me") +} + +func NewYamlInstaller(yaml types.Yaml, kubeconfig string) Installer { + return &YamlInstallHelper{} +} From f5ed41171580622938f52eab434223b1bf21b57c Mon Sep 17 00:00:00 2001 From: sophon Date: Sun, 25 Jun 2023 21:02:12 +0800 Subject: [PATCH 24/44] chore: chore: refine code for addon --- internal/cli/cmd/infrastructure/pipeline.go | 51 +++++++++++---------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/internal/cli/cmd/infrastructure/pipeline.go b/internal/cli/cmd/infrastructure/pipeline.go index 0912ea9af20..8415394a088 100644 --- a/internal/cli/cmd/infrastructure/pipeline.go +++ b/internal/cli/cmd/infrastructure/pipeline.go @@ -20,40 +20,45 @@ along with this program. If not, see . package infrastructure import ( - "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/os" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/precheck" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/certs" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/container" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/module" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/etcd" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/filesystem" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/kubernetes" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/dns" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/plugins/network" + + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" ) func NewCreatePipeline(o *createOptions) []module.Module { return []module.Module{ - //&precheck.GreetingsModule{}, - //&tasks.CheckNodeArchitectureModule{}, - //&precheck.NodePreCheckModule{}, - //&tasks.InstallDependenciesModule{}, - //&tasks.PrepareK8sBinariesModule{BinaryVersion: o.version}, - //&tasks.ConfigureOSModule{}, - //&kubernetes.StatusModule{}, - //&tasks.InstallCRIModule{SandBoxImage: o.sandBoxImage}, - //&etcd.PreCheckModule{}, - //&etcd.CertsModule{}, - //&etcd.InstallETCDBinaryModule{}, - //&etcd.ConfigureModule{}, - //&etcd.BackupModule{}, - //&kubernetes.InstallKubeBinariesModule{}, - //&kubernetes.InitKubernetesModule{}, - //&dns.ClusterDNSModule{}, + &precheck.GreetingsModule{}, + &tasks.CheckNodeArchitectureModule{}, + &precheck.NodePreCheckModule{}, + &tasks.InstallDependenciesModule{}, + &tasks.PrepareK8sBinariesModule{BinaryVersion: o.version}, + &tasks.ConfigureOSModule{}, + &kubernetes.StatusModule{}, + &tasks.InstallCRIModule{SandBoxImage: o.sandBoxImage}, + &etcd.PreCheckModule{}, + &etcd.CertsModule{}, + &etcd.InstallETCDBinaryModule{}, + &etcd.ConfigureModule{}, + &etcd.BackupModule{}, + &kubernetes.InstallKubeBinariesModule{}, + &kubernetes.InitKubernetesModule{}, + &dns.ClusterDNSModule{}, &kubernetes.StatusModule{}, - //&tasks.SaveKubeConfigModule{OutputKubeconfig: o.outputKubeconfig}, - //&kubernetes.JoinNodesModule{}, - //&network.DeployNetworkPluginModule{}, - //&kubernetes.ConfigureKubernetesModule{}, - //&filesystem.ChownModule{}, - //&kubernetes.SecurityEnhancementModule{Skip: !o.securityEnhancement}, + &tasks.SaveKubeConfigModule{OutputKubeconfig: o.outputKubeconfig}, + &kubernetes.JoinNodesModule{}, + &network.DeployNetworkPluginModule{}, + &kubernetes.ConfigureKubernetesModule{}, + &filesystem.ChownModule{}, + &kubernetes.SecurityEnhancementModule{Skip: !o.securityEnhancement}, &tasks.AddonsInstaller{Addons: o.Addons}, } } From f02a205585029cb0f17541430649e6fd26b27ade Mon Sep 17 00:00:00 2001 From: sophon Date: Sun, 25 Jun 2023 21:06:44 +0800 Subject: [PATCH 25/44] chore: Minor adjust --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e1d696d354e..3855dd4560d 100644 --- a/go.mod +++ b/go.mod @@ -53,6 +53,7 @@ require ( github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 github.com/onsi/ginkgo/v2 v2.9.1 github.com/onsi/gomega v1.27.4 + github.com/opencontainers/image-spec v1.1.0-rc2 github.com/pkg/errors v0.9.1 github.com/pmezard/go-difflib v1.0.0 github.com/redis/go-redis/v9 v9.0.1 @@ -309,7 +310,6 @@ require ( github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.0-rc2 // indirect github.com/opencontainers/runc v1.1.5 // indirect github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect github.com/opencontainers/selinux v1.10.2 // indirect From 6daaf566f027d10b0e825ebb5187c4acd568b1d5 Mon Sep 17 00:00:00 2001 From: sophon-zt Date: Sun, 25 Jun 2023 13:12:31 +0000 Subject: [PATCH 26/44] chore: auto update cli doc changes --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3855dd4560d..e1d696d354e 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,6 @@ require ( github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 github.com/onsi/ginkgo/v2 v2.9.1 github.com/onsi/gomega v1.27.4 - github.com/opencontainers/image-spec v1.1.0-rc2 github.com/pkg/errors v0.9.1 github.com/pmezard/go-difflib v1.0.0 github.com/redis/go-redis/v9 v9.0.1 @@ -310,6 +309,7 @@ require ( github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.1.0-rc2 // indirect github.com/opencontainers/runc v1.1.5 // indirect github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect github.com/opencontainers/selinux v1.10.2 // indirect From ba0487bd76594bf0968d7510cab0bf1b4cafbed1 Mon Sep 17 00:00:00 2001 From: sophon Date: Mon, 26 Jun 2023 10:36:10 +0800 Subject: [PATCH 27/44] chore: refine download code --- .../cli/cmd/infrastructure/tasks/download.go | 25 +++++--- internal/cli/cmd/infrastructure/types/type.go | 12 ++-- .../cmd/infrastructure/utils/helm_wrapper.go | 59 ++++++++++++++++--- .../cli/cmd/infrastructure/utils/install.go | 24 ++++++++ .../cmd/infrastructure/utils/yaml_wrapper.go | 2 +- 5 files changed, 100 insertions(+), 22 deletions(-) create mode 100644 internal/cli/cmd/infrastructure/utils/install.go diff --git a/internal/cli/cmd/infrastructure/tasks/download.go b/internal/cli/cmd/infrastructure/tasks/download.go index 913a88a217a..d1591fb7898 100644 --- a/internal/cli/cmd/infrastructure/tasks/download.go +++ b/internal/cli/cmd/infrastructure/tasks/download.go @@ -61,17 +61,10 @@ func downloadKubernetesBinaryWithArch(downloadPath string, arch string, binaryVe if err := binary.CreateBaseDir(); err != nil { return nil, cfgcore.WrapError(err, "failed to create file %s base dir.", binary.FileName) } - logger.Log.Messagef(common.LocalHost, "downloading %s %s %s ...", arch, binary.ID, binary.Version) binariesMap[binary.ID] = binary - if util.IsExist(binary.Path()) { - if err := kbutils.CheckSha256sum(binary); err != nil { - logger.Log.Messagef(common.LocalHost, "failed to check %s sha256, error: %v", binary.ID, err) - _ = os.Remove(binary.Path()) - } else { - logger.Log.Messagef(common.LocalHost, "%s is existed", binary.ID) - continue - } + if checkDownloadBinary(binary) { + continue } if err := download(binary); err != nil { return nil, cfgcore.WrapError(err, "failed to download %s binary: %s", binary.ID, binary.GetCmd()) @@ -80,6 +73,20 @@ func downloadKubernetesBinaryWithArch(downloadPath string, arch string, binaryVe return binariesMap, nil } +func checkDownloadBinary(binary *files.KubeBinary) bool { + if !util.IsExist(binary.Path()) { + return false + } + err := kbutils.CheckSha256sum(binary) + if err != nil { + logger.Log.Messagef(common.LocalHost, "failed to check %s sha256, error: %v", binary.ID, err) + _ = os.Remove(binary.Path()) + return false + } + logger.Log.Messagef(common.LocalHost, "%s is existed", binary.ID) + return true +} + func download(binary *files.KubeBinary) error { if err := kbutils.RunCommand(exec.Command("/bin/sh", "-c", binary.GetCmd())); err != nil { return err diff --git a/internal/cli/cmd/infrastructure/types/type.go b/internal/cli/cmd/infrastructure/types/type.go index ddfbb3be5d4..5727f7bf926 100644 --- a/internal/cli/cmd/infrastructure/types/type.go +++ b/internal/cli/cmd/infrastructure/types/type.go @@ -19,6 +19,8 @@ along with this program. If not, see . package types +import "helm.sh/helm/v3/pkg/cli/values" + type InfraVersionInfo struct { KubernetesVersion string EtcdVersion string @@ -41,11 +43,11 @@ type PluginSources struct { } type HelmChart struct { - Name string `json:"name,omitempty"` - Version string `json:"version,omitempty"` - Repo string `json:"repo,omitempty"` - Path string `json:"path,omitempty"` - Values []string `json:"values,omitempty"` + Name string `json:"name,omitempty"` + Version string `json:"version,omitempty"` + Repo string `json:"repo,omitempty"` + Path string `json:"path,omitempty"` + ValueOptions values.Options `json:"options,omitempty"` } type Yaml struct { diff --git a/internal/cli/cmd/infrastructure/utils/helm_wrapper.go b/internal/cli/cmd/infrastructure/utils/helm_wrapper.go index 8fdee5679ed..9c4145f5765 100644 --- a/internal/cli/cmd/infrastructure/utils/helm_wrapper.go +++ b/internal/cli/cmd/infrastructure/utils/helm_wrapper.go @@ -19,20 +19,65 @@ along with this program. If not, see . package utils -import "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" +import ( + "path/filepath" -type Installer interface { - Install(name, ns string) error -} + "helm.sh/helm/v3/pkg/repo" + "k8s.io/klog/v2" + + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/types" + "github.com/apecloud/kubeblocks/internal/cli/util/helm" +) type HelmInstallHelper struct { + types.HelmChart + kubeconfig string } func (h *HelmInstallHelper) Install(name, ns string) error { - //TODO implement me - panic("implement me") + if err := h.addRepo(); err != nil { + return err + } + helmConfig := helm.NewConfig(ns, h.kubeconfig, "", klog.V(1).Enabled()) + return h.buildChart(name, ns).Upgrade(helmConfig) } func NewHelmInstaller(chart types.HelmChart, kubeconfig string) Installer { - return &HelmInstallHelper{} + installer := HelmInstallHelper{ + HelmChart: chart, + kubeconfig: kubeconfig} + return &installer +} + +func (h *HelmInstallHelper) buildChart(name, ns string) *helm.InstallOpts { + return &helm.InstallOpts{ + Name: name, + Chart: h.getChart(), + Wait: true, + Version: h.Version, + Namespace: ns, + ValueOpts: &h.ValueOptions, + TryTimes: 3, + CreateNamespace: true, + Atomic: true, + } +} + +func (h *HelmInstallHelper) getChart() string { + if h.Name == "" { + return "" + } + // install helm package form local path + if h.Repo == "" && h.Path != "" { + return filepath.Join(h.Path, h.Name) + } else { + return h.Name + } +} + +func (h *HelmInstallHelper) addRepo() error { + if h.Repo == "" { + return nil + } + return helm.AddRepo(&repo.Entry{Name: h.Name, URL: h.Repo}) } diff --git a/internal/cli/cmd/infrastructure/utils/install.go b/internal/cli/cmd/infrastructure/utils/install.go new file mode 100644 index 00000000000..6da5dce9719 --- /dev/null +++ b/internal/cli/cmd/infrastructure/utils/install.go @@ -0,0 +1,24 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package utils + +type Installer interface { + Install(name, ns string) error +} diff --git a/internal/cli/cmd/infrastructure/utils/yaml_wrapper.go b/internal/cli/cmd/infrastructure/utils/yaml_wrapper.go index 860a9bbd767..aaf400c4d75 100644 --- a/internal/cli/cmd/infrastructure/utils/yaml_wrapper.go +++ b/internal/cli/cmd/infrastructure/utils/yaml_wrapper.go @@ -25,7 +25,7 @@ type YamlInstallHelper struct { } func (y *YamlInstallHelper) Install(name, ns string) error { - //TODO implement me + // TODO implement me panic("implement me") } From 566b8cf388e44d3605dcaef1ec3c986d92861dfe Mon Sep 17 00:00:00 2001 From: sophon Date: Mon, 26 Jun 2023 11:53:14 +0800 Subject: [PATCH 28/44] chore: add helm repo installer --- internal/cli/cmd/infrastructure/pipeline.go | 2 +- internal/cli/cmd/infrastructure/tasks/addon.go | 18 +++++++++--------- .../cmd/infrastructure/utils/helm_wrapper.go | 14 ++++++++------ 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/internal/cli/cmd/infrastructure/pipeline.go b/internal/cli/cmd/infrastructure/pipeline.go index 8415394a088..d9fb70eb332 100644 --- a/internal/cli/cmd/infrastructure/pipeline.go +++ b/internal/cli/cmd/infrastructure/pipeline.go @@ -59,7 +59,7 @@ func NewCreatePipeline(o *createOptions) []module.Module { &kubernetes.ConfigureKubernetesModule{}, &filesystem.ChownModule{}, &kubernetes.SecurityEnhancementModule{Skip: !o.securityEnhancement}, - &tasks.AddonsInstaller{Addons: o.Addons}, + &tasks.AddonsInstaller{Addons: o.Addons, Kubeconfig: o.outputKubeconfig}, } } diff --git a/internal/cli/cmd/infrastructure/tasks/addon.go b/internal/cli/cmd/infrastructure/tasks/addon.go index d2883d57a44..6b7c1bcbbb0 100644 --- a/internal/cli/cmd/infrastructure/tasks/addon.go +++ b/internal/cli/cmd/infrastructure/tasks/addon.go @@ -20,9 +20,6 @@ along with this program. If not, see . package tasks import ( - "fmt" - "path/filepath" - cfgcore "github.com/apecloud/kubeblocks/internal/configuration" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" @@ -34,12 +31,16 @@ import ( type AddonsInstaller struct { common.KubeModule - Addons []types.PluginMeta + + Addons []types.PluginMeta + Kubeconfig string } type KBAddonsInstall struct { common.KubeAction - Addons []types.PluginMeta + + Addons []types.PluginMeta + Kubeconfig string } func (a *AddonsInstaller) Init() { @@ -49,19 +50,18 @@ func (a *AddonsInstaller) Init() { &task.LocalTask{ Name: "AddonsInstaller", Desc: "Install helm addons", - Action: &KBAddonsInstall{Addons: a.Addons}, + Action: &KBAddonsInstall{Addons: a.Addons, Kubeconfig: a.Kubeconfig}, }} } func (i *KBAddonsInstall) Execute(runtime connector.Runtime) error { - kubeConfig := filepath.Join(runtime.GetWorkDir(), fmt.Sprintf("config-%s", runtime.GetObjName())) var installer utils.Installer for _, addon := range i.Addons { switch { case addon.Sources.Chart != nil: - installer = utils.NewHelmInstaller(*addon.Sources.Chart, kubeConfig) + installer = utils.NewHelmInstaller(*addon.Sources.Chart, i.Kubeconfig) case addon.Sources.Yaml != nil: - installer = utils.NewYamlInstaller(*addon.Sources.Yaml, kubeConfig) + installer = utils.NewYamlInstaller(*addon.Sources.Yaml, i.Kubeconfig) default: return cfgcore.MakeError("addon source not supported: addon: %v", addon) } diff --git a/internal/cli/cmd/infrastructure/utils/helm_wrapper.go b/internal/cli/cmd/infrastructure/utils/helm_wrapper.go index 9c4145f5765..214057b8d95 100644 --- a/internal/cli/cmd/infrastructure/utils/helm_wrapper.go +++ b/internal/cli/cmd/infrastructure/utils/helm_wrapper.go @@ -52,7 +52,7 @@ func NewHelmInstaller(chart types.HelmChart, kubeconfig string) Installer { func (h *HelmInstallHelper) buildChart(name, ns string) *helm.InstallOpts { return &helm.InstallOpts{ Name: name, - Chart: h.getChart(), + Chart: h.getChart(name), Wait: true, Version: h.Version, Namespace: ns, @@ -63,16 +63,18 @@ func (h *HelmInstallHelper) buildChart(name, ns string) *helm.InstallOpts { } } -func (h *HelmInstallHelper) getChart() string { +func (h *HelmInstallHelper) getChart(name string) string { if h.Name == "" { return "" } // install helm package form local path - if h.Repo == "" && h.Path != "" { - return filepath.Join(h.Path, h.Name) - } else { - return h.Name + if h.Repo != "" { + return filepath.Join(h.Name, name) } + if h.Path != "" { + return filepath.Join(h.Path, name) + } + return "" } func (h *HelmInstallHelper) addRepo() error { From b0f599e47aec5e90af2788ef818f819363a3ed35 Mon Sep 17 00:00:00 2001 From: sophon Date: Mon, 26 Jun 2023 16:53:31 +0800 Subject: [PATCH 29/44] chore: adjust code for creating Cluster --- .../builder/template/kubekey_cluster.tpl | 25 ++-- .../cli/cmd/infrastructure/constant/const.go | 11 ++ internal/cli/cmd/infrastructure/create.go | 1 + internal/cli/cmd/infrastructure/delete.go | 2 + .../cli/cmd/infrastructure/loader_adapter.go | 2 + .../cmd/infrastructure/loader_adapter_test.go | 1 + internal/cli/cmd/infrastructure/pipeline.go | 2 +- internal/cli/cmd/infrastructure/types/type.go | 131 ++++++++++++++++-- 8 files changed, 150 insertions(+), 25 deletions(-) diff --git a/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl b/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl index ad8e2318698..c1cb3ab5a0f 100644 --- a/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl +++ b/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl @@ -23,7 +23,7 @@ spec: {{- end }} {{- end }} controlPlaneEndpoint: - domain: lb.apiservice.local + domain: {{ $.Kubernetes.ControlPlaneEndpoint.Domain }} {{- $address := ""}} {{- if hasKey $.RoleGroups "master" }} {{- $mName := index (get $.RoleGroups "master") 0 }} @@ -37,22 +37,17 @@ spec: {{- failed "require control address." }} {{- end }} address: {{ $address }} - port: 6443 + port: {{ $.Kubernetes.ControlPlaneEndpoint.Port }} kubernetes: nodelocaldns: false - dnsDomain: cluster.local + dnsDomain: {{ $.Kubernetes.Networking.DNSDomain }} version: {{ $.Version }} - clusterName: {{ $.Name }} + clusterName: {{ $.Kubernetes.ClusterName }} {{- $criType := "containerd" }} nodeCidrMaskSize: 24 - proxyMode: ipvs - {{- if eq $criType "containerd" }} - containerRuntimeEndpoint: "unix:///run/containerd/containerd.sock" - {{- end }} - {{- if hasKey . "CRIType" }} - {{ $criType = $.CRIType }} - {{- end }} - containerManager: {{ $criType }} + proxyMode: {{ $.Kubernetes.ProxyMode }} + containerRuntimeEndpoint: {{ $.Kubernetes.CRI.ContainerRuntimeEndpoint }} + containerManager: {{ $.Kubernetes.CRI.ContainerRuntimeType }} etcd: backupDir: /var/backups/kube_etcd backupPeriod: 1800 @@ -64,6 +59,6 @@ spec: type: kubeadm {{- end }} network: - plugin: cilium - kubePodsCIDR: 10.233.64.0/18 - kubeServiceCIDR: 10.233.0.0/18 \ No newline at end of file + plugin: {{ $.Kubernetes.Networking.Plugin }} + kubePodsCIDR: {{ $.Kubernetes.Networking.PodSubnet }} + kubeServiceCIDR: {{ $.Kubernetes.Networking.ServiceSubnet }} \ No newline at end of file diff --git a/internal/cli/cmd/infrastructure/constant/const.go b/internal/cli/cmd/infrastructure/constant/const.go index 25c2c5ebba5..cf9046f5d6a 100644 --- a/internal/cli/cmd/infrastructure/constant/const.go +++ b/internal/cli/cmd/infrastructure/constant/const.go @@ -39,3 +39,14 @@ const ( DefaultCniVersion = "v1.3.0" // https://github.com/containernetworking/plugins/releases DefaultContainerdVersion = "1.7.2" // https://github.com/containerd/containerd/releases ) + +const ( + DefaultK8sClusterName = "cluster.local" + DefaultK8sDNSDomain = "cluster.local" + DefaultAPIDNSDomain = "lb.kubeblocks.local" + DefaultK8sProxyMode = "ipvs" + DefaultAPIServerPort = 6443 + + DefaultClusterCIDR = "10.233.64.0/18" + DefaultNetworkPlugin = "calico" +) diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index 4aec11abe84..b8ceb1c312f 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -67,6 +67,7 @@ func (o *createOptions) Run() error { return cfgcore.MakeError("kubernetes version must be greater than %s", minKubernetesVersion) } + o.Cluster.Kubernetes.AutoDefaultFill() cluster, err := createClusterWithOptions(buildTemplateParams(o)) if err != nil { return err diff --git a/internal/cli/cmd/infrastructure/delete.go b/internal/cli/cmd/infrastructure/delete.go index 03b3066d766..b7f614b054b 100644 --- a/internal/cli/cmd/infrastructure/delete.go +++ b/internal/cli/cmd/infrastructure/delete.go @@ -40,12 +40,14 @@ type deleteOptions struct { } func (o *deleteOptions) Run() error { + o.Cluster.Kubernetes.AutoDefaultFill() cluster, err := createClusterWithOptions(&gotemplate.TplValues{ builtinClusterNameObject: o.clusterName, builtinClusterVersionObject: "0.0.0", builtinUserObject: o.User, builtinHostsObject: o.Nodes, builtinTimeoutObject: o.timeout, + builtinKubernetesObject: o.Cluster.Kubernetes, builtinRoleGroupsObject: gotemplate.TplValues{ common.ETCD: o.RoleGroup.ETCD, common.Master: o.RoleGroup.Master, diff --git a/internal/cli/cmd/infrastructure/loader_adapter.go b/internal/cli/cmd/infrastructure/loader_adapter.go index aebd3da7002..fe2149106b0 100644 --- a/internal/cli/cmd/infrastructure/loader_adapter.go +++ b/internal/cli/cmd/infrastructure/loader_adapter.go @@ -51,6 +51,7 @@ const ( builtinUserObject = "User" builtinHostsObject = "Hosts" builtinRoleGroupsObject = "RoleGroups" + builtinKubernetesObject = "Kubernetes" ) func buildTemplateParams(o *createOptions) *gotemplate.TplValues { @@ -61,6 +62,7 @@ func buildTemplateParams(o *createOptions) *gotemplate.TplValues { builtinUserObject: o.User, builtinHostsObject: o.Nodes, builtinTimeoutObject: o.timeout, + builtinKubernetesObject: o.Cluster.Kubernetes, builtinRoleGroupsObject: gotemplate.TplValues{ common.ETCD: o.RoleGroup.ETCD, common.Master: o.RoleGroup.Master, diff --git a/internal/cli/cmd/infrastructure/loader_adapter_test.go b/internal/cli/cmd/infrastructure/loader_adapter_test.go index 91847e3f83c..144d1265950 100644 --- a/internal/cli/cmd/infrastructure/loader_adapter_test.go +++ b/internal/cli/cmd/infrastructure/loader_adapter_test.go @@ -68,6 +68,7 @@ func TestCreateClusterWithOptions(t *testing.T) { }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + tt.args.Cluster.Kubernetes.AutoDefaultFill() got, err := createClusterWithOptions(buildTemplateParams(tt.args)) if (err != nil) != tt.wantErr { t.Errorf("createClusterWithOptions() error = %v, wantErr %v", err, tt.wantErr) diff --git a/internal/cli/cmd/infrastructure/pipeline.go b/internal/cli/cmd/infrastructure/pipeline.go index d9fb70eb332..cf226424868 100644 --- a/internal/cli/cmd/infrastructure/pipeline.go +++ b/internal/cli/cmd/infrastructure/pipeline.go @@ -43,7 +43,7 @@ func NewCreatePipeline(o *createOptions) []module.Module { &tasks.PrepareK8sBinariesModule{BinaryVersion: o.version}, &tasks.ConfigureOSModule{}, &kubernetes.StatusModule{}, - &tasks.InstallCRIModule{SandBoxImage: o.sandBoxImage}, + &tasks.InstallCRIModule{SandBoxImage: o.Cluster.Kubernetes.CRI.SandBoxImage}, &etcd.PreCheckModule{}, &etcd.CertsModule{}, &etcd.InstallETCDBinaryModule{}, diff --git a/internal/cli/cmd/infrastructure/types/type.go b/internal/cli/cmd/infrastructure/types/type.go index 5727f7bf926..809211c4051 100644 --- a/internal/cli/cmd/infrastructure/types/type.go +++ b/internal/cli/cmd/infrastructure/types/type.go @@ -19,7 +19,11 @@ along with this program. If not, see . package types -import "helm.sh/helm/v3/pkg/cli/values" +import ( + "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/constant" + kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" + "helm.sh/helm/v3/pkg/cli/values" +) type InfraVersionInfo struct { KubernetesVersion string @@ -38,16 +42,16 @@ type PluginMeta struct { } type PluginSources struct { - Chart *HelmChart `json:"chart,omitempty"` - Yaml *Yaml `json:"yaml,omitempty"` + Chart *HelmChart `json:"chart"` + Yaml *Yaml `json:"yaml"` } type HelmChart struct { - Name string `json:"name,omitempty"` - Version string `json:"version,omitempty"` - Repo string `json:"repo,omitempty"` - Path string `json:"path,omitempty"` - ValueOptions values.Options `json:"options,omitempty"` + Name string `json:"name"` + Version string `json:"version"` + Repo string `json:"repo"` + Path string `json:"path"` + ValueOptions values.Options `json:"options"` } type Yaml struct { @@ -60,6 +64,9 @@ type Cluster struct { RoleGroup RoleGroup `json:"roleGroup"` Addons []PluginMeta `json:"addons"` + + // for kubeadm configuration + Kubernetes Kubernetes `json:"kubernetes"` } type RoleGroup struct { @@ -74,6 +81,54 @@ type ClusterNode struct { InternalAddress string `json:"internalAddress"` } +type Kubernetes struct { + ClusterName string `json:"clusterName"` + DNSDomain string `json:"dnsDomain"` + ProxyMode string `json:"proxyMode"` + + Networking Networking `json:"networking"` + CRI ContainerRuntime `json:"cri"` + + ControlPlaneEndpoint ControlPlaneEndpoint `json:"controlPlaneEndpoint"` + APIServer APIServer `json:"apiServer"` + Scheduler Scheduler `json:"scheduler"` +} + +type Networking struct { + // using network plugin, default is calico + Plugin string `json:"omitempty"` + ServiceSubnet string `json:"serviceSubnet"` + PodSubnet string `json:"podSubnet"` + DNSDomain string `json:"dnsDomain"` +} + +type ContainerRuntime struct { + ContainerRuntimeType string `json:"containerRuntimeType"` + ContainerRuntimeEndpoint string `json:"containerRuntimeEndpoint"` + SandBoxImage string `json:"sandBoxImage"` +} + +type ControlPlaneComponent struct { + // apiserver extra args + ExtraArgs map[string]string `json:"extraArgs"` +} + +type APIServer struct { + ControlPlaneComponent `json:",inline"` +} + +type Scheduler struct { + ControlPlaneComponent `json:",inline"` +} + +type ControlPlaneEndpoint struct { + Domain string `json:"domain"` + Port int `json:"port"` + + // TODO support apiserver loadbalancer + LoadBalancer string `json:"loadBalancer"` +} + type ClusterUser struct { // user name Name string `json:"name"` @@ -84,6 +139,64 @@ type ClusterUser struct { PrivateKeyPath string `json:"privateKeyPath"` } -func (g RoleGroup) IsValidate() bool { +func (g *RoleGroup) IsValidate() bool { return len(g.ETCD) > 0 && len(g.Master) > 0 && len(g.Worker) > 0 } + +func (k *Kubernetes) AutoDefaultFill() { + if k.ClusterName == "" { + k.ClusterName = constant.DefaultK8sClusterName + } + if k.DNSDomain == "" { + k.DNSDomain = constant.DefaultK8sDNSDomain + } + if k.ProxyMode == "" { + k.ProxyMode = constant.DefaultK8sProxyMode + } + + fillNetworkField(&k.Networking) + fillContainerRuntimeField(&k.CRI) + fillAPIServerField(&k.APIServer) + fillSchedulerField(&k.Scheduler) + fillControlPlaneField(&k.ControlPlaneEndpoint) +} + +func fillContainerRuntimeField(c *ContainerRuntime) { + if c.ContainerRuntimeType == "" { + c.ContainerRuntimeType = kubekeyapiv1alpha2.Conatinerd + c.ContainerRuntimeEndpoint = kubekeyapiv1alpha2.DefaultContainerdEndpoint + } + if c.SandBoxImage == "" { + c.SandBoxImage = constant.DefaultSandBoxImage + } +} + +func fillControlPlaneField(c *ControlPlaneEndpoint) { + if c.Port == 0 { + c.Port = constant.DefaultAPIServerPort + } + if c.Domain == "" { + c.Domain = constant.DefaultAPIDNSDomain + } +} + +func fillSchedulerField(s *Scheduler) { +} + +func fillAPIServerField(a *APIServer) { +} + +func fillNetworkField(n *Networking) { + if n.Plugin == "" { + n.Plugin = constant.DefaultNetworkPlugin + } + if n.DNSDomain == "" { + n.DNSDomain = constant.DefaultK8sDNSDomain + } + if n.ServiceSubnet == "" { + n.ServiceSubnet = kubekeyapiv1alpha2.DefaultServiceCIDR + } + if n.PodSubnet == "" { + n.PodSubnet = kubekeyapiv1alpha2.DefaultPodsCIDR + } +} From 32a0489b0e810e20e120f3ec8c2e855ee444d4a5 Mon Sep 17 00:00:00 2001 From: sophon Date: Mon, 26 Jun 2023 17:30:48 +0800 Subject: [PATCH 30/44] chore: ignore helm release not found --- internal/cli/cmd/infrastructure/utils/helm_wrapper.go | 9 ++++++++- internal/cli/util/helm/errors.go | 2 +- internal/cli/util/helm/helm.go | 2 +- internal/cli/util/helm/helm_test.go | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/internal/cli/cmd/infrastructure/utils/helm_wrapper.go b/internal/cli/cmd/infrastructure/utils/helm_wrapper.go index 214057b8d95..0bbaa213fd0 100644 --- a/internal/cli/cmd/infrastructure/utils/helm_wrapper.go +++ b/internal/cli/cmd/infrastructure/utils/helm_wrapper.go @@ -20,6 +20,7 @@ along with this program. If not, see . package utils import ( + "fmt" "path/filepath" "helm.sh/helm/v3/pkg/repo" @@ -39,7 +40,13 @@ func (h *HelmInstallHelper) Install(name, ns string) error { return err } helmConfig := helm.NewConfig(ns, h.kubeconfig, "", klog.V(1).Enabled()) - return h.buildChart(name, ns).Upgrade(helmConfig) + installOpts := h.buildChart(name, ns) + output, err := installOpts.Install(helmConfig) + if err != nil && helm.ReleaseNotFound(err) { + fmt.Println(output) + return nil + } + return err } func NewHelmInstaller(chart types.HelmChart, kubeconfig string) Installer { diff --git a/internal/cli/util/helm/errors.go b/internal/cli/util/helm/errors.go index 687872499b6..9f0b7d3e9ea 100644 --- a/internal/cli/util/helm/errors.go +++ b/internal/cli/util/helm/errors.go @@ -34,7 +34,7 @@ import ( var ErrReleaseNotDeployed = fmt.Errorf("release: not in deployed status") -func releaseNotFound(err error) bool { +func ReleaseNotFound(err error) bool { if err == nil { return false } diff --git a/internal/cli/util/helm/helm.go b/internal/cli/util/helm/helm.go index df995d48973..474c770bf83 100644 --- a/internal/cli/util/helm/helm.go +++ b/internal/cli/util/helm/helm.go @@ -198,7 +198,7 @@ func (i *InstallOpts) tryInstall(cfg *action.Configuration) (*release.Release, e if released != nil { return released, nil } - if err != nil && !releaseNotFound(err) { + if err != nil && !ReleaseNotFound(err) { return nil, err } } diff --git a/internal/cli/util/helm/helm_test.go b/internal/cli/util/helm/helm_test.go index 56addc920e1..62a1364f794 100644 --- a/internal/cli/util/helm/helm_test.go +++ b/internal/cli/util/helm/helm_test.go @@ -119,7 +119,7 @@ var _ = Describe("helm util", func() { }) It("should fail when release is not found", func() { - Expect(releaseNotFound(o.Upgrade(cfg))).Should(BeTrue()) + Expect(ReleaseNotFound(o.Upgrade(cfg))).Should(BeTrue()) Expect(o.Uninstall(cfg)).Should(HaveOccurred()) // release not found }) From ff3f1a2345ed582ce59007d295904add1c762c3c Mon Sep 17 00:00:00 2001 From: sophon Date: Tue, 27 Jun 2023 10:13:57 +0800 Subject: [PATCH 31/44] chore: support hugpage feature --- .../builder/template/init_os.sh.tpl | 17 +++++++ internal/cli/cmd/infrastructure/pipeline.go | 2 +- .../cmd/infrastructure/tasks/kubernetes.go | 48 +++++++++++++++---- .../cli/cmd/infrastructure/types/features.go | 27 +++++++++++ internal/cli/cmd/infrastructure/types/type.go | 11 +++-- 5 files changed, 92 insertions(+), 13 deletions(-) create mode 100644 internal/cli/cmd/infrastructure/types/features.go diff --git a/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl b/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl index 7bdda1eabea..3a016ae43a8 100644 --- a/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl +++ b/internal/cli/cmd/infrastructure/builder/template/init_os.sh.tpl @@ -71,6 +71,19 @@ function set_network() { echo } +function install_hugepage() { + local -r hugepage="${1:?missing key}" + + echo "install hugepage..." + hpg_sz=$(grep Hugepagesize /proc/meminfo | awk '{print $2}') + ## convert to KB + re_hpg_num=$(echo $hugepage | awk '{sub("GB", "*1024*1024*1024", $1) || sub("MB", "*1024*1024", $1) || sub("KB", "*1024", $1); printf $1 "+"} END {print 0}' | bc) + hpg_num=$(echo "$re_hpg_num / ( $hpg_sz * 1024 )" | bc) + + sysctl_set_keyvalue "vm.nr_hugepages" "$hpg_num" + echo +} + function common_os_setting() { swap_off selinux_off @@ -128,6 +141,10 @@ EOF fi } +{{- if $.Options.HugePageFeature }} +install_hugepage {{ $.Options.HugePageFeature.HugePageSize }} +{{- end }} + install_netfilter install_ipvs install_hosts diff --git a/internal/cli/cmd/infrastructure/pipeline.go b/internal/cli/cmd/infrastructure/pipeline.go index cf226424868..810391e5e6b 100644 --- a/internal/cli/cmd/infrastructure/pipeline.go +++ b/internal/cli/cmd/infrastructure/pipeline.go @@ -41,7 +41,7 @@ func NewCreatePipeline(o *createOptions) []module.Module { &precheck.NodePreCheckModule{}, &tasks.InstallDependenciesModule{}, &tasks.PrepareK8sBinariesModule{BinaryVersion: o.version}, - &tasks.ConfigureOSModule{}, + &tasks.ConfigureNodeOSModule{Nodes: o.Nodes}, &kubernetes.StatusModule{}, &tasks.InstallCRIModule{SandBoxImage: o.Cluster.Kubernetes.CRI.SandBoxImage}, &etcd.PreCheckModule{}, diff --git a/internal/cli/cmd/infrastructure/tasks/kubernetes.go b/internal/cli/cmd/infrastructure/tasks/kubernetes.go index 30a1bae87b8..8c14780308a 100644 --- a/internal/cli/cmd/infrastructure/tasks/kubernetes.go +++ b/internal/cli/cmd/infrastructure/tasks/kubernetes.go @@ -49,8 +49,9 @@ type PrepareK8sBinariesModule struct { BinaryVersion types.InfraVersionInfo } -type ConfigureOSModule struct { +type ConfigureNodeOSModule struct { common.KubeModule + Nodes []types.ClusterNode } type SaveKubeConfigModule struct { @@ -71,8 +72,8 @@ func (p *PrepareK8sBinariesModule) Init() { }} } -func (c *ConfigureOSModule) Init() { - c.Name = "ConfigureOSModule" +func (c *ConfigureNodeOSModule) Init() { + c.Name = "ConfigureNodeOSModule" c.Desc = "Init os dependencies" c.Tasks = []task.Interface{ &task.RemoteTask{ @@ -93,12 +94,10 @@ func (c *ConfigureOSModule) Init() { Name: "GenerateScript", Desc: "Generate init os script", Hosts: c.Runtime.GetAllHosts(), - Action: &builder.Template{ - Template: constant.ConfigureOSScripts, - Dst: filepath.Join(common.KubeScriptDir, "initOS.sh"), - Values: gotemplate.TplValues{ - "Hosts": templates.GenerateHosts(c.Runtime, c.KubeConf), - }}, + Action: &NodeScriptGenerator{ + Hosts: templates.GenerateHosts(c.Runtime, c.KubeConf), + Nodes: c.Nodes, + }, Parallel: true, }, &task.RemoteTask{ @@ -177,6 +176,37 @@ func (c *SaveKubeConfig) Execute(runtime connector.Runtime) error { return kubeconfigWrite(kc, c.outputKubeconfig) } +type NodeScriptGenerator struct { + common.KubeAction + + Nodes []types.ClusterNode + Hosts []string +} + +func (c *NodeScriptGenerator) Execute(runtime connector.Runtime) error { + foundHostOptions := func(nodes []types.ClusterNode, host connector.Host) types.NodeOptions { + for _, node := range nodes { + switch { + default: + return types.NodeOptions{} + case node.Name != host.GetName(): + case node.NodeOptions != nil: + return *node.NodeOptions + } + } + return types.NodeOptions{} + } + + scriptsTemplate := builder.Template{ + Template: constant.ConfigureOSScripts, + Dst: filepath.Join(common.KubeScriptDir, "initOS.sh"), + Values: gotemplate.TplValues{ + "Hosts": c.Hosts, + "Options": foundHostOptions(c.Nodes, runtime.RemoteHost()), + }} + return scriptsTemplate.Execute(runtime) +} + func updateClusterAPIServer(kc *clientcmdapi.Config, master connector.Host, endpoint kubekeyapiv1alpha2.ControlPlaneEndpoint) { cpePrefix := fmt.Sprintf("https://%s:", endpoint.Domain) for _, cluster := range kc.Clusters { diff --git a/internal/cli/cmd/infrastructure/types/features.go b/internal/cli/cmd/infrastructure/types/features.go new file mode 100644 index 00000000000..e79d61063f0 --- /dev/null +++ b/internal/cli/cmd/infrastructure/types/features.go @@ -0,0 +1,27 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package types + +type HugePageFeature struct { + HugePageSize string `json:"hugePageSize"` + + // HugeSizeWithUnit is the huge page size with unit, such as 2Mi, 1Gi. + HugeSizeWithUnit string `json:"hugeSizeWithUnit"` +} diff --git a/internal/cli/cmd/infrastructure/types/type.go b/internal/cli/cmd/infrastructure/types/type.go index 809211c4051..f9a515bd81a 100644 --- a/internal/cli/cmd/infrastructure/types/type.go +++ b/internal/cli/cmd/infrastructure/types/type.go @@ -76,9 +76,14 @@ type RoleGroup struct { } type ClusterNode struct { - Name string `json:"name"` - Address string `json:"address"` - InternalAddress string `json:"internalAddress"` + Name string `json:"name"` + Address string `json:"address"` + InternalAddress string `json:"internalAddress"` + NodeOptions *NodeOptions `json:"options"` +} + +type NodeOptions struct { + HugePageFeature *HugePageFeature `json:"hugePageFeature"` } type Kubernetes struct { From 2dc1a61182436ce8ad1c697a03abf432d82ef178 Mon Sep 17 00:00:00 2001 From: sophon Date: Tue, 27 Jun 2023 15:40:53 +0800 Subject: [PATCH 32/44] support zone --- internal/cli/cmd/infrastructure/create.go | 10 +++++ .../cli/cmd/infrastructure/create_test.go | 40 +++++++++++++++++++ .../cli/cmd/infrastructure/tasks/download.go | 5 ++- internal/cli/util/util.go | 4 +- internal/cli/util/util_test.go | 2 +- 5 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 internal/cli/cmd/infrastructure/create_test.go diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index b8ceb1c312f..5d1805749ae 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -21,6 +21,7 @@ package infrastructure import ( "fmt" + "os" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" @@ -93,6 +94,7 @@ func (o *createOptions) Run() error { Modules: NewCreatePipeline(o), Runtime: runtime, } + checkAndUpdateZone() if err := pipeline.Start(); err != nil { return err } @@ -100,6 +102,14 @@ func (o *createOptions) Run() error { return nil } +func checkAndUpdateZone() { + const ZoneName = "KKZONE" + if location, _ := util.GetIPLocation(); location == "CN" { + os.Setenv(ZoneName, "cn") + } + fmt.Printf("current zone: %s\n", os.Getenv(ZoneName)) +} + func NewCreateKubernetesCmd(streams genericclioptions.IOStreams) *cobra.Command { o := &createOptions{ clusterOptions: clusterOptions{ diff --git a/internal/cli/cmd/infrastructure/create_test.go b/internal/cli/cmd/infrastructure/create_test.go new file mode 100644 index 00000000000..335f8948083 --- /dev/null +++ b/internal/cli/cmd/infrastructure/create_test.go @@ -0,0 +1,40 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package infrastructure + +import ( + . "github.com/onsi/ginkgo/v2" +) + +var _ = Describe("reconfigure test", func() { + + BeforeEach(func() { + }) + + AfterEach(func() { + }) + + It("check params for creating infra", func() { + By("Create cluster with config file") + + By("Create cluster with args") + }) + +}) diff --git a/internal/cli/cmd/infrastructure/tasks/download.go b/internal/cli/cmd/infrastructure/tasks/download.go index d1591fb7898..83b6cc8aada 100644 --- a/internal/cli/cmd/infrastructure/tasks/download.go +++ b/internal/cli/cmd/infrastructure/tasks/download.go @@ -35,7 +35,10 @@ import ( ) const ( - defaultDownloadURL = "curl -L -o %s %s" + CurlDownloadURLFormat = "curl -L -o %s %s" + WgetDownloadURLFormat = "wget -O %s %s" + + defaultDownloadURL = CurlDownloadURLFormat ) func downloadKubernetesBinaryWithArch(downloadPath string, arch string, binaryVersion types.InfraVersionInfo) (map[string]*files.KubeBinary, error) { diff --git a/internal/cli/util/util.go b/internal/cli/util/util.go index d6692151d22..8039c140e8f 100644 --- a/internal/cli/util/util.go +++ b/internal/cli/util/util.go @@ -559,7 +559,7 @@ func IsSupportReconfigureParams(tpl appsv1alpha1.ComponentConfigSpec, values map return true, nil } -func getIPLocation() (string, error) { +func GetIPLocation() (string, error) { client := &http.Client{Timeout: 10 * time.Second} req, err := http.NewRequest("GET", "https://ifconfig.io/country_code", nil) if err != nil { @@ -595,7 +595,7 @@ func GetHelmChartRepoURL() string { // if helm repo url is not specified, choose one from GitHub and GitLab based on the IP location // if location is CN, or we can not get location, use GitLab helm chart repo repo := types.KubeBlocksChartURL - location, _ := getIPLocation() + location, _ := GetIPLocation() if location == "CN" || location == "" { repo = types.GitLabHelmChartRepo } diff --git a/internal/cli/util/util_test.go b/internal/cli/util/util_test.go index 5c5708853be..0531d5c6761 100644 --- a/internal/cli/util/util_test.go +++ b/internal/cli/util/util_test.go @@ -252,7 +252,7 @@ var _ = Describe("util", func() { }) It("get IP location", func() { - _, _ = getIPLocation() + _, _ = GetIPLocation() }) It("get helm chart repo url", func() { From 9e521715d54c00cd009d82569577fa4d48256dc5 Mon Sep 17 00:00:00 2001 From: sophon Date: Tue, 27 Jun 2023 16:03:56 +0800 Subject: [PATCH 33/44] support specified component version --- internal/cli/cmd/infrastructure/create.go | 35 ++++++++++++++----- internal/cli/cmd/infrastructure/types/type.go | 16 +++++---- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index 5d1805749ae..f6a1da2925a 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -69,6 +69,8 @@ func (o *createOptions) Run() error { } o.Cluster.Kubernetes.AutoDefaultFill() + o.version = o.Version + o.checkAndSetDefaultVersion() cluster, err := createClusterWithOptions(buildTemplateParams(o)) if err != nil { return err @@ -115,7 +117,7 @@ func NewCreateKubernetesCmd(streams genericclioptions.IOStreams) *cobra.Command clusterOptions: clusterOptions{ IOStreams: streams, }} - o.setDefaultVersion() + o.checkAndSetDefaultVersion() cmd := &cobra.Command{ Use: "create", Short: "create kubernetes cluster.", @@ -127,6 +129,7 @@ func NewCreateKubernetesCmd(streams genericclioptions.IOStreams) *cobra.Command }, } o.buildCreateInfraFlags(cmd) + o.Version = o.version return cmd } @@ -139,12 +142,26 @@ func (o *createOptions) buildCreateInfraFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&o.outputKubeconfig, "output-kubeconfig", "", tasks.GetDefaultConfig(), "Specified output kubeconfig. [option]") } -func (o *createOptions) setDefaultVersion() { - o.version.KubernetesVersion = constant.DefaultK8sVersion - o.version.EtcdVersion = constant.DefaultEtcdVersion - o.version.ContainerVersion = constant.DefaultContainerdVersion - o.version.HelmVersion = constant.DefaultHelmVersion - o.version.CRICtlVersion = constant.DefaultCRICtlVersion - o.version.CniVersion = constant.DefaultCniVersion - o.version.RuncVersion = constant.DefaultRuncVersion +func (o *createOptions) checkAndSetDefaultVersion() { + if o.version.KubernetesVersion == "" { + o.version.KubernetesVersion = constant.DefaultK8sVersion + } + if o.version.EtcdVersion == "" { + o.version.EtcdVersion = constant.DefaultEtcdVersion + } + if o.version.ContainerVersion == "" { + o.version.ContainerVersion = constant.DefaultContainerdVersion + } + if o.version.HelmVersion == "" { + o.version.HelmVersion = constant.DefaultHelmVersion + } + if o.version.CRICtlVersion == "" { + o.version.CRICtlVersion = constant.DefaultCRICtlVersion + } + if o.version.CniVersion == "" { + o.version.CniVersion = constant.DefaultCniVersion + } + if o.version.RuncVersion == "" { + o.version.RuncVersion = constant.DefaultRuncVersion + } } diff --git a/internal/cli/cmd/infrastructure/types/type.go b/internal/cli/cmd/infrastructure/types/type.go index f9a515bd81a..2ffa1952689 100644 --- a/internal/cli/cmd/infrastructure/types/type.go +++ b/internal/cli/cmd/infrastructure/types/type.go @@ -26,13 +26,13 @@ import ( ) type InfraVersionInfo struct { - KubernetesVersion string - EtcdVersion string - ContainerVersion string - CRICtlVersion string - RuncVersion string - CniVersion string - HelmVersion string + KubernetesVersion string `json:"kubernetesVersion"` + EtcdVersion string `json:"etcdVersion"` + ContainerVersion string `json:"containerVersion"` + CRICtlVersion string `json:"crictlVersion"` + RuncVersion string `json:"runcVersion"` + CniVersion string `json:"cniVersion"` + HelmVersion string `json:"helmVersion"` } type PluginMeta struct { @@ -67,6 +67,8 @@ type Cluster struct { // for kubeadm configuration Kubernetes Kubernetes `json:"kubernetes"` + + Version InfraVersionInfo `json:"version"` } type RoleGroup struct { From 5205a97be66eee56c12c036b17eb38e95f75cb50 Mon Sep 17 00:00:00 2001 From: sophon Date: Tue, 27 Jun 2023 16:43:08 +0800 Subject: [PATCH 34/44] fix: invalid delete-cri --- internal/cli/cmd/infrastructure/delete.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cli/cmd/infrastructure/delete.go b/internal/cli/cmd/infrastructure/delete.go index b7f614b054b..02da66b6911 100644 --- a/internal/cli/cmd/infrastructure/delete.go +++ b/internal/cli/cmd/infrastructure/delete.go @@ -88,7 +88,7 @@ func (o *deleteOptions) Run() error { func (o *deleteOptions) buildDeleteInfraFlags(cmd *cobra.Command) { buildCommonFlags(cmd, &o.clusterOptions) cmd.Flags().BoolVarP(&o.debug, "debug", "", false, "set debug mode") - cmd.Flags().BoolVarP(&o.debug, "delete-cri", "", false, "delete cri") + cmd.Flags().BoolVarP(&o.deleteCRI, "delete-cri", "", false, "delete cri") } func NewDeleteKubernetesCmd(streams genericclioptions.IOStreams) *cobra.Command { From 75aaf2f49866376d572e667bc942fcfd96969a98 Mon Sep 17 00:00:00 2001 From: sophon Date: Tue, 27 Jun 2023 20:03:30 +0800 Subject: [PATCH 35/44] chore: adjust pluin: cilium --- internal/cli/cmd/infrastructure/cluster.go | 3 ++- internal/cli/cmd/infrastructure/constant/const.go | 3 +-- internal/cli/cmd/infrastructure/types/type.go | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/cli/cmd/infrastructure/cluster.go b/internal/cli/cmd/infrastructure/cluster.go index b74af0b2005..daff33f0282 100644 --- a/internal/cli/cmd/infrastructure/cluster.go +++ b/internal/cli/cmd/infrastructure/cluster.go @@ -70,7 +70,7 @@ func buildCommonFlags(cmd *cobra.Command, o *clusterOptions) { } func (o *clusterOptions) Complete() error { - if o.clusterName == "" { + if o.clusterName == "" && o.clusterConfig == "" { o.clusterName = "kubeblocks-" + rand.String(6) fmt.Printf("The cluster name is not set, auto generate cluster name: %s\n", o.clusterName) } @@ -195,6 +195,7 @@ func (o *clusterOptions) fillClusterConfig(configFile string) error { return err } o.Cluster = *c + o.clusterName = o.Cluster.Name return nil } diff --git a/internal/cli/cmd/infrastructure/constant/const.go b/internal/cli/cmd/infrastructure/constant/const.go index cf9046f5d6a..75fca885484 100644 --- a/internal/cli/cmd/infrastructure/constant/const.go +++ b/internal/cli/cmd/infrastructure/constant/const.go @@ -47,6 +47,5 @@ const ( DefaultK8sProxyMode = "ipvs" DefaultAPIServerPort = 6443 - DefaultClusterCIDR = "10.233.64.0/18" - DefaultNetworkPlugin = "calico" + DefaultNetworkPlugin = "cilium" ) diff --git a/internal/cli/cmd/infrastructure/types/type.go b/internal/cli/cmd/infrastructure/types/type.go index 2ffa1952689..fced9eaf73a 100644 --- a/internal/cli/cmd/infrastructure/types/type.go +++ b/internal/cli/cmd/infrastructure/types/type.go @@ -23,6 +23,7 @@ import ( "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/constant" kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2" "helm.sh/helm/v3/pkg/cli/values" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) type InfraVersionInfo struct { @@ -59,6 +60,9 @@ type Yaml struct { } type Cluster struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + User ClusterUser `json:"user"` Nodes []ClusterNode `json:"nodes"` @@ -103,7 +107,7 @@ type Kubernetes struct { type Networking struct { // using network plugin, default is calico - Plugin string `json:"omitempty"` + Plugin string `json:"plugin"` ServiceSubnet string `json:"serviceSubnet"` PodSubnet string `json:"podSubnet"` DNSDomain string `json:"dnsDomain"` From 93960cee36903d89b858a4cf322da1fe98949ab7 Mon Sep 17 00:00:00 2001 From: sophon Date: Tue, 27 Jun 2023 23:38:24 +0800 Subject: [PATCH 36/44] chore: refactor pipeline runner --- .../builder/template/kubekey_cluster.tpl | 2 +- internal/cli/cmd/infrastructure/create.go | 11 +- .../infrastructure/tasks/pipeline_runner.go | 107 ++++++++++++++++++ internal/cli/cmd/infrastructure/types/type.go | 12 +- 4 files changed, 117 insertions(+), 15 deletions(-) create mode 100644 internal/cli/cmd/infrastructure/tasks/pipeline_runner.go diff --git a/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl b/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl index c1cb3ab5a0f..19395439517 100644 --- a/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl +++ b/internal/cli/cmd/infrastructure/builder/template/kubekey_cluster.tpl @@ -42,7 +42,7 @@ spec: nodelocaldns: false dnsDomain: {{ $.Kubernetes.Networking.DNSDomain }} version: {{ $.Version }} - clusterName: {{ $.Kubernetes.ClusterName }} + clusterName: {{ $.Name }} {{- $criType := "containerd" }} nodeCidrMaskSize: 24 proxyMode: {{ $.Kubernetes.ProxyMode }} diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index f6a1da2925a..582c13d2e35 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -25,7 +25,6 @@ import ( "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common" "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" - "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/pipeline" "github.com/spf13/cobra" versionutil "k8s.io/apimachinery/pkg/util/version" "k8s.io/cli-runtime/pkg/genericclioptions" @@ -89,15 +88,11 @@ func (o *createOptions) Run() error { Cluster: cluster, ClusterName: o.clusterName, } - syncClusterNodeRole(cluster, runtime) - pipeline := pipeline.Pipeline{ - Name: "CreateCluster", - Modules: NewCreatePipeline(o), - Runtime: runtime, - } + syncClusterNodeRole(cluster, runtime) checkAndUpdateZone() - if err := pipeline.Start(); err != nil { + pipelineRunner := tasks.NewPipelineRunner("CreateCluster", NewCreatePipeline(o), runtime) + if err := pipelineRunner.Do(o.IOStreams.Out); err != nil { return err } fmt.Fprintf(o.IOStreams.Out, "Kubernetes Installation is complete.\n\n") diff --git a/internal/cli/cmd/infrastructure/tasks/pipeline_runner.go b/internal/cli/cmd/infrastructure/tasks/pipeline_runner.go new file mode 100644 index 00000000000..d9d72555694 --- /dev/null +++ b/internal/cli/cmd/infrastructure/tasks/pipeline_runner.go @@ -0,0 +1,107 @@ +/* +Copyright (C) 2022-2023 ApeCloud Co., Ltd + +This file is part of KubeBlocks project + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +package tasks + +import ( + "fmt" + "io" + + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/cache" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/connector" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/ending" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/module" + "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/pipeline" + + cfgcore "github.com/apecloud/kubeblocks/internal/configuration" +) + +type PipelineWrapper struct { + pipeline.Pipeline +} + +func NewPipelineRunner(name string, modules []module.Module, runtime connector.Runtime) *PipelineWrapper { + return &PipelineWrapper{ + Pipeline: pipeline.Pipeline{ + Name: name, + Modules: modules, + Runtime: runtime, + PipelineCache: cache.NewCache(), + SpecHosts: len(runtime.GetAllHosts()), + }, + } +} + +func (w *PipelineWrapper) Do(output io.Writer) error { + defer func() { + w.PipelineCache.Clean() + w.releaseHostsConnector() + }() + + for i := range w.Modules { + m := w.Modules[i] + if m.IsSkip() { + continue + } + if res := w.safeRunModule(m); res.IsFailed() { + return cfgcore.WrapError(res.CombineResult, "failed to execute module: %s", getModuleName(m)) + } + } + + if w.SpecHosts != len(w.Runtime.GetAllHosts()) { + return cfgcore.MakeError("failed to execute pipeline: there are some error in your spec hosts", w.Name) + } + fmt.Fprintf(output, "succeed to execute all modules in the pipeline[%s]", w.Name) + return nil +} + +func (w *PipelineWrapper) safeRunModule(m module.Module) *ending.ModuleResult { + newCache := func() *cache.Cache { + if moduleCache, ok := w.ModuleCachePool.Get().(*cache.Cache); ok { + return moduleCache + } + return cache.NewCache() + } + releaseCache := func(cache *cache.Cache) { + cache.Clean() + w.ModuleCachePool.Put(cache) + } + + moduleCache := newCache() + defer releaseCache(moduleCache) + m.Default(w.Runtime, w.PipelineCache, moduleCache) + m.AutoAssert() + m.Init() + return w.RunModule(m) +} + +func (w *PipelineWrapper) releaseHostsConnector() { + for _, host := range w.Runtime.GetAllHosts() { + if connector := w.Runtime.GetConnector(); connector != nil { + connector.Close(host) + } + } +} + +func getModuleName(m module.Module) string { + if b, ok := m.(*module.BaseModule); ok { + return b.Name + } + return "" +} diff --git a/internal/cli/cmd/infrastructure/types/type.go b/internal/cli/cmd/infrastructure/types/type.go index fced9eaf73a..9a8c54d4e79 100644 --- a/internal/cli/cmd/infrastructure/types/type.go +++ b/internal/cli/cmd/infrastructure/types/type.go @@ -93,9 +93,9 @@ type NodeOptions struct { } type Kubernetes struct { - ClusterName string `json:"clusterName"` - DNSDomain string `json:"dnsDomain"` - ProxyMode string `json:"proxyMode"` + // ClusterName string `json:"clusterName"` + DNSDomain string `json:"dnsDomain"` + ProxyMode string `json:"proxyMode"` Networking Networking `json:"networking"` CRI ContainerRuntime `json:"cri"` @@ -155,9 +155,9 @@ func (g *RoleGroup) IsValidate() bool { } func (k *Kubernetes) AutoDefaultFill() { - if k.ClusterName == "" { - k.ClusterName = constant.DefaultK8sClusterName - } + // if k.ClusterName == "" { + // k.ClusterName = constant.DefaultK8sClusterName + // } if k.DNSDomain == "" { k.DNSDomain = constant.DefaultK8sDNSDomain } From 8b1e57a2e2113da6b6c97458f5c4718e45be50a7 Mon Sep 17 00:00:00 2001 From: sophon Date: Tue, 27 Jun 2023 23:48:31 +0800 Subject: [PATCH 37/44] chore: Minor adjust --- internal/cli/cmd/infrastructure/tasks/pipeline_runner.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/internal/cli/cmd/infrastructure/tasks/pipeline_runner.go b/internal/cli/cmd/infrastructure/tasks/pipeline_runner.go index d9d72555694..d4200c571cd 100644 --- a/internal/cli/cmd/infrastructure/tasks/pipeline_runner.go +++ b/internal/cli/cmd/infrastructure/tasks/pipeline_runner.go @@ -63,10 +63,6 @@ func (w *PipelineWrapper) Do(output io.Writer) error { return cfgcore.WrapError(res.CombineResult, "failed to execute module: %s", getModuleName(m)) } } - - if w.SpecHosts != len(w.Runtime.GetAllHosts()) { - return cfgcore.MakeError("failed to execute pipeline: there are some error in your spec hosts", w.Name) - } fmt.Fprintf(output, "succeed to execute all modules in the pipeline[%s]", w.Name) return nil } From 79ffda7e9a7b1cc60d82ae1772c4e4d8ad31a73d Mon Sep 17 00:00:00 2001 From: sophon Date: Wed, 28 Jun 2023 00:54:05 +0800 Subject: [PATCH 38/44] chore: Minor adjust --- internal/cli/cmd/infrastructure/cluster.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/cli/cmd/infrastructure/cluster.go b/internal/cli/cmd/infrastructure/cluster.go index daff33f0282..90c77690da7 100644 --- a/internal/cli/cmd/infrastructure/cluster.go +++ b/internal/cli/cmd/infrastructure/cluster.go @@ -120,6 +120,9 @@ func (o *clusterOptions) Validate() error { if o.User.Name == "" { return cfgcore.MakeError("user name is empty") } + if o.clusterName == "" { + return cfgcore.MakeError("kubernetes name is empty") + } if err := validateUser(o); err != nil { return err } @@ -195,7 +198,7 @@ func (o *clusterOptions) fillClusterConfig(configFile string) error { return err } o.Cluster = *c - o.clusterName = o.Cluster.Name + o.clusterName = c.Name return nil } From 3dfe7e3d41f897fb9459ee0d677ad74f09e20fe1 Mon Sep 17 00:00:00 2001 From: sophon Date: Wed, 28 Jun 2023 18:15:51 +0800 Subject: [PATCH 39/44] add ut --- .../cli/cmd/infrastructure/constant/const.go | 9 ++- .../cli/cmd/infrastructure/create_test.go | 66 ++++++++++++++++++- internal/cli/cmd/infrastructure/types/type.go | 12 ++-- .../infrastructure/infra-cluster.yaml | 56 ++++++++++++++++ 4 files changed, 130 insertions(+), 13 deletions(-) create mode 100644 test/testdata/infrastructure/infra-cluster.yaml diff --git a/internal/cli/cmd/infrastructure/constant/const.go b/internal/cli/cmd/infrastructure/constant/const.go index 75fca885484..18b3e44bbb5 100644 --- a/internal/cli/cmd/infrastructure/constant/const.go +++ b/internal/cli/cmd/infrastructure/constant/const.go @@ -41,11 +41,10 @@ const ( ) const ( - DefaultK8sClusterName = "cluster.local" - DefaultK8sDNSDomain = "cluster.local" - DefaultAPIDNSDomain = "lb.kubeblocks.local" - DefaultK8sProxyMode = "ipvs" - DefaultAPIServerPort = 6443 + DefaultK8sDNSDomain = "cluster.local" + DefaultAPIDNSDomain = "lb.kubeblocks.local" + DefaultK8sProxyMode = "ipvs" + DefaultAPIServerPort = 6443 DefaultNetworkPlugin = "cilium" ) diff --git a/internal/cli/cmd/infrastructure/create_test.go b/internal/cli/cmd/infrastructure/create_test.go index 335f8948083..85593f929bb 100644 --- a/internal/cli/cmd/infrastructure/create_test.go +++ b/internal/cli/cmd/infrastructure/create_test.go @@ -20,21 +20,81 @@ along with this program. If not, see . package infrastructure import ( + "os" + "path/filepath" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + + "k8s.io/cli-runtime/pkg/genericclioptions" + cmdtesting "k8s.io/kubectl/pkg/cmd/testing" + + "github.com/apecloud/kubeblocks/internal/cli/testing" + "github.com/apecloud/kubeblocks/test/testdata" ) -var _ = Describe("reconfigure test", func() { +var _ = Describe("infra create test", func() { + + var ( + tf *cmdtesting.TestFactory + streams genericclioptions.IOStreams + ) BeforeEach(func() { + streams, _, _, _ = genericclioptions.NewTestIOStreams() + tf = cmdtesting.NewTestFactory().WithNamespace(testing.Namespace) }) AfterEach(func() { + tf.Cleanup() }) - It("check params for creating infra", func() { + mockPrivateKeyFile := func(tmpDir string) string { + privateKeyFile := filepath.Join(tmpDir, "id_rsa.pem") + Expect(os.WriteFile(privateKeyFile, []byte("private key"), os.ModePerm)).Should(Succeed()) + return privateKeyFile + } + + It("test create k8s cluster with config file", func() { + tmpDir, _ := os.MkdirTemp(os.TempDir(), "test-") + defer os.RemoveAll(tmpDir) + By("Create cluster with config file") + o := &createOptions{ + clusterOptions: clusterOptions{ + IOStreams: streams, + }} + o.checkAndSetDefaultVersion() + o.clusterConfig = testdata.SubTestDataPath("infrastructure/infra-cluster.yaml") + Expect(o.Complete()).To(Succeed()) + o.Cluster.User.PrivateKeyPath = mockPrivateKeyFile(tmpDir) + Expect(o.Validate()).To(Succeed()) + }) + + It("test create k8s cluster with params", func() { + tmpDir, _ := os.MkdirTemp(os.TempDir(), "test-") + defer os.RemoveAll(tmpDir) + + By("Create cluster with config file") + o := &createOptions{ + clusterOptions: clusterOptions{ + IOStreams: streams, + }} + o.checkAndSetDefaultVersion() + + o.nodes = []string{ + "node0:1.1.1.1:10.128.0.1", + "node1:1.1.1.2:10.128.0.2", + "node2:1.1.1.3:10.128.0.3", + } + o.Cluster.User.PrivateKeyPath = mockPrivateKeyFile(tmpDir) + Expect(o.Complete()).Should(Succeed()) + Expect(o.Validate()).ShouldNot(Succeed()) - By("Create cluster with args") + o.Cluster.RoleGroup.Master = []string{"node0"} + o.Cluster.RoleGroup.ETCD = []string{"node0"} + o.Cluster.RoleGroup.Worker = []string{"node1", "node2"} + Expect(o.Validate()).Should(Succeed()) }) }) diff --git a/internal/cli/cmd/infrastructure/types/type.go b/internal/cli/cmd/infrastructure/types/type.go index 9a8c54d4e79..e73ebd1aaeb 100644 --- a/internal/cli/cmd/infrastructure/types/type.go +++ b/internal/cli/cmd/infrastructure/types/type.go @@ -94,7 +94,7 @@ type NodeOptions struct { type Kubernetes struct { // ClusterName string `json:"clusterName"` - DNSDomain string `json:"dnsDomain"` + // DNSDomain string `json:"dnsDomain"` ProxyMode string `json:"proxyMode"` Networking Networking `json:"networking"` @@ -107,7 +107,9 @@ type Kubernetes struct { type Networking struct { // using network plugin, default is calico - Plugin string `json:"plugin"` + Plugin string `json:"plugin"` + + // apis/kubeadm/types.Networking ServiceSubnet string `json:"serviceSubnet"` PodSubnet string `json:"podSubnet"` DNSDomain string `json:"dnsDomain"` @@ -158,9 +160,9 @@ func (k *Kubernetes) AutoDefaultFill() { // if k.ClusterName == "" { // k.ClusterName = constant.DefaultK8sClusterName // } - if k.DNSDomain == "" { - k.DNSDomain = constant.DefaultK8sDNSDomain - } + // if k.DNSDomain == "" { + // k.DNSDomain = constant.DefaultK8sDNSDomain + // } if k.ProxyMode == "" { k.ProxyMode = constant.DefaultK8sProxyMode } diff --git a/test/testdata/infrastructure/infra-cluster.yaml b/test/testdata/infrastructure/infra-cluster.yaml new file mode 100644 index 00000000000..67fde9ad270 --- /dev/null +++ b/test/testdata/infrastructure/infra-cluster.yaml @@ -0,0 +1,56 @@ +metadata: + name: kb-k8s-test-cluster +user: + name: user1 + privateKeyPath: ~/.ssh/test.pem +nodes: + - name: kb-infra-node-0 + address: 1.1.1.1 + internalAddress: 10.128.0.19 + - name: kb-infra-node-1 + address: 1.1.1.2 + internalAddress: 10.128.0.20 + - name: kb-infra-node-2 + address: 1.1.1.3 + internalAddress: 10.128.0.21 + options: + hugePageFeature: + hugePageSize: 10GB +roleGroup: + etcd: + - kb-infra-node-0 + - kb-infra-node-1 + - kb-infra-node-2 + master: + - kb-infra-node-0 + worker: + - kb-infra-node-1 + - kb-infra-node-2 + +kubernetes: + containerManager: containerd + # apis/kubeadm/types.Networking + networking: + plugin: cilium + dnsDomain: cluster.local + podSubnet: 10.233.64.0/18 + serviceSubnet: 10.233.0.0/18 + controlPlaneEndpoint: + domain: lb.kubeblocks.local + port: 6443 + cri: + containerRuntimeType: "containerd" + containerRuntimeEndpoint: "unix:///run/containerd/containerd.sock" + sandBoxImage: "k8s.gcr.io/pause:3.8" +addons: + - name: openebs + namespace: kube-blocks + sources: + chart: + name: openebs + version: 3.7.0 + repo: https://openebs.github.io/charts + options: + values: + - "localprovisioner.basePath=/mnt/disks" + - "localprovisioner.hostpathClass.isDefaultClass=true" From e1b9305c3728022ee370fd47ca9778c5521b68ea Mon Sep 17 00:00:00 2001 From: sophon Date: Wed, 28 Jun 2023 18:34:04 +0800 Subject: [PATCH 40/44] chore: update go.mod --- go.mod | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e1d696d354e..348cf8a14ea 100644 --- a/go.mod +++ b/go.mod @@ -53,6 +53,7 @@ require ( github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 github.com/onsi/ginkgo/v2 v2.9.1 github.com/onsi/gomega v1.27.4 + github.com/opencontainers/image-spec v1.1.0-rc2 github.com/pkg/errors v0.9.1 github.com/pmezard/go-difflib v1.0.0 github.com/redis/go-redis/v9 v9.0.1 @@ -136,6 +137,7 @@ require ( github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/aws/aws-sdk-go v1.44.180 // indirect + github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bhmj/xpression v0.9.1 // indirect @@ -309,7 +311,6 @@ require ( github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.0-rc2 // indirect github.com/opencontainers/runc v1.1.5 // indirect github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect github.com/opencontainers/selinux v1.10.2 // indirect From f4ec00c38a32639407ee7992120292bb725bca63 Mon Sep 17 00:00:00 2001 From: sophon Date: Wed, 5 Jul 2023 20:50:59 +0800 Subject: [PATCH 41/44] for rebase main --- go.mod | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 348cf8a14ea..b008620fc4f 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/Shopify/sarama v1.30.0 github.com/StudioSol/set v1.0.0 github.com/authzed/controller-idioms v0.7.0 - github.com/aws/aws-sdk-go v1.44.122 + github.com/aws/aws-sdk-go v1.44.180 github.com/bhmj/jsonslice v1.1.2 github.com/briandowns/spinner v1.23.0 github.com/cenkalti/backoff/v4 v4.2.0 @@ -136,8 +136,6 @@ require ( github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect github.com/benbjohnson/clock v1.3.0 // indirect - github.com/aws/aws-sdk-go v1.44.180 // indirect - github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bhmj/xpression v0.9.1 // indirect @@ -205,7 +203,6 @@ require ( github.com/go-openapi/swag v0.22.3 // indirect github.com/go-openapi/validate v0.22.0 // indirect github.com/go-redis/redis/v7 v7.4.1 // indirect - github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect github.com/go-test/deep v1.1.0 // indirect github.com/gobwas/glob v0.2.3 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect From a3c968086de874a8aeb599687717f9cda6a034cc Mon Sep 17 00:00:00 2001 From: sophon Date: Wed, 5 Jul 2023 21:27:53 +0800 Subject: [PATCH 42/44] fix: failed to build-tools-image --- docker/Dockerfile-tools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile-tools b/docker/Dockerfile-tools index a7c9670be40..410030ab071 100644 --- a/docker/Dockerfile-tools +++ b/docker/Dockerfile-tools @@ -70,7 +70,7 @@ RUN --mount=type=bind,target=. \ RUN --mount=type=bind,target=. \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ - CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOFLAGS="-mod=mod" go build -ldflags="${LD_FLAGS}" -a -o /out/kbcli cmd/cli/main.go + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOFLAGS="-mod=mod" go build -ldflags="${LD_FLAGS}" -tags="containers_image_openpgp" -a -o /out/kbcli cmd/cli/main.go # Use alpine with tag 20230329 is corresponding to "edge" tag (latest release to date is 3.18) as of 20230625 FROM docker.io/alpine:edge as dist From 8793a5290ed03c44ae051de541b287e695f44da2 Mon Sep 17 00:00:00 2001 From: sophon Date: Wed, 5 Jul 2023 21:45:32 +0800 Subject: [PATCH 43/44] add infra command example --- internal/cli/cmd/infrastructure/create.go | 66 ++++++++++++++++++++++- internal/cli/cmd/infrastructure/delete.go | 8 ++- 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/internal/cli/cmd/infrastructure/create.go b/internal/cli/cmd/infrastructure/create.go index 582c13d2e35..2d432a9148f 100644 --- a/internal/cli/cmd/infrastructure/create.go +++ b/internal/cli/cmd/infrastructure/create.go @@ -28,6 +28,7 @@ import ( "github.com/spf13/cobra" versionutil "k8s.io/apimachinery/pkg/util/version" "k8s.io/cli-runtime/pkg/genericclioptions" + "k8s.io/kubectl/pkg/util/templates" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/constant" "github.com/apecloud/kubeblocks/internal/cli/cmd/infrastructure/tasks" @@ -49,8 +50,69 @@ type createOptions struct { outputKubeconfig string } -var createExamples = ` -` +var createExamples = templates.Examples(` + # Create kubernetes cluster with specified config yaml + kbcli infra create -c cluster.yaml + + # example cluster.yaml + cat cluster.yaml +metadata: + name: kb-k8s-test-cluster +user: + name: user1 + privateKeyPath: ~/.ssh/test.pem +nodes: + - name: kb-infra-node-0 + address: 1.1.1.1 + internalAddress: 10.128.0.19 + - name: kb-infra-node-1 + address: 1.1.1.2 + internalAddress: 10.128.0.20 + - name: kb-infra-node-2 + address: 1.1.1.3 + internalAddress: 10.128.0.21 + options: + hugePageFeature: + hugePageSize: 10GB +roleGroup: + etcd: + - kb-infra-node-0 + - kb-infra-node-1 + - kb-infra-node-2 + master: + - kb-infra-node-0 + worker: + - kb-infra-node-1 + - kb-infra-node-2 + +kubernetes: + containerManager: containerd + # apis/kubeadm/types.Networking + networking: + plugin: cilium + dnsDomain: cluster.local + podSubnet: 10.233.64.0/18 + serviceSubnet: 10.233.0.0/18 + controlPlaneEndpoint: + domain: lb.kubeblocks.local + port: 6443 + cri: + containerRuntimeType: "containerd" + containerRuntimeEndpoint: "unix:///run/containerd/containerd.sock" + sandBoxImage: "k8s.gcr.io/pause:3.8" +addons: + - name: openebs + namespace: kube-blocks + sources: + chart: + name: openebs + version: 3.7.0 + repo: https://openebs.github.io/charts + options: + values: + - "localprovisioner.basePath=/mnt/disks" + - "localprovisioner.hostpathClass.isDefaultClass=true" +`) func (o *createOptions) Run() error { const minKubernetesVersion = "v1.24.0" diff --git a/internal/cli/cmd/infrastructure/delete.go b/internal/cli/cmd/infrastructure/delete.go index 02da66b6911..2c0f27c6cd0 100644 --- a/internal/cli/cmd/infrastructure/delete.go +++ b/internal/cli/cmd/infrastructure/delete.go @@ -28,6 +28,7 @@ import ( "github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/pipeline" "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" + "k8s.io/kubectl/pkg/util/templates" "github.com/apecloud/kubeblocks/internal/cli/util" ) @@ -39,6 +40,11 @@ type deleteOptions struct { debug bool } +var deleteExamples = templates.Examples(` + # delete kubernetes cluster with specified config yaml + kbcli infra delete -c cluster.yaml +`) + func (o *deleteOptions) Run() error { o.Cluster.Kubernetes.AutoDefaultFill() cluster, err := createClusterWithOptions(&gotemplate.TplValues{ @@ -99,7 +105,7 @@ func NewDeleteKubernetesCmd(streams genericclioptions.IOStreams) *cobra.Command cmd := &cobra.Command{ Use: "delete", Short: "delete kubernetes cluster.", - Example: createExamples, + Example: deleteExamples, Run: func(cmd *cobra.Command, args []string) { util.CheckErr(o.Complete()) util.CheckErr(o.Validate()) From 4fde98195dece80302726f2cf32a5201d3516b1c Mon Sep 17 00:00:00 2001 From: sophon-zt Date: Wed, 5 Jul 2023 13:52:22 +0000 Subject: [PATCH 44/44] chore: auto update cli doc changes --- docs/user_docs/cli/kbcli_builder_template.md | 4 +- docs/user_docs/cli/kbcli_infra_create.md | 63 +++++++++++++++++++- docs/user_docs/cli/kbcli_infra_delete.md | 4 +- 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/docs/user_docs/cli/kbcli_builder_template.md b/docs/user_docs/cli/kbcli_builder_template.md index ce129743fa7..621a3c0ec2d 100644 --- a/docs/user_docs/cli/kbcli_builder_template.md +++ b/docs/user_docs/cli/kbcli_builder_template.md @@ -21,10 +21,10 @@ kbcli builder template [flags] ### Options ``` - -a, --all template all config specs --clean specify whether to clear the output dir --cluster string the cluster yaml file - --cluster-definition string the cluster definition yaml file + --cluster-definition string specify the cluster definition name + --cluster-version string specify the cluster version name --component-name string specify the component name of the clusterdefinition --config-spec string specify the config spec to be rendered --cpu string specify the cpu of the component diff --git a/docs/user_docs/cli/kbcli_infra_create.md b/docs/user_docs/cli/kbcli_infra_create.md index 56d153b6506..979b60fbb1b 100644 --- a/docs/user_docs/cli/kbcli_infra_create.md +++ b/docs/user_docs/cli/kbcli_infra_create.md @@ -11,8 +11,67 @@ kbcli infra create [flags] ### Examples ``` - - + # Create kubernetes cluster with specified config yaml + kbcli infra create -c cluster.yaml + + # example cluster.yaml + cat cluster.yaml + metadata: + name: kb-k8s-test-cluster + user: + name: user1 + privateKeyPath: ~/.ssh/test.pem + nodes: + - name: kb-infra-node-0 + address: 1.1.1.1 + internalAddress: 10.128.0.19 + - name: kb-infra-node-1 + address: 1.1.1.2 + internalAddress: 10.128.0.20 + - name: kb-infra-node-2 + address: 1.1.1.3 + internalAddress: 10.128.0.21 + options: + hugePageFeature: + hugePageSize: 10GB + roleGroup: + etcd: + - kb-infra-node-0 + - kb-infra-node-1 + - kb-infra-node-2 + master: + - kb-infra-node-0 + worker: + - kb-infra-node-1 + - kb-infra-node-2 + + kubernetes: + containerManager: containerd + # apis/kubeadm/types.Networking + networking: + plugin: cilium + dnsDomain: cluster.local + podSubnet: 10.233.64.0/18 + serviceSubnet: 10.233.0.0/18 + controlPlaneEndpoint: + domain: lb.kubeblocks.local + port: 6443 + cri: + containerRuntimeType: "containerd" + containerRuntimeEndpoint: "unix:///run/containerd/containerd.sock" + sandBoxImage: "k8s.gcr.io/pause:3.8" + addons: + - name: openebs + namespace: kube-blocks + sources: + chart: + name: openebs + version: 3.7.0 + repo: https://openebs.github.io/charts + options: + values: + - "localprovisioner.basePath=/mnt/disks" + - "localprovisioner.hostpathClass.isDefaultClass=true" ``` ### Options diff --git a/docs/user_docs/cli/kbcli_infra_delete.md b/docs/user_docs/cli/kbcli_infra_delete.md index 87b402cb6b1..df0df7a78e6 100644 --- a/docs/user_docs/cli/kbcli_infra_delete.md +++ b/docs/user_docs/cli/kbcli_infra_delete.md @@ -11,8 +11,8 @@ kbcli infra delete [flags] ### Examples ``` - - + # delete kubernetes cluster with specified config yaml + kbcli infra delete -c cluster.yaml ``` ### Options