Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds flags for installing knative a la carte #279

Merged
merged 1 commit into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/command/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (

var name string
var kubernetesVersion string
var installServing bool
var installEventing bool

func clusterNameOption(targetCmd *cobra.Command, flagDefault string) {
targetCmd.Flags().StringVarP(
Expand All @@ -41,3 +43,11 @@ func kubernetesVersionOption(targetCmd *cobra.Command, flagDefault string, usage
flagDefault,
usageText)
}

func installServingOption(targetCmd *cobra.Command) {
targetCmd.Flags().BoolVar(&installServing, "install-serving", false, "install Serving on quickstart cluster")
}

func installEventingOption(targetCmd *cobra.Command) {
targetCmd.Flags().BoolVar(&installEventing, "install-eventing", false, "install Eventing on quickstart cluster")
}
4 changes: 3 additions & 1 deletion internal/command/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ func NewKindCommand() *cobra.Command {
Short: "Quickstart with Kind",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("Running Knative Quickstart using Kind")
return kind.SetUp(name, kubernetesVersion)
return kind.SetUp(name, kubernetesVersion, installServing, installEventing)
},
}
// Set kindCmd options
clusterNameOption(kindCmd, "knative")
kubernetesVersionOption(kindCmd, "", "kubernetes version to use (1.x.y) or (kindest/node:v1.x.y)")
installServingOption(kindCmd)
installEventingOption(kindCmd)

return kindCmd
}
4 changes: 3 additions & 1 deletion internal/command/minikube.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ func NewMinikubeCommand() *cobra.Command {
Short: "Quickstart with Minikube",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("Running Knative Quickstart using Minikube")
return minikube.SetUp(name, kubernetesVersion)
return minikube.SetUp(name, kubernetesVersion, installServing, installEventing)
},
}
// Set minikubeCmd options
clusterNameOption(minikubeCmd, "knative")
kubernetesVersionOption(minikubeCmd, "", "kubernetes version to use (1.x.y)")
installServingOption(minikubeCmd)
installEventingOption(minikubeCmd)
return minikubeCmd
}
36 changes: 25 additions & 11 deletions pkg/kind/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@ var clusterName string
var kindVersion = 0.11

// SetUp creates a local Kind cluster and installs all the relevant Knative components
func SetUp(name, kVersion string) error {
func SetUp(name, kVersion string, installServing, installEventing bool) error {
start := time.Now()

// if neither the "install-serving" or "install-eventing" flags are set,
// then we assume the user wants to install both serving and eventing
if !installServing && !installEventing {
installServing = true
installEventing = true
}

// kubectl is required, fail if not found
if _, err := exec.LookPath("kubectl"); err != nil {
fmt.Println("ERROR: kubectl is required for quickstart")
Expand All @@ -53,18 +60,25 @@ func SetUp(name, kVersion string) error {
if err := createKindCluster(); err != nil {
return fmt.Errorf("creating cluster: %w", err)
}
if err := install.Serving(); err != nil {
return fmt.Errorf("install serving: %w", err)
}
if err := install.Kourier(); err != nil {
return fmt.Errorf("install kourier: %w", err)
}
if err := install.KourierKind(); err != nil {
return fmt.Errorf("configure kourier: %w", err)

if installServing {
if err := install.Serving(); err != nil {
return fmt.Errorf("install serving: %w", err)
}
if err := install.Kourier(); err != nil {
return fmt.Errorf("install kourier: %w", err)
}
if err := install.KourierKind(); err != nil {
return fmt.Errorf("configure kourier: %w", err)
}
}
if err := install.Eventing(); err != nil {
return fmt.Errorf("install eventing: %w", err)

if installEventing {
if err := install.Eventing(); err != nil {
return fmt.Errorf("install eventing: %w", err)
}
}

finish := time.Since(start).Round(time.Second)
fmt.Printf("🚀 Knative install took: %s \n", finish)
fmt.Println("🎉 Now have some fun with Serverless and Event Driven Apps!")
Expand Down
35 changes: 24 additions & 11 deletions pkg/minikube/minikube.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,16 @@ var cpus = "3"
var memory = "3072"

// SetUp creates a local Minikube cluster and installs all the relevant Knative components
func SetUp(name, kVersion string) error {
func SetUp(name, kVersion string, installServing, installEventing bool) error {
start := time.Now()

// if neither the "install-serving" or "install-eventing" flags are set,
// then we assume the user wants to install both serving and eventing
if !installServing && !installEventing {
installServing = true
installEventing = true
}

// kubectl is required, fail if not found
if _, err := exec.LookPath("kubectl"); err != nil {
fmt.Println("ERROR: kubectl is required for quickstart")
Expand All @@ -62,17 +69,23 @@ func SetUp(name, kVersion string) error {
fmt.Println("\nPress the Enter key to continue")
fmt.Scanln()
}
if err := install.Serving(); err != nil {
return fmt.Errorf("install serving: %w", err)
}
if err := install.Kourier(); err != nil {
return fmt.Errorf("install kourier: %w", err)
}
if err := install.KourierMinikube(); err != nil {
return fmt.Errorf("configure kourier: %w", err)

if installServing {
if err := install.Serving(); err != nil {
return fmt.Errorf("install serving: %w", err)
}
if err := install.Kourier(); err != nil {
return fmt.Errorf("install kourier: %w", err)
}
if err := install.KourierMinikube(); err != nil {
return fmt.Errorf("configure kourier: %w", err)
}
}
if err := install.Eventing(); err != nil {
return fmt.Errorf("install eventing: %w", err)

if installEventing {
if err := install.Eventing(); err != nil {
return fmt.Errorf("install eventing: %w", err)
}
}

finish := time.Since(start).Round(time.Second)
Expand Down