Skip to content

Commit 3649422

Browse files
amoralejopenshift-merge-bot[bot]
authored andcommitted
Use Watcher user for the dbsync job
Currently, the dbsync job pod is running as root which is not required and against the minimum privilege principle. This patch switches the dbsync job to use the Watcher user id. Signed-off-by: Alfredo Moralejo <amoralej@redhat.com>
1 parent 9fbdd7b commit 3649422

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

internal/watcher/dbsync.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package watcher
22

33
import (
4+
"k8s.io/utils/ptr"
5+
46
watcherv1beta1 "github.com/openstack-k8s-operators/watcher-operator/api/v1beta1"
57

68
"github.com/openstack-k8s-operators/lib-common/modules/common/env"
@@ -11,7 +13,7 @@ import (
1113

1214
const (
1315
// DBSyncCommand -
14-
DBSyncCommand = "/usr/local/bin/kolla_set_configs && /usr/local/bin/kolla_start"
16+
DBSyncCommand = "/usr/local/bin/kolla_start"
1517
)
1618

1719
// DbSyncJob func
@@ -64,7 +66,6 @@ func DbSyncJob(instance *watcherv1beta1.Watcher, labels map[string]string, annot
6466

6567
args := []string{"-c", DBSyncCommand}
6668

67-
runAsUser := int64(0)
6869
envVars := map[string]env.Setter{}
6970
envVars["KOLLA_CONFIG_STRATEGY"] = env.SetValue("COPY_ALWAYS")
7071
envVars["KOLLA_BOOTSTRAP"] = env.SetValue("TRUE")
@@ -92,7 +93,7 @@ func DbSyncJob(instance *watcherv1beta1.Watcher, labels map[string]string, annot
9293
Args: args,
9394
Image: instance.Spec.APIContainerImageURL,
9495
SecurityContext: &corev1.SecurityContext{
95-
RunAsUser: &runAsUser,
96+
RunAsUser: ptr.To(WatcherUserID),
9697
},
9798
Env: env.MergeEnvs([]corev1.EnvVar{}, envVars),
9899
VolumeMounts: append(GetVolumeMounts(secretNames),

0 commit comments

Comments
 (0)