Skip to content

Commit 0d3ea0e

Browse files
Secure agent_config by using volume mounts instead of env vars
Signed-off-by: Aayush Chouhan <[email protected]>
1 parent 6fd8a36 commit 0d3ea0e

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed

deploy/internal/pod-agent.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ spec:
2121
# Insert the relevant config for the current agent
2222
- name: CONTAINER_PLATFORM
2323
value: KUBERNETES
24-
- name: AGENT_CONFIG
24+
- name: AGENT_CONFIG_PATH
25+
value: /etc/agent-config/agent_config
2526
- name: NOOBAA_LOG_LEVEL
2627
- name: NOOBAA_LOG_COLOR
2728
command: ["/noobaa_init_files/noobaa_init.sh", "agent"]
@@ -34,6 +35,9 @@ spec:
3435
mountPath: /noobaa_storage
3536
- name: tmp-logs-vol
3637
mountPath: /usr/local/noobaa/logs
38+
- name: agent-config-secret
39+
mountPath: /etc/agent-config
40+
readOnly: true
3741
securityContext:
3842
runAsNonRoot: true
3943
allowPrivilegeEscalation: false
@@ -49,3 +53,6 @@ spec:
4953
- name: noobaastorage
5054
persistentVolumeClaim:
5155
claimName: noobaa-pv-claim
56+
- name: agent-config-secret
57+
secret:
58+
secretName: AGENT_CONFIG_SECRET_NAME

pkg/backingstore/reconciler.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,8 @@ func (r *Reconciler) ReconcilePool() error {
993993
}
994994
return err
995995
}
996-
if r.Secret.StringData["AGENT_CONFIG"] == "" {
997-
r.Secret.StringData["AGENT_CONFIG"] = res
996+
if r.Secret.StringData["agent_config"] == "" {
997+
r.Secret.StringData["agent_config"] = res
998998
util.KubeUpdate(r.Secret)
999999
}
10001000
err = r.NBClient.UpdateAllBucketsDefaultPool(nb.UpdateDefaultResourceParams{
@@ -1049,14 +1049,14 @@ func (r *Reconciler) reconcilePvPool() error {
10491049
if r.Secret.StringData == nil {
10501050
return fmt.Errorf("reconcilePvPool: r.Secret.StringData is not initialized yet")
10511051
}
1052-
if r.Secret.StringData["AGENT_CONFIG"] == "" {
1052+
if r.Secret.StringData["agent_config"] == "" {
10531053
res, err := r.NBClient.GetHostsPoolAgentConfigAPI(nb.GetHostsPoolAgentConfigParams{
10541054
Name: r.BackingStore.Name,
10551055
})
10561056
if err != nil {
10571057
return err
10581058
}
1059-
r.Secret.StringData["AGENT_CONFIG"] = res
1059+
r.Secret.StringData["agent_config"] = res
10601060
util.KubeUpdate(r.Secret)
10611061
}
10621062
podsList := &corev1.PodList{}
@@ -1286,15 +1286,6 @@ func (r *Reconciler) updatePodTemplate() error {
12861286
c := &r.PodAgentTemplate.Spec.Containers[0]
12871287
for j := range c.Env {
12881288
switch c.Env[j].Name {
1289-
case "AGENT_CONFIG":
1290-
c.Env[j].ValueFrom = &corev1.EnvVarSource{
1291-
SecretKeyRef: &corev1.SecretKeySelector{
1292-
LocalObjectReference: corev1.LocalObjectReference{
1293-
Name: r.Secret.Name,
1294-
},
1295-
Key: "AGENT_CONFIG",
1296-
},
1297-
}
12981289
case "NOOBAA_LOG_LEVEL":
12991290
c.Env[j].Value = r.CoreAppConfig.Data["NOOBAA_LOG_LEVEL"]
13001291
case "NOOBAA_LOG_COLOR":
@@ -1354,6 +1345,13 @@ func (r *Reconciler) updatePodTemplate() error {
13541345
r.PodAgentTemplate.Spec.TopologySpreadConstraints = []corev1.TopologySpreadConstraint{topologySpreadConstraint}
13551346
}
13561347

1348+
// replace AGENT_CONFIG_SECRET_NAME with actual secret name
1349+
for i, vol := range r.PodAgentTemplate.Spec.Volumes {
1350+
if vol.Secret != nil && vol.Secret.SecretName == "AGENT_CONFIG_SECRET_NAME" {
1351+
r.PodAgentTemplate.Spec.Volumes[i].Secret.SecretName = r.Secret.Name
1352+
}
1353+
}
1354+
13571355
return r.updatePodResourcesTemplate(c)
13581356
}
13591357

pkg/bundle/deploy.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4477,7 +4477,7 @@ spec:
44774477
storage: 30Gi
44784478
`
44794479

4480-
const Sha256_deploy_internal_pod_agent_yaml = "0d3d438a85024b605e1d1b3587c0bf9522f7e30f187fdd0f1d607337e3df90d1"
4480+
const Sha256_deploy_internal_pod_agent_yaml = "74237f435120c893cd8e349e9ac685dd1c884e121c018f46e48228f845a51093"
44814481

44824482
const File_deploy_internal_pod_agent_yaml = `apiVersion: v1
44834483
kind: Pod
@@ -4502,7 +4502,8 @@ spec:
45024502
# Insert the relevant config for the current agent
45034503
- name: CONTAINER_PLATFORM
45044504
value: KUBERNETES
4505-
- name: AGENT_CONFIG
4505+
- name: AGENT_CONFIG_PATH
4506+
value: /etc/agent-config/agent_config
45064507
- name: NOOBAA_LOG_LEVEL
45074508
- name: NOOBAA_LOG_COLOR
45084509
command: ["/noobaa_init_files/noobaa_init.sh", "agent"]
@@ -4515,6 +4516,9 @@ spec:
45154516
mountPath: /noobaa_storage
45164517
- name: tmp-logs-vol
45174518
mountPath: /usr/local/noobaa/logs
4519+
- name: agent-config-secret
4520+
mountPath: /etc/agent-config
4521+
readOnly: true
45184522
securityContext:
45194523
runAsNonRoot: true
45204524
allowPrivilegeEscalation: false
@@ -4530,6 +4534,9 @@ spec:
45304534
- name: noobaastorage
45314535
persistentVolumeClaim:
45324536
claimName: noobaa-pv-claim
4537+
- name: agent-config-secret
4538+
secret:
4539+
secretName: AGENT_CONFIG_SECRET_NAME
45334540
`
45344541

45354542
const Sha256_deploy_internal_prometheus_rules_yaml = "9dba8cfe7b655d3467b091531c95e6d34e8bd179f36ece6eaf3cff8ef73df23d"

pkg/options/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const (
3030
// ContainerImageRepo is the repo of the default image url
3131
ContainerImageRepo = "noobaa-core"
3232
// ContainerImageTag is the tag of the default image url
33-
ContainerImageTag = "master-20250911"
33+
ContainerImageTag = "master-20251028"
3434
// ContainerImageSemverLowerBound is the lower bound for supported image versions
3535
ContainerImageSemverLowerBound = "5.0.0"
3636
// ContainerImageSemverUpperBound is the upper bound for supported image versions

0 commit comments

Comments
 (0)