diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 5a99dce4..c8793c28 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -12,6 +12,8 @@ ## Bug Fixes +* [#491](https://github.com/suse-edge/edge-image-builder/issues/491) - Large Helm manifests fail to install + --- # v1.1.0-rc1 diff --git a/pkg/combustion/templates/k3s-multi-node-installer.sh.tpl b/pkg/combustion/templates/k3s-multi-node-installer.sh.tpl index 42322189..b296835f 100644 --- a/pkg/combustion/templates/k3s-multi-node-installer.sh.tpl +++ b/pkg/combustion/templates/k3s-multi-node-installer.sh.tpl @@ -38,6 +38,28 @@ CONFIGFILE={{ .configFilePath }}/{{ .initialiserConfigFile }} mkdir -p /opt/eib-k8s/manifests cp {{ .manifestsPath }}/* /opt/eib-k8s/manifests/ +cat <<- 'EOF' > /opt/eib-k8s/create_manifests.sh +#!/bin/bash +set -x +failed=false + +for file in /opt/eib-k8s/manifests/*; do + output=$(/opt/bin/kubectl create -f "$file" --kubeconfig=/etc/rancher/k3s/k3s.yaml 2>&1) + + if [ $? != 0 ]; then + if ! echo "$output" | grep -q "AlreadyExists"; then + failed=true + fi + fi +done + +if [ $failed = "true" ]; then + exit 1 +fi +EOF + +chmod +x /opt/eib-k8s/create_manifests.sh + cat <<- EOF > /etc/systemd/system/kubernetes-resources-install.service [Unit] Description=Kubernetes Resources Install @@ -53,7 +75,7 @@ WantedBy=multi-user.target Type=oneshot Restart=on-failure RestartSec=60 -ExecStart=/opt/bin/kubectl apply -f /opt/eib-k8s/manifests --kubeconfig=/etc/rancher/k3s/k3s.yaml +ExecStart=/opt/eib-k8s/create_manifests.sh # Disable the service and clean up ExecStartPost=/bin/sh -c "systemctl disable kubernetes-resources-install.service" ExecStartPost=rm -f /etc/systemd/system/kubernetes-resources-install.service diff --git a/pkg/combustion/templates/k3s-single-node-installer.sh.tpl b/pkg/combustion/templates/k3s-single-node-installer.sh.tpl index f3c25e22..e591a044 100644 --- a/pkg/combustion/templates/k3s-single-node-installer.sh.tpl +++ b/pkg/combustion/templates/k3s-single-node-installer.sh.tpl @@ -12,6 +12,28 @@ umount /var mkdir -p /opt/eib-k8s/manifests cp {{ .manifestsPath }}/* /opt/eib-k8s/manifests/ +cat <<- 'EOF' > /opt/eib-k8s/create_manifests.sh +#!/bin/bash +set -x +failed=false + +for file in /opt/eib-k8s/manifests/*; do + output=$(/opt/bin/kubectl create -f "$file" --kubeconfig=/etc/rancher/k3s/k3s.yaml 2>&1) + + if [ $? != 0 ]; then + if ! echo "$output" | grep -q "AlreadyExists"; then + failed=true + fi + fi +done + +if [ $failed = "true" ]; then + exit 1 +fi +EOF + +chmod +x /opt/eib-k8s/create_manifests.sh + cat <<- EOF > /etc/systemd/system/kubernetes-resources-install.service [Unit] Description=Kubernetes Resources Install @@ -27,7 +49,7 @@ WantedBy=multi-user.target Type=oneshot Restart=on-failure RestartSec=60 -ExecStart=/opt/bin/kubectl apply -f /opt/eib-k8s/manifests --kubeconfig=/etc/rancher/k3s/k3s.yaml +ExecStart=/opt/eib-k8s/create_manifests.sh # Disable the service and clean up ExecStartPost=/bin/sh -c "systemctl disable kubernetes-resources-install.service" ExecStartPost=rm -f /etc/systemd/system/kubernetes-resources-install.service diff --git a/pkg/combustion/templates/rke2-multi-node-installer.sh.tpl b/pkg/combustion/templates/rke2-multi-node-installer.sh.tpl index 94df592d..889c9abc 100644 --- a/pkg/combustion/templates/rke2-multi-node-installer.sh.tpl +++ b/pkg/combustion/templates/rke2-multi-node-installer.sh.tpl @@ -38,6 +38,28 @@ CONFIGFILE={{ .configFilePath }}/{{ .initialiserConfigFile }} mkdir -p /opt/eib-k8s/manifests cp {{ .manifestsPath }}/* /opt/eib-k8s/manifests/ +cat <<- 'EOF' > /opt/eib-k8s/create_manifests.sh +#!/bin/bash +set -x +failed=false + +for file in /opt/eib-k8s/manifests/*; do + output=$(/opt/eib-k8s/kubectl create -f "$file" --kubeconfig /etc/rancher/rke2/rke2.yaml 2>&1) + + if [ $? != 0 ]; then + if ! echo "$output" | grep -q "AlreadyExists"; then + failed=true + fi + fi +done + +if [ $failed = "true" ]; then + exit 1 +fi +EOF + +chmod +x /opt/eib-k8s/create_manifests.sh + cat <<- EOF > /etc/systemd/system/kubernetes-resources-install.service [Unit] Description=Kubernetes Resources Install @@ -55,7 +77,7 @@ Restart=on-failure RestartSec=60 # Copy kubectl in order to avoid SELinux permission issues ExecStartPre=cp /var/lib/rancher/rke2/bin/kubectl /opt/eib-k8s/kubectl -ExecStart=/opt/eib-k8s/kubectl apply -f /opt/eib-k8s/manifests --kubeconfig /etc/rancher/rke2/rke2.yaml +ExecStart=/opt/eib-k8s/create_manifests.sh # Disable the service and clean up ExecStartPost=/bin/sh -c "systemctl disable kubernetes-resources-install.service" ExecStartPost=rm -f /etc/systemd/system/kubernetes-resources-install.service diff --git a/pkg/combustion/templates/rke2-single-node-installer.sh.tpl b/pkg/combustion/templates/rke2-single-node-installer.sh.tpl index 3928463b..8bc1d862 100644 --- a/pkg/combustion/templates/rke2-single-node-installer.sh.tpl +++ b/pkg/combustion/templates/rke2-single-node-installer.sh.tpl @@ -12,6 +12,28 @@ umount /var mkdir -p /opt/eib-k8s/manifests cp {{ .manifestsPath }}/* /opt/eib-k8s/manifests/ +cat <<- 'EOF' > /opt/eib-k8s/create_manifests.sh +#!/bin/bash +set -x +failed=false + +for file in /opt/eib-k8s/manifests/*; do + output=$(/opt/eib-k8s/kubectl create -f "$file" --kubeconfig /etc/rancher/rke2/rke2.yaml 2>&1) + + if [ $? != 0 ]; then + if ! echo "$output" | grep -q "AlreadyExists"; then + failed=true + fi + fi +done + +if [ $failed = "true" ]; then + exit 1 +fi +EOF + +chmod +x /opt/eib-k8s/create_manifests.sh + cat <<- EOF > /etc/systemd/system/kubernetes-resources-install.service [Unit] Description=Kubernetes Resources Install @@ -29,7 +51,7 @@ Restart=on-failure RestartSec=60 # Copy kubectl in order to avoid SELinux permission issues ExecStartPre=cp /var/lib/rancher/rke2/bin/kubectl /opt/eib-k8s/kubectl -ExecStart=/opt/eib-k8s/kubectl apply -f /opt/eib-k8s/manifests --kubeconfig /etc/rancher/rke2/rke2.yaml +ExecStart=/opt/eib-k8s/create_manifests.sh # Disable the service and clean up ExecStartPost=/bin/sh -c "systemctl disable kubernetes-resources-install.service" ExecStartPost=rm -f /etc/systemd/system/kubernetes-resources-install.service