Skip to content

Commit

Permalink
Updated node/pod HOSTNAME, HOST and IDENTITY and ADDRESS env variable…
Browse files Browse the repository at this point in the history
… with Kubernetes pod name from metadata name

This StatefulSet of Apache NiFi deployment uses hostname as reference in the cluster names. When Apache NiFi nodes/pods occasionally terminated and redeployed old zombie nodes/pods hostnames are still list in the cluster page and can not be removed, this will/should fix that bug

The HOSTNAME env variable is never empty as Kubernetes controller will always populate it if is not set
  • Loading branch information
saidsef committed Aug 3, 2023
1 parent 2681b5a commit 8c54395
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions deployment/nifi-ssl-configmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ data:
then
echo "Creating keystore"
keytool -genkey -noprompt -alias nifi-keystore \
-dname "CN=SA,OU=${ORGANISATION_UNIT},O=${ORGANISATION},L=${CITY},S=${STATE},C=${COUNTRY_CODE}" \
-dname "CN=${HOSTNAME},OU=${ORGANISATION_UNIT},O=${ORGANISATION},L=${CITY},S=${STATE},C=${COUNTRY_CODE}" \
-keystore ${NIFI_HOME}/keytool/keystore.p12 \
-storepass ${KEYSTORE_PASS:-$NIFI_SENSITIVE_PROPS_KEY} \
-KeySize 2048 \
Expand All @@ -40,7 +40,7 @@ data:
then
echo "Creating truststore"
keytool -genkey -noprompt -alias nifi-truststore \
-dname "CN=SA,OU=${ORGANISATION_UNIT},O=${ORGANISATION},L=${CITY},S=${STATE},C=${COUNTRY_CODE}" \
-dname "CN=${HOSTNAME},OU=${ORGANISATION_UNIT},O=${ORGANISATION},L=${CITY},S=${STATE},C=${COUNTRY_CODE}" \
-keystore ${NIFI_HOME}/keytool/truststore.jks \
-storetype jks \
-keypass ${KEYSTORE_PASS:-$NIFI_SENSITIVE_PROPS_KEY} \
Expand Down
11 changes: 6 additions & 5 deletions deployment/nifi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
automountServiceAccountToken: false
enableServiceLinks: false
restartPolicy: Always
subdomain: nifi
securityContext:
runAsGroup: 1000
runAsUser: 1000
Expand Down Expand Up @@ -77,23 +78,23 @@ spec:
- name: NIFI_WEB_HTTP_HOST
valueFrom:
fieldRef:
fieldPath: status.podIP
fieldPath: metadata.name # Use pod name as web host
- name: NIFI_CLUSTER_NODE_ADDRESS
valueFrom:
fieldRef:
fieldPath: status.podIP
fieldPath: $(HOSTNAME).nifi # Use pod name as node address
- name: NIFI_REMOTE_INPUT_HOST
valueFrom:
fieldRef:
fieldPath: status.podIP
fieldPath: metadata.name # Use pod name as input host
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: status.podIP
fieldPath: metadata.name # Use pod name as hostname
- name: NODE_IDENTITY
valueFrom:
fieldRef:
fieldPath: metadata.name
fieldPath: metadata.name # Use pod name as identity
envFrom:
- configMapRef:
name: nifi-cm
Expand Down

0 comments on commit 8c54395

Please sign in to comment.