func DefaultTAppTemplateForEtcd(e *v1alpha1.EtcdCluster) corev1.PodTemplateSpec {
	tpl := corev1.PodTemplateSpec{
		ObjectMeta: v1.ObjectMeta{
			Name:        helpers.NameForTApp(e),
			Labels:      e.Spec.Template.Labels,
			Annotations: e.Spec.Template.Annotations,
		},
		Spec: corev1.PodSpec{
			Affinity:                  e.Spec.Template.Affinity,
			Tolerations:               e.Spec.Template.Tolerations,
			TopologySpreadConstraints: e.Spec.Template.TopologySpreadConstraints,
			InitContainers: []corev1.Container{
				NewEtcdInitContainer(e),
			},
			Containers: []corev1.Container{
				{
					Name:      "etcd",
					Image:     helpers.ImageForEtcd(e),
					Command:   []string{"etcd"},
					Env:       e.Spec.Template.Env,
					Resources: e.Spec.Template.Resources,
					LivenessProbe: &corev1.Probe{
						Handler: corev1.Handler{
							TCPSocket: &corev1.TCPSocketAction{
								Port: intstr.FromInt(constants.EtcdDefaultPeerPort),
							},
						},
						InitialDelaySeconds: 5,
						TimeoutSeconds:      1,
						PeriodSeconds:       10,
						SuccessThreshold:    1,
						FailureThreshold:    5,
					},
					ReadinessProbe: &corev1.Probe{
						Handler: corev1.Handler{
							TCPSocket: &corev1.TCPSocketAction{
								Port: func() intstr.IntOrString {
									if e.Spec.ClientPort != nil {
										return intstr.FromInt(int(*e.Spec.ClientPort))
									}
									return intstr.FromInt(constants.EtcdDefaultClientPort)
								}(),
							},
						},
						InitialDelaySeconds: 10,
						TimeoutSeconds:      1,
						PeriodSeconds:       10,
						SuccessThreshold:    1,
						FailureThreshold:    5,
					},
					Ports: []corev1.ContainerPort{
						{
							Name:          constants.EtcdPeerPortName,
							ContainerPort: constants.EtcdDefaultPeerPort,
						},
						{
							Name: constants.EtcdClientPortName,
							ContainerPort: func() int32 {
								if e.Spec.ClientPort != nil {
									return *e.Spec.ClientPort
								}
								return constants.EtcdDefaultClientPort
							}(),
						},
					},
					ImagePullPolicy: corev1.PullIfNotPresent,
				},
			},
		},
	}
	if tpl.Labels == nil {
		tpl.Labels = make(map[string]string)
	}
	tpl.Labels[constants.LabelEtcdClusterNameSelector] = e.Name
	tpl.Labels[constants.LabelEtcdVotingMemberSelector] = "true"

	return tpl
}
// DefaultTAppTemplateForEtcd create TApp template from the EtcdCluster template
DefaultTAppTemplateForEtcd create TApp template from the EtcdCluster template
// DefaultTAppTemplateForEtcd create TApp template from the EtcdCluster template
func DefaultTAppTemplateForEtcd(e *v1alpha1.EtcdCluster) corev1.PodTemplateSpec {
	tpl := corev1.PodTemplateSpec{
		ObjectMeta: v1.ObjectMeta{
			Name:        helpers.NameForTApp(e),
			Labels:      e.Spec.Template.Labels,
			Annotations: e.Spec.Template.Annotations,
		},
		Spec: corev1.PodSpec{
			Affinity:                  e.Spec.Template.Affinity,
			Tolerations:               e.Spec.Template.Tolerations,
			TopologySpreadConstraints: e.Spec.Template.TopologySpreadConstraints,
			InitContainers: []corev1.Container{
				NewEtcdInitContainer(e),
			},
			Containers: []corev1.Container{
				{
					Name:      "etcd",
					Image:     helpers.ImageForEtcd(e),
					Command:   []string{"etcd"},
					Env:       e.Spec.Template.Env,
					Resources: e.Spec.Template.Resources,
					LivenessProbe: &corev1.Probe{
						Handler: corev1.Handler{
							TCPSocket: &corev1.TCPSocketAction{
								Port: intstr.FromInt(constants.EtcdDefaultPeerPort),
							},
						},
						InitialDelaySeconds: 5,
						TimeoutSeconds:      1,
						PeriodSeconds:       10,
						SuccessThreshold:    1,
						FailureThreshold:    5,
					},
					ReadinessProbe: &corev1.Probe{
						Handler: corev1.Handler{
							TCPSocket: &corev1.TCPSocketAction{
								Port: func() intstr.IntOrString {
									if e.Spec.ClientPort != nil {
										return intstr.FromInt(int(*e.Spec.ClientPort))
									}
									return intstr.FromInt(constants.EtcdDefaultClientPort)
								}(),
							},
						},
						InitialDelaySeconds: 10,
						TimeoutSeconds:      1,
						PeriodSeconds:       10,
						SuccessThreshold:    1,
						FailureThreshold:    5,
					},
					Ports: []corev1.ContainerPort{
						{
							Name:          constants.EtcdPeerPortName,
							ContainerPort: constants.EtcdDefaultPeerPort,
						},
						{
							Name: constants.EtcdClientPortName,
							ContainerPort: func() int32 {
								if e.Spec.ClientPort != nil {
									return *e.Spec.ClientPort
								}
								return constants.EtcdDefaultClientPort
							}(),
						},
					},
					ImagePullPolicy: corev1.PullIfNotPresent,
				},
			},
		},
	}
	if tpl.Labels == nil {
		tpl.Labels = make(map[string]string)
	}
	tpl.Labels[constants.LabelEtcdClusterNameSelector] = e.Name
	tpl.Labels[constants.LabelEtcdVotingMemberSelector] = "true"
	return tpl
}
func DefaultTAppTemplateForEtcd ( e * v1alpha1 . EtcdCluster ) corev1 . PodTemplateSpec { tpl := corev1 . PodTemplateSpec { ObjectMeta : v1 . ObjectMeta { Name : helpers . NameForTApp ( e ) , Labels : e . Spec . Template . Labels , Annotations : e . Spec . Template . Annotations , } , Spec : corev1 . PodSpec { Affinity : e . Spec . Template . Affinity , Tolerations : e . Spec . Template . Tolerations , TopologySpreadConstraints : e . Spec . Template . TopologySpreadConstraints , InitContainers : [ ] corev1 . Container { NewEtcdInitContainer ( e ) , } , Containers : [ ] corev1 . Container { { Name : " " , Image : helpers . ImageForEtcd ( e ) , Command : [ ] string { " " } , Env : e . Spec . Template . Env , Resources : e . Spec . Template . Resources , LivenessProbe : & corev1 . Probe { Handler : corev1 . Handler { TCPSocket : & corev1 . TCPSocketAction { Port : intstr . FromInt ( constants . EtcdDefaultPeerPort ) , } , } , InitialDelaySeconds : 5 , TimeoutSeconds : 1 , PeriodSeconds : 10 , SuccessThreshold : 1 , FailureThreshold : 5 , } , ReadinessProbe : & corev1 . Probe { Handler : corev1 . Handler { TCPSocket : & corev1 . TCPSocketAction { Port : func ( ) intstr . IntOrString { if e . Spec . ClientPort != nil { return intstr . FromInt ( int ( * e . Spec . ClientPort ) ) } return intstr . FromInt ( constants . EtcdDefaultClientPort ) } ( ) , } , } , InitialDelaySeconds : 10 , TimeoutSeconds : 1 , PeriodSeconds : 10 , SuccessThreshold : 1 , FailureThreshold : 5 , } , Ports : [ ] corev1 . ContainerPort { { Name : constants . EtcdPeerPortName , ContainerPort : constants . EtcdDefaultPeerPort , } , { Name : constants . EtcdClientPortName , ContainerPort : func ( ) int32 { if e . Spec . ClientPort != nil { return * e . Spec . ClientPort } return constants . EtcdDefaultClientPort } ( ) , } , } , ImagePullPolicy : corev1 . PullIfNotPresent , } , } , } , } if tpl . Labels == nil { tpl . Labels = make ( map [ string ] string ) } tpl . Labels [ constants . LabelEtcdClusterNameSelector ] = e . Name tpl . Labels [ constants . LabelEtcdVotingMemberSelector ] = " " return tpl }
DefaultTAppTemplateForEtcd create TApp template from the EtcdCluster template
DefaultTAppTemplateForEtcd create TApp template from the EtcdCluster template