github.com/openshift/installer@v1.4.17/pkg/asset/kubeconfig/agent.go (about) 1 package kubeconfig 2 3 import ( 4 "context" 5 "fmt" 6 "strings" 7 8 "github.com/openshift/installer/pkg/asset" 9 agentmanifests "github.com/openshift/installer/pkg/asset/agent/manifests" 10 "github.com/openshift/installer/pkg/asset/tls" 11 ) 12 13 // AgentAdminClient is the asset for the agent admin kubeconfig. 14 type AgentAdminClient struct { 15 AdminClient 16 } 17 18 // Dependencies returns the dependency of the kubeconfig. 19 func (k *AgentAdminClient) Dependencies() []asset.Asset { 20 return []asset.Asset{ 21 &tls.AdminKubeConfigClientCertKey{}, 22 &tls.KubeAPIServerCompleteCABundle{}, 23 &agentmanifests.ClusterDeployment{}, 24 } 25 } 26 27 // Generate generates the kubeconfig. 28 func (k *AgentAdminClient) Generate(_ context.Context, parents asset.Parents) error { 29 ca := &tls.KubeAPIServerCompleteCABundle{} 30 clientCertKey := &tls.AdminKubeConfigClientCertKey{} 31 parents.Get(ca, clientCertKey) 32 33 clusterDeployment := &agentmanifests.ClusterDeployment{} 34 parents.Get(clusterDeployment) 35 36 clusterName := clusterDeployment.Config.Spec.ClusterName 37 extAPIServerURL := fmt.Sprintf("https://api.%s.%s:6443", clusterName, strings.TrimSuffix(clusterDeployment.Config.Spec.BaseDomain, ".")) 38 39 return k.kubeconfig.generate( 40 ca, 41 clientCertKey, 42 extAPIServerURL, 43 clusterName, 44 "admin", 45 kubeconfigAdminPath, 46 ) 47 }