Install kubectl client during K3s cluster installation 79/14579/1
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 19 Sep 2024 10:38:36 +0000 (12:38 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 19 Sep 2024 12:03:49 +0000 (14:03 +0200)
Change-Id: I09743f3bf8f8c3c26112e78303ee2b6017f99a7e
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
installers/install_k3s_cluster.sh

index 86bc135..e117ab4 100755 (executable)
@@ -16,6 +16,7 @@
 set +eux
 
 # K3s releases: https://github.com/k3s-io/k3s/releases/
+K8S_CLIENT_VERSION="v1.29.3"
 K8S_VERSION="v1.29.3+k3s1"
 
 # configure registry
@@ -143,6 +144,15 @@ function check_for_readiness() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
+# Install kubectl client
+function install_kubectl() {
+    [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
+    curl -LO "https://dl.k8s.io/release/${K8S_CLIENT_VERSION}/bin/linux/amd64/kubectl"
+    sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
+    rm kubectl
+    [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
+}
+
 # Initializes kubeconfig file
 function save_kubeconfig() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
@@ -226,5 +236,6 @@ track k8scluster k3s_node_ready_ok
 # update_service_nodeport_range
 # check_for_readiness
 # track k8scluster k3s_update_nodeport_range_ok
+install_kubectl
 save_kubeconfig
 track k8scluster k3s_creds_ok