Skip to content

fix: Add core-site entries when kerberos is enabled - #867

Open
adwk67 wants to merge 14 commits into
mainfrom
fix/kerberized-endpoints
Open

adwk67 wants to merge 14 commits into
mainfrom
fix/kerberized-endpoints

Conversation

@adwk67

@adwk67 adwk67 commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Description

Part of https://github.com/stackabletech/internal-issues/issues/191
Read this and the following comments: https://github.com/stackabletech/internal-issues/issues/191#issuecomment-7136264854

With Kerberos enabled, the HTTP endpoints of name, data and journal nodes enforce SPNEGO, with /prom as the only exception, as Prometheus cannot authenticate via SPNEGO. SPNEGO works both via the pod FQDNs and via the listener addresses published in the discovery ConfigMap.

  • core-site.xml: hadoop.http.authentication.type=kerberos, anonymous access off, /prom whitelisted. Data nodes additionally get AuthenticationFilterInitializer in hadoop.http.filter.initializers, as DatanodeHttpServer does not use DFSUtil.getHttpServerTemplate.
  • Principals: the HTTP servers accept every HTTP/ principal in the keytab (hadoop.http.authentication.kerberos.principal=*). The keytab volume gets the pod scope (pod FQDNs, used by /imagetransfer and /getJournal) and, for name and data nodes, the listener scope, so SPNEGO also works via the addresses published in the discovery ConfigMap, including NodePort IPs.
  • Keytab: for *, Hadoop reads the keytab with Kerby, which cannot parse the keytab as the secret-operator writes it (the entry it adds and removes leaves a hole). The main container rewrites the keytab with ktutil to /stackable/config/spnego.keytab, which the HTTP servers use. That directory is a memory-backed emptyDir, so the copy stays off the node's disk, like the secret-operator's tmpfs original.
  • Journal nodes: GetJournalEditServlet.isValidRequestor only accepts requesters with the journal node's own short name, so journal nodes map the name node principal to jn via hadoop.security.auth_to_local. The rule is set on journal nodes only; no principal is mapped to nn.

BREAKING: a configOverrides entry for hadoop.security.auth_to_local on journal nodes replaces
the operator's rule and must include it, otherwise name nodes cannot fetch edits and fail to start.

Tested

  • Unit tests for the core-site settings, the keytab volume scopes and the keytab rewrite.
  • kuttl kerberos, new step 33: without a ticket 401, with SPNEGO 200, via pod FQDNs and via the name node addresses from the discovery ConfigMap; /prom stays open. The test now uses the external-unstable listener class, so the discovered addresses are NodePort IPs.
--- PASS: kuttl (2225.52s)
    --- PASS: kuttl/harness (0.00s)
        --- PASS: kuttl/harness/kerberos_hadoop-3.5.0_zookeeper-latest-3.9.6_krb5-1.21.1_opa-latest-1.20.2_kerberos-realm-CLUSTER.LOCAL_kerberos-backend-mit_openshift-false (1074.81s)
        --- PASS: kuttl/harness/kerberos_hadoop-3.4.3_zookeeper-latest-3.9.6_krb5-1.21.1_opa-latest-1.20.2_kerberos-realm-CLUSTER.LOCAL_kerberos-backend-mit_openshift-false (1080.03s)
        --- PASS: kuttl/harness/kerberos_hadoop-3.5.0_zookeeper-latest-3.9.6_krb5-1.21.1_opa-latest-1.20.2_kerberos-realm-PROD.MYCORP_kerberos-backend-mit_openshift-false (1133.83s)
        --- PASS: kuttl/harness/kerberos_hadoop-3.4.3_zookeeper-latest-3.9.6_krb5-1.21.1_opa-latest-1.20.2_kerberos-realm-PROD.MYCORP_kerberos-backend-mit_openshift-false (1145.48s)
PASS
  • Passed locally on 3.4.3 and 3.5.0 (3.5.0 also with cluster-internal), including the chaos monkey step (name node restarts reading edits via /getJournal).
  • Manually from outside the kind cluster: curl --negotiate via a name node's NodePort address returns 401 without and 200 with a ticket.
