diff --git a/apps/cohorter/WebAPP/.gitignore b/apps/cohorter/WebAPP/.gitignore index d2ae0960..6510288b 100644 --- a/apps/cohorter/WebAPP/.gitignore +++ b/apps/cohorter/WebAPP/.gitignore @@ -39,5 +39,4 @@ Thumbs.db # ========================= .env .env.* -!.env.example secrets/ diff --git a/apps/nifi/.gitignore b/apps/nifi/.gitignore index 8293d963..1c7bc21e 100644 --- a/apps/nifi/.gitignore +++ b/apps/nifi/.gitignore @@ -1,10 +1,9 @@ # NiFi and Py4J type stubs are maintained source files. !typings/**/*.pyi -# Share the K3s example and keep deployment env files private. +# Keep deployment env files private. !/env/ /env/* -!/env/nifi.env.example # Mutable host configuration and processor state. conf/flow.json.gz diff --git a/apps/nifi/README.md b/apps/nifi/README.md index 36f90aa5..89d33caa 100644 --- a/apps/nifi/README.md +++ b/apps/nifi/README.md @@ -11,15 +11,19 @@ production configurations use `cogstacksystems/nifi` and `cogstacksystems/nginx` ### Environment files -From the repository root, create `apps/nifi/env/` and add `general.env` and -`nifi.env`. Both files are Git-ignored. `general.env` can be empty if you have -no shared settings. Use the following as a starting point for `nifi.env`. +Edit `apps/nifi/env/nifi.env` directly. For a new checkout, create it with the +settings below. This file also supplies NiFi and NGINX settings when rendering +Helm values. For Docker, create `apps/nifi/env/general.env` for shared settings. +It can be empty. Both files are Git-ignored. ```dotenv NIFI_DOCKER_CPU_MIN=1 NIFI_DOCKER_CPU_MAX=2 NIFI_DOCKER_RAM=4g +NIFI_UID=1000 +NIFI_GID=1000 +NIFI_INTERNAL_PORT_NGINX=8443 NIFI_WEB_PROXY_HOST=localhost:8443 NIFI_HEALTHCHECK_HOST=nifi ``` @@ -44,9 +48,26 @@ for additional settings. ### TLS certificates -Use the existing certificate generators or supply a TLS bundle. Place the files -under `deployment/security/certificates/`, or set `SECURITY_DIR` in `nifi.env` -to the parent of your deployment’s `certificates/` directory. +Compose uses `deployment/security/certificates/` by default. To select a bundle, +set `SECURITY_DIR` in `apps/nifi/env/general.env` to the absolute path of the +directory containing `certificates/`. + +```dotenv +SECURITY_DIR=/path/to/cogstack_platform/deployment/security +``` + +The Make targets load this file before running Compose. For direct Compose +commands, source `./export_env_vars.sh` from `apps/nifi/docker/` first. + +For a fresh local bundle, configure the store passwords in +[`certificates.env`](../../deployment/env/certificates.env) and run the +deployment targets from the repository root: + +```bash +make -C deployment -j1 certs-root certs-nifi certs-nginx +``` + +The bundle needs these files under `certificates/`. | Files | Purpose | | --- | --- | diff --git a/apps/nifi/docker/setup_dev_tls.sh b/apps/nifi/docker/setup_dev_tls.sh deleted file mode 100755 index 9eef1d87..00000000 --- a/apps/nifi/docker/setup_dev_tls.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -umask 077 - -if [[ $# -ne 1 || -z ${1:-} ]]; then - printf 'Usage: %s \n' "$0" >&2 - exit 1 -fi - -env_file=$1 -[[ "$env_file" == /* ]] || env_file="$PWD/$env_file" -if [[ ! -f "$env_file" || ! -r "$env_file" ]]; then - printf 'Cannot read certificate settings at %s.\n' "$env_file" >&2 - exit 1 -fi - -unset SECURITY_DIR ROOT_CERTIFICATE_KEYSTORE_PASSWORD KEYSTORE_PASSWORD TRUSTSTORE_PASSWORD -unset NIFI_UPSTREAM_TLS_NAME NIFI_HEALTHCHECK_HOST KUBE_NAMESPACE CLUSTER_DOMAIN NGINX_TLS_NAMES -set -a -# shellcheck disable=SC1090 -source "$env_file" -set +a - -: "${ROOT_CERTIFICATE_KEYSTORE_PASSWORD:?Set ROOT_CERTIFICATE_KEYSTORE_PASSWORD in the certificate env file}" -: "${KEYSTORE_PASSWORD:?Set KEYSTORE_PASSWORD in the certificate env file}" -: "${TRUSTSTORE_PASSWORD:?Set TRUSTSTORE_PASSWORD in the certificate env file}" -if [[ ${SECURITY_DIR:-} != /* ]]; then - printf 'Set SECURITY_DIR to an absolute path in %s.\n' "$env_file" >&2 - exit 1 -fi - -while [[ "$SECURITY_DIR" != / && "$SECURITY_DIR" == */ ]]; do - SECURITY_DIR=${SECURITY_DIR%/} -done -certs="$SECURITY_DIR/certificates" - -valid_bundle() { - local path - for path in "$SECURITY_DIR" "$certs" "$certs/"{root,nifi,nginx}; do - [[ -d "$path" && ! -L "$path" ]] || return 1 - done - for path in "$certs/root/root-ca.pem" \ - "$certs/nifi/"nifi-{keystore,truststore}.jks "$certs/nginx/"tls.{crt,key}; do - [[ -f "$path" && ! -L "$path" && -r "$path" && -s "$path" ]] || return 1 - done - - keytool -list -storetype JKS -keystore "$certs/nifi/nifi-keystore.jks" \ - -storepass:env KEYSTORE_PASSWORD >/dev/null 2>&1 && - keytool -list -storetype JKS -keystore "$certs/nifi/nifi-truststore.jks" \ - -storepass:env TRUSTSTORE_PASSWORD >/dev/null 2>&1 -} - -mkdir -p -- "$(dirname -- "$SECURITY_DIR")" -if ! mkdir -- "$SECURITY_DIR" 2>/dev/null; then - valid_bundle && exit 0 - printf 'Cannot create or reuse demo TLS bundle at %s. Use a new directory or fix the existing bundle.\n' "$SECURITY_DIR" >&2 - exit 1 -fi - -# Only remove a directory reserved by this invocation. -trap 'rm -rf -- "$SECURITY_DIR"' EXIT -trap 'exit 130' INT -trap 'exit 143' TERM - -script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) -generators="$script_dir/../../../deployment/scripts/security" -"$generators/create_root_ca_cert.sh" >/dev/null -"$generators/create_nifi_certs.sh" >/dev/null -"$generators/create_nginx_certs.sh" >/dev/null -trap - EXIT diff --git a/deployment/charts/nifi/README.md b/deployment/charts/nifi/README.md index ba39214c..019e218d 100644 --- a/deployment/charts/nifi/README.md +++ b/deployment/charts/nifi/README.md @@ -38,9 +38,8 @@ Use the NGINX `/nifi/` and `/nifi-api/` routes with HTTP Basic authentication. ## Persistent configuration and data The chart creates six PVCs per replica. Set their sizes in -`apps/nifi/env/nifi.env` using Kubernetes quantities such as `200Gi`. For a new -deployment, copy the example to that path. [NiFi env example](../../../apps/nifi/env/nifi.env.example) -[Environment-based values](#environment-based-values) +`apps/nifi/env/nifi.env` using Kubernetes quantities such as `200Gi`. +[NiFi environment settings](../../../apps/nifi/README.md#environment-files) | Volume | Environment variable | Size per replica | | --- | --- | --- | @@ -73,9 +72,9 @@ and readiness probes use NiFi's loopback HTTP endpoint. ## Environment-based values Run `make -C deployment helm-values-nifi` to render `values.env.yaml` using -`deployment/env/nifi.env`. Set `NIFI_K3S_WHITELIST` to comma-separated names -from `kubectl get nodes` to populate `allowedNodes`. An empty list allows any -otherwise eligible node. +`deployment/env/nifi.env`, which links to `apps/nifi/env/nifi.env`. Set +`NIFI_K3S_WHITELIST` to comma-separated names from `kubectl get nodes` to +populate `allowedNodes`. An empty list allows any otherwise eligible node. ## Resource names