Skip to content

Commit

Permalink
k8s: Make it work even if kubectl is not installed on the machine
Browse files Browse the repository at this point in the history
There's code in the k8s provider that takes care of pulling the
kubectl binary from the cluster and use that one for subsequent
operations; however, right before that happens, a few settings
are changed in kubeconfig, which means that it's necessary for
the host system to provide its own kubectl binary.

Invert the order of these operations, and make sure that we
always invoke the binary obtained from the cluster. This way, it
is possible to successfully bring up a cluster on a machine that
doesn't have kubectl installed.

kubevirt#1293

Signed-off-by: Andrea Bolognani <[email protected]>
  • Loading branch information
andreabolognani committed Feb 10, 2025
1 parent f3ed3dc commit 8428362
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cluster-up/cluster/k8s-provider-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@ function up() {
eval ${_cli:?} run $params

${_cli} scp --prefix $provider_prefix /etc/kubernetes/admin.conf - >${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kubeconfig

# Set server and disable tls check
export KUBECONFIG=${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kubeconfig
kubectl config set-cluster kubernetes --server="https://$(_main_ip):$(_port k8s)"
kubectl config set-cluster kubernetes --insecure-skip-tls-verify=true

${_cli} scp --prefix ${provider_prefix:?} /usr/bin/kubectl - >${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kubectl

chmod u+x ${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kubectl

# Set server and disable tls check
export KUBECONFIG=${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kubeconfig
${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kubectl config set-cluster kubernetes --server="https://$(_main_ip):$(_port k8s)"
${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kubectl config set-cluster kubernetes --insecure-skip-tls-verify=true

# Make sure that local config is correct
prepare_config
ssh="${_cli} --prefix $provider_prefix ssh"
Expand Down

0 comments on commit 8428362

Please sign in to comment.