Andrey Smirnov 230e46e567
refactor: extract parts of kubernetes libraries
The shared code is going out to the
github.com/siderolabs/go-kubernetes library.

The code will be used in Talos and other projects using same features.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2023-02-22 14:56:49 +04:00

50 lines
1.2 KiB
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package kubernetes
import (
"fmt"
"io"
"github.com/siderolabs/go-kubernetes/kubernetes/upgrade"
appsv1 "k8s.io/api/apps/v1"
)
const (
namespace = "kube-system"
kubeAPIServer = "kube-apiserver"
kubeControllerManager = "kube-controller-manager"
kubeScheduler = "kube-scheduler"
kubeProxy = "kube-proxy"
)
// UpgradeOptions represents Kubernetes control plane upgrade settings.
type UpgradeOptions struct {
Path *upgrade.Path
ControlPlaneEndpoint string
LogOutput io.Writer
UpgradeKubelet bool
DryRun bool
extraUpdaters []daemonsetUpdater
controlPlaneNodes []string
workerNodes []string
}
// Log writes the line to logger or to stdout if no logger was provided.
func (options *UpgradeOptions) Log(line string, args ...interface{}) {
if options.LogOutput != nil {
options.LogOutput.Write([]byte(fmt.Sprintf(line, args...))) //nolint:errcheck
return
}
fmt.Printf(line+"\n", args...)
}
type daemonsetUpdater func(ds string, daemonset *appsv1.DaemonSet) error