|
| 1 | +/* |
| 2 | +Copyright 2021 RadonDB. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package container |
| 18 | + |
| 19 | +import ( |
| 20 | + corev1 "k8s.io/api/core/v1" |
| 21 | + |
| 22 | + "github.com/radondb/radondb-mysql-kubernetes/mysqlcluster" |
| 23 | + "github.com/radondb/radondb-mysql-kubernetes/utils" |
| 24 | +) |
| 25 | + |
| 26 | +// errorLog used for auditlog container. |
| 27 | +type errorLog struct { |
| 28 | + *mysqlcluster.MysqlCluster |
| 29 | + |
| 30 | + // The name of the auditlog container. |
| 31 | + name string |
| 32 | +} |
| 33 | + |
| 34 | +// getName get the container name. |
| 35 | +func (c *errorLog) getName() string { |
| 36 | + return c.name |
| 37 | +} |
| 38 | + |
| 39 | +// getImage get the container image. |
| 40 | +func (c *errorLog) getImage() string { |
| 41 | + return c.Spec.PodPolicy.BusyboxImage |
| 42 | +} |
| 43 | + |
| 44 | +// getCommand get the container command. |
| 45 | +func (c *errorLog) getCommand() []string { |
| 46 | + logsName := "/mysql-error.log" |
| 47 | + return []string{"sh", "-c", "while true; do if [ -f " + utils.LogsVolumeMountPath + logsName + " ] ; then break; fi;sleep 1; done; " + |
| 48 | + "tail -f " + utils.LogsVolumeMountPath + logsName} |
| 49 | +} |
| 50 | + |
| 51 | +// getEnvVars get the container env. |
| 52 | +func (c *errorLog) getEnvVars() []corev1.EnvVar { |
| 53 | + return nil |
| 54 | +} |
| 55 | + |
| 56 | +// getLifecycle get the container lifecycle. |
| 57 | +func (c *errorLog) getLifecycle() *corev1.Lifecycle { |
| 58 | + return nil |
| 59 | +} |
| 60 | + |
| 61 | +// getResources get the container resources. |
| 62 | +func (c *errorLog) getResources() corev1.ResourceRequirements { |
| 63 | + return c.Spec.PodPolicy.ExtraResources |
| 64 | +} |
| 65 | + |
| 66 | +// getPorts get the container ports. |
| 67 | +func (c *errorLog) getPorts() []corev1.ContainerPort { |
| 68 | + return nil |
| 69 | +} |
| 70 | + |
| 71 | +// getLivenessProbe get the container livenessProbe. |
| 72 | +func (c *errorLog) getLivenessProbe() *corev1.Probe { |
| 73 | + return nil |
| 74 | +} |
| 75 | + |
| 76 | +// getReadinessProbe get the container readinessProbe. |
| 77 | +func (c *errorLog) getReadinessProbe() *corev1.Probe { |
| 78 | + return nil |
| 79 | +} |
| 80 | + |
| 81 | +// getVolumeMounts get the container volumeMounts. |
| 82 | +func (c *errorLog) getVolumeMounts() []corev1.VolumeMount { |
| 83 | + return []corev1.VolumeMount{ |
| 84 | + { |
| 85 | + Name: utils.LogsVolumeName, |
| 86 | + MountPath: utils.LogsVolumeMountPath, |
| 87 | + }, |
| 88 | + } |
| 89 | +} |
0 commit comments