sqs-operator v0.1.9: fix SQS_ENDPOINT context-path, add sidecar to source
- ensureDeployment: sidecar elasticmq-ui добавлен в Go-код (не Python патч) - SQS_ENDPOINT=http://localhost:9324/sqs/{tenantID} — с context-path - ElasticMQ не отвечает на root /, только на /sqs/{tenantID} - Sidecar условный: добавляется только при spec.enableUI=true
This commit is contained in:
@@ -527,71 +527,101 @@ func (r *QueueServiceReconciler) ensureDeployment(ctx context.Context, qs *sqsv1
|
||||
SecurityContext: &corev1.PodSecurityContext{
|
||||
FSGroup: func() *int64 { v := int64(999); return &v }(),
|
||||
},
|
||||
Containers: []corev1.Container{
|
||||
{
|
||||
Name: "elasticmq",
|
||||
Image: image,
|
||||
Ports: []corev1.ContainerPort{
|
||||
{ContainerPort: port, Protocol: corev1.ProtocolTCP},
|
||||
},
|
||||
// JVM-образ имеет ENTRYPOINT: java -Dconfig.file=/opt/elasticmq.conf -jar ...
|
||||
// JAVA_TOOL_OPTIONS задаёт Xmx чтобы JVM не выбил OOMKill ниже k8s лимита.
|
||||
Env: []corev1.EnvVar{
|
||||
{
|
||||
Name: "JAVA_TOOL_OPTIONS",
|
||||
Value: jvmOpts,
|
||||
Containers: func() []corev1.Container {
|
||||
ctrs := []corev1.Container{
|
||||
{
|
||||
Name: "elasticmq",
|
||||
Image: image,
|
||||
Ports: []corev1.ContainerPort{
|
||||
{ContainerPort: port, Protocol: corev1.ProtocolTCP},
|
||||
},
|
||||
},
|
||||
Resources: corev1.ResourceRequirements{
|
||||
Requests: corev1.ResourceList{
|
||||
corev1.ResourceCPU: cpuRequest,
|
||||
corev1.ResourceMemory: memRequest,
|
||||
},
|
||||
Limits: corev1.ResourceList{
|
||||
corev1.ResourceCPU: cpuLimit,
|
||||
corev1.ResourceMemory: memLimit,
|
||||
},
|
||||
},
|
||||
VolumeMounts: []corev1.VolumeMount{
|
||||
{
|
||||
// Монтируем конфиг на путь который JVM-образ читает по дефолту.
|
||||
Name: "elasticmq-config",
|
||||
MountPath: "/opt/elasticmq.conf",
|
||||
SubPath: "elasticmq.conf",
|
||||
ReadOnly: true,
|
||||
},
|
||||
{
|
||||
// PVC для H2 persistence
|
||||
Name: "elasticmq-data",
|
||||
MountPath: "/data",
|
||||
},
|
||||
},
|
||||
ReadinessProbe: &corev1.Probe{
|
||||
ProbeHandler: corev1.ProbeHandler{
|
||||
HTTPGet: &corev1.HTTPGetAction{
|
||||
Path: "/health",
|
||||
Port: intstr.FromInt(int(port)),
|
||||
Scheme: corev1.URISchemeHTTP,
|
||||
// JVM-образ имеет ENTRYPOINT: java -Dconfig.file=/opt/elasticmq.conf -jar ...
|
||||
// JAVA_TOOL_OPTIONS задаёт Xmx чтобы JVM не выбил OOMKill ниже k8s лимита.
|
||||
Env: []corev1.EnvVar{
|
||||
{
|
||||
Name: "JAVA_TOOL_OPTIONS",
|
||||
Value: jvmOpts,
|
||||
},
|
||||
},
|
||||
InitialDelaySeconds: 2,
|
||||
PeriodSeconds: 5,
|
||||
FailureThreshold: 3,
|
||||
},
|
||||
LivenessProbe: &corev1.Probe{
|
||||
ProbeHandler: corev1.ProbeHandler{
|
||||
HTTPGet: &corev1.HTTPGetAction{
|
||||
Path: "/health",
|
||||
Port: intstr.FromInt(int(port)),
|
||||
Scheme: corev1.URISchemeHTTP,
|
||||
Resources: corev1.ResourceRequirements{
|
||||
Requests: corev1.ResourceList{
|
||||
corev1.ResourceCPU: cpuRequest,
|
||||
corev1.ResourceMemory: memRequest,
|
||||
},
|
||||
Limits: corev1.ResourceList{
|
||||
corev1.ResourceCPU: cpuLimit,
|
||||
corev1.ResourceMemory: memLimit,
|
||||
},
|
||||
},
|
||||
InitialDelaySeconds: 5,
|
||||
PeriodSeconds: 10,
|
||||
FailureThreshold: 5,
|
||||
VolumeMounts: []corev1.VolumeMount{
|
||||
{
|
||||
// Монтируем конфиг на путь который JVM-образ читает по дефолту.
|
||||
Name: "elasticmq-config",
|
||||
MountPath: "/opt/elasticmq.conf",
|
||||
SubPath: "elasticmq.conf",
|
||||
ReadOnly: true,
|
||||
},
|
||||
{
|
||||
// PVC для H2 persistence
|
||||
Name: "elasticmq-data",
|
||||
MountPath: "/data",
|
||||
},
|
||||
},
|
||||
ReadinessProbe: &corev1.Probe{
|
||||
ProbeHandler: corev1.ProbeHandler{
|
||||
HTTPGet: &corev1.HTTPGetAction{
|
||||
Path: "/health",
|
||||
Port: intstr.FromInt(int(port)),
|
||||
Scheme: corev1.URISchemeHTTP,
|
||||
},
|
||||
},
|
||||
InitialDelaySeconds: 2,
|
||||
PeriodSeconds: 5,
|
||||
FailureThreshold: 3,
|
||||
},
|
||||
LivenessProbe: &corev1.Probe{
|
||||
ProbeHandler: corev1.ProbeHandler{
|
||||
HTTPGet: &corev1.HTTPGetAction{
|
||||
Path: "/health",
|
||||
Port: intstr.FromInt(int(port)),
|
||||
Scheme: corev1.URISchemeHTTP,
|
||||
},
|
||||
},
|
||||
InitialDelaySeconds: 5,
|
||||
PeriodSeconds: 10,
|
||||
FailureThreshold: 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
if qs.Spec.EnableUI {
|
||||
// SQS_ENDPOINT включает context-path: ElasticMQ принимает запросы
|
||||
// только на /sqs/{tenantID}, root / возвращает текстовую ошибку "The request...".
|
||||
ctrs = append(ctrs, corev1.Container{
|
||||
Name: "elasticmq-ui",
|
||||
Image: elasticMQUIImage,
|
||||
Ports: []corev1.ContainerPort{
|
||||
{ContainerPort: int32(elasticMQUIPort), Protocol: corev1.ProtocolTCP},
|
||||
},
|
||||
Env: []corev1.EnvVar{
|
||||
{
|
||||
Name: "SQS_ENDPOINT",
|
||||
Value: fmt.Sprintf("http://localhost:%d/sqs/%s", elasticMQPort, qs.Spec.TenantID),
|
||||
},
|
||||
},
|
||||
Resources: corev1.ResourceRequirements{
|
||||
Requests: corev1.ResourceList{
|
||||
corev1.ResourceCPU: resource.MustParse("10m"),
|
||||
corev1.ResourceMemory: resource.MustParse("64Mi"),
|
||||
},
|
||||
Limits: corev1.ResourceList{
|
||||
corev1.ResourceCPU: resource.MustParse("200m"),
|
||||
corev1.ResourceMemory: resource.MustParse("128Mi"),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
return ctrs
|
||||
}(),
|
||||
Volumes: []corev1.Volume{
|
||||
{
|
||||
Name: "elasticmq-config",
|
||||
|
||||
Reference in New Issue
Block a user