Manual testing

Testing SPNEGO from outside the cluster

With a Kerberos-enabled cluster whose name nodes use external-unstable (e.g. the kerberos
kuttl test with --skip-delete), in its namespace:

  1. Get a name node HTTPS address from the discovery ConfigMap:

    export NS=<namespace>
    kubectl -n $NS get cm hdfs -o jsonpath='{.data.hdfs-site\.xml}' | grep -A1 https-address
  2. Create a test principal on the KDC:

    kubectl -n $NS exec krb5-kdc-0 -c kdc -- kadmin.local add_principal -pw tester tester
  3. In a second terminal, forward the KDC (TCP only):

    kubectl -n $NS port-forward svc/krb5-kdc 18888:88
  4. Save as /tmp/krb5.conf, with <REALM> replaced by the test's realm:

    [libdefaults]
      default_realm = <REALM>
      udp_preference_limit = 1
      rdns = false
      dns_canonicalize_hostname = false
    [realms]
      <REALM> = {
        kdc = 127.0.0.1:18888
      }
  5. Without a ticket, expect 401:

    curl -k -o /dev/null -w '%{http_code}\n' https://<address>/jmx
  6. With a ticket (password tester), expect 200:

    export KRB5_CONFIG=/tmp/krb5.conf
    kinit tester
    curl -k --negotiate -u : -o /dev/null -w '%{http_code}\n' https://<address>/jmx
    klist

    klist shows a ticket for HTTP/<address without port>@<REALM>.

-k skips certificate verification to keep the steps short. rdns/dns_canonicalize_hostname
make the client request a ticket for the address exactly as given, including an IP.

Follow-ups

  • secret-operator: keytabs start with a hole (deleted dummy entry) that Kerby cannot parse; fixing that makes the ktutil rewrite unnecessary.
  • Hadoop's Java WebHDFS client replaces an IP with its reverse-DNS name for TLS and SPNEGO, which matches neither the certificate nor the keytab when listeners publish IPs.

Definition of Done Checklist

  • Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
  • Please make sure all these things are done and tick the boxes

Author

  • Changes are OpenShift compatible
  • CRD changes approved
  • CRD documentation for all fields, following the style guide.
  • Helm chart can be installed and deployed operator works
  • Integration tests passed (for non trivial changes)
  • Changes need to be "offline" compatible
  • Links to generated (nightly) docs added
  • Release note snippet added

Reviewer

  • Code contains useful comments
  • Code contains useful logging statements
  • (Integration-)Test cases added
  • Documentation added or updated. Follows the style guide.
  • Changelog updated
  • Cargo.toml only contains references to git tags (not specific commits or branches)

Acceptance

  • Feature Tracker has been updated
  • Proper release label has been added
  • Links to generated (nightly) docs added
  • Release note snippet added
  • Add type/deprecation label & add to the deprecation schedule
  • Add type/experimental label & add to the experimental features tracker

@adwk67 adwk67 self-assigned this Nov 24, 2026
@adwk67 adwk67 moved this to Development: In Progress in Stackable Engineering Nov 24, 2026
@adwk67 adwk67 changed the title fix: Add necessary core-site entries when kerberos enabled fix: Add core-site entries when kerberos is enabled Nov 30, 2026
@adwk67

adwk67 commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Nightly tests:

