Skip to content

Commit

Permalink
fix: inventory_name is localhost, install failed (#2344)
Browse files Browse the repository at this point in the history
* fix: misspelling

Signed-off-by: joyceliu <[email protected]>

* fix: misspelling

Signed-off-by: joyceliu <[email protected]>

* fix: misspelling

Signed-off-by: joyceliu <[email protected]>

* fix: misspelling

Signed-off-by: joyceliu <[email protected]>

* feat: user go-template instance pongo2-template

Signed-off-by: joyceliu <[email protected]>

* feat: not set incorrect

Signed-off-by: joyceliu <[email protected]>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <[email protected]>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <[email protected]>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <[email protected]>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <[email protected]>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <[email protected]>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <[email protected]>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <[email protected]>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <[email protected]>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <[email protected]>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <[email protected]>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <[email protected]>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <[email protected]>

* feat: more beautiful progress bar

Signed-off-by: joyceliu <[email protected]>

* feat: deal localhost node.

Signed-off-by: joyceliu <[email protected]>

---------

Signed-off-by: joyceliu <[email protected]>
Co-authored-by: joyceliu <[email protected]>
  • Loading branch information
redscholar and joyceliu authored Aug 5, 2024
1 parent 4919e63 commit 526e234
Show file tree
Hide file tree
Showing 38 changed files with 373 additions and 285 deletions.
48 changes: 24 additions & 24 deletions builtin/roles/addons/cni/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
cni:
kube_proxy: |
{{- .kubernetes.kube_proxy.enabled | default true -}}
{{ .kubernetes.kube_proxy.enabled | default true }}
# apiVersion for policy may be changed for difference kubernetes version. https://kube-api.ninja
api_version_policy: |
{{- if .kube_version | semverCompare "<v1.21" -}}
{{- if .kube_version | semverCompare "<v1.21" }}
policy/v1beta1
{{- else -}}
{{- else }}
policy/v1
{{- end -}}
{{- end }}
kube_network_plugin: |
{{- .kubernetes.kube_network_plugin | default "calico" -}}
{{ .kubernetes.kube_network_plugin | default "calico" }}
# ip cidr config.
# dual stack. support ipv4/ipv6
ipv6_support: |
{{- if gt ( .kubernetes.networking.pod_cidr | default "10.233.64.0/18" | splitList "," | len) 1 -}}
{{- if gt ( .kubernetes.networking.pod_cidr | default "10.233.64.0/18" | splitList "," | len) 1 }}
true
{{- else -}}
{{- else }}
false
{{- end -}}
{{- end }}
kube_pods_v4_cidr: |
{{- .kubernetes.networking.pod_cidr | default "10.233.64.0/18" | splitList "," | first -}}
{{ .kubernetes.networking.pod_cidr | default "10.233.64.0/18" | splitList "," | first }}
kube_pods_v6_cidr: |
{{- if .cni.ipv6_support -}}
{{- .kubernetes.networking.pod_cidr | splitList "," | last -}}
{{- end -}}
{{- if .cni.ipv6_support }}
{{ .kubernetes.networking.pod_cidr | splitList "," | last }}
{{- end }}
node_cidr_mask_size: |
{{- .kubernetes.controller_manager.kube_network_node_prefix | default 24 -}}
{{ .kubernetes.controller_manager.kube_network_node_prefix | default 24 }}
kube_svc_cidr: |
{{- .kubernetes.networking.service_cidr | default "10.233.0.0/18" -}}
{{ .kubernetes.networking.service_cidr | default "10.233.0.0/18" }}
multus:
enabled: false
image: |
{{ .dockerio_registry }}/kubesphere/multus-cni:v3.8
calico:
# when cluster node > 50. it default true.
typha: |
{{- if gt (.groups.k8s_cluster | default list | len) 50 -}}
{{- if gt (.groups.k8s_cluster | default list | len) 50 }}
true
{{- else -}}
{{- else }}
false
{{- end -}}
{{- end }}
veth_mtu: 0
ipip_mode: Always
vxlan_mode: Never
Expand Down Expand Up @@ -94,19 +94,19 @@ cni:
spire_server_repository: |
{{ .ghcrio_registry }}/spiffe/spire-server
k8s_endpoint: |
{{- if and .kubernetes.control_plane_endpoint (ne .kubernetes.control_plane_endpoint "") -}}
{{- .kubernetes.control_plane_endpoint -}}
{{- else -}}
{{- .groups.kube_control_plane | default list | first -}}
{{- end -}}
{{- if and .kubernetes.control_plane_endpoint (ne .kubernetes.control_plane_endpoint "") }}
{{ .kubernetes.control_plane_endpoint }}
{{- else }}
{{ .groups.kube_control_plane | default list | first }}
{{- end }}
k8s_port: |
{{- .kubernetes.apiserver.port | default 6443 -}}
{{ .kubernetes.apiserver.port | default 6443 }}
kubeovn:
replica: 1
registry: |
{{ .dockerio_registry }}/kubeovn
hybridnet:
registry: |
{{- .dockerio_registry -}}
{{ .dockerio_registry }}
# hybridnet_image: hybridnetdev/hybridnet
# hybridnet_tag: v0.8.8
8 changes: 4 additions & 4 deletions builtin/roles/addons/cni/tasks/cilium.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
--set operator.replicas={{ .cni.cilium.operator_replicas }} \
--set ipv6.enabled={{ .cni.ipv6_support }} \
--set ipv4NativeRoutingCIDR: {{ .cni.kube_pods_v4_cidr }} \
{{- if .cni.ipv6_support -}}
{{- if .cni.ipv6_support }}
--set ipv6NativeRoutingCIDR: {{ .cni.kube_pods_v6_cidr }} \
{{- end -}}
{{- if .cni.kube_proxy -}}
{{- end }}
{{- if .cni.kube_proxy }}
--set kubeProxyReplacement=strict --set k8sServiceHost={{ .cni.cilium.k8s_endpoint }} --set k8sServicePort={{ .cni.cilium.k8s_port }}
{{- end -}}
{{- end }}
8 changes: 4 additions & 4 deletions builtin/roles/addons/cni/tasks/hybridnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
- name: Install hybridnet
command: |
helm install hybridnet /etc/kubernetes/cni/hybridnet-{{ .hybridnet_version }}.tgz --namespace kube-system \
{{- if ne .cni.hybridnet.hybridnet_image "" -}}
{{- if ne .cni.hybridnet.hybridnet_image "" }}
--set images.hybridnet.image={{ .cni.hybridnet.hybridnet_image }} \
{{- end -}}
{{- if ne .cni.hybridnet.hybridnet_tag "" -}}
{{- end }}
{{- if ne .cni.hybridnet.hybridnet_tag "" }}
--set images.hybridnet.tag={{ .cni.hybridnet.hybridnet_tag }} \
{{- end -}}
{{- end }}
--set image.registryURL={{ .cni.hybridnet.registry }} \
14 changes: 7 additions & 7 deletions builtin/roles/addons/cni/tasks/kubeovn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
- name: Install kubeovn
command: |
helm install kubeovn /etc/kubernetes/cni/kubeovn-{{ .kubeovn_version }}.tgz --set replicaCount={{ .cni.kubeovn.replica }} \
{{ $ips := list }}
{{- range .groups.kube_control_plane | default list -}}
{{- $ips = append $ips (index $.inventory_hosts . "internal_ipv4") -}}
{{- end -}}
--set MASTER_NODES={{ $ips |join "," }} \
{{- $ips := list }}
{{- range .groups.kube_control_plane | default list }}
{{- $ips = append $ips (index $.inventory_hosts . "internal_ipv4") }}
{{- end }}
--set MASTER_NODES={{ $ips | join "," }} \
--set global.registry.address={{ .cni.kubeovn.registry }} \
--set ipv4.POD_CIDR={{ .cni.kubeovn.kube_pods_v4_cidr }} --set ipv4.SVC_CIDR={{ .cni.kubeovn.kube_svc_cidr }} \
{{- if .cni.ipv6_support -}}
{{- if .cni.ipv6_support }}
--set networking.NET_STACK=dual_stack \
--set dual_stack.POD_CIDR={{ .cni.kubeovn.kube_pods_v4_cidr }},{{ .cni.kubeovn.kube_pods_v6_cidr }} \
--set dual_stack.SVC_CIDR={{ .cni.kubeovn.kube_svc_cidr }} \
{{- end -}}
{{- end }}
10 changes: 7 additions & 3 deletions builtin/roles/addons/cni/templates/calico/v3.27.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ data:
"log_file_path": "/var/log/calico/cni/cni.log",
"datastore_type": "kubernetes",
"nodename": "__KUBERNETES_NODE_NAME__",
"mtu": __CNI_MTU__,
"mtu": "__CNI_MTU__",
"ipam": {
"type": "calico-ipam"
},
Expand Down Expand Up @@ -5149,7 +5149,9 @@ spec:
spec:
nodeSelector:
kubernetes.io/os: linux
{{ .cni.calico.node_selector|to_yaml:8|safe }}
{{- if .cni.calico.node_selector }}
{{ .cni.calico.node_selector | toYaml | indent 8 }}
{{- end }}
tolerations:
# Mark the pod as a critical add-on for rescheduling.
- key: CriticalAddonsOnly
Expand Down Expand Up @@ -5244,7 +5246,9 @@ spec:
spec:
nodeSelector:
kubernetes.io/os: linux
{{ .cni.calico.node_selector|to_yaml:8|safe }}
{{- if .cni.calico.node_selector }}
{{ .cni.calico.node_selector| toYaml | indent 8 }}
{{- end }}
hostNetwork: true
# Typha supports graceful shut down, disconnecting clients slowly during the grace period.
# The TYPHA_SHUTDOWNTIMEOUTSECS env var should be kept in sync with this value.
Expand Down
2 changes: 1 addition & 1 deletion builtin/roles/addons/sc/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ sc:
enabled: false
default: false
server: |
{{ groups.nfs | first }}
{{ .groups.nfs | default list | first }}
path: /share/kubernetes
14 changes: 7 additions & 7 deletions builtin/roles/certs/renew-kubernetes/tasks/kube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@
tags: ["certs"]
run_once: true
command: |
{{- if .kubeadm_install_version.stdout | semverCompare "<v1.20.0" -}}
{{- if .kubeadm_install_version.stdout | semverCompare "<v1.20.0" }}
/usr/local/bin/kubeadm alpha certs renew apiserver
/usr/local/bin/kubeadm alpha certs renew apiserver-kubelet-client
/usr/local/bin/kubeadm alpha certs renew front-proxy-client
/usr/local/bin/kubeadm alpha certs renew admin.conf
/usr/local/bin/kubeadm alpha certs renew controller-manager.conf
/usr/local/bin/kubeadm alpha certs renew scheduler.conf
{{- if and (.kubernetes.etcd.deployment_type | eq "internal") .renew_etcd -}}
{{- if and (.kubernetes.etcd.deployment_type | eq "internal") .renew_etcd }}
/usr/local/bin/kubeadm alpha certs renew etcd-healthcheck-client
/usr/local/bin/kubeadm alpha certs renew etcd-peer
/usr/local/bin/kubeadm alpha certs renew etcd-server
{{- end -}}
{{- else -}}
{{- end }}
{{- else }}
/usr/local/bin/kubeadm certs renew apiserver
/usr/local/bin/kubeadm certs renew apiserver-kubelet-client
/usr/local/bin/kubeadm certs renew front-proxy-client
/usr/local/bin/kubeadm certs renew admin.conf
/usr/local/bin/kubeadm certs renew controller-manager.conf
/usr/local/bin/kubeadm certs renew scheduler.conf
{{- if and (.kubernetes.etcd.deployment_type | eq "internal") .renew_etcd -}}
{{- if and (.kubernetes.etcd.deployment_type | eq "internal") .renew_etcd }}
/usr/local/bin/kubeadm certs renew etcd-healthcheck-client
/usr/local/bin/kubeadm certs renew etcd-peer
/usr/local/bin/kubeadm certs renew etcd-server
{{- end -}}
{{- end -}}
{{- end }}
{{- end }}
- name: Fetch kubeconfig to local
tags: ["certs"]
Expand Down
14 changes: 7 additions & 7 deletions builtin/roles/certs/renew-kubernetes/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
- name: Reload kubernetes pods
tags: [ "certs" ]
command: |
{{- if .cri.container_manager | eq "docker" -}}
{{- if .cri.container_manager | eq "docker" }}
docker ps -af name=k8s_PODS_kube-apiserver* -q | xargs --no-run-if-empty docker rm -f
docker ps -af name=k8s_PODS_kube-controller-manager* -q | xargs --no-run-if-empty docker rm -f
docker ps -af name=k8s_PODS_kube-scheduler* -q | xargs --no-run-if-empty docker rm -f
{{- if and (.kubernetes.etcd.deployment_type | eq "docker") .renew_etcd -}}
{{- if and (.kubernetes.etcd.deployment_type | eq "docker") .renew_etcd }}
docker ps -af name=k8s_PODS_etcd* -q | xargs --no-run-if-empty docker rm -f
{{- end -}}
{{- else -}}
{{- end }}
{{- else }}
crictl pods --name kube-apiserver-* -q | xargs -I% --no-run-if-empty bash -c 'crictl stopp % && crictl rmp %'
crictl pods --name kube-controller-manager-* -q | xargs -I% --no-run-if-empty bash -c 'crictl stopp % && crictl rmp %'
crictl pods --name kube-scheduler-* -q | xargs -I% --no-run-if-empty bash -c 'crictl stopp % && crictl rmp %'
{{- if and (.kubernetes.etcd.deployment_type | eq "internal") .renew_etcd -}}
{{- if and (.kubernetes.etcd.deployment_type | eq "internal") .renew_etcd }}
crictl pods --name etcd-* -q | xargs -I% --no-run-if-empty bash -c 'crictl stopp % && crictl rmp %'
{{- end -}}
{{- end -}}
{{- end }}
{{- end }}
Loading

0 comments on commit 526e234

Please sign in to comment.