Skip to main content
Question

25R2SU05 install-k8s.sh does not work anymore on Ubuntu

  • June 30, 2026
  • 3 replies
  • 35 views

Forum|alt.badge.img+7

Hello,

Im currently doing a 25R1SU05→ 25R2SU05 Release Update.
 

The command 

.\main.ps1 -resource 'KUBERNETES'

Does not work anymore:

# Verify and install snap daemon snap before installing other snaps
if ! sudo snap ack ./microk8s/snapd*.assert; then
handle_error 1 "snapd assertion failed."
fi

wildcards are not allowed anymore

INFO: Copied file: snapd_25577.snap
INFO: [2026-06-29 17:49:19.970][INFO] Installing Kubernetes on Linux Box (xxxxx-com)
INFO: [2026-06-29 17:49:19.992][INFO] Start Install-Kubernetes
INFO: xxxx.com
FullName : /home/ifs/install-k8s.sh
LastAccessTime : 6/29/2026 5:49:20 PM
LastWriteTime : 6/29/2026 5:49:20 PM
Length : 8551
UserId : 1002

INFO: [2026-06-29 17:49:20.263][ERROR] error: too many arguments for command
ERROR: snapd assertion failed.
INFO: [2026-06-29 17:49:20.282][ERROR] Error during Kubernetes installation:
error: too many arguments for command
ERROR: snapd assertion failed.
INFO: [2026-06-29 17:49:20.282][ERROR] SSH Output:
INFO: [2026-06-29 17:49:20.297][ERROR] SSH Error:
error: too many arguments for command
ERROR: snapd assertion failed.
INFO: [2026-06-29 17:49:20.297][ERROR] Execution failed: Kubernetes installation unsuccessful
INFO: [2026-06-29 17:49:20.314][ERROR] Error during Kubernetes installation: Kubernetes installation failed with exit code 1.
INFO: [2026-06-29 17:49:20.329][ERROR] Error found in Kubernetes installation failed with exit code 1.. Please check logs for details.
INFO: [2026-06-29 17:49:20.343][INFO] >>> Finalize Script Execution <<<

Solution!

Rewritten the install-k8s.sh 

#!/bin/bash

set -e

# Function for consistent error handling
handle_error() {
local exit_code=$1
local error_msg=$2
if [ "$exit_code" -ne 0 ]; then
echo "ERROR: $error_msg" >&2
exit "$exit_code" # No error message here (PowerShell will catch it)
fi
}

# Verify and install snap daemon snap before installing other snaps
for file in ./microk8s/snapd*.assert; do
if ! sudo snap ack "$file"; then
handle_error 1 "snapd assertion failed on $file."
fi
done

for file in ./microk8s/snapd*.snap; do
if ! sudo snap install "$file" --classic; then
handle_error 1 "snapd snap installation failed on $file."
fi
done

# Verify that snapd is installed
if ! sudo snap list | grep -q "^snapd"; then
handle_error 1 "snapd must be installed before installing other snaps."
fi

ASSERTS=(
./microk8s/core*.assert
./microk8s/microk8s*.assert
./microk8s/kubectl*.assert
)

SNAPS=(
./microk8s/core*.snap
./microk8s/microk8s*.snap
./microk8s/kubectl*.snap
)

# Install snaps for ubuntu core, microk8s and kubectl
for ASSERT in "${ASSERTS[@]}"; do
for file in $ASSERT; do
# Skip if no files matched
[[ -e "$file" ]] || continue

if ! sudo snap ack "$file"; then
handle_error 1 "Assertion failed on $file."
fi
done
done

for SNAP in "${SNAPS[@]}"; do
for file in $SNAP; do
[[ -e "$file" ]] || continue

if ! sudo snap install "$file" --classic; then
handle_error 1 "Snap installation failed on $file."
fi
done
done

PATH=$PATH:/snap/bin

sudo usermod -a -G microk8s ifs || handle_error 1 "Failed to add user ifs to microk8s group"

if [[ -z "$2" ]]; then
echo "No argument supplied"
else

DOCKER_REGISTRY=$2
PROTOCOL=$3
DOCKER_REPO_PATH=$4
DOCKER_USERNAME=$5
DOCKER_PASSWORD=$6

sudo sed -i "/sandbox_image/s|registry.k8s.io|$DOCKER_REGISTRY/$DOCKER_REPO_PATH|g" /var/snap/microk8s/current/args/containerd-template.toml

sudo mkdir -p "/var/snap/microk8s/current/args/certs.d/$DOCKER_REGISTRY"

sudo tee "/var/snap/microk8s/current/args/certs.d/$DOCKER_REGISTRY/hosts.toml" > /dev/null <<EOF
server = "$PROTOCOL://$DOCKER_REGISTRY"