--- PASS: kuttl (2364.87s)
    --- PASS: kuttl/harness (0.00s)
        --- PASS: kuttl/harness/orphaned-resources_hadoop-latest-3.5.0_zookeeper-latest-3.9.6_openshift-false (167.98s)
        --- PASS: kuttl/harness/profiling_hadoop-3.5.0_zookeeper-latest-3.9.6_openshift-false (182.91s)
        --- PASS: kuttl/harness/cluster-operation_hadoop-latest-3.5.0_zookeeper-latest-3.9.6_openshift-false (267.93s)
        --- PASS: kuttl/harness/logging_hadoop-3.5.0_zookeeper-latest-3.9.6_openshift-false (429.91s)
        --- PASS: kuttl/harness/topology-provider_hadoop-latest-3.5.0_zookeeper-latest-3.9.6_krb5-1.21.1_kerberos-backend-mit_openshift-false (235.41s)
        --- PASS: kuttl/harness/smoke_hadoop-3.5.0_zookeeper-3.9.6_zookeeper-latest-3.9.6_number-of-datanodes-2_datanode-pvcs-2hdd-1ssd_listener-class-external-unstable_openshift-false (174.75s)
        --- PASS: kuttl/harness/smoke_hadoop-3.5.0_zookeeper-3.9.5_zookeeper-latest-3.9.6_number-of-datanodes-2_datanode-pvcs-2hdd-1ssd_listener-class-external-unstable_openshift-false (190.50s)
        --- PASS: kuttl/harness/smoke_hadoop-3.5.0_zookeeper-3.9.5_zookeeper-latest-3.9.6_number-of-datanodes-2_datanode-pvcs-2hdd-1ssd_listener-class-cluster-internal_openshift-false (166.83s)
        --- PASS: kuttl/harness/smoke_hadoop-3.5.0_zookeeper-3.9.6_zookeeper-latest-3.9.6_number-of-datanodes-2_datanode-pvcs-2hdd-1ssd_listener-class-cluster-internal_openshift-false (647.31s)
        --- PASS: kuttl/harness/kerberos_hadoop-3.5.0_zookeeper-latest-3.9.6_krb5-1.21.1_opa-latest-1.20.2_kerberos-realm-CLUSTER.LOCAL_kerberos-backend-mit_openshift-false (1109.51s)
        --- PASS: kuttl/harness/kerberos_hadoop-3.5.0_zookeeper-latest-3.9.6_krb5-1.21.1_opa-latest-1.20.2_kerberos-realm-PROD.MYCORP_kerberos-backend-mit_openshift-false (1146.52s)
PASS

@adwk67
adwk67 marked this pull request as ready for review December 1, 2026 15:28
@adwk67 adwk67 moved this from Development: In Progress to Development: Waiting for Review in Stackable Engineering Dec 1, 2026

@NickLarsenNZ NickLarsenNZ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Partial review. need to close all of the github tabs because it is unusable.

Comment on lines +1115 to +1120
if cluster.has_kerberos_enabled() {
volume_mounts.push(
VolumeMountBuilder::new(&*SPNEGO_KEYTAB_VOLUME_NAME, SPNEGO_KEYTAB_DIR)
.build(),
);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I understand correctly, volumes (further above) are always set, but the mounts are only set if cluster.has_kerberos_enabled().

Do we want to also make volumes conditional?

Comment on lines +781 to +784
/// with Kerby, which cannot parse the keytab as the secret-operator writes it, but parses
/// the same entries written by `ktutil`. `wkt` appends to an existing file, so any existing
/// file is removed first. `ktutil` exits with 0 even when a command fails, so success is
/// judged by the written file.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does secret-operator do something wrong?
Can you give an example of the differences in the keytab secret-operator produces and the one Kerby expects?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, there is an issue here: stackabletech/secret-operator#785

/// HDFS superuser, and likewise for `dn` and `jn`. So only the principals the daemons log in as
/// keep these short names. Any other principal with these service names is left unchanged, and
/// Hadoop rejects the non-simple result, so it cannot authenticate. `DEFAULT` maps all other
/// principals.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is that to say:

  • nn/host1 -> nn
  • dn/host1 -> dn
  • jn/host1 -> jn
  • foo/host1 -> foo/host1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think a test for auth_to_local_rules would help.

Apologies if there already is one, the Github review page is almost unusable for me and I can't easily find things anymore.

@NickLarsenNZ NickLarsenNZ moved this from Development: Waiting for Review to Development: In Review in Stackable Engineering Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development: In Review

Development

Successfully merging this pull request may close these issues.

2 participants