Skip to content

Commit 03305a2

Browse files
committed
modifications for ReadOnlyRootFilesystem
1 parent afb7aff commit 03305a2

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

pkg/apis/cpo.opensource.cybertec.at/v1/operator_configuration_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type KubernetesMetaConfiguration struct {
6262
PodTerminateGracePeriod Duration `json:"pod_terminate_grace_period,omitempty"`
6363
SpiloPrivileged bool `json:"spilo_privileged,omitempty"`
6464
SpiloAllowPrivilegeEscalation *bool `json:"spilo_allow_privilege_escalation,omitempty"`
65-
ReadOnlyRootFilesystem bool `json:"container_readonly_root_filesystem" default:"true"`
65+
ReadOnlyRootFilesystem *bool `json:"container_readonly_root_filesystem" default:"true"`
6666
SpiloRunAsUser *int64 `json:"spilo_runasuser,omitempty"`
6767
SpiloRunAsGroup *int64 `json:"spilo_runasgroup,omitempty"`
6868
SpiloFSGroup *int64 `json:"spilo_fsgroup,omitempty"`

pkg/apis/cpo.opensource.cybertec.at/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cluster/k8sres.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,12 @@ func (c *Cluster) generatePodTemplate(
878878
addEmptyDirVolume(&podSpec, "exporter-tmp", "postgres-exporter", "/tmp")
879879
}
880880

881-
if sharePgSocketWithSidecars != nil && *sharePgSocketWithSidecars || c.OpConfig.ReadOnlyRootFilesystem {
881+
var readOnly bool
882+
if c.OpConfig.ReadOnlyRootFilesystem != nil {
883+
readOnly = *c.OpConfig.ReadOnlyRootFilesystem
884+
}
885+
886+
if sharePgSocketWithSidecars != nil && *sharePgSocketWithSidecars || readOnly {
882887
addVarRunVolume(&podSpec)
883888

884889
}

pkg/controller/operator_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *cpov1.OperatorConfigura
7575
result.PodTerminateGracePeriod = util.CoalesceDuration(time.Duration(fromCRD.Kubernetes.PodTerminateGracePeriod), "5m")
7676
result.SpiloPrivileged = fromCRD.Kubernetes.SpiloPrivileged
7777
result.SpiloAllowPrivilegeEscalation = util.CoalesceBool(fromCRD.Kubernetes.SpiloAllowPrivilegeEscalation, util.True())
78+
result.ReadOnlyRootFilesystem = util.CoalesceBool(fromCRD.Kubernetes.ReadOnlyRootFilesystem, util.True())
7879
result.SpiloRunAsUser = fromCRD.Kubernetes.SpiloRunAsUser
7980
result.SpiloRunAsGroup = fromCRD.Kubernetes.SpiloRunAsGroup
8081
result.SpiloFSGroup = fromCRD.Kubernetes.SpiloFSGroup

pkg/util/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type Resources struct {
3838
SpiloPrivileged bool `name:"spilo_privileged" default:"false"`
3939
SpiloAllowPrivilegeEscalation *bool `name:"spilo_allow_privilege_escalation" default:"true"`
4040
AdditionalPodCapabilities []string `name:"additional_pod_capabilities" default:""`
41-
ReadOnlyRootFilesystem bool `name:"container_readonly_root_filesystem" default:"true"`
41+
ReadOnlyRootFilesystem *bool `name:"container_readonly_root_filesystem" default:"true"`
4242
ClusterLabels map[string]string `name:"cluster_labels" default:"application:cpo"`
4343
InheritedLabels []string `name:"inherited_labels" default:""`
4444
InheritedAnnotations []string `name:"inherited_annotations" default:""`

0 commit comments

Comments
 (0)