mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
fix: kubectl version check failed
Signed-off-by: William Wang <williamw0825@gmail.com>
This commit is contained in:
parent
d5c928b61d
commit
0c39ac1d17
|
|
@ -30,12 +30,17 @@
|
|||
|
||||
- name: Check if kubectl is installed
|
||||
ignore_errors: true
|
||||
command: kubectl version --short
|
||||
command: |
|
||||
{{- if .kubernetes.kube_version | semverCompare ">=v1.28.0" -}}
|
||||
kubectl version --client
|
||||
{{- else -}}
|
||||
kubectl version --client --short
|
||||
{{- end -}}
|
||||
register: kubectl_install_version
|
||||
register_type: yaml
|
||||
- name: Sync kubectl to remote
|
||||
when: |
|
||||
or (.kubectl_install_version.error | empty | not) ((get .kubectl_install_version.stdout "Server Version") | ne .kube_version)
|
||||
or (.kubectl_install_version.error | empty | not) ((get .kubectl_install_version.stdout "Client Version") | ne .kube_version)
|
||||
copy:
|
||||
src: >-
|
||||
{{ .binary_dir }}/kube/{{ .kube_version }}/{{ .binary_type }}/kubectl
|
||||
|
|
|
|||
|
|
@ -32,13 +32,18 @@
|
|||
|
||||
- name: Binary | Check if kubectl is installed
|
||||
ignore_errors: true
|
||||
command: kubectl version --short
|
||||
command: |
|
||||
{{- if .kubernetes.kube_version | semverCompare ">=v1.28.0" -}}
|
||||
kubectl version --client
|
||||
{{- else -}}
|
||||
kubectl version --client --short
|
||||
{{- end -}}
|
||||
register: kubectl_install_version
|
||||
register_type: yaml
|
||||
|
||||
- name: Binary | Install kubectl if not present or version mismatch
|
||||
when: |
|
||||
or (.kubectl_install_version.error | empty | not) ((get .kubectl_install_version.stdout "Server Version") | ne .kubernetes.kube_version)
|
||||
or (.kubectl_install_version.error | empty | not) ((get .kubectl_install_version.stdout "Client Version") | ne .kubernetes.kube_version)
|
||||
copy:
|
||||
src: >-
|
||||
{{ .binary_dir }}/kube/{{ .kubernetes.kube_version }}/{{ .binary_type }}/kubectl
|
||||
|
|
|
|||
Loading…
Reference in New Issue