diff --git a/cmd/kubenest/node-agent/app/serve/serve.go b/cmd/kubenest/node-agent/app/serve/serve.go index a4bc5366d..0ecedf783 100644 --- a/cmd/kubenest/node-agent/app/serve/serve.go +++ b/cmd/kubenest/node-agent/app/serve/serve.go @@ -57,7 +57,7 @@ func init() { func serveCmdRun(_ *cobra.Command, _ []string) error { user := viper.GetString("WEB_USER") password := viper.GetString("WEB_PASS") - port := viper.GetString("WEB_PORT") + port := viper.GetString("WEB_PORT") if len(user) == 0 || len(password) == 0 { log.Errorf("-user and -password are required %s %s", user, password) return errors.New("-user and -password are required") diff --git a/pkg/kubenest/controlplane/endpoint.go b/pkg/kubenest/controlplane/endpoint.go index 2a815781a..e809eddd5 100644 --- a/pkg/kubenest/controlplane/endpoint.go +++ b/pkg/kubenest/controlplane/endpoint.go @@ -105,12 +105,14 @@ func CreateOrUpdateAPIServerExternalService(kubeClient kubernetes.Interface) err } _, err = kubeClient.CoreV1().Services(constants.DefaultNs).Get(context.TODO(), constants.APIServerExternalService, metav1.GetOptions{}) if err != nil { - if !apierrors.IsNotFound(err) { + if apierrors.IsNotFound(err) { // Try to create the service _, err = kubeClient.CoreV1().Services(constants.DefaultNs).Create(context.TODO(), &svc, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("error when creating api-server-external-service: %w", err) } + } else { + return fmt.Errorf("error when get api-server-external-service: %w", err) } } klog.V(4).Info("successfully created api-server-external-service service")