// Generate generates the cert/key pair based on its dependencies.
Generate generates the cert/key pair based on its dependencies.
// Generate generates the cert / key pair based on its dependencies .
func (a *APIServerCertKey) Generate(dependencies asset.Parents) error {
	kubeCA := &KubeCA{}
	installConfig := &installconfig.InstallConfig{}
	dependencies.Get(kubeCA, installConfig)
	apiServerAddress, err := cidrhost(installConfig.Config.Networking.ServiceCIDR.IPNet, 1)
	if err != nil {
		return errors.Wrap(err, "failed to get API Server address from InstallConfig")
	}
	cfg := &CertCfg{
		Subject:      pkix.Name{CommonName: "kube-apiserver", Organization: []string{"kube-master"}},
		KeyUsages:    x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
		ExtKeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth},
		Validity:     ValidityTenYears,
		DNSNames: []string{
			apiAddress(installConfig.Config),
			"kubernetes", "kubernetes.default",
			"kubernetes.default.svc",
			"kubernetes.default.svc.cluster.local",
			"localhost",
		},
		IPAddresses: []net.IP{net.ParseIP(apiServerAddress), net.ParseIP("127.0.0.1")},
	}
	return a.CertKey.Generate(cfg, kubeCA, "apiserver", AppendParent)
}
func ( a * APIServerCertKey ) Generate ( dependencies asset . Parents ) error { kubeCA := & KubeCA { } installConfig := & installconfig . InstallConfig { } dependencies . Get ( kubeCA , installConfig ) apiServerAddress , err := cidrhost ( installConfig . Config . Networking . ServiceCIDR . IPNet , 1 ) if err != nil { return errors . Wrap ( err , " " ) } cfg := & CertCfg { Subject : pkix . Name { CommonName : " " , Organization : [ ] string { " " } } , KeyUsages : x509 . KeyUsageKeyEncipherment | x509 . KeyUsageDigitalSignature , ExtKeyUsages : [ ] x509 . ExtKeyUsage { x509 . ExtKeyUsageServerAuth , x509 . ExtKeyUsageClientAuth } , Validity : ValidityTenYears , DNSNames : [ ] string { apiAddress ( installConfig . Config ) , " " , " " , " " , " " , " " , } , IPAddresses : [ ] net . IP { net . ParseIP ( apiServerAddress ) , net . ParseIP ( " " ) } , } return a . CertKey . Generate ( cfg , kubeCA , " " , AppendParent ) }
Generate generates the cert/key pair based on its dependencies.
Generate generates the cert / key pair based on its dependencies .