Skip to content

Commit

Permalink
Merge pull request #24 from konpyutaika/ft_configurable_template_serv…
Browse files Browse the repository at this point in the history
…ice_n_users

[Feature/Operator] Configurable node services and users template
  • Loading branch information
erdrix authored Mar 23, 2022
2 parents e0e9ad4 + de5aaa5 commit 8e490b7
Show file tree
Hide file tree
Showing 62 changed files with 3,356 additions and 194 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

### Added

### Changed

### Deprecated

### Removed

### Fixed Bugs

## v0.9.0

### Added

- [PR #23](https://github.com/konpyutaika/nifikop/pull/23) - **[Operator/NiFiCluster]** Add ability to set services and pods labels
- [PR #21](https://github.com/konpyutaika/nifikop/pull/21) - **[Operator]** Propagate user provided issuerRef Group for custom CertManager Issuer.
- [PR #20](https://github.com/konpyutaika/nifikop/pull/20) - **[Operator]** Configurable log levels
Expand All @@ -13,6 +25,7 @@
### Changed

- [PR #5](https://github.com/konpyutaika/nifikop/pull/5) - **[Documentation]** Change minikube by k3d.
- [PR #24](https://github.com/konpyutaika/nifikop/pull/24) - **[Operator/NiFiCluster]** Configurable node services and users template

### Deprecated

Expand Down
40 changes: 39 additions & 1 deletion api/v1alpha1/nificluster_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v1alpha1

import (
"fmt"
"strings"

cmmeta "github.com/jetstack/cert-manager/pkg/apis/meta/v1"
Expand Down Expand Up @@ -71,6 +72,8 @@ type NifiClusterSpec struct {
ReadOnlyConfig ReadOnlyConfig `json:"readOnlyConfig,omitempty"`
// nodeConfigGroups specifies multiple node configs with unique name
NodeConfigGroups map[string]NodeConfig `json:"nodeConfigGroups,omitempty"`
// NodeUserIdentityTemplate specifies the template to be used when naming the node user identity (e.g. node-%d-mysuffix)
NodeUserIdentityTemplate *string `json:"nodeUserIdentityTemplate,omitempty"`
// all node requires an image, unique id, and storageConfigs settings
Nodes []Node `json:"nodes"`
// Defines the configuration for PodDisruptionBudget
Expand All @@ -89,6 +92,14 @@ type NifiClusterSpec struct {
ExternalServices []ExternalServiceConfig `json:"externalServices,omitempty"`
// TopologySpreadConstraints specifies any TopologySpreadConstraint objects to be applied to all nodes
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
// NifiControllerTemplate specifies the template to be used when naming the node controller (e.g. %s-mysuffix)
// Warning: once defined don't change this value either the operator will no longer be able to manage the cluster
NifiControllerTemplate *string `json:"nifiControllerTemplate,omitempty"`
// ControllerUserIdentity specifies what to call the static admin user's identity
// Warning: once defined don't change this value either the operator will no longer be able to manage the cluster
ControllerUserIdentity *string `json:"controllerUserIdentity,omitempty"`

// @TODO: Block Controller change
}

// DisruptionBudget defines the configuration for PodDisruptionBudget
Expand All @@ -103,8 +114,10 @@ type DisruptionBudget struct {

type ServicePolicy struct {
// HeadlessEnabled specifies if the cluster should use headlessService for Nifi or individual services
// using service per nodes may come an handy case of service mesh.
// using service per nodes may come a handy case of service mesh.
HeadlessEnabled bool `json:"headlessEnabled"`
// ServiceTemplate specifies the template to be used when naming the service (e.g. %s-mysuffix)
ServiceTemplate string `json:"serviceTemplate,omitempty"`
// Annotations specifies the annotations to attach to services the operator creates
Annotations map[string]string `json:"annotations,omitempty"`
// Labels specifies the labels to attach to services the operator creates
Expand Down Expand Up @@ -695,6 +708,31 @@ func (nSpec *NifiClusterSpec) GetMetricPort() *int {
return nil
}

func (cluster *NifiCluster) GetNifiControllerUserIdentity() string {
if cluster.Spec.ControllerUserIdentity != nil {
return *cluster.Spec.ControllerUserIdentity
}
template := "%s-controller"
if cluster.Spec.NifiControllerTemplate != nil {
template = *cluster.Spec.NifiControllerTemplate
}
return fmt.Sprintf(template, cluster.Name)
}

func (cluster *NifiCluster) GetNodeServiceName() string {
return fmt.Sprintf(cluster.Spec.Service.GetServiceTemplate(), cluster.Name)
}

func (service *ServicePolicy) GetServiceTemplate() string {
if service.ServiceTemplate != "" {
return service.ServiceTemplate
}
if service.HeadlessEnabled {
return "%s-headless"
}
return "%s-all-node"
}

func (cluster *NifiCluster) RootProcessGroupId() string {
return cluster.Status.RootProcessGroupId
}
Expand Down
15 changes: 15 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.

21 changes: 20 additions & 1 deletion config/crd/bases/nifi.konpyutaika.com_nificlusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ spec:
description: clusterImage can specify the whole NiFi cluster image
in one place
type: string
controllerUserIdentity:
description: 'ControllerUserIdentity specifies what to call the static
admin user''s identity Warning: once defined don''t change this
value either the operator will no longer be able to manage the cluster'
type: string
disruptionBudget:
description: Defines the configuration for PodDisruptionBudget
properties:
Expand Down Expand Up @@ -1430,6 +1435,12 @@ spec:
required:
- retryDurationMinutes
type: object
nifiControllerTemplate:
description: 'NifiControllerTemplate specifies the template to be
used when naming the node controller (e.g. %s-mysuffix) Warning:
once defined don''t change this value either the operator will no
longer be able to manage the cluster'
type: string
nifiURI:
description: nifiURI used access through a LB uri (used if external
type)
Expand Down Expand Up @@ -3484,6 +3495,10 @@ spec:
description: nodeURITemplate used to dynamically compute node uri
(used if external type)
type: string
nodeUserIdentityTemplate:
description: NodeUserIdentityTemplate specifies the template to be
used when naming the node user identity (e.g. node-%d-mysuffix)
type: string
nodes:
description: all node requires an image, unique id, and storageConfigs
settings
Expand Down Expand Up @@ -6477,14 +6492,18 @@ spec:
headlessEnabled:
description: HeadlessEnabled specifies if the cluster should use
headlessService for Nifi or individual services using service
per nodes may come an handy case of service mesh.
per nodes may come a handy case of service mesh.
type: boolean
labels:
additionalProperties:
type: string
description: Labels specifies the labels to attach to services
the operator creates
type: object
serviceTemplate:
description: ServiceTemplate specifies the template to be used
when naming the service (e.g. %s-mysuffix)
type: string
required:
- headlessEnabled
type: object
Expand Down
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
- /manager
args:
- --leader-elect
image: ghcr.io/konpyutaika/docker-images/nifikop:v0.8.0-release
image: ghcr.io/konpyutaika/docker-images/nifikop:v0.9.0-release
name: nifikop
securityContext:
allowPrivilegeEscalation: false
Expand Down
2 changes: 1 addition & 1 deletion config/samples/keycloak-example/step-1/operator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# nifikop 0.8.0
# nifikop 0.9.0
rbacEnable: true
namespaces:
- nifi
4 changes: 4 additions & 0 deletions config/samples/nifi_v1alpha1_nificluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ spec:
# headlessEnabled specifies if the cluster should use headlessService for Nifi or individual services
# using service per nodes may come an handy case of service mesh.
headlessEnabled: true
# serviceTemplate specifies the template to be used when naming the service (e.g. %s-mysuffix)
serviceTemplate: "%s-svc"
# Annotations specifies the annotations to attach to services the operator creates
# annotations:
# Labels specifies the labels to attach to services the operator creates
Expand Down Expand Up @@ -162,6 +164,8 @@ spec:
# https://nifi.apache.org/docs/nifi-docs/html/administration-guide.html#bootstrap_properties
overrideConfigs: |
# java.arg.4=-Djava.net.preferIPv4Stack=true
# nodeUserIdentityTemplate specifies the template to be used when naming the node user identity (e.g. node-%d-mysuffix)
nodeUserIdentityTemplate: "n-%d"
# nodeConfigGroups specifies multiple node configs with unique name
nodeConfigGroups:
default_group:
Expand Down
Loading

0 comments on commit 8e490b7

Please sign in to comment.