Skip to content

Commit 0748838

Browse files
Secure agent_config by using volume mounts instead of env vars
Signed-off-by: Aayush Chouhan <[email protected]>
1 parent 22f1cc3 commit 0748838

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
@@ -994,8 +994,8 @@ func (r *Reconciler) ReconcilePool() error {
994994
}
995995
return err
996996
}
997-
if r.Secret.StringData["AGENT_CONFIG"] == "" {
998-
r.Secret.StringData["AGENT_CONFIG"] = res
997+
if r.Secret.StringData["agent_config"] == "" {
998+
r.Secret.StringData["agent_config"] = res
999999
util.KubeUpdate(r.Secret)
10001000
}
10011001
err = r.NBClient.UpdateAllBucketsDefaultPool(nb.UpdateDefaultResourceParams{
@@ -1050,14 +1050,14 @@ func (r *Reconciler) reconcilePvPool() error {
10501050
if r.Secret.StringData == nil {
10511051
return fmt.Errorf("reconcilePvPool: r.Secret.StringData is not initialized yet")
10521052
}
1053-
if r.Secret.StringData["AGENT_CONFIG"] == "" {
1053+
if r.Secret.StringData["agent_config"] == "" {
10541054
res, err := r.NBClient.GetHostsPoolAgentConfigAPI(nb.GetHostsPoolAgentConfigParams{
10551055
Name: r.BackingStore.Name,
10561056
})
10571057
if err != nil {
10581058
return err
10591059
}
1060-
r.Secret.StringData["AGENT_CONFIG"] = res
1060+
r.Secret.StringData["agent_config"] = res
10611061
util.KubeUpdate(r.Secret)
10621062
}
10631063
podsList := &corev1.PodList{}
@@ -1287,15 +1287,6 @@ func (r *Reconciler) updatePodTemplate() error {
12871287
c := &r.PodAgentTemplate.Spec.Containers[0]
12881288
for j := range c.Env {
12891289
switch c.Env[j].Name {
1290-
case "AGENT_CONFIG":
1291-
c.Env[j].ValueFrom = &corev1.EnvVarSource{
1292-
SecretKeyRef: &corev1.SecretKeySelector{
1293-
LocalObjectReference: corev1.LocalObjectReference{
1294-
Name: r.Secret.Name,
1295-
},
1296-
Key: "AGENT_CONFIG",
1297-
},
1298-
}
12991290
case "NOOBAA_LOG_LEVEL":
13001291
c.Env[j].Value = r.CoreAppConfig.Data["NOOBAA_LOG_LEVEL"]
13011292
case "NOOBAA_LOG_COLOR":
@@ -1355,6 +1346,13 @@ func (r *Reconciler) updatePodTemplate() error {
13551346
r.PodAgentTemplate.Spec.TopologySpreadConstraints = []corev1.TopologySpreadConstraint{topologySpreadConstraint}
13561347
}
13571348

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

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)