func NewEtcdServerCertSecret(e *v1alpha1.EtcdCluster, caSecret *corev1.Secret) (*corev1.Secret, error) {
	dnss := defaultDNSsForEtcdServer(e)
	dnss = append(dnss, e.Spec.Secure.TLS.AutoTLSCert.ExtraServerCertSANs...)

	var ips []net.IP
	for _, i := range e.Status.LoadBalancer.Ingress {
		ips = append(ips, net.ParseIP(i.IP))
	}

	cert, key, err := GenerateCertAndKey(CertConfig{
		CommonName:  "root",
		DNSs:        dnss,
		IPs:         ips,
		CACert:      caSecret.Data[EtcdCACertName],
		CAKey:       caSecret.Data[EtcdCAKeyName],
		KeyUsage:    x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
		ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
		NotAfter:    time.Now().AddDate(10, 0, 0).UTC(),
	})
	if err != nil {
		return nil, err
	}
	secret := &corev1.Secret{
		ObjectMeta: v1.ObjectMeta{
			Namespace: e.Namespace,
			Name:      NameForEtcdCertSecret(e.Name, EtcdServerCert),
		},
		Data: map[string][]byte{
			EtcdCACertName:     caSecret.Data[EtcdCACertName],
			EtcdServerCertName: cert,
			EtcdServerKeyName:  key,
		},
	}
	controller.SetEtcdOwnerReference(&secret.ObjectMeta, e)

	return secret, nil
}
// NewEtcdServerCertSecret will generate an new etcd server certificate secret based on the etcd cluster's configuration
NewEtcdServerCertSecret will generate an new etcd server certificate secret based on the etcd cluster's configuration
// NewEtcdServerCertSecret will generate an new etcd server certificate secret based on the etcd cluster ' s configuration
func NewEtcdServerCertSecret(e *v1alpha1.EtcdCluster, caSecret *corev1.Secret) (*corev1.Secret, error) {
	dnss := defaultDNSsForEtcdServer(e)
	dnss = append(dnss, e.Spec.Secure.TLS.AutoTLSCert.ExtraServerCertSANs...)
	var ips []net.IP
	for _, i := range e.Status.LoadBalancer.Ingress {
		ips = append(ips, net.ParseIP(i.IP))
	}
	cert, key, err := GenerateCertAndKey(CertConfig{
		CommonName:  "root",
		DNSs:        dnss,
		IPs:         ips,
		CACert:      caSecret.Data[EtcdCACertName],
		CAKey:       caSecret.Data[EtcdCAKeyName],
		KeyUsage:    x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
		ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
		NotAfter:    time.Now().AddDate(10, 0, 0).UTC(),
	})
	if err != nil {
		return nil, err
	}
	secret := &corev1.Secret{
		ObjectMeta: v1.ObjectMeta{
			Namespace: e.Namespace,
			Name:      NameForEtcdCertSecret(e.Name, EtcdServerCert),
		},
		Data: map[string][]byte{
			EtcdCACertName:     caSecret.Data[EtcdCACertName],
			EtcdServerCertName: cert,
			EtcdServerKeyName:  key,
		},
	}
	controller.SetEtcdOwnerReference(&secret.ObjectMeta, e)
	return secret, nil
}
func NewEtcdServerCertSecret ( e * v1alpha1 . EtcdCluster , caSecret * corev1 . Secret ) ( * corev1 . Secret , error ) { dnss := defaultDNSsForEtcdServer ( e ) dnss = append ( dnss , e . Spec . Secure . TLS . AutoTLSCert . ExtraServerCertSANs ... ) var ips [ ] net . IP for _ , i := range e . Status . LoadBalancer . Ingress { ips = append ( ips , net . ParseIP ( i . IP ) ) } cert , key , err := GenerateCertAndKey ( CertConfig { CommonName : " " , DNSs : dnss , IPs : ips , CACert : caSecret . Data [ EtcdCACertName ] , CAKey : caSecret . Data [ EtcdCAKeyName ] , KeyUsage : x509 . KeyUsageKeyEncipherment | x509 . KeyUsageDigitalSignature , ExtKeyUsage : [ ] x509 . ExtKeyUsage { x509 . ExtKeyUsageClientAuth , x509 . ExtKeyUsageServerAuth } , NotAfter : time . Now ( ) . AddDate ( 10 , 0 , 0 ) . UTC ( ) , } ) if err != nil { return nil , err } secret := & corev1 . Secret { ObjectMeta : v1 . ObjectMeta { Namespace : e . Namespace , Name : NameForEtcdCertSecret ( e . Name , EtcdServerCert ) , } , Data : map [ string ] [ ] byte { EtcdCACertName : caSecret . Data [ EtcdCACertName ] , EtcdServerCertName : cert , EtcdServerKeyName : key , } , } controller . SetEtcdOwnerReference ( & secret . ObjectMeta , e ) return secret , nil }
NewEtcdServerCertSecret will generate an new etcd server certificate secret based on the etcd cluster's configuration
NewEtcdServerCertSecret will generate an new etcd server certificate secret based on the etcd cluster ' s configuration