mirror of
https://github.com/kairos-io/provider-kairos.git
synced 2025-09-25 06:24:19 +00:00
🤖 Use static assets, wait longer
Signed-off-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
#cloud-config
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
initramfs:
|
initramfs:
|
||||||
- name: "Set user and password"
|
- name: "Set user and password"
|
||||||
@@ -6,4 +8,126 @@ stages:
|
|||||||
passwd: "kairos"
|
passwd: "kairos"
|
||||||
|
|
||||||
k3s:
|
k3s:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
|
write_files:
|
||||||
|
- path: /var/lib/rancher/k3s/server/manifests/suc.yaml
|
||||||
|
permissions: "0644"
|
||||||
|
content: |
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: system-upgrade
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: system-upgrade
|
||||||
|
namespace: system-upgrade
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
metadata:
|
||||||
|
name: system-upgrade
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: ClusterRole
|
||||||
|
name: cluster-admin
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: system-upgrade
|
||||||
|
namespace: system-upgrade
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
SYSTEM_UPGRADE_CONTROLLER_DEBUG: "false"
|
||||||
|
SYSTEM_UPGRADE_CONTROLLER_THREADS: "2"
|
||||||
|
SYSTEM_UPGRADE_JOB_ACTIVE_DEADLINE_SECONDS: "900"
|
||||||
|
SYSTEM_UPGRADE_JOB_BACKOFF_LIMIT: "99"
|
||||||
|
SYSTEM_UPGRADE_JOB_IMAGE_PULL_POLICY: Always
|
||||||
|
SYSTEM_UPGRADE_JOB_KUBECTL_IMAGE: rancher/kubectl:v1.21.9
|
||||||
|
SYSTEM_UPGRADE_JOB_PRIVILEGED: "true"
|
||||||
|
SYSTEM_UPGRADE_JOB_TTL_SECONDS_AFTER_FINISH: "900"
|
||||||
|
SYSTEM_UPGRADE_PLAN_POLLING_INTERVAL: 15m
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: default-controller-env
|
||||||
|
namespace: system-upgrade
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: system-upgrade-controller
|
||||||
|
namespace: system-upgrade
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
upgrade.cattle.io/controller: system-upgrade-controller
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
upgrade.cattle.io/controller: system-upgrade-controller
|
||||||
|
spec:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: node-role.kubernetes.io/master
|
||||||
|
operator: Exists
|
||||||
|
containers:
|
||||||
|
- env:
|
||||||
|
- name: SYSTEM_UPGRADE_CONTROLLER_NAME
|
||||||
|
valueFrom:
|
||||||
|
fieldRef:
|
||||||
|
fieldPath: metadata.labels['upgrade.cattle.io/controller']
|
||||||
|
- name: SYSTEM_UPGRADE_CONTROLLER_NAMESPACE
|
||||||
|
valueFrom:
|
||||||
|
fieldRef:
|
||||||
|
fieldPath: metadata.namespace
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: default-controller-env
|
||||||
|
image: rancher/system-upgrade-controller:v0.9.1
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
name: system-upgrade-controller
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /etc/ssl
|
||||||
|
name: etc-ssl
|
||||||
|
- mountPath: /etc/pki
|
||||||
|
name: etc-pki
|
||||||
|
- mountPath: /etc/ca-certificates
|
||||||
|
name: etc-ca-certificates
|
||||||
|
- mountPath: /tmp
|
||||||
|
name: tmp
|
||||||
|
serviceAccountName: system-upgrade
|
||||||
|
tolerations:
|
||||||
|
- key: CriticalAddonsOnly
|
||||||
|
operator: Exists
|
||||||
|
- effect: NoSchedule
|
||||||
|
key: node-role.kubernetes.io/master
|
||||||
|
operator: Exists
|
||||||
|
- effect: NoSchedule
|
||||||
|
key: node-role.kubernetes.io/controlplane
|
||||||
|
operator: Exists
|
||||||
|
- effect: NoSchedule
|
||||||
|
key: node-role.kubernetes.io/control-plane
|
||||||
|
operator: Exists
|
||||||
|
- effect: NoExecute
|
||||||
|
key: node-role.kubernetes.io/etcd
|
||||||
|
operator: Exists
|
||||||
|
volumes:
|
||||||
|
- hostPath:
|
||||||
|
path: /etc/ssl
|
||||||
|
type: Directory
|
||||||
|
name: etc-ssl
|
||||||
|
- hostPath:
|
||||||
|
path: /etc/pki
|
||||||
|
type: DirectoryOrCreate
|
||||||
|
name: etc-pki
|
||||||
|
- hostPath:
|
||||||
|
path: /etc/ca-certificates
|
||||||
|
type: DirectoryOrCreate
|
||||||
|
name: etc-ca-certificates
|
||||||
|
- emptyDir: {}
|
||||||
|
name: tmp
|
||||||
|
@@ -19,6 +19,10 @@ import (
|
|||||||
"github.com/spectrocloud/peg/pkg/machine/types"
|
"github.com/spectrocloud/peg/pkg/machine/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var kubectl = func(s string) (string, error) {
|
||||||
|
return Sudo("k3s kubectl " + s)
|
||||||
|
}
|
||||||
|
|
||||||
func TestSuite(t *testing.T) {
|
func TestSuite(t *testing.T) {
|
||||||
RegisterFailHandler(Fail)
|
RegisterFailHandler(Fail)
|
||||||
RunSpecs(t, "kairos Test Suite")
|
RunSpecs(t, "kairos Test Suite")
|
||||||
|
@@ -2,12 +2,7 @@
|
|||||||
package mos_test
|
package mos_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
@@ -109,37 +104,15 @@ var _ = Describe("k3s upgrade test", Label("upgrade-k8s"), func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("upgrades", func() {
|
It("upgrades", func() {
|
||||||
By("installing system-upgrade-controller", func() {
|
By("wait system-upgrade-controller", func() {
|
||||||
kubectl := func(s string) (string, error) {
|
|
||||||
return Sudo("k3s kubectl " + s)
|
|
||||||
}
|
|
||||||
temp, err := ioutil.TempFile("", "temp")
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
defer os.RemoveAll(temp.Name())
|
|
||||||
|
|
||||||
Eventually(func() string {
|
Eventually(func() string {
|
||||||
// Re-attempt to download in case it fails
|
out, _ := kubectl("get pods -A")
|
||||||
resp, err := http.Get("https://github.com/rancher/system-upgrade-controller/releases/download/v0.9.1/system-upgrade-controller.yaml")
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
defer resp.Body.Close()
|
|
||||||
data := bytes.NewBuffer([]byte{})
|
|
||||||
|
|
||||||
_, err = io.Copy(data, resp.Body)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
err = ioutil.WriteFile(temp.Name(), data.Bytes(), os.ModePerm)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
err = Machine.SendFile(temp.Name(), "/tmp/kubectl.yaml", "0770")
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
kubectl("apply -f /tmp/kubectl.yaml")
|
|
||||||
out, _ := kubectl("apply -f /tmp/kubectl.yaml")
|
|
||||||
return out
|
return out
|
||||||
}, 900*time.Second, 10*time.Second).Should(ContainSubstring("unchanged"))
|
}, 900*time.Second, 10*time.Second).Should(ContainSubstring("system-upgrade-controller"))
|
||||||
|
})
|
||||||
|
By("applying plan", func() {
|
||||||
|
|
||||||
err = Machine.SendFile("assets/suc.yaml", "./suc.yaml", "0770")
|
err := Machine.SendFile("assets/suc.yaml", "./suc.yaml", "0770")
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
Eventually(func() string {
|
Eventually(func() string {
|
||||||
|
@@ -2,11 +2,8 @@
|
|||||||
package mos_test
|
package mos_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -126,37 +123,17 @@ var _ = Describe("k3s upgrade test from k8s", Label("upgrade-latest-with-kuberne
|
|||||||
return out
|
return out
|
||||||
}, 900*time.Second, 10*time.Second).Should(ContainSubstring("https:"))
|
}, 900*time.Second, 10*time.Second).Should(ContainSubstring("https:"))
|
||||||
|
|
||||||
kubectl := func(s string) (string, error) {
|
|
||||||
return Sudo("k3s kubectl " + s)
|
|
||||||
}
|
|
||||||
|
|
||||||
currentVersion, err := Machine.Command("source /etc/os-release; echo $VERSION")
|
currentVersion, err := Machine.Command("source /etc/os-release; echo $VERSION")
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(currentVersion).To(ContainSubstring("v"))
|
Expect(currentVersion).To(ContainSubstring("v"))
|
||||||
|
|
||||||
By("installing system-upgrade-controller", func() {
|
By("wait system-upgrade-controller", func() {
|
||||||
resp, err := http.Get("https://github.com/rancher/system-upgrade-controller/releases/download/v0.9.1/system-upgrade-controller.yaml")
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
defer resp.Body.Close()
|
|
||||||
data := bytes.NewBuffer([]byte{})
|
|
||||||
|
|
||||||
_, err = io.Copy(data, resp.Body)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
temp, err := ioutil.TempFile("", "temp")
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
defer os.RemoveAll(temp.Name())
|
|
||||||
err = ioutil.WriteFile(temp.Name(), data.Bytes(), os.ModePerm)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
err = Machine.SendFile(temp.Name(), "/tmp/kubectl.yaml", "0770")
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
Eventually(func() string {
|
Eventually(func() string {
|
||||||
out, _ := kubectl("apply -f /tmp/kubectl.yaml")
|
out, _ := kubectl("get pods -A")
|
||||||
return out
|
return out
|
||||||
}, 900*time.Second, 10*time.Second).Should(ContainSubstring("unchanged"))
|
}, 900*time.Second, 10*time.Second).Should(ContainSubstring("system-upgrade-controller"))
|
||||||
})
|
})
|
||||||
|
|
||||||
By("triggering an upgrade", func() {
|
By("triggering an upgrade", func() {
|
||||||
|
Reference in New Issue
Block a user