Skip to content

Commit

Permalink
refactor: adjust server endpoint in hub kubeconfig template (#603)
Browse files Browse the repository at this point in the history
## What type of PR is this?

/kind refactor

## What this PR does / why we need it:

Adjust server endpoint from `karpor-server.karpor.svc` to `127.0.0.1` in
hub cluster kubeconfig template, becuase the k8s internal domain cannot
be resolved in the local environment.

## Which issue(s) this PR fixes:

Fixes #520
  • Loading branch information
elliotxx authored Aug 22, 2024
1 parent 221d1eb commit f032650
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/util/certgenerator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import (
"k8s.io/client-go/util/keyutil"
)

const kubeConfigTemplate = `apiVersion: v1
const hubClusterKubeConfigTemplate = `apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: https://karpor-server.%s.svc:7443
server: https://127.0.0.1:7443
name: karpor
contexts:
- context:
Expand Down Expand Up @@ -189,5 +189,5 @@ func generateAdminKubeconfig(namespace string, cert *x509.Certificate, key crypt
if err != nil {
return "", fmt.Errorf("unable to marshal private key to PEM %s", err)
}
return fmt.Sprintf(kubeConfigTemplate, namespace, base64.StdEncoding.EncodeToString(certData), base64.StdEncoding.EncodeToString(keyData)), nil
return fmt.Sprintf(hubClusterKubeConfigTemplate, base64.StdEncoding.EncodeToString(certData), base64.StdEncoding.EncodeToString(keyData)), nil
}

0 comments on commit f032650

Please sign in to comment.