Skip to content

Commit

Permalink
Add support for readOnlyRootFilesystem (fixes #1402)
Browse files Browse the repository at this point in the history
  • Loading branch information
olim7t committed Sep 10, 2024
1 parent 08585c3 commit 6fdb3a9
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG/CHANGELOG-1.20.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ When cutting a new release, update the `unreleased` heading to the tag being gen
## unreleased

* [BUGFIX] [#1399](https://github.com/k8ssandra/k8ssandra-operator/issues/1399) Fixed SecretSyncController to handle multiple namespaces
* [FEATURE] [#1402](https://github.com/k8ssandra/k8ssandra-operator/issues/1402) Add support for readOnlyRootFilesystem
4 changes: 4 additions & 0 deletions apis/k8ssandra/v1alpha1/k8ssandracluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ type DatacenterOptions struct {
// Use cautiously.
// +optional
DatacenterName string `json:"datacenterName,omitempty"`

// ReadOnlyRootFilesystem makes the cassandra container to be run with a read-only root filesystem. Currently only functional when used with the
// new k8ssandra-client config builder (Cassandra 4.1 and newer and HCD)
ReadOnlyRootFilesystem *bool `json:"readOnlyRootFilesystem,omitempty"`
}

// NetworkingConfig is a copy of cass-operator's NetworkingConfig struct. It is copied here to
Expand Down
5 changes: 5 additions & 0 deletions apis/k8ssandra/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10671,6 +10671,11 @@ spec:
- name
type: object
type: array
readOnlyRootFilesystem:
description: |-
ReadOnlyRootFilesystem makes the cassandra container to be run with a read-only root filesystem. Currently only functional when used with the
new k8ssandra-client config builder (Cassandra 4.1 and newer and HCD)
type: boolean
resources:
description: Resources is the cpu and memory resources for
the cassandra container.
Expand Down Expand Up @@ -23112,6 +23117,11 @@ spec:
- name
type: object
type: array
readOnlyRootFilesystem:
description: |-
ReadOnlyRootFilesystem makes the cassandra container to be run with a read-only root filesystem. Currently only functional when used with the
new k8ssandra-client config builder (Cassandra 4.1 and newer and HCD)
type: boolean
resources:
description: Resources is the cpu and memory resources for the
cassandra container.
Expand Down
10 changes: 10 additions & 0 deletions config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10609,6 +10609,11 @@ spec:
- name
type: object
type: array
readOnlyRootFilesystem:
description: |-
ReadOnlyRootFilesystem makes the cassandra container to be run with a read-only root filesystem. Currently only functional when used with the
new k8ssandra-client config builder (Cassandra 4.1 and newer and HCD)
type: boolean
resources:
description: Resources is the cpu and memory resources for
the cassandra container.
Expand Down Expand Up @@ -23050,6 +23055,11 @@ spec:
- name
type: object
type: array
readOnlyRootFilesystem:
description: |-
ReadOnlyRootFilesystem makes the cassandra container to be run with a read-only root filesystem. Currently only functional when used with the
new k8ssandra-client config builder (Cassandra 4.1 and newer and HCD)
type: boolean
resources:
description: Resources is the cpu and memory resources for the
cassandra container.
Expand Down
35 changes: 19 additions & 16 deletions pkg/cassandra/datacenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ type DatacenterConfig struct {
ExternalSecrets bool
McacEnabled bool
DatacenterName string
ReadOnlyRootFilesystem *bool

// InitialTokensByPodName is a list of initial tokens for the RF first pods in the cluster. It
// is only populated when num_tokens < 16 in the whole cluster. Used for generating default
Expand Down Expand Up @@ -165,22 +166,23 @@ func NewDatacenter(klusterKey types.NamespacedName, template *DatacenterConfig)
}, labels.CleanedUpByLabels(klusterKey)),
},
Spec: cassdcapi.CassandraDatacenterSpec{
Size: template.Size,
Stopped: template.Stopped,
ServerVersion: template.ServerVersion.String(),
ServerImage: template.ServerImage,
ServerType: string(template.ServerType),
Config: rawConfig,
Racks: template.Racks,
StorageConfig: *template.StorageConfig,
ClusterName: template.Cluster,
SuperuserSecretName: superUserSecretName,
Users: template.Users,
Networking: template.Networking,
PodTemplateSpec: &template.PodTemplateSpec,
CDC: template.CDC,
DseWorkloads: template.DseWorkloads,
ServiceAccountName: template.ServiceAccount,
Size: template.Size,
Stopped: template.Stopped,
ServerVersion: template.ServerVersion.String(),
ServerImage: template.ServerImage,
ServerType: string(template.ServerType),
Config: rawConfig,
Racks: template.Racks,
StorageConfig: *template.StorageConfig,
ClusterName: template.Cluster,
SuperuserSecretName: superUserSecretName,
Users: template.Users,
Networking: template.Networking,
PodTemplateSpec: &template.PodTemplateSpec,
CDC: template.CDC,
DseWorkloads: template.DseWorkloads,
ServiceAccountName: template.ServiceAccount,
ReadOnlyRootFilesystem: template.ReadOnlyRootFilesystem,
},
}

Expand Down Expand Up @@ -365,6 +367,7 @@ func Coalesce(clusterName string, clusterTemplate *api.CassandraClusterTemplate,
dcConfig.PodTemplateSpec.Spec.SecurityContext = mergedOptions.PodSecurityContext
dcConfig.PerNodeInitContainerImage = mergedOptions.PerNodeConfigInitContainerImage
dcConfig.ServiceAccount = mergedOptions.ServiceAccount
dcConfig.ReadOnlyRootFilesystem = mergedOptions.ReadOnlyRootFilesystem

dcConfig.Meta.Tags = goalesceutils.MergeCRs(clusterTemplate.Meta.Tags, dcTemplate.Meta.Tags)
dcConfig.Meta.CommonLabels = goalesceutils.MergeCRs(clusterTemplate.Meta.CommonLabels, dcTemplate.Meta.CommonLabels)
Expand Down

0 comments on commit 6fdb3a9

Please sign in to comment.