Skip to content

Commit

Permalink
feature: use go template instance pongo2 template (#2340)
Browse files Browse the repository at this point in the history
* fix: misspelling

Signed-off-by: joyceliu <joyceliu@yunify.com>

* fix: misspelling

Signed-off-by: joyceliu <joyceliu@yunify.com>

* fix: misspelling

Signed-off-by: joyceliu <joyceliu@yunify.com>

* fix: misspelling

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: user go-template instance pongo2-template

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: not set incorrect

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <joyceliu@yunify.com>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <joyceliu@yunify.com>

---------

Signed-off-by: joyceliu <joyceliu@yunify.com>
Co-authored-by: joyceliu <joyceliu@yunify.com>
  • Loading branch information
redscholar and joyceliu authored Aug 5, 2024
1 parent 3b361c9 commit 4919e63
Show file tree
Hide file tree
Showing 302 changed files with 17,342 additions and 10,249 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
version: v1.59.1

verify:
name: verify
Expand Down
42 changes: 27 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ GOTESTSUM_PKG := gotest.tools/gotestsum
HADOLINT_VER := v2.10.0
HADOLINT_FAILURE_THRESHOLD = warning

GOLANGCI_LINT_VER := $(shell cat .github/workflows/golangci-lint.yml | grep [[:space:]]version | sed 's/.*version: //')
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(abspath $(OUTPUT_TOOLS_DIR)/$(GOLANGCI_LINT_BIN))
GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint

GORELEASER_VERSION := v2.0.1
GORELEASER_BIN := goreleaser
Expand Down Expand Up @@ -175,7 +177,7 @@ generate-manifests-kubekey: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RB

.PHONY: generate-modules
generate-modules: ## Run go mod tidy to ensure modules are up to date
go mod tidy
@go mod tidy && go mod vendor

.PHONY: generate-goimports
generate-goimports: ## Format all import, `goimports` is required.
Expand Down Expand Up @@ -587,22 +589,32 @@ $(GOLANGCI_LINT_BIN): $(GOLANGCI_LINT) ## Build a local copy of golangci-lint
.PHONY: $(GORELEASER)
$(GORELEASER_BIN): $(GORELEASER) ## Build a local copy of golangci-lint

$(CONTROLLER_GEN): # Build controller-gen from tools folder.
CGO_ENABLED=0 GOBIN=$(OUTPUT_TOOLS_DIR) $(GO_INSTALL) $(CONTROLLER_GEN_PKG) $(CONTROLLER_GEN_BIN) $(CONTROLLER_GEN_VER)
$(CONTROLLER_GEN): # Build controller-gen into tools folder.
@if [ ! -f $(OUTPUT_TOOLS_DIR)/$(CONTROLLER_GEN_BIN) ]; then \
CGO_ENABLED=0 GOBIN=$(OUTPUT_TOOLS_DIR) $(GO_INSTALL) $(CONTROLLER_GEN_PKG) $(CONTROLLER_GEN_BIN) $(CONTROLLER_GEN_VER); \
fi

$(GOTESTSUM): # Build gotestsum from tools folder.
CGO_ENABLED=0 GOBIN=$(OUTPUT_TOOLS_DIR) $(GO_INSTALL) $(GOTESTSUM_PKG) $(GOTESTSUM_BIN) $(GOTESTSUM_VER)
$(GOTESTSUM): # Build gotestsum into tools folder.
@if [ ! -f $(OUTPUT_TOOLS_DIR)/$(GOTESTSUM_BIN) ]; then \
CGO_ENABLED=0 GOBIN=$(OUTPUT_TOOLS_DIR) $(GO_INSTALL) $(GOTESTSUM_PKG) $(GOTESTSUM_BIN) $(GOTESTSUM_VER); \
fi

$(KUSTOMIZE): # Build kustomize from tools folder.
CGO_ENABLED=0 GOBIN=$(OUTPUT_TOOLS_DIR) $(GO_INSTALL) $(KUSTOMIZE_PKG) $(KUSTOMIZE_BIN) $(KUSTOMIZE_VER)
$(KUSTOMIZE): # Build kustomize into tools folder.
@if [ ! -f $(OUTPUT_TOOLS_DIR)/$(KUSTOMIZE_PKG) ]; then \
CGO_ENABLED=0 GOBIN=$(OUTPUT_TOOLS_DIR) $(GO_INSTALL) $(KUSTOMIZE_PKG) $(KUSTOMIZE_BIN) $(KUSTOMIZE_VER); \
fi

$(SETUP_ENVTEST): # Build setup-envtest from tools folder.
GOBIN=$(OUTPUT_TOOLS_DIR) $(GO_INSTALL) $(SETUP_ENVTEST_PKG) $(SETUP_ENVTEST_BIN) $(SETUP_ENVTEST_VER)
$(SETUP_ENVTEST): # Build setup-envtest into tools folder.
if [ ! -f $(OUTPUT_TOOLS_DIR)/$(SETUP_ENVTEST_BIN) ]; then \
CGO_ENABLED=0 GOBIN=$(OUTPUT_TOOLS_DIR) $(GO_INSTALL) $(SETUP_ENVTEST_PKG) $(SETUP_ENVTEST_BIN) $(SETUP_ENVTEST_VER); \
fi

$(GOLANGCI_LINT): .github/workflows/golangci-lint.yml # Download golangci-lint using hack script into tools folder.
hack/ensure-golangci-lint.sh \
-b $(OUTPUT_TOOLS_DIR) \
$(shell cat .github/workflows/golangci-lint.yml | grep [[:space:]]version | sed 's/.*version: //')
$(GOLANGCI_LINT): # Build golangci-lint into tools folder.
@if [ ! -f $(OUTPUT_TOOLS_DIR)/$(GOLANGCI_LINT_BIN) ]; then \
CGO_ENABLED=0 GOBIN=$(OUTPUT_TOOLS_DIR) $(GO_INSTALL) $(GOLANGCI_LINT_PKG) $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER); \
fi

