Skip to content

Commit

Permalink
fix kubeconfig to use correct cluster name (kubernetes-sigs#457)
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Amarnath <[email protected]>
  • Loading branch information
ashish-amarnath authored and k8s-ci-robot committed Dec 12, 2018
1 parent 55671b3 commit 3152b0f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ kubeconfig
/bazel-genfiles
/bazel-out
/bazel-testlogs

# vscode
.vscode
4 changes: 1 addition & 3 deletions pkg/cloud/aws/services/certificates/certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func NewSelfSignedCACert(key *rsa.PrivateKey) (*x509.Certificate, error) {
}

// NewKubeconfig creates a new Kubeconfig where endpoint is the ELB endpoint.
func NewKubeconfig(endpoint string, caCert *x509.Certificate, caKey *rsa.PrivateKey) (*api.Config, error) {
func NewKubeconfig(clusterName, endpoint string, caCert *x509.Certificate, caKey *rsa.PrivateKey) (*api.Config, error) {
cfg := &Config{
CommonName: "kubernetes-admin",
Organization: []string{"system:masters"},
Expand All @@ -160,8 +160,6 @@ func NewKubeconfig(endpoint string, caCert *x509.Certificate, caKey *rsa.Private
return nil, errors.Wrap(err, "unable to sign certificate")
}

// TODO: make this configurable.
clusterName := "test1"
userName := "kubernetes-admin"
contextName := fmt.Sprintf("%s@%s", userName, clusterName)

Expand Down
2 changes: 1 addition & 1 deletion pkg/deployer/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (d *Deployer) GetKubeConfig(cluster *clusterv1.Cluster, _ *clusterv1.Machin

server := fmt.Sprintf("https://%s:6443", dnsName)

cfg, err := certificates.NewKubeconfig(server, cert, key)
cfg, err := certificates.NewKubeconfig(cluster.Name, server, cert, key)
if err != nil {
return "", errors.Wrap(err, "failed to generate a kubeconfig")
}
Expand Down

0 comments on commit 3152b0f

Please sign in to comment.