// apim1Deployment creates a new Deployment for a Apimanager instance 1 resource. It also sets
// the appropriate OwnerReferences on the resource so handleObject can discover
// the Apimanager resource that 'owns' it.
apim1Deployment creates a new Deployment for a Apimanager instance 1 resource. It also sets
the appropriate OwnerReferences on the resource so handleObject can discover
the Apimanager resource that 'owns' it.
// apim1Deployment creates a new Deployment for a Apimanager instance 1 resource . It also sets // the appropriate OwnerReferences on the resource so handleObject can discover // the Apimanager resource that ' owns ' it .
func apim1Deployment(apimanager *apimv1alpha1.Apimanager) *appsv1.Deployment {
	labels := map[string]string{
		"deployment": "wso2am-pattern-1-am",
		"node": "wso2am-pattern-1-am-1",
	}
	return &appsv1.Deployment{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "apim-1-deploy",
			Namespace: apimanager.Namespace,
			OwnerReferences: []metav1.OwnerReference{
				*metav1.NewControllerRef(apimanager, apimv1alpha1.SchemeGroupVersion.WithKind("Apimanager")),
			},
		},
		Spec: appsv1.DeploymentSpec{
			Replicas: apimanager.Spec.Replicas,
			MinReadySeconds:240,
			Strategy: appsv1.DeploymentStrategy{
				Type: appsv1.DeploymentStrategyType(appsv1.RollingUpdateDaemonSetStrategyType),
				RollingUpdate: &appsv1.RollingUpdateDeployment{
					MaxSurge: &intstr.IntOrString{
						Type:   intstr.Int,
						IntVal: 1,
					},
					MaxUnavailable: &intstr.IntOrString{
						Type:   intstr.Int,
						IntVal: 0,
					},
				},
			},
			Selector: &metav1.LabelSelector{
				MatchLabels: labels,
			},
			Template: corev1.PodTemplateSpec{
				ObjectMeta: metav1.ObjectMeta{
					Labels: labels,
				},
				Spec: corev1.PodSpec{
					HostAliases: []corev1.HostAlias{
						{
							IP: "127.0.0.1",
							Hostnames: []string{
								"wso2-am",
								"wso2-gateway",
							},
						},
					},
						},
							Name: "init-am-analytics-worker",
					 "-c", "echo -e \"Checking for the availability of WSO2 API Manager Analytics Worker deployment\" ; while ! nc -z \"while ! nc -z \"wso2am-pattern-1-analytics-worker-service 7712; do sleep 1; printf \"-\" ;done; echo -e \" >> WSO2 API Manager Analytics Worker has started \"; ",
						},
					},
					Containers: []corev1.Container{
						{
							Name:  "wso2-pattern-1-am",
							Image: "wso2/wso2am:3.0.0",
							LivenessProbe: &corev1.Probe{
								Handler: corev1.Handler{
									Exec:&corev1.ExecAction{
										Command:[]string{
											"/bin/sh",
											"-c",
											"nc -z localhost 9443",
										},
									},
								},
								InitialDelaySeconds: 240,
								PeriodSeconds:       10,
							},
							ReadinessProbe: &corev1.Probe{
								Handler: corev1.Handler{
									Exec:&corev1.ExecAction{
										Command:[]string{
											"/bin/sh",
											"-c",
											"nc -z localhost 9443",
										},
									},
								},
								InitialDelaySeconds: 240,
								PeriodSeconds:       10,
							},
							Lifecycle: &corev1.Lifecycle{
								PreStop:&corev1.Handler{
									Exec:&corev1.ExecAction{
										Command:[]string{
											"sh",
											"-c",
											"${WSO2_SERVER_HOME}/bin/worker.sh stop",
										},
									},
								},
							},
							Resources:corev1.ResourceRequirements{
								Requests:corev1.ResourceList{
									corev1.ResourceCPU:apim1cpu,
									corev1.ResourceMemory:apim1mem,
								},
								Limits:corev1.ResourceList{
									corev1.ResourceCPU:apim1cpu2,
									corev1.ResourceMemory:apim1mem2,
								},
							},
							ImagePullPolicy: "Always",
							Ports: []corev1.ContainerPort{
								{
									ContainerPort: 8280,
									Protocol:      "TCP",
								},
								{
									ContainerPort: 8243,
									Protocol:      "TCP",
								},
								{
									ContainerPort: 9763,
									Protocol:      "TCP",
								},
								{
									ContainerPort: 9443,
									Protocol:      "TCP",
								},
							},
							Env: []corev1.EnvVar{
								 {
								 	Name:  "HOST_NAME",
								 	Value: "wso2-am",
								 },
								{
									Name: "NODE_IP",
									ValueFrom: &corev1.EnvVarSource{
										FieldRef: &corev1.ObjectFieldSelector{
											FieldPath: "status.podIP",
										},
									},
								},
							},
							VolumeMounts: []corev1.VolumeMount{
								{
									Name: "wso2am-pattern-1-am-volume-claim-synapse-configs",
									MountPath: "/home/wso2carbon/wso2-artifact-volume/repository/deployment/server/synapse-configs",
								},
								{
									Name: "wso2am-pattern-1-am-volume-claim-executionplans",
									MountPath:"/home/wso2carbon/wso2-artifact-volume/repository/deployment/server/executionplans",
								},
								{
									Name: "wso2am-pattern-1-am-1-conf",
									MountPath: "/home/wso2carbon/wso2-config-volume/repository/conf/deployment.toml",
									SubPath:"deployment.toml",
								},
								{
									Name: "mysql-jdbc-driver",
									MountPath: "/home/wso2carbon/wso2-artifact-volume/repository/components/lib",
								},
								{
									Name: "wso2am-pattern-1-am-conf-entrypoint",
									MountPath: "/home/wso2carbon/docker-entrypoint.sh",
									SubPath:"docker-entrypoint.sh",
								},
							},
						},
					},
					ServiceAccountName: "wso2am-pattern-1-svc-account",
					ImagePullSecrets:[]corev1.LocalObjectReference{
						{
							Name:"wso2am-pattern-1-creds",
						},
					},
					Volumes: []corev1.Volume{
						{
							Name: "wso2am-pattern-1-am-volume-claim-synapse-configs",
							VolumeSource: corev1.VolumeSource{
								PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
									ClaimName:"pvc-synapse-configs",
								},
							},
						},
						{
							Name: "wso2am-pattern-1-am-volume-claim-executionplans",
							VolumeSource: corev1.VolumeSource{
								PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
									ClaimName: "pvc-execution-plans",
								},
							},
						},
						{
							Name: "wso2am-pattern-1-am-1-conf",
							VolumeSource: corev1.VolumeSource{
								ConfigMap: &corev1.ConfigMapVolumeSource{
									LocalObjectReference: corev1.LocalObjectReference{
										Name: "wso2am-pattern-1-am-1-conf",
									},
								},
							},
						},
						{
							Name: "wso2am-pattern-1-am-conf-entrypoint",
							VolumeSource: corev1.VolumeSource{
								ConfigMap: &corev1.ConfigMapVolumeSource{
									LocalObjectReference: corev1.LocalObjectReference{
										Name: "wso2am-pattern-1-am-conf-entrypoint",
									},
									DefaultMode:&defaultmode,
							},
						},
						{
							Name: "mysql-jdbc-driver",
							VolumeSource: corev1.VolumeSource{
								ConfigMap: &corev1.ConfigMapVolumeSource{
									LocalObjectReference: corev1.LocalObjectReference{
										Name: "mysql-jdbc-driver-cm",
									},
								},
							},
						},
					},
				},
			},
		},
	}
}
func apim1Deployment ( apimanager * apimv1alpha1 . Apimanager ) * appsv1 . Deployment { labels := map [ string ] string { " " : " " , " " : " " , } return & appsv1 . Deployment { ObjectMeta : metav1 . ObjectMeta { Name : " " , Namespace : apimanager . Namespace , OwnerReferences : [ ] metav1 . OwnerReference { * metav1 . NewControllerRef ( apimanager , apimv1alpha1 . SchemeGroupVersion . WithKind ( " " ) ) , } , } , Spec : appsv1 . DeploymentSpec { Replicas : apimanager . Spec . Replicas , MinReadySeconds : 240 , Strategy : appsv1 . DeploymentStrategy { Type : appsv1 . DeploymentStrategyType ( appsv1 . RollingUpdateDaemonSetStrategyType ) , RollingUpdate : & appsv1 . RollingUpdateDeployment { MaxSurge : & intstr . IntOrString { Type : intstr . Int , IntVal : 1 , } , MaxUnavailable : & intstr . IntOrString { Type : intstr . Int , IntVal : 0 , } , } , } , Selector : & metav1 . LabelSelector { MatchLabels : labels , } , Template : corev1 . PodTemplateSpec { ObjectMeta : metav1 . ObjectMeta { Labels : labels , } , Spec : corev1 . PodSpec { HostAliases : [ ] corev1 . HostAlias { { IP : " " , Hostnames : [ ] string { " " , " " , } , } , } , Containers : [ ] corev1 . Container { { Name : " " , Image : " " , LivenessProbe : & corev1 . Probe { Handler : corev1 . Handler { Exec : & corev1 . ExecAction { Command : [ ] string { " " , " " , " " , } , } , } , InitialDelaySeconds : 240 , PeriodSeconds : 10 , } , ReadinessProbe : & corev1 . Probe { Handler : corev1 . Handler { Exec : & corev1 . ExecAction { Command : [ ] string { " " , " " , " " , } , } , } , InitialDelaySeconds : 240 , PeriodSeconds : 10 , } , Lifecycle : & corev1 . Lifecycle { PreStop : & corev1 . Handler { Exec : & corev1 . ExecAction { Command : [ ] string { " " , " " , " " , } , } , } , } , ImagePullPolicy : " " , Ports : [ ] corev1 . ContainerPort { { ContainerPort : 8280 , Protocol : " " , } , { ContainerPort : 8243 , Protocol : " " , } , { ContainerPort : 9763 , Protocol : " " , } , { ContainerPort : 9443 , Protocol : " " , } , } , Env : [ ] corev1 . EnvVar { { Name : " " , ValueFrom : & corev1 . EnvVarSource { FieldRef : & corev1 . ObjectFieldSelector { FieldPath : " " , } , } , } , } , VolumeMounts : [ ] corev1 . VolumeMount { { Name : " " , MountPath : " " , } , { Name : " " , MountPath : " " , } , { Name : " " , MountPath : " " , SubPath : " " , } , { Name : " " , MountPath : " " , } , } , } , } , ServiceAccountName : " " , ImagePullSecrets : [ ] corev1 . LocalObjectReference { { Name : " " , } , } , Volumes : [ ] corev1 . Volume { { Name : " " , VolumeSource : corev1 . VolumeSource { PersistentVolumeClaim : & corev1 . PersistentVolumeClaimVolumeSource { ClaimName : " " , } , } , } , { Name : " " , VolumeSource : corev1 . VolumeSource { PersistentVolumeClaim : & corev1 . PersistentVolumeClaimVolumeSource { ClaimName : " " , } , } , } , { Name : " " , VolumeSource : corev1 . VolumeSource { ConfigMap : & corev1 . ConfigMapVolumeSource { LocalObjectReference : corev1 . LocalObjectReference { Name : " " , } , } , } , } , { Name : " " , VolumeSource : corev1 . VolumeSource { ConfigMap : & corev1 . ConfigMapVolumeSource { LocalObjectReference : corev1 . LocalObjectReference { Name : " " , } , } , } , } , } , } , } , } , } }
apim1Deployment creates a new Deployment for a Apimanager instance 1 resource.
apim1Deployment creates a new Deployment for a Apimanager instance 1 resource .
//apim1cpu, _ :=resource.ParseQuantity("2000m") //apim1mem, _ := resource.ParseQuantity("2Gi") //apim1cpu2, _ :=resource.ParseQuantity("3000m") //apim1mem2, _ := resource.ParseQuantity("3Gi") //defaultmode := int32(0407) //InitContainers: []corev1.Container{ //	{ //		Name: "init-apim-analytics-db", //		Image: "busybox:1.31", //		Command: []string { //			//"sh", "-c", "echo -e \"Checking for the availability of MySQL Server deployment\" ; while ! nc -z \"while ! nc -z \"wso2am-mysql-db-service \"3306; do sleep 1; printf \"-\" ;done; echo -e \" >> MySQL Server has started \"; ", //			"sh", //			"-c", //			"echo -e \"Checking for the availability of MySQL Server deployment\"; while ! nc -z \"wso2am-mysql-db-service\" 3306; do sleep 1; printf \"-\"; done; echo -e \"  >> MySQL Server has started\";", //		}, // //	}, //	{ //		Name: "init-am-analytics-worker", //		Image: "busybox:1.31", //		Command: []string { //			"sh", "-c", "echo -e \"Checking for the availability of WSO2 API Manager Analytics Worker deployment\" ; while ! nc -z \"while ! nc -z \"wso2am-pattern-1-analytics-worker-service 7712; do sleep 1; printf \"-\" ;done; echo -e \" >> WSO2 API Manager Analytics Worker has started \"; ", //		}, // //	}, //}, //Resources:corev1.ResourceRequirements{ //	Requests:corev1.ResourceList{ //		corev1.ResourceCPU:apim1cpu, //		corev1.ResourceMemory:apim1mem, //	}, //	Limits:corev1.ResourceList{ //		corev1.ResourceCPU:apim1cpu2, //		corev1.ResourceMemory:apim1mem2, //	}, //}, // { // 	Name:  "HOST_NAME", // 	Value: "wso2-am", // }, //{ //	Name: "wso2am-pattern-1-am-conf-entrypoint", //	MountPath: "/home/wso2carbon/docker-entrypoint.sh", //	SubPath:"docker-entrypoint.sh", //}, //{ //	Name: "wso2am-pattern-1-am-conf-entrypoint", //	VolumeSource: corev1.VolumeSource{ //		ConfigMap: &corev1.ConfigMapVolumeSource{ //			LocalObjectReference: corev1.LocalObjectReference{ //				Name: "wso2am-pattern-1-am-conf-entrypoint", //			}, //			DefaultMode:&defaultmode, //		}, //	}, //},