// mysqlDeployment creates a new Deployment for a MySQL
mysqlDeployment creates a new Deployment for a MySQL
// mysqlDeployment creates a new Deployment for a MySQL
func mysqlDeployment(apimanager *apimv1alpha1.Apimanager) *appsv1.Deployment {
	labels := map[string]string{
		"deployment": "wso2apim-with-analytics-mysql",
	}
	runasuser := int64(999)
	mysqlreplics := int32(1)
	return &appsv1.Deployment{
		ObjectMeta: metav1.ObjectMeta{
			Name:      "mysql-deploy",
			Namespace: apimanager.Namespace,
			OwnerReferences: []metav1.OwnerReference{
				*metav1.NewControllerRef(apimanager, apimv1alpha1.SchemeGroupVersion.WithKind("Apimanager")),
			},
		},
		Spec: appsv1.DeploymentSpec{
			Replicas: &mysqlreplics,
			Selector: &metav1.LabelSelector{
				MatchLabels: labels,
			},
			Template: corev1.PodTemplateSpec{
				ObjectMeta: metav1.ObjectMeta{
					Labels: labels,
				},
				Spec: corev1.PodSpec{
					Containers: []corev1.Container{
						{
							Name:  "wso2apim-with-analytics-mysql",
							Image: "mysql:5.7",
							ImagePullPolicy: "IfNotPresent",
							SecurityContext: &corev1.SecurityContext{
								RunAsUser: &runasuser,
							},
							Env: []corev1.EnvVar{
								{
									Name:  "MYSQL_ROOT_PASSWORD",
									Value: "root",
								},
								{
									Name:  "MYSQL_USER",
									Value: "wso2carbon",
								},
								{
									Name:  "MYSQL_PASSWORD",
									Value: "wso2carbon",
								},
							},
							Ports: []corev1.ContainerPort{
								{
									ContainerPort: 3306,
									Protocol:      "TCP",
								},
							},
							VolumeMounts: []corev1.VolumeMount{
								{
									Name: "mysql-dbscripts",
									MountPath: "/docker-entrypoint-initdb.d",
								},
								{
									Name: "apim-rdbms-persistent-storage",
									MountPath: "/var/lib/mysql",
								},
							},
							Args: []string{
								"--max-connections",
								"10000",
							},
						},
					},
					Volumes: []corev1.Volume{
						{
							Name: "mysql-dbscripts",
							VolumeSource: corev1.VolumeSource{
								ConfigMap: &corev1.ConfigMapVolumeSource{
									LocalObjectReference: corev1.LocalObjectReference{
										Name: "mysql-dbscripts",
									},
								},
							},
						},
						{
							Name: "apim-rdbms-persistent-storage",
							VolumeSource: corev1.VolumeSource{
								PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
									ClaimName:"pvc-mysql",
								},
							},
						},
					},
					ServiceAccountName: "wso2am-pattern-1-svc-account",
				},
			},
		},
	}
}
func mysqlDeployment ( apimanager * apimv1alpha1 . Apimanager ) * appsv1 . Deployment { labels := map [ string ] string { " " : " " , } runasuser := int64 ( 999 ) mysqlreplics := int32 ( 1 ) return & appsv1 . Deployment { ObjectMeta : metav1 . ObjectMeta { Name : " " , Namespace : apimanager . Namespace , OwnerReferences : [ ] metav1 . OwnerReference { * metav1 . NewControllerRef ( apimanager , apimv1alpha1 . SchemeGroupVersion . WithKind ( " " ) ) , } , } , Spec : appsv1 . DeploymentSpec { Replicas : & mysqlreplics , Selector : & metav1 . LabelSelector { MatchLabels : labels , } , Template : corev1 . PodTemplateSpec { ObjectMeta : metav1 . ObjectMeta { Labels : labels , } , Spec : corev1 . PodSpec { Containers : [ ] corev1 . Container { { Name : " " , Image : " " , ImagePullPolicy : " " , SecurityContext : & corev1 . SecurityContext { RunAsUser : & runasuser , } , Env : [ ] corev1 . EnvVar { { Name : " " , Value : " " , } , { Name : " " , Value : " " , } , { Name : " " , Value : " " , } , } , Ports : [ ] corev1 . ContainerPort { { ContainerPort : 3306 , Protocol : " " , } , } , VolumeMounts : [ ] corev1 . VolumeMount { { Name : " " , MountPath : " " , } , { Name : " " , MountPath : " " , } , } , Args : [ ] string { " " , " " , } , } , } , Volumes : [ ] corev1 . Volume { { Name : " " , VolumeSource : corev1 . VolumeSource { ConfigMap : & corev1 . ConfigMapVolumeSource { LocalObjectReference : corev1 . LocalObjectReference { Name : " " , } , } , } , } , { Name : " " , VolumeSource : corev1 . VolumeSource { PersistentVolumeClaim : & corev1 . PersistentVolumeClaimVolumeSource { ClaimName : " " , } , } , } , } , ServiceAccountName : " " , } , } , } , } }
mysqlDeployment creates a new Deployment for a MySQL
mysqlDeployment creates a new Deployment for a MySQL