From 3152b0f9f3c15d330008a4239a9a09a1ff46935f Mon Sep 17 00:00:00 2001 From: Ashish Amarnath Date: Wed, 12 Dec 2018 08:08:37 -0800 Subject: [PATCH] fix kubeconfig to use correct cluster name (#457) Signed-off-by: Ashish Amarnath --- .gitignore | 3 +++ pkg/cloud/aws/services/certificates/certificates.go | 4 +--- pkg/deployer/deployer.go | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5083208fcb..1bd1209816 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,6 @@ kubeconfig /bazel-genfiles /bazel-out /bazel-testlogs + +# vscode +.vscode diff --git a/pkg/cloud/aws/services/certificates/certificates.go b/pkg/cloud/aws/services/certificates/certificates.go index 659e4d068a..037508290a 100644 --- a/pkg/cloud/aws/services/certificates/certificates.go +++ b/pkg/cloud/aws/services/certificates/certificates.go @@ -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"}, @@ -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) diff --git a/pkg/deployer/deployer.go b/pkg/deployer/deployer.go index ef967a2b05..fbc2a991a7 100644 --- a/pkg/deployer/deployer.go +++ b/pkg/deployer/deployer.go @@ -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") }