Skip to content

Commit 95db72b

Browse files
committed
improvement(neutronapi): Enhance readiness probe to verify SSL certificate presence
- Updated the existing readiness probe in the Neutron API deployment to check for the presence of the internal.crt SSL certificate before marking the pod as ready. - Applied the SSL certificate check to the HTTPD container as well, ensuring secure traffic handling. - Improved the deployment reliability by ensuring that pods are only marked as ready when they have the necessary SSL certificates in place.
1 parent 7c5c6cf commit 95db72b

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

pkg/neutronapi/deployment.go

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ func Deployment(
4141
labels map[string]string,
4242
annotations map[string]string,
4343
) (*appsv1.Deployment, error) {
44-
// TODO(lucasagomes): Look into how to implement separated probes
45-
// for the httpd and neutron-api containers. Right now the code uses
46-
// the same liveness and readiness probes for both containers which
47-
// only checks the port 9696 (NeutronPublicPort) which is the port
48-
// that httpd is listening to. Ideally, we should also include a
49-
// probe on port 9697 which is the port that neutron-api binds to
44+
// TODO(lucasagomes): Look into how to implement separated probes
45+
// for the httpd and neutron-api containers. Right now the code uses
46+
// the same liveness and readiness probes for both containers which
47+
// only checks the port 9696 (NeutronPublicPort) which is the port
48+
// that httpd is listening to. Ideally, we should also include a
49+
// probe on port 9697 which is the port that neutron-api binds to
5050
livenessProbe := &corev1.Probe{
5151
TimeoutSeconds: 30,
5252
PeriodSeconds: 30,
@@ -56,8 +56,14 @@ func Deployment(
5656
TimeoutSeconds: 30,
5757
PeriodSeconds: 30,
5858
InitialDelaySeconds: 5,
59+
Exec: &corev1.ExecAction{
60+
Command: []string{
61+
"cat",
62+
"/etc/pki/tls/certs/internal.crt",
63+
},
64+
},
5965
}
60-
args := []string{"-c", ServiceCommand}
66+
args := []string{"-c", ServiceCommand}
6167
httpdArgs := []string{"-DFOREGROUND"}
6268

6369
//
@@ -71,7 +77,7 @@ func Deployment(
7177
Path: "/",
7278
Port: intstr.IntOrString{Type: intstr.Int, IntVal: int32(NeutronPublicPort)},
7379
}
74-
80+
// Use HTTPS if TLS is enabled
7581
if instance.Spec.TLS.API.Enabled(service.EndpointPublic) {
7682
livenessProbe.HTTPGet.Scheme = corev1.URISchemeHTTPS
7783
readinessProbe.HTTPGet.Scheme = corev1.URISchemeHTTPS
@@ -93,6 +99,7 @@ func Deployment(
9399
httpdVolumeMounts = append(httpdVolumeMounts, instance.Spec.TLS.CreateVolumeMounts(nil)...)
94100
}
95101

102+
// handle TLS certificates for HTTPD
96103
for _, endpt := range []service.Endpoint{service.EndpointInternal, service.EndpointPublic} {
97104
if instance.Spec.TLS.API.Enabled(endpt) {
98105
var tlsEndptCfg tls.GenericService
@@ -134,8 +141,7 @@ func Deployment(
134141
Selector: &metav1.LabelSelector{
135142
MatchLabels: labels,
136143
},
137-
PodManagementPolicy: appsv1.ParallelPodManagement,
138-
Replicas: instance.Spec.Replicas,
144+
Replicas: instance.Spec.Replicas,
139145
Template: corev1.PodTemplateSpec{
140146
ObjectMeta: metav1.ObjectMeta{
141147
Annotations: annotations,
@@ -154,6 +160,7 @@ func Deployment(
154160
VolumeMounts: apiVolumeMounts,
155161
Resources: instance.Spec.Resources,
156162
LivenessProbe: livenessProbe,
163+
ReadinessProbe: readinessProbe,
157164
TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
158165
},
159166
{
@@ -175,14 +182,13 @@ func Deployment(
175182
},
176183
},
177184
}
178-
179-
// If possible two pods of the same service should not
180-
// run on the same worker node. If this is not possible
181-
// the get still created on the same worker node.
185+
// If possible two pods of the same service should not
186+
// run on the same worker node. If this is not possible
187+
// the get still created on the same worker node.
182188
deployment.Spec.Template.Spec.Affinity = affinity.DistributePods(
183189
common.AppSelector,
184190
[]string{
185-
ServiceName,
191+
ServiceName,
186192
},
187193
corev1.LabelHostname,
188194
)

0 commit comments

Comments
 (0)