pacoxu / kubeadm-operator

Test work on the design of kubeadm operator. Also you can try https://github.com/chendave/kubeadm-operator
Apache License 2.0
10 stars 2 forks source link

runKubeadmUpgradeNode: add real dry run support #46

Open github-actions[bot] opened 2 years ago

github-actions[bot] commented 2 years ago

add real dry run support

https://github.com/pacoxu/kubeadm-operator/blob/867d34f7974d42b73cd340f55a49dad78753c4c1/commands/kubeadm_upgrade_node.go#L33


import (
    "fmt"
    "strings"

    "github.com/go-logr/logr"
    "github.com/pkg/errors"

    operatorv1 "k8s.io/kubeadm/operator/api/v1alpha1"
)

// "kubeadm upgrade node" on current node
func runKubeadmUpgradeNode(spec *operatorv1.KubeadmUpgradeNodeCommandSpec, log logr.Logger) error {
    var cmd *cmd

    // TODO: add real dry run support
    cmd = newCmd("kubeadm", "upgrade", "node", "--v=4")
    if spec.DryRun {
        cmd = newCmd("kubeadm", "upgrade", "node", "--dry-run", "--v=4")
    }

    lines, err := cmd.RunAndCapture()
    if err != nil {
        return errors.WithStack(errors.WithMessage(err, strings.Join(lines, "\n")))
    }

    log.Info(fmt.Sprintf("%s", strings.Join(lines, "\n")))

    return nil
}
ndex 4905de7..970466c 100644
++ b/commands/kubectl_drain.go

6fba2b34bb8f7decd1f9180da9619d2d9c241a87