$(GORELEASER):
CGO_ENABLED=0 GOBIN=$(OUTPUT_TOOLS_DIR) $(GO_INSTALL) $(GORELEASER_PKG) $(GORELEASER_BIN) $(GORELEASER_VERSION)
$(GORELEASER): # Build goreleaser into tools folder.
@if [ ! -f $(OUTPUT_TOOLS_DIR)/$(GOLANGCI_LINT_BIN) ]; then \
CGO_ENABLED=0 GOBIN=$(OUTPUT_TOOLS_DIR) $(GO_INSTALL) $(GORELEASER_PKG) $(GORELEASER_BIN) $(GORELEASER_VERSION); \
fi
46 changes: 23 additions & 23 deletions builtin/inventory/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,40 @@ spec:
# kkzone: cn
# work_dir is the directory where the artifact is extracted.
# work_dir: /var/lib/kubekey/
# cni binary
cni_version: v1.2.0
# the version of kubernetes to be installed.
# should be greater than or equal to kube_version_min_required.
kube_version: v1.23.15
# helm binary
helm_version: v3.14.2
# docker-compose binary
dockercompose_version: v2.24.6
# harbor image tag
harbor_version: v2.10.1
# registry image tag
registry_version: 2.8.3
# keepalived image tag
keepalived_version: stable
# runc binary
runc_version: v1.1.11
# cni binary
cni_version: v1.2.0
# calicoctl binary
calico_version: v3.27.2
# etcd binary
etcd_version: v3.5.6
# harbor image tag
# harbor_version: v2.10.1
# docker-compose binary
# dockercompose_version: v2.24.6
# registry image tag
# registry_version: 2.8.3
# keepalived image tag
# keepalived_version: stable
# crictl binary
crictl_version: v1.29.0
# docker binary
docker_version: 24.0.6
# cilium helm
cilium_version: 1.15.4
# cilium_version: 1.15.4
# kubeovn helm
kubeovn_version: 0.1.0
# kubeovn_version: 0.1.0
# hybridnet helm
hybridnet_version: 0.6.8
# hybridnet_version: 0.6.8
# containerd binary
containerd_version: v1.7.0
# docker binary
docker_version: 24.0.6
# containerd_version: v1.7.0
# runc binary
# runc_version: v1.1.11
# cridockerd
cridockerd_version: v0.3.10
# the version of kubernetes to be installed.
# should be greater than or equal to kube_version_min_required.
kube_version: v1.23.15
# cridockerd_version: v0.3.10
# nfs provisioner helm version
nfs_provisioner_version: 4.0.18
# nfs_provisioner_version: 4.0.18
33 changes: 12 additions & 21 deletions builtin/inventory/inventory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,13 @@ metadata:
name: default
spec:
hosts: # your can set all nodes here. or set nodes on special groups.
# localhost: {} localhost is the default host.
# node1:
# ssh_host: xxxxx
# ssh_port: 22
# ssh_user: user
# ssh_password: password
# node2:
# ssh_host: xxxxx
# ssh_port: 22
# ssh_user: user
# ssh_password: password
# node3:
# ssh_host: xxxxx
# ssh_port: 22
# ssh_user: user
# ssh_password: password
# connector:
# type: ssh
# host: node1
# port: 22
# user: root
# password: 123456
groups:
# all kubernetes nodes.
k8s_cluster:
Expand All @@ -38,10 +29,10 @@ spec:
etcd:
hosts:
- localhost
image_registry:
hosts:
- localhost
# image_registry:
# hosts:
# - localhost
# nfs nodes for registry storage. and kubernetes nfs storage
nfs:
hosts:
- localhost
# nfs:
# hosts:
# - localhost
6 changes: 3 additions & 3 deletions builtin/playbooks/artifact_export.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
tasks:
- name: Package image
image:
pull: "{{ image_manifests }}"
when: image_manifests|length > 0
pull: "{{ .image_manifests }}"
when: .image_manifests | default list | len | lt 0
- name: Export artifact
command: |
cd {{ work_dir }} && tar -czvf kubekey-artifact.tar.gz kubekey/
cd {{ .work_dir }} && tar -czvf kubekey-artifact.tar.gz kubekey/
6 changes: 3 additions & 3 deletions builtin/playbooks/certs_renew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- vars/certs_renew.yaml
roles:
- role: certs/renew-etcd
when: groups['etcd']|length > 0 && renew_etcd
when: and (.groups.etcd | default list | len | lt 0) .renew_etcd

