aboutsummaryrefslogtreecommitdiffstats
path: root/testing/kubernetes
diff options
context:
space:
mode:
authorTBK <tbk@jjtc.eu>2019-04-01 19:09:58 +0200
committerFrancesco Colista <fcolista@alpinelinux.org>2019-04-01 18:43:16 +0000
commitfb0b2db4e4b5a93fc5f5b18fa1ad211a9783f63b (patch)
tree604bd2fbc472b175c669f2bf3c851a28f9a99f12 /testing/kubernetes
parentb1ecc7e07067534aebc9a078b7967120e64c8af8 (diff)
downloadaports-fb0b2db4e4b5a93fc5f5b18fa1ad211a9783f63b.tar.bz2
aports-fb0b2db4e4b5a93fc5f5b18fa1ad211a9783f63b.tar.xz
testing/kubernetes: add openrc support
https://bugs.alpinelinux.org/issues/10179 https://github.com/kubernetes/kubernetes/pull/73101
Diffstat (limited to 'testing/kubernetes')
-rw-r--r--testing/kubernetes/APKBUILD2
-rw-r--r--testing/kubernetes/add-openrc-support.patch110
2 files changed, 112 insertions, 0 deletions
diff --git a/testing/kubernetes/APKBUILD b/testing/kubernetes/APKBUILD
index 6daf326138..970d97ee7f 100644
--- a/testing/kubernetes/APKBUILD
+++ b/testing/kubernetes/APKBUILD
@@ -17,6 +17,7 @@ source="$pkgname-$pkgver.tar.gz::https://github.com/kubernetes/kubernetes/archiv
make-e2e_node-run-over-distro-bins.patch
make-test-cmd-run-over-hyperkube-based-kubectl.patch
remove-apiserver-add-kube-prefix-for-hyperkube.patch
+ add-openrc-support.patch
"
build() {
@@ -45,3 +46,4 @@ b7710dfe8a80f495e5eeb1d35d03179466bff4a3208d70591d1a9896709ec7383d17314d58eefc6c
06e3e8626b70077eb693da9c53dca3bc566aea4590a27c5dd3997b6d34abec5bf5d749b7be94b60b83361884c29b3a6dbb56c40b18c008b19e7cbd6e0d5c87e6 make-e2e_node-run-over-distro-bins.patch
cf6d9a5e873603462f0b8de60d3c72b10cbe68175f621f814cb5a85c11cb18f408639181227dfae6718671109cd198ef8720ee15a7d4132bba691bbd7224860f make-test-cmd-run-over-hyperkube-based-kubectl.patch
f60cb7006b85cac00b0f18f87cc9196541e359a82ba37b3e0938d5e9a6e178ef964df0695fff3135d4a6cc4f4d91e963bd184e3af140c7c1072735890ff4351d remove-apiserver-add-kube-prefix-for-hyperkube.patch"
+8aec0a1cda24fcd7001e34ff6163aee7eaf679dea953068b58df3578c016f70e1406903e032a51519bc16ac0dbe583159d1cf4d504adbb2930d811cc2f762cfe add-openrc-support.patch"
diff --git a/testing/kubernetes/add-openrc-support.patch b/testing/kubernetes/add-openrc-support.patch
new file mode 100644
index 0000000000..f4da52f082
--- /dev/null
+++ b/testing/kubernetes/add-openrc-support.patch
@@ -0,0 +1,110 @@
+Needed for OpenRC support until https://github.com/kubernetes/kubernetes/pull/73101 is merged.
+
+Brought to attention by https://bugs.alpinelinux.org/issues/10179
+
+---------------------------------
+--- a/pkg/util/initsystem/initsystem.go
++++ b/pkg/util/initsystem/initsystem.go
+@@ -1,5 +1,5 @@
+ /*
+-Copyright 2016 The Kubernetes Authors.
++Copyright 2019 The Kubernetes Authors.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+@@ -23,6 +23,9 @@
+ )
+
+ type InitSystem interface {
++ // return a string describing how to enable a service
++ EnableCommand(service string) string
++
+ // ServiceStart tries to start a specific service
+ ServiceStart(service string) error
+
+@@ -42,8 +45,63 @@
+ ServiceIsActive(service string) bool
+ }
+
++type OpenRCInitSystem struct{}
++
++func (openrc OpenRCInitSystem) ServiceStart(service string) error {
++ args := []string{service, "start"}
++ return exec.Command("rc-service", args...).Run()
++}
++
++func (openrc OpenRCInitSystem) ServiceStop(service string) error {
++ args := []string{service, "stop"}
++ return exec.Command("rc-service", args...).Run()
++}
++
++func (openrc OpenRCInitSystem) ServiceRestart(service string) error {
++ args := []string{service, "restart"}
++ return exec.Command("rc-service", args...).Run()
++}
++
++// openrc writes to stderr if a service is not found or not enabled
++// this is in contrast to systemd which only writes to stdout.
++// Hence, we use the Combinedoutput, and ignore the error.
++func (openrc OpenRCInitSystem) ServiceExists(service string) bool {
++ args := []string{service, "status"}
++ outBytes, _ := exec.Command("rc-service", args...).CombinedOutput()
++ if strings.Contains(string(outBytes), "does not exist") {
++ return false
++ }
++ return true
++}
++
++func (openrc OpenRCInitSystem) ServiceIsEnabled(service string) bool {
++ args := []string{"show", "default"}
++ outBytes, _ := exec.Command("rc-update", args...).Output()
++ if strings.Contains(string(outBytes), service) {
++ return true
++ }
++ return false
++}
++
++func (openrc OpenRCInitSystem) ServiceIsActive(service string) bool {
++ args := []string{service, "status"}
++ outBytes, _ := exec.Command("rc-service", args...).Output()
++ if strings.Contains(string(outBytes), "stopped") {
++ return false
++ }
++ return true
++}
++
++func (openrc OpenRCInitSystem) EnableCommand(service string) string {
++ return fmt.Sprintf("rc-update add %s default", service)
++}
++
+ type SystemdInitSystem struct{}
+
++func (sysd SystemdInitSystem) EnableCommand(service string) string {
++ return fmt.Sprintf("systemctl enable %s.service", service)
++}
++
+ func (sysd SystemdInitSystem) reloadSystemd() error {
+ if err := exec.Command("systemctl", "daemon-reload").Run(); err != nil {
+ return fmt.Errorf("failed to reload systemd: %v", err)
+@@ -110,6 +168,10 @@
+ // WindowsInitSystem is the windows implementation of InitSystem
+ type WindowsInitSystem struct{}
+
++func (sysd WindowsInitSystem) EnableCommand(service string) string {
++ return fmt.Sprintf("Set-Service '%s' -StartupType Automatic", service)
++}
++
+ func (sysd WindowsInitSystem) ServiceStart(service string) error {
+ args := []string{"Start-Service", service}
+ err := exec.Command("powershell", args...).Run()
+@@ -170,6 +232,10 @@
+ _, err := exec.LookPath("systemctl")
+ if err == nil {
+ return &SystemdInitSystem{}, nil
++ }
++ _, err = exec.LookPath("openrc")
++ if err == nil {
++ return &OpenRCInitSystem{}, nil
+ }
+ _, err = exec.LookPath("wininit.exe")
+ if err == nil {