Skip to content

Commit 76bfae1

Browse files
psschweidsimansk
andauthored
Make kind local registry optional (#428)
* make kind registry optional Signed-off-by: Paul S. Schweigert <[email protected]> * Update internal/command/flags.go Co-authored-by: David Simansky <[email protected]> * add temporary warning about local registry Signed-off-by: Paul S. Schweigert <[email protected]> --------- Signed-off-by: Paul S. Schweigert <[email protected]> Co-authored-by: David Simansky <[email protected]>
1 parent 19ed9c6 commit 76bfae1

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

internal/command/flags.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var name string
2424
var kubernetesVersion string
2525
var installServing bool
2626
var installEventing bool
27+
var installKindRegistry bool
2728

2829
func clusterNameOption(targetCmd *cobra.Command, flagDefault string) {
2930
targetCmd.Flags().StringVarP(
@@ -51,3 +52,7 @@ func installServingOption(targetCmd *cobra.Command) {
5152
func installEventingOption(targetCmd *cobra.Command) {
5253
targetCmd.Flags().BoolVar(&installEventing, "install-eventing", false, "install Eventing on quickstart cluster")
5354
}
55+
56+
func installKindRegistryOption(targetCmd *cobra.Command) {
57+
targetCmd.Flags().BoolVar(&installKindRegistry, "registry", false, "install registry for Kind quickstart cluster")
58+
}

internal/command/kind.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ func NewKindCommand() *cobra.Command {
2828
Short: "Quickstart with Kind",
2929
RunE: func(cmd *cobra.Command, args []string) error {
3030
fmt.Println("Running Knative Quickstart using Kind")
31-
return kind.SetUp(name, kubernetesVersion, installServing, installEventing)
31+
return kind.SetUp(name, kubernetesVersion, installServing, installEventing, installKindRegistry)
3232
},
3333
}
3434
// Set kindCmd options
3535
clusterNameOption(kindCmd, "knative")
3636
kubernetesVersionOption(kindCmd, "", "kubernetes version to use (1.x.y) or (kindest/node:v1.x.y)")
3737
installServingOption(kindCmd)
3838
installEventingOption(kindCmd)
39+
installKindRegistryOption(kindCmd)
3940

4041
return kindCmd
4142
}

pkg/kind/kind.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ import (
2626
"knative.dev/kn-plugin-quickstart/pkg/install"
2727
)
2828

29-
var kubernetesVersion = "kindest/node:v1.25.3"
29+
var kubernetesVersion = "kindest/node:v1.26.6"
3030
var clusterName string
3131
var kindVersion = 0.16
3232
var container_reg_name = "kind-registry"
3333
var container_reg_port = "5001"
3434
var installKnative = true
3535

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

4040
// if neither the "install-serving" or "install-eventing" flags are set,
@@ -60,7 +60,7 @@ func SetUp(name, kVersion string, installServing, installEventing bool) error {
6060
}
6161
}
6262

63-
if err := createKindCluster(); err != nil {
63+
if err := createKindCluster(installKindRegistry); err != nil {
6464
return fmt.Errorf("creating cluster: %w", err)
6565
}
6666
if installKnative {
@@ -88,18 +88,27 @@ func SetUp(name, kVersion string, installServing, installEventing bool) error {
8888
return nil
8989
}
9090

91-
func createKindCluster() error {
91+
func createKindCluster(registry bool) error {
9292

9393
if err := checkDocker(); err != nil {
9494
return fmt.Errorf("%w", err)
9595
}
96-
if err := createLocalRegistry(); err != nil {
97-
return fmt.Errorf("%w", err)
98-
}
9996
fmt.Println("✅ Checking dependencies...")
10097
if err := checkKindVersion(); err != nil {
10198
return fmt.Errorf("kind version: %w", err)
10299
}
100+
if registry {
101+
fmt.Println("💽 Installing local registry...")
102+
if err := createLocalRegistry(); err != nil {
103+
return fmt.Errorf("%w", err)
104+
}
105+
} else {
106+
// temporary warning that registry creation is now opt-in
107+
// remove in v1.12
108+
fmt.Println("\nA local registry is no longer created by default.")
109+
fmt.Println(" To create a local registry, use the --registry flag.")
110+
}
111+
103112
if err := checkForExistingCluster(); err != nil {
104113
return fmt.Errorf("existing cluster: %w", err)
105114
}
@@ -165,7 +174,7 @@ func checkKindVersion() error {
165174
if err != nil {
166175
return fmt.Errorf("kind version: %w", err)
167176
}
168-
fmt.Printf(" Kind version is: %s\n", string(out))
177+
fmt.Printf(" Kind version is: %s", string(out))
169178

170179
userKindVersion, err := parseKindVersion(string(out))
171180
if err != nil {
@@ -201,7 +210,7 @@ func checkForExistingCluster() error {
201210
matches := r.Match(out)
202211
if matches {
203212
var resp string
204-
fmt.Print("Knative Cluster kind-" + clusterName + " already installed.\nDelete and recreate [y/N]: ")
213+
fmt.Print("\nKnative Cluster kind-" + clusterName + " already installed.\nDelete and recreate [y/N]: ")
205214
fmt.Scanf("%s", &resp)
206215
if resp == "y" || resp == "Y" {
207216
if err := recreateCluster(); err != nil {

0 commit comments

Comments
 (0)