[host."$PROTOCOL://$DOCKER_REGISTRY"]
capabilities = ["pull", "resolve"]
skip_verify = true
[host."$PROTOCOL://$DOCKER_REGISTRY".header]
authorization = "Basic $(echo -n "${DOCKER_USERNAME}:${DOCKER_PASSWORD}" | base64 -w0)"
EOF

# Enabling use of strong cryptographic ciphers for apiserver and kubelet
for file in /var/snap/microk8s/current/args/kube-apiserver /var/snap/microk8s/current/args/kubelet; do
if sudo grep -q "^--tls-cipher-suites=" "$file"; then
sudo sed -i '/^--tls-cipher-suites=/d' "$file" || handle_error 1 "Failed to remove existing tls-cipher-suites from $file"
fi

echo "--tls-cipher-suites=TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_256_GCM_SHA384" | sudo tee -a "$file" > /dev/null || handle_error 1 "Failed to add tls-cipher-suites to $file"
done

# Enforcing minimum tls Version
echo "--min-tls-version=tls13" | sudo tee -a /var/snap/microk8s/current/args/cluster-agent > /dev/null || handle_error 1 "Failed to set min-tls-version"

sudo microk8s stop || handle_error 1 "Failed to stop microk8s"
sudo microk8s start || handle_error 1 "Failed to start microk8s"
sleep 120

sudo microk8s kubectl delete -f /var/snap/microk8s/current/args/cni-network/cni.yaml || handle_error 1 "Failed to delete existing cni configuration"

sudo rm -rf /var/snap/microk8s/current/args/cni-network/cni.yaml || handle_error 1 "Failed to remove existing cni.yaml"
sudo cp /home/ifs/microk8s/cni.yaml /var/snap/microk8s/current/args/cni-network/cni.yaml || handle_error 1 "Failed to copy new cni.yaml"

sudo sed -i "s|REMOTE_ARTIFACT_DOCKER_REPO_PATH|$DOCKER_REPO_PATH|g" /var/snap/microk8s/current/args/cni-network/cni.yaml || handle_error 1 "Failed to update cni.yaml with docker repo path"
sudo sed -i "s|REMOTE_ARTIFACT_DOCKER_REPO|$DOCKER_REGISTRY|g" /var/snap/microk8s/current/args/cni-network/cni.yaml || handle_error 1 "Failed to update cni.yaml with docker registry"

sudo microk8s kubectl create -f /var/snap/microk8s/current/args/cni-network/cni.yaml || handle_error 1 "Failed to apply new cni configuration"

# Enable MicroK8s Add-ons
sudo microk8s enable dns || handle_error 1 "Failed to enable dns"
sudo microk8s enable metrics-server || handle_error 1 "Failed to enable metrics-server"

sudo microk8s kubectl set image deployment/coredns coredns="${DOCKER_REGISTRY}/${DOCKER_REPO_PATH}/coredns/coredns:1.12.3" -n kube-system || handle_error 1 "Failed to set coredns image"
sudo microk8s kubectl set image deployment/metrics-server metrics-server="${DOCKER_REGISTRY}/${DOCKER_REPO_PATH}/metrics-server/metrics-server:v0.8.0" -n kube-system || handle_error 1 "Failed to set metrics-server image"

# Installing longhorn storage only if nodes joined as HA
if [[ "$1" == "True" ]]; then
sudo microk8s enable community || handle_error 1 "Failed to enable community"
sudo systemctl enable iscsid || handle_error 1 "Failed to enable iscsid"
else
sudo microk8s enable hostpath-storage || handle_error 1 "Failed to enable hostpath-storage"
sudo microk8s kubectl get deploy -n kube-system hostpath-provisioner -o yaml | sed -E "s|busybox:1.28.4|$DOCKER_REGISTRY/$DOCKER_REPO_PATH/busybox:1.28.4|g" | sudo microk8s kubectl apply -f - || handle_error 1 "Failed to update hostpath-provisioner"
sudo microk8s kubectl set image deployment/hostpath-provisioner hostpath-provisioner="${DOCKER_REGISTRY}/${DOCKER_REPO_PATH}/cdkbot/hostpath-provisioner:1.6.0" -n kube-system || handle_error 1 "Failed to set hostpath-provisioner image"
fi
fi

# Hold the auto update forever for each installed snap and verify the hold is applied correctly
INSTALLED_SNAPS=$(snap list | awk 'NR>1 {print $1}')

for SNAP in ${INSTALLED_SNAPS}; do
if ! sudo snap refresh --hold "${SNAP}" > /dev/null 2>&1; then
handle_error 1 "Failed to apply the update hold for ${SNAP}!"
fi

SNAP_STATUS=$(snap list "${SNAP}" | awk 'NR==1 {print "Name Notes"; next} {print $1, $NF}')
if [[ "${SNAP_STATUS}" != *"held"* ]]; then
handle_error 1 "Snap ${SNAP} is not held correctly!"
else
echo "General refreshes of Snap ${SNAP} held indefinitely and verified"
fi
done

