MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / Pod

Function Pod

internal/pgadmin/reconcile.go:154–301  ·  view source on GitHub ↗

Pod populates a PodSpec with the container and volumes needed to run pgAdmin.

(
	inCluster *v1beta1.PostgresCluster,
	inConfigMap *corev1.ConfigMap,
	outPod *corev1.PodSpec, pgAdminVolume *corev1.PersistentVolumeClaim,
)

Source from the content-addressed store, hash-verified

152
153// Pod populates a PodSpec with the container and volumes needed to run pgAdmin.
154func Pod(
155 inCluster *v1beta1.PostgresCluster,
156 inConfigMap *corev1.ConfigMap,
157 outPod *corev1.PodSpec, pgAdminVolume *corev1.PersistentVolumeClaim,
158) {
159 if inCluster.Spec.UserInterface == nil || inCluster.Spec.UserInterface.PGAdmin == nil {
160 // pgAdmin is disabled; there is nothing to do.
161 return
162 }
163
164 // create the pgAdmin Pod volumes
165 tmp := corev1.Volume{Name: tmpVolume}
166 tmp.EmptyDir = &corev1.EmptyDirVolumeSource{
167 Medium: corev1.StorageMediumMemory,
168 }
169
170 pgAdminLog := corev1.Volume{Name: logVolume}
171 pgAdminLog.EmptyDir = &corev1.EmptyDirVolumeSource{
172 Medium: corev1.StorageMediumMemory,
173 }
174
175 pgAdminData := corev1.Volume{Name: dataVolume}
176 pgAdminData.VolumeSource = corev1.VolumeSource{
177 PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
178 ClaimName: pgAdminVolume.Name,
179 ReadOnly: false,
180 },
181 }
182
183 configVolumeMount := corev1.VolumeMount{
184 Name: "pgadmin-config", MountPath: configMountPath, ReadOnly: true,
185 }
186 configVolume := corev1.Volume{Name: configVolumeMount.Name}
187 configVolume.Projected = &corev1.ProjectedVolumeSource{
188 Sources: podConfigFiles(inConfigMap, *inCluster.Spec.UserInterface.PGAdmin),
189 }
190
191 startupVolumeMount := corev1.VolumeMount{
192 Name: "pgadmin-startup", MountPath: startupMountPath, ReadOnly: true,
193 }
194 startupVolume := corev1.Volume{Name: startupVolumeMount.Name}
195 startupVolume.EmptyDir = &corev1.EmptyDirVolumeSource{
196 Medium: corev1.StorageMediumMemory,
197
198 // When this volume is too small, the Pod will be evicted and recreated
199 // by the StatefulSet controller.
200 // - https://kubernetes.io/docs/concepts/storage/volumes/#emptydir
201 // NOTE: tmpfs blocks are PAGE_SIZE, usually 4KiB, and size rounds up.
202 SizeLimit: resource.NewQuantity(32<<10, resource.BinarySI),
203 }
204
205 // pgadmin container
206 container := corev1.Container{
207 Name: naming.ContainerPGAdmin,
208 Env: []corev1.EnvVar{
209 {
210 Name: "PGADMIN_SETUP_EMAIL",
211 Value: loginEmail,

Callers 2

TestPodFunction · 0.70

Calls 4

PGAdminContainerImageFunction · 0.92
podConfigFilesFunction · 0.70
startupCommandFunction · 0.70

Tested by 1

TestPodFunction · 0.56