func()

in pkg/resources/statefulset/mysqld_statefulset.go [233:276]


func (mss *mysqldStatefulSet) getInitDBContainer(nc *v1.NdbCluster) corev1.Container {
	// Generate the command and arguments to be used
	cmdAndArgs := append([]string{
		helperScriptsMountPath + "/" + constants.MysqldInitScript,
	}, mss.getMySQLServerCmd(nc)...)

	mysqlInitContainer := mss.createContainer(nc,
		mss.getContainerName(true),
		cmdAndArgs, mss.getVolumeMounts(nc), mysqldPorts)

	// Add Env variables required by init script
	ndbOperatorPodNamespace, _ := helpers.GetCurrentNamespace()
	rootPasswordSecretName, _ := resources.GetMySQLRootPasswordSecretName(nc)
	mysqlInitContainer.Env = append(mysqlInitContainer.Env, corev1.EnvVar{
		// Password of the root user
		Name: "MYSQL_ROOT_PASSWORD",
		ValueFrom: &corev1.EnvVarSource{
			SecretKeyRef: &corev1.SecretKeySelector{
				LocalObjectReference: corev1.LocalObjectReference{
					Name: rootPasswordSecretName,
				},
				Key: corev1.BasicAuthPasswordKey,
			},
		},
	}, corev1.EnvVar{
		// Host from which the ndb operator user account can be accessed.
		// Use the hostname defined by the Ndb Operator deployment's template spec.
		Name:  "NDB_OPERATOR_HOST",
		Value: "ndb-operator-pod.ndb-operator-svc." + ndbOperatorPodNamespace + ".svc.%",
	}, corev1.EnvVar{
		// Password of the NDB operator user
		Name: "NDB_OPERATOR_PASSWORD",
		ValueFrom: &corev1.EnvVarSource{
			SecretKeyRef: &corev1.SecretKeySelector{
				LocalObjectReference: corev1.LocalObjectReference{
					Name: resources.GetMySQLNDBOperatorPasswordSecretName(nc),
				},
				Key: corev1.BasicAuthPasswordKey,
			},
		},
	})

	return mysqlInitContainer
}