Skip to content

Commit

Permalink
Check Kubernetes version.
Browse files Browse the repository at this point in the history
This commit checks whether the Kubernetes version is >= v1.8
It fails the installation otherwise.

Testing Done:

* Verified the version check succeeds for v1.8

* Verified that the version check fails for v1.7

Refs argoproj#473
  • Loading branch information
Shri Javadekar authored and shrinandj committed Dec 1, 2017
1 parent a390927 commit 30d7fba
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@
[[constraint]]
name = "github.com/minio/minio-go"
version = "3.0.2"

[[constraint]]
branch = "master"
name = "github.com/hashicorp/go-version"
27 changes: 27 additions & 0 deletions cmd/argo/commands/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/argoproj/argo/workflow/common"
"github.com/argoproj/argo/workflow/controller"
"github.com/ghodss/yaml"
goversion "github.com/hashicorp/go-version"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
appsv1beta2 "k8s.io/api/apps/v1beta2"
Expand Down Expand Up @@ -155,11 +156,37 @@ func setupArgoRoleBinding(clientset *kubernetes.Clientset) error {

return nil
}
func kubernetesVersionCheck(clientset *kubernetes.Clientset) {
// Check if the Kubernetes version is >= 1.8
versionInfo, err := clientset.ServerVersion()
if err != nil {
log.Fatalf("Failed to get Kubernetes version: %v", err)
}

serverVersion, err := goversion.NewVersion(versionInfo.String())
if err != nil {
log.Fatalf("Failed to create version: %v", err)
}

minVersion, err := goversion.NewVersion("1.8")
if err != nil {
log.Fatalf("Failed to create minimum version: %v", err)
}

if serverVersion.LessThan(minVersion) {
log.Fatalf("Server version %v < %v. Installation won't proceed...\n", serverVersion, minVersion)
}

fmt.Printf("Proceeding with Kubernetes version %v\n", serverVersion)
}

func install(cmd *cobra.Command, args []string) {
fmt.Printf("Installing into namespace '%s'\n", installArgs.namespace)

clientset = initKubeClient()

kubernetesVersionCheck(clientset)

clusterAdminFound, err := getClusterAdmin(clientset)
if err != nil {
fmt.Printf("%s\n", err)
Expand Down

0 comments on commit 30d7fba

Please sign in to comment.