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

fix: Clarify the manager CLI command deploy kontrol service location argument #247

Merged
merged 3 commits into from
Sep 25, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:

- name: Deploy Kardinal manager
run: |
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli manager deploy local-minikube
KARDINAL_CLI_DEV_MODE=TRUE /tmp/kardinal-cli manager deploy local-kardinal-kontrol

# Check that the three kardinal manager service pods are running and ready
while [ $(kubectl get pods -n default --no-headers -o custom-columns=NAMESPACE:metadata.namespace,POD:metadata.name,PodIP:status.podIP,READY-true:status.containerStatuses[*].ready | grep "true" | wc -l) -ne 3 ]
Expand Down
12 changes: 7 additions & 5 deletions kardinal-cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"kardinal.cli/kubernetes"
"log"
"net"
"net/http"
Expand All @@ -17,6 +16,8 @@ import (
"strings"
"time"

"kardinal.cli/kubernetes"

"gopkg.in/yaml.v3"
"kardinal.cli/consts"
"kardinal.cli/multi_os_cmd_executor"
Expand Down Expand Up @@ -471,9 +472,10 @@ var topologyManifestCmd = &cobra.Command{
}

var deployManagerCmd = &cobra.Command{
Use: fmt.Sprintf("deploy [kontrol location] accepted values: %s and %s ", kontrol.KontrolLocationLocalMinikube, kontrol.KontrolLocationKloudKontrol),
Use: fmt.Sprintf("deploy [kardinal-kontrol service location] accepted values: %s and %s ", kontrol.KontrolLocationLocal, kontrol.KontrolLocationKloud),
Short: "Deploy Kardinal manager into the cluster",
ValidArgs: []string{kontrol.KontrolLocationLocalMinikube, kontrol.KontrolLocationKloudKontrol},
Long: "The Kardinal Manager retrieves the latest configuration from the Kardinal Kontrol service and applies changes to the user K8S topology. The Kardinal Kontrol service can be the one running in the Kardinal Cloud or can be the one deployed locally.",
ValidArgs: []string{kontrol.KontrolLocationLocal, kontrol.KontrolLocationKloud},
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
Run: func(cmd *cobra.Command, args []string) {
kontrolLocation := args[0]
Expand Down Expand Up @@ -1087,10 +1089,10 @@ func getKontrolBaseURLForManager() (string, error) {
)

switch kontrolLocation {
case kontrol.KontrolLocationLocalMinikube:
case kontrol.KontrolLocationLocal:
scheme = httpSchme
host = localMinikubeKontrolAPIHost
case kontrol.KontrolLocationKloudKontrol:
case kontrol.KontrolLocationKloud:
scheme = httpsScheme
host = kloudKontrolAPIHost
default:
Expand Down
7 changes: 4 additions & 3 deletions kardinal-cli/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package deployment
import (
"bytes"
"context"
"kardinal.cli/kubernetes"
"text/template"

"kardinal.cli/kubernetes"

"kardinal.cli/kontrol"

"github.com/kurtosis-tech/stacktrace"
Expand Down Expand Up @@ -208,9 +209,9 @@ func DeployKardinalManagerInCluster(ctx context.Context, clusterResourcesURL str
var imagePullPolicy string

switch kontrolLocation {
case kontrol.KontrolLocationLocalMinikube:
case kontrol.KontrolLocationLocal:
imagePullPolicy = "IfNotPresent"
case kontrol.KontrolLocationKloudKontrol:
case kontrol.KontrolLocationKloud:
imagePullPolicy = "Always"
default:
stacktrace.NewError("invalid Kontrol location: %s", kontrolLocation)
Expand Down
19 changes: 15 additions & 4 deletions kardinal-cli/kontrol/location.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package kontrol

import (
"fmt"
"os"

"github.com/kurtosis-tech/stacktrace"
"github.com/sirupsen/logrus"
"kardinal.cli/host_machine_directories"
"os"
)

const (
KontrolLocationLocalMinikube = "local-minikube"
KontrolLocationKloudKontrol = "kloud-kontrol"
KontrolLocationLocal = "local-kardinal-kontrol"
KontrolLocationKloud = "kloud-kardinal-kontrol"
OldKontrolLocationLocal = "local-minikube"
OldKontrolLocationKloud = "kloud-kontrol"
kontrolLocationFilePermissions os.FileMode = 0644
)

Expand All @@ -33,9 +37,10 @@ func GetKontrolLocation() (string, error) {
return "", stacktrace.Propagate(err, "An error occurred getting the Kontrol location filepath")
}

fmt.Println(kontrolLocationFilepath)
_, err = os.Stat(kontrolLocationFilepath)
if err != nil {
return "", stacktrace.Propagate(err, "An error occurred getting the Kontrol location file info")
return "", stacktrace.Propagate(err, "An error occurred getting the Kontrol location file info")
}

kontrolLocationFileBytes, err := os.ReadFile(kontrolLocationFilepath)
Expand All @@ -44,6 +49,12 @@ func GetKontrolLocation() (string, error) {
}

kontrolLocationFileStr := string(kontrolLocationFileBytes)
switch kontrolLocationFileStr {
case OldKontrolLocationLocal:
kontrolLocationFileStr = KontrolLocationLocal
case OldKontrolLocationKloud:
kontrolLocationFileStr = KontrolLocationKloud
}

logrus.Infof("Using Kontrol location %s", kontrolLocationFileStr)
return kontrolLocationFileStr, nil
Expand Down
Loading