disable GC and backup deletion if Kubernetes is less than v1.7.5

Signed-off-by: Steve Kriss <steve@heptio.com>
This commit is contained in:
Steve Kriss
2017-12-21 12:47:15 -08:00
parent 8e5feec39c
commit 1c974782fa
8 changed files with 395 additions and 18 deletions

View File

@@ -20,11 +20,14 @@ import (
"fmt"
"os"
"github.com/pkg/errors"
"github.com/spf13/cobra"
api "github.com/heptio/ark/pkg/apis/ark/v1"
"github.com/heptio/ark/pkg/client"
"github.com/heptio/ark/pkg/cmd"
"github.com/heptio/ark/pkg/controller"
kubeutil "github.com/heptio/ark/pkg/util/kube"
)
func NewDeleteCommand(f client.Factory, use string) *cobra.Command {
@@ -37,6 +40,16 @@ func NewDeleteCommand(f client.Factory, use string) *cobra.Command {
os.Exit(1)
}
kubeClient, err := f.KubeClient()
cmd.CheckError(err)
serverVersion, err := kubeutil.ServerVersion(kubeClient.Discovery())
cmd.CheckError(err)
if !serverVersion.AtLeast(controller.MinVersionForDelete) {
cmd.CheckError(errors.Errorf("this command requires the Kubernetes server version to be at least %s", controller.MinVersionForDelete))
}
arkClient, err := f.Client()
cmd.CheckError(err)