github.com/openshift/installer@v1.4.17/pkg/asset/kubeconfig/kubelet.go (about)

     1  package kubeconfig
     2  
     3  import (
     4  	"context"
     5  	"path/filepath"
     6  
     7  	"github.com/openshift/installer/pkg/asset"
     8  	"github.com/openshift/installer/pkg/asset/installconfig"
     9  	"github.com/openshift/installer/pkg/asset/tls"
    10  )
    11  
    12  var (
    13  	kubeconfigKubeletPath = filepath.Join("auth", "kubeconfig-kubelet")
    14  )
    15  
    16  // Kubelet is the asset for the kubelet kubeconfig.
    17  type Kubelet struct {
    18  	kubeconfig
    19  }
    20  
    21  var _ asset.WritableAsset = (*Kubelet)(nil)
    22  
    23  // Dependencies returns the dependency of the kubeconfig.
    24  func (k *Kubelet) Dependencies() []asset.Asset {
    25  	return []asset.Asset{
    26  		&tls.KubeAPIServerCompleteCABundle{},
    27  		&tls.KubeletClientCertKey{},
    28  		&installconfig.InstallConfig{},
    29  	}
    30  }
    31  
    32  // Generate generates the kubeconfig.
    33  func (k *Kubelet) Generate(_ context.Context, parents asset.Parents) error {
    34  	ca := &tls.KubeAPIServerCompleteCABundle{}
    35  	clientcertkey := &tls.KubeletClientCertKey{}
    36  	installConfig := &installconfig.InstallConfig{}
    37  	parents.Get(ca, clientcertkey, installConfig)
    38  
    39  	return k.kubeconfig.generate(
    40  		ca,
    41  		clientcertkey,
    42  		getIntAPIServerURL(installConfig.Config),
    43  		installConfig.Config.GetName(),
    44  		"kubelet",
    45  		kubeconfigKubeletPath,
    46  	)
    47  }
    48  
    49  // Name returns the human-friendly name of the asset.
    50  func (k *Kubelet) Name() string {
    51  	return "Kubeconfig Kubelet"
    52  }
    53  
    54  // Load is a no-op because kubelet kubeconfig is not written to disk.
    55  func (k *Kubelet) Load(asset.FileFetcher) (bool, error) {
    56  	return false, nil
    57  }