Skip to content

Commit

Permalink
fix: create api-server-external-service
Browse files Browse the repository at this point in the history
Signed-off-by: baoyinghai_yewu <[email protected]>
  • Loading branch information
OrangeBao committed Nov 1, 2024
1 parent 21229cb commit 6b0f55b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/kubenest/node-agent/app/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion pkg/kubenest/controlplane/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 6b0f55b

Please sign in to comment.