# prevents the system for initiating connections to Snap Store (required snapd 2.61 and above)
if sudo snap set system store.access=offline; then
echo "System store access has been set to offline"
else
handle_error 1 "Failed to set system store access to offline!"
fi

# Add hostname fqdn to csr config
HOSTNAME_FQDN=$(hostname -f 2>/dev/null)

if [[ -n "$HOSTNAME_FQDN" ]]; then
echo "Adding FQDN ($HOSTNAME_FQDN) to csr.conf.template..."

if sudo grep -q "^\[ *alt_names *\]" /var/snap/microk8s/current/certs/csr.conf.template; then
sudo sed -i "/^\[ *alt_names *\]/a DNS.99 = $HOSTNAME_FQDN" /var/snap/microk8s/current/certs/csr.conf.template
echo "Successfully added DNS.99 = $HOSTNAME_FQDN under [ alt_names ]"
else
handle_error 1 "[ alt_names ] section not found in csr.conf.template!"
fi
else
echo "No FQDN detected for hostname. Skipping DNS.99 entry in csr.conf.template"
fi

MAX_RETRIES=3
SLEEP_SECONDS=5

# Refresh server.crt
for i in $(seq 1 $MAX_RETRIES); do
echo "Attempt $i: Refreshing server.crt..."
sudo microk8s refresh-certs -e server.crt && {
echo "Successfully refreshed server.crt"
break
}
echo "Failed to refresh server.crt"
sleep $SLEEP_SECONDS
if [ "$i" -eq "$MAX_RETRIES" ]; then
handle_error 1 "ERROR: Could not refresh server.crt after $MAX_RETRIES attempts."
fi
done

# Refresh front-proxy-client.crt
for i in $(seq 1 $MAX_RETRIES); do
echo "Attempt $i: Refreshing front-proxy-client.crt..."
sudo microk8s refresh-certs -e front-proxy-client.crt && {
echo "Successfully refreshed front-proxy-client.crt"
break
}
echo "Failed to refresh front-proxy-client.crt"
sleep $SLEEP_SECONDS
if [ "$i" -eq "$MAX_RETRIES" ]; then
handle_error 1 "ERROR: Could not refresh front-proxy-client.crt after $MAX_RETRIES attempts."
fi
done

OS: Ubuntu with manually installed snapd

snapd/noble-updates,now 2.75.2+ubuntu24.04 amd64 [installed]
snapd/noble-security 2.73+ubuntu24.04.2 amd64
snapd/noble 2.62+24.04build1 amd64

 

3 replies

Forum|alt.badge.img
  • Do Gooder (Customer)
  • July 21, 2026

Hi MCIPSTEV,

We have seen the same behavior across multiple installations. The root cause is that the binaries from the previous installation were not removed before the update.

Before installing a new RU/SU, all existing binaries must be deleted completely, and the new folder must then be copied into place.

In the installation directory, there are multiple files such as:

snapd_25577.snap

and similar files remaining from the previous installation. As a result, the loop processes these arguments one after another, which leads to the observed behavior.

Removing the old binaries before copying the new RU/SU folder resolved these issues for us.

 

Best Regards

Patrick


Forum|alt.badge.img+7
  • Author
  • Sidekick (Customer)
  • July 21, 2026

Hi MCIPSTEV,

We have seen the same behavior across multiple installations. The root cause is that the binaries from the previous installation were not removed before the update.

Before installing a new RU/SU, all existing binaries must be deleted completely, and the new folder must then be copied into place.

In the installation directory, there are multiple files such as:

snapd_25577.snap

and similar files remaining from the previous installation. As a result, the loop processes these arguments one after another, which leads to the observed behavior.

Removing the old binaries before copying the new RU/SU folder resolved these issues for us.

 

Best Regards

Patrick

This means that the main.ps script does fully do the job, because it should delete all snaps and reinstall the snapd


Forum|alt.badge.img
  • Do Gooder (Customer)
  • July 21, 2026

Yes, this is working as designed.

The idea behind the implementation is that main.ps1 remains generic and the version of the snapd file is detected dynamically. It would be possible to enhance the logic to select only the file with the highest version number, but this step was intentionally not implemented because the installation procedure requires deleting the binary directory before copying the new binaries.

The binaries included with the latest RU/SU always contain the complete set of required binaries. Therefore, there should never be multiple versions of files such as snapd*.snap or snapd*.assert in the directory.

The relevant section is:

# Verify and install snap daemon snap before installing other snaps
if ! sudo snap ack ./microk8s/snapd*.assert; then
handle_error 1 "snapd assertion failed."
fi

If older binaries are left in the directory, the wildcard matches multiple files, causing them to be processed sequentially, which leads to the observed behavior.