Skip to content

feat(Openshift): Openshift CRD Flag to Ignore fsGroup #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/v1alpha1/dragonfly_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ type DragonflySpec struct {
// +kubebuilder:validation:Optional
Snapshot *Snapshot `json:"snapshot,omitempty"`

// (Optional) Skip Assigning FileSystem Group. Required for platforms such as Openshift that require IDs to not be set, as it injects a fixed randomized ID per namespace into all pods.
// +optional
// +kubebuilder:validation:Optional
SkipFSGroup bool `json:"skipFSGroup,omitempty"`

// (Optional) Dragonfly Service configuration
// +optional
// +kubebuilder:validation:Optional
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/dragonflydb.io_dragonflies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,11 @@ spec:
description: (Optional) Dragonfly Service type
type: string
type: object
skipFSGroup:
description: (Optional) Skip Assigning FileSystem Group. Required
for platforms such as Openshift that require IDs to not be set,
as it injects a fixed randomized ID per namespace into all pods.
type: boolean
snapshot:
description: (Optional) Dragonfly Snapshot configuration
properties:
Expand Down
10 changes: 7 additions & 3 deletions internal/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,18 @@ func GetDragonflyResources(ctx context.Context, df *resourcesv1.Dragonfly) ([]cl
ImagePullPolicy: corev1.PullAlways,
},
},
SecurityContext: &corev1.PodSecurityContext{
FSGroup: &dflyUserGroup,
},
},
},
},
}

// Skip Assigning FileSystem Group. Required for platforms such as Openshift that require IDs to not be set, as it injects a fixed randomized ID per namespace into all pods.
if !df.Spec.SkipFSGroup {
statefulset.Spec.Template.Spec.SecurityContext = &corev1.PodSecurityContext{
FSGroup: &dflyUserGroup,
}
}

// set only if resources are specified
if df.Spec.Resources != nil {
statefulset.Spec.Template.Spec.Containers[0].Resources = *df.Spec.Resources
Expand Down