Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Commit

Permalink
Replace hardcoded FSGroup (1000) with property
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Anisimov committed Jan 12, 2021
1 parent 6756286 commit a1ef5ef
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
13 changes: 13 additions & 0 deletions api/v1alpha1/nificluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ type NodeConfig struct {
//RunAsUser define the id of the user to run in the Nifi image
// +kubebuilder:validation:Minimum=1
RunAsUser *int64 `json:"runAsUser,omitempty"`
//FSGroup define the id of the group for each volumes in Nifi image
// +kubebuilder:validation:Minimum=1
FSGroup *int64 `json:"FSGroup,omitempty"`
// Set this to true if the instance is a node in a cluster.
// https://nifi.apache.org/docs/nifi-docs/html/administration-guide.html#basic-cluster-setup
IsNode *bool `json:"isNode,omitempty"`
Expand Down Expand Up @@ -543,6 +546,16 @@ func (nConfig *NodeConfig) GetRunAsUser() *int64 {
return func(i int64) *int64 { return &i }(defaultUserID)
}

//
func (nConfig *NodeConfig) GetFSGroup() *int64 {
var defaultGroupID int64 = 1000
if nConfig.FSGroup != nil {
return nConfig.FSGroup
}

return func(i int64) *int64 { return &i }(defaultGroupID)
}

//
func (nConfig *NodeConfig) GetIsNode() bool {
if nConfig.IsNode != nil {
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

12 changes: 12 additions & 0 deletions config/crd/bases/nifi.orange.com_nificlusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,12 @@ spec:
additionalProperties:
description: NodeConfig defines the node configuration
properties:
FSGroup:
description: FSGroup define the id of the group for each volumes
in Nifi image
format: int64
minimum: 1
type: integer
image:
description: ' Docker image used by the operator to create the
node associated https://hub.docker.com/r/apache/nifi/'
Expand Down Expand Up @@ -1917,6 +1923,12 @@ spec:
nodeConfig:
description: node configuration
properties:
FSGroup:
description: FSGroup define the id of the group for each
volumes in Nifi image
format: int64
minimum: 1
type: integer
image:
description: ' Docker image used by the operator to create
the node associated https://hub.docker.com/r/apache/nifi/'
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/nifi/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (r *Reconciler) pod(id int32, nodeConfig *v1alpha1.NodeConfig, pvcs []corev
SecurityContext: &corev1.PodSecurityContext{
RunAsUser: nodeConfig.GetRunAsUser(),
RunAsNonRoot: func(b bool) *bool { return &b }(true),
FSGroup: func(i int64) *int64 { return &i }(1000),
FSGroup: nodeConfig.GetFSGroup(),
},
InitContainers: append(initContainers, []corev1.Container{
{
Expand Down

0 comments on commit a1ef5ef

Please sign in to comment.