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

added labels to nodeConfig and pod policy #150

Closed
wants to merge 2 commits into from
Closed

added labels to nodeConfig and pod policy #150

wants to merge 2 commits into from

Conversation

mh013370
Copy link
Contributor

@mh013370 mh013370 commented Nov 4, 2021

Q A
Bug fix? yes
New feature? yes
API breaks? technically yes due to #151
Deprecations? no
Related tickets fixes #149, #151
License Apache 2.0

What's in this PR?

Added the ability to attach additional labels to pods nifikop creates via NodeConfig and PodPolicy. For example:

apiVersion: nifi.orange.com/v1alpha1
kind: NifiCluster
metadata:
  name: simplenifi
spec:
  ...
  pod:
    labels:
      specific-pod-label: "abc"
  nodeConfigGroup:
    default_group:
      nodeLabels:
        my-special-label: "true"
  ...

Why?

I'd like to attach arbitrary labels to pods that nifikop creates. Specifically, i'd like to label pods with meaningful things as a means to select pods for log aggregation via https://rancher.com/docs/rancher/v2.6/en/logging/

Context

I tested this by running nifikop locally pointing at a remote k8s cluster. I deployed the updated simplenificluster with node labels and pod labels and verified they both showed up in the deployed pod.

Example NiFiCluster (truncated):

apiVersion: nifi.orange.com/v1alpha1
kind: NifiCluster
metadata:
  name: simplenifi
spec:
  service:
    headlessEnabled: true
  pod:
    labels:
      pod-label: "pod-label-value"
  nodeConfigGroups:
    default_group:
      nodeAnnotations:
        node-annotation: "node-annotation-value"
      nodeLabels:
        node-label: "node-label-value"
...

Pod yaml:

apiVersion: v1
kind: Pod
metadata:
  annotations:
    node-annotation: "node-annotation-value"
    prometheus.io/port: "9090"
    prometheus.io/scrape: "true"
  labels:
    app: nifi
    nifi_cr: simplenifi
    node-label: "node-label-value"
    nodeId: "1"
    pod-label: "pod-label-value"

Checklist

  • Implementation tested
  • Error handling code meets the guideline
  • Logging code meets the guideline
  • User guide and development docs updated (if needed)
  • Append changelog with changes

@@ -281,7 +283,10 @@ type NodeConfig struct {
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// Additionnal annotation to attach to the pod associated
// https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#syntax-and-character-set
NodeAnnotations map[string]string `json:"nifiAnnotations,omitempty"`
Copy link
Contributor Author

@mh013370 mh013370 Nov 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discovered & fixed a bug where NodeAnnotations was documented as nodeAnnotations in the NiFiCluster CRD . However, it was nifiAnnotations in the actual custom resource definition. I've renamed it here (and it's reflected in the CRD) to match the documentation. This is technically an API breaking change, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #151 to cover this issue

@mh013370
Copy link
Contributor Author

mh013370 commented Feb 7, 2022

I've rebased this on the latest master

@mh013370
Copy link
Contributor Author

I've fixed the build on this PR as i mimicked changes seen in fe69e9e

fix mismatched nodeAnnotations and nifiAnnotations, renamed incorrect nifiLabels to nodeLabels

fix wrong text

Signed-off-by: Michael H <[email protected]>

updated changelog

Signed-off-by: Michael H <[email protected]>
Signed-off-by: Michael H <[email protected]>
@mh013370 mh013370 closed this by deleting the head repository Nov 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to attach additional labels to NiFi pods
2 participants