Skip to content

Commit

Permalink
Revert "Adding a new Minikube flag for helm chart install of Apache C…
Browse files Browse the repository at this point in the history
…amel K (#521)" (#553)

This reverts commit 136c4ab.
  • Loading branch information
matzew authored Nov 27, 2024
1 parent e50d13a commit 6143cc6
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 94 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Getting Started

Note: In order to use the `quickstart` plugin, you must install the [Kubernetes CLI `kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl) and either [`kind`](https://kind.sigs.k8s.io/docs/user/quick-start) or [`minikube`](https://minikube.sigs.k8s.io/docs/start/). If you want to install the Apache Camel K option you also need the [`helm`](https://helm.sh/) CLI.
Note: In order to use the `quickstart` plugin, you must install the [Kubernetes CLI `kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl) and either [`kind`](https://kind.sigs.k8s.io/docs/user/quick-start) or [`minikube`](https://minikube.sigs.k8s.io/docs/start/).

### Installation

Expand Down
5 changes: 0 additions & 5 deletions internal/command/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ var name string
var kubernetesVersion string
var installServing bool
var installEventing bool
var installCamel bool
var installKindRegistry bool
var installKindExtraMountHostPath string
var installKindExtraMountContainerPath string
Expand Down Expand Up @@ -56,10 +55,6 @@ func installEventingOption(targetCmd *cobra.Command) {
targetCmd.Flags().BoolVar(&installEventing, "install-eventing", false, "install Eventing on quickstart cluster")
}

func installCamelOption(targetCmd *cobra.Command) {
targetCmd.Flags().BoolVar(&installCamel, "install-camel", false, "install Apache Camel K on quickstart cluster")
}

func installKindRegistryOption(targetCmd *cobra.Command) {
targetCmd.Flags().BoolVar(&installKindRegistry, "registry", false, "install registry for Kind quickstart cluster")
}
Expand Down
3 changes: 1 addition & 2 deletions internal/command/minikube.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +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, installServing, installEventing, installCamel)
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)
installCamelOption(minikubeCmd)
return minikubeCmd
}
62 changes: 0 additions & 62 deletions pkg/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,34 +205,6 @@ metadata:
return nil
}

func CamelK(registryAddress string) error {
fmt.Println("🐪 Installing Apache Camel K ... ")

if err := addHelmRepo(); err != nil {
fmt.Printf("Error adding Helm repo: %v\n", err)
return err
}
fmt.Println("Helm repo added successfully")

// Run the Helm install command
if err := runHelmInstall(registryAddress); err != nil {
fmt.Printf("Error: %v\n", err)
return err
}

if err := waitForCRDsEstablished(); err != nil {
return fmt.Errorf("crds: %w", err)
}
fmt.Println(" CRDs installed...")

if err := waitForPodsReady("default"); err != nil {
return fmt.Errorf("core: %w", err)
}
fmt.Println(" Apache Camel K installed...")

return nil
}

func runCommand(c *exec.Cmd) error {
if out, err := c.CombinedOutput(); err != nil {
fmt.Println(string(out))
Expand Down Expand Up @@ -265,37 +237,3 @@ func waitForCRDsEstablished() error {
func waitForPodsReady(ns string) error {
return runCommand(exec.Command("kubectl", "wait", "pod", "--timeout=10m", "--for=condition=Ready", "-l", "!job-name", "-n", ns))
}

//nolint:gosec // avoid linter warnings
func runHelmInstall(registryAddress string) error {

// Check if helm CLI is installed
if _, err := exec.LookPath("helm"); err != nil {
return fmt.Errorf("Please install helm CLI")
}

cmd := exec.Command("helm", "install",
"--generate-name",
"--set", fmt.Sprintf("platform.build.registry.address=%s", registryAddress),
"--set", "platform.build.registry.insecure=true",
"camel-k/camel-k")

cmd.Stdout = cmd.Stderr

if out, err := cmd.CombinedOutput(); err != nil {
fmt.Println(string(out))
return fmt.Errorf("failed to run helm install: %w", err)
}
return nil
}

func addHelmRepo() error {
cmd := exec.Command("helm", "repo", "add", "camel-k", "https://apache.github.io/camel-k/charts/")
cmd.Stdout = cmd.Stderr

if out, err := cmd.CombinedOutput(); err != nil {
fmt.Println(string(out))
return fmt.Errorf("failed to add helm repo: %w", err)
}
return nil
}
25 changes: 1 addition & 24 deletions pkg/minikube/minikube.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var memory = "3072"
var installKnative = true

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

// if neither the "install-serving" or "install-eventing" flags are set,
Expand Down Expand Up @@ -83,19 +83,6 @@ func SetUp(name, kVersion string, installServing, installEventing, installCamel
if err := install.Eventing(); err != nil {
return fmt.Errorf("install eventing: %w", err)
}

if installCamel {

registryAddress, err := getMinikubeRegistryAddress()
if err != nil {
fmt.Printf("Error: %v\n", err)
return err
}

if err := install.CamelK(registryAddress); err != nil {
return fmt.Errorf("install Apache Camel K: %w", err)
}
}
}
}

Expand Down Expand Up @@ -284,13 +271,3 @@ func recreateCluster() error {
}
return nil
}

func getMinikubeRegistryAddress() (string, error) {
cmd := exec.Command("kubectl", "-n", "kube-system", "get", "service", "registry", "-o", "jsonpath={.spec.clusterIP}")
out, err := cmd.CombinedOutput()
if err != nil {
return "", fmt.Errorf("failed to get registry address: %w", err)
}
address := strings.TrimSpace(string(out))
return address, nil
}

0 comments on commit 6143cc6

Please sign in to comment.