- hosts:
- image_registry
Expand All @@ -22,7 +22,7 @@
- vars/certs_renew.yaml
roles:
- role: certs/renew-registry
when: groups['image_registry']|length > 0 && renew_image_registry
when: and (.groups.image_registry | default list | len | lt 0) .renew_image_registry

- hosts:
- kube_control_plane
Expand All @@ -31,4 +31,4 @@
tags: ["certs"]
roles:
- role: certs/renew-kubernetes
when: groups['kube_control_plane']|length > 0 && renew_kubernetes
when: and (.groups.kube_control_plane | default list | len | lt 0) .renew_kubernetes
2 changes: 1 addition & 1 deletion builtin/playbooks/create_cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
- kube_control_plane
roles:
- role: install/certs
when: renew_certs.enabled|default_if_none:false
when: .renew_certs.enabled

- hosts:
- k8s_cluster|random
Expand Down
7 changes: 5 additions & 2 deletions builtin/playbooks/hook/post_install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
- name: Copy post install scripts to remote
ignore_errors: yes
copy:
src: "{{ work_dir }}/scripts/post_install_{{ inventory_name }}.sh"
dest: "/etc/kubekey/scripts/post_install_{{ inventory_name }}.sh"
src: |
{{ .work_dir }}/scripts/post_install_{{ .inventory_name }}.sh
dest: |
/etc/kubekey/scripts/post_install_{{ .inventory_name }}.sh
mode: 0755
- name: Execute post install scripts
command: |
for file in /etc/kubekey/scripts/post_install_*.sh; do
Expand Down
7 changes: 5 additions & 2 deletions builtin/playbooks/hook/pre_install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
- name: Copy pre install scripts to remote
ignore_errors: yes
copy:
src: "{{ work_dir }}/scripts/pre_install_{{ inventory_name }}.sh"
dest: "/etc/kubekey/scripts/pre_install_{{ inventory_name }}.sh"
src: |
{{ .work_dir }}/scripts/pre_install_{{ .inventory_name }}.sh
dest: |
/etc/kubekey/scripts/pre_install_{{ .inventory_name }}.sh
mode: 0755
- name: Execute pre install scripts
command: |
for file in /etc/kubekey/scripts/pre_install_*.sh; do
Expand Down
2 changes: 1 addition & 1 deletion builtin/playbooks/precheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- localhost
roles:
- role: precheck/artifact_check
when: artifact_file | defined
when: and .artifact.artifact_file (ne .artifact.artifact_file "")

- hosts:
- k8s_cluster
Expand Down
28 changes: 24 additions & 4 deletions builtin/playbooks/vars/create_cluster_kubernetes.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
global_registry: ""
dockerio_registry: "{% if (global_registry != '') %}{{ global_registry }}{% else %}docker.io{% endif %}"
quayio_registry: "{% if (global_registry != '') %}{{ global_registry }}{% else %}quay.io{% endif %}"
ghcrio_registry: "{% if (global_registry != '') %}{{ global_registry }}{% else %}ghcr.io{% endif %}"
k8s_registry: "{% if (global_registry != '') %}{{ global_registry }}{% else %}registry.k8s.io{% endif %}"
dockerio_registry: |
{{- if ne .global_registry "" -}}
{{ .global_registry }}
{{- else -}}
docker.io
{{- end -}}
quayio_registry: |
{{- if ne .global_registry "" -}}
{{ .global_registry }}
{{- else -}}
quay.io
{{- end -}}
ghcrio_registry: |
{{- if ne .global_registry "" -}}
{{ .global_registry }}
{{- else -}}
ghcr.io
{{- end -}}
k8s_registry: |
{{- if ne .global_registry "" -}}
{{ .global_registry }}
{{- else -}}
registry.k8s.io
{{- end -}}
security_enhancement: false
Loading

0 comments on commit 4919e63

Please sign in to comment.