Skip to content

Commit

Permalink
fix version comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
cstanislawski committed Oct 25, 2024
1 parent 4a954ea commit 4c4c67f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions kubelift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,13 @@ function join_worker_nodes() {
function verify_version_compatibility() {
local nodes_versions
nodes_versions=$(ssh -o StrictHostKeyChecking=no "$SSH_USER@$CONTROL_PLANE_IP" \
kubectl get nodes -o=jsonpath='{range .items[*]}{.status.nodeInfo.kubeletVersion}{"\n"}{end}' | sort -u)
"kubectl get nodes -o jsonpath='{.items[*].status.nodeInfo.kubeletVersion}'") || \
error "Failed to get cluster version info"

[[ -z "$nodes_versions" ]] && error "No nodes found in the cluster"

local current_version
current_version=$(echo "$nodes_versions" | head -1)
current_version=$(echo "$nodes_versions" | tr ' ' '\n' | sort -u | head -1)

[[ $current_version != "v$KUBERNETES_VERSION" ]] || error "Cluster already at version $KUBERNETES_VERSION"

Expand Down

0 comments on commit 4c4c67f

Please sign in to comment.