Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support user authentication using Kerberos #436

Merged
merged 37 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1510569
WIP
sbernauer Nov 9, 2023
aadb976
Merge remote-tracking branch 'origin/main' into feat/kerberos-reloaded
sbernauer Jan 9, 2024
fcbda97
Use resolver 2
sbernauer Jan 9, 2024
a556214
fix clippy lint
sbernauer Jan 9, 2024
6e3e898
Improve test and let it pass
sbernauer Jan 9, 2024
f3ffa66
Merge remote-tracking branch 'origin/main' into feat/kerberos-reloaded
sbernauer Jan 10, 2024
92a9063
Improve test output
sbernauer Jan 10, 2024
8bea542
revert tests/test-definition.yaml
sbernauer Jan 10, 2024
a8d2156
(hopefully) fix tests
sbernauer Jan 10, 2024
85bdb9c
fix more tests
sbernauer Jan 11, 2024
74c261e
Merge remote-tracking branch 'origin/main' into feat/kerberos-reloaded
sbernauer Jan 12, 2024
5485d0e
snafufy
sbernauer Jan 12, 2024
f922e50
fix: Set rest server http and ui ports correctly
sbernauer Jan 12, 2024
1ae79a8
vector container shall be the last in the list
sbernauer Jan 12, 2024
6e12f13
fix probe
sbernauer Jan 12, 2024
c31b113
Add test to check restserver
sbernauer Jan 12, 2024
db94e91
increase test timeout
sbernauer Jan 12, 2024
e151092
minor cleanup
sbernauer Jan 15, 2024
1b44f55
fix: Also "sed" core-site and hdfs-site
sbernauer Jan 15, 2024
a4070ba
add docs
sbernauer Jan 15, 2024
90ed2ee
remove ycsb.yaml
sbernauer Jan 15, 2024
b934309
docs link
sbernauer Jan 15, 2024
f23562f
changelog
sbernauer Jan 16, 2024
d6986d2
docs: Add Kerberos discovery
sbernauer Jan 17, 2024
c635838
Apply suggestions from code review
sbernauer Jan 17, 2024
8411d89
Update docs/modules/hbase/pages/usage-guide/security.adoc
sbernauer Jan 17, 2024
b911ab1
Update rust/crd/src/lib.rs
sbernauer Jan 17, 2024
d3e1719
refactor cli_role_name out
sbernauer Jan 17, 2024
afd8a22
Update tests/templates/kuttl/kerberos/42-test-rest-server.yaml
sbernauer Jan 17, 2024
4d2bec4
Change port numbers according to Arch meeting decision
sbernauer Jan 17, 2024
cd979e4
Port unification
sbernauer Jan 17, 2024
13d0e7b
fix test
sbernauer Jan 17, 2024
cd864fd
Update tests/templates/kuttl/kerberos/30-assert.yaml
sbernauer Jan 18, 2024
9028cee
Fix file name
sbernauer Jan 18, 2024
befba73
refactor!: Align with HDFS CRD
sbernauer Jan 18, 2024
2099493
fixup
sbernauer Jan 18, 2024
8edc644
refactor: Move out ui_port_name
sbernauer Jan 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added

- Support user authentication using Kerberos ([#436]).
- More CRD documentation ([#425]).

### Changed
Expand All @@ -18,6 +19,7 @@


[#425]: https://github.com/stackabletech/hbase-operator/pull/425
[#436]: https://github.com/stackabletech/hbase-operator/pull/436
[#438]: https://github.com/stackabletech/hbase-operator/pull/438

## [23.11.0] - 2023-11-24
Expand Down
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ built = { version = "0.6", features = ["chrono", "git2"] }
clap = "4.3"
fnv = "1.0"
futures = { version = "0.3", features = ["compat"] }
indoc = "2.0"
rstest = "0.18"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
20 changes: 20 additions & 0 deletions deploy/helm/hbase-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ spec:
clusterConfig:
description: Configuration that applies to all roles and role groups. This includes settings for logging, ZooKeeper and HDFS connection, among other things.
properties:
authentication:
description: Settings related to user [authentication](https://docs.stackable.tech/home/nightly/usage-guide/security).
nullable: true
properties:
sbernauer marked this conversation as resolved.
Show resolved Hide resolved
kerberos:
description: Kerberos configuration.
properties:
secretClass:
description: Name of the SecretClass providing the keytab for the HBase services.
type: string
required:
- secretClass
type: object
tlsSecretClass:
default: tls
description: Name of the SecretClass providing the tls certificates for the WebUIs.
type: string
required:
- kerberos
type: object
hdfsConfigMapName:
description: Name of the [discovery ConfigMap](https://docs.stackable.tech/home/nightly/concepts/service_discovery) for an HDFS cluster.
type: string
Expand Down
9 changes: 8 additions & 1 deletion docs/modules/hbase/pages/reference/discovery.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ The resulting discovery ConfigMap is located at `{namespace}/{cluster-name}`.
The ConfigMap data values are formatted as Hadoop XML files which allows simple mounting of that ConfigMap into pods that require access to HBase.

`hbase-site.xml`::
Contains the `hbase.zookeeper.quorum` property.
Contains the needed information to connect to Zookeeper and use that to establish a connection to HBase.

=== Kerberos
In case Kerberos is enabled according to the xref:usage-guide/security.adoc[security documentation], the discovery ConfigMap also includes the information that clients must authenticate themselves using Kerberos.

If you want to use the discovery ConfigMap outside Stackable services, you need to substitute `${env.KERBEROS_REALM}` with your actual realm (e.g. by using `sed -i -e 's/${{env.KERBEROS_REALM}}/'"$KERBEROS_REALM/g" hbase-site.xml`).

One example would be the property `hbase.master.kerberos.principal` being set to `hbase/hbase.default.svc.cluster.local@${env.KERBEROS_REALM}`.
60 changes: 60 additions & 0 deletions docs/modules/hbase/pages/usage-guide/security.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
= Security

== Authentication
Currently the only supported authentication mechanism is Kerberos, which is disabled by default.
For Kerberos to work a Kerberos KDC is needed, which the users need to provide.
The xref:home:secret-operator:secretclass.adoc#backend-kerberoskeytab[secret-operator documentation] states which kind of Kerberos servers are supported and how they can be configured.

=== 1. Prepare Kerberos server
To configure HDFS to use Kerberos you first need to collect information about your Kerberos server, e.g. hostname and port.
Additionally, you need a service-user which the secret-operator uses to create principals for the HDFS services.

=== 2. Create Kerberos SecretClass

Check notice on line 12 in docs/modules/hbase/pages/usage-guide/security.adoc

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] docs/modules/hbase/pages/usage-guide/security.adoc#L12

In American English, ‘afterward’ is the preferred variant. ‘Afterwards’ is more commonly used in British English and other dialects. (AFTERWARDS_US[1]) Suggestions: `Afterward` Rule: https://community.languagetool.org/rule/show/AFTERWARDS_US?lang=en-US&subId=1 Category: BRITISH_ENGLISH
Raw output
docs/modules/hbase/pages/usage-guide/security.adoc:12:35: In American English, ‘afterward’ is the preferred variant. ‘Afterwards’ is more commonly used in British English and other dialects. (AFTERWARDS_US[1])
 Suggestions: `Afterward`
 Rule: https://community.languagetool.org/rule/show/AFTERWARDS_US?lang=en-US&subId=1
 Category: BRITISH_ENGLISH
Afterwards you need to enter all the needed information into a SecretClass, as described in xref:home:secret-operator:secretclass.adoc#backend-kerberoskeytab[secret-operator documentation].
The following guide assumes you have named your SecretClass `kerberos`.

=== 3. Configure HDFS to use SecretClass
The next step is to configure your HdfsCluster to use the newly created SecretClass.
Please follow the xref:hdfs:usage-guide/security.adoc[HDFS security guide] to set up and test this.
Please watch out to use the SecretClass named `kerberos`.

=== 4. Configure HBase to use SecretClass
The last step is to configure the same SecretClass for HBase, which is done similar to HDFS.

IMPORTANT: HDFS and HBase need to use the same SecretClass (or at least use the same underlying Kerberos server).

[source,yaml]
----
spec:
clusterConfig:
authentication:
tlsSecretClass: tls # Optional, defaults to "tls"
kerberos:
secretClass: kerberos # Put your SecretClass name in here
----

The `kerberos.secretClass` is used to give HBase the possibility to request keytabs from the secret-operator.

The `tlsSecretClass` is needed to request TLS certificates, used e.g. for the Web UIs.

=== 5. Verify that Kerberos authentication is required
Shell into the `hbase-master-default-0` Pod and execute the following commands:

1. `kdestroy` (just in case you run `kinit` in the Pod already in the past)
2. `echo 'list;' | bin/hbase shell`

The last command should fail with the error message `ERROR: Found no valid authentication method from options`.
You can also check the RestServer by calling `curl -v --insecure https://hbase-restserver-default:8081`, which should return `HTTP ERROR 401 Authentication required`.

=== 6. Access HBase
In case you want to access your HBase it is recommended to start up a client Pod that connects to HBase, rather than shelling into the master.
We have an https://github.com/stackabletech/hbase-operator/blob/main/tests/templates/kuttl/kerberos/41-access-hbase.yaml.j2[integration test] for this exact purpose, where you can see how to connect and get a valid keytab.

Check notice on line 51 in docs/modules/hbase/pages/usage-guide/security.adoc

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] docs/modules/hbase/pages/usage-guide/security.adoc#L51

Use “a” instead of ‘an’ if the following word doesn’t start with a vowel sound, e.g. ‘a sentence’, ‘a university’. (EN_A_VS_AN) Suggestions: `a` URL: https://languagetool.org/insights/post/indefinite-articles/ Rule: https://community.languagetool.org/rule/show/EN_A_VS_AN?lang=en-US Category: MISC
Raw output
docs/modules/hbase/pages/usage-guide/security.adoc:51:8: Use “a” instead of ‘an’ if the following word doesn’t start with a vowel sound, e.g. ‘a sentence’, ‘a university’. (EN_A_VS_AN)
 Suggestions: `a`
 URL: https://languagetool.org/insights/post/indefinite-articles/ 
 Rule: https://community.languagetool.org/rule/show/EN_A_VS_AN?lang=en-US
 Category: MISC

== Authorization
Together with Kerberos authorization is enabled.
You need to explicitly grant table permissions to all users.
E.g. the integration tests run `grant 'testuser', 'C';` to grant the testuser the permission to create tables.

== Wire encryption
In case Kerberos is enabled, `Privacy` mode is used for best security.
Wire encryption without Kerberos as well as other wire encryption modes are *not* supported.
3 changes: 2 additions & 1 deletion docs/modules/hbase/partials/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
** xref:hbase:getting_started/first_steps.adoc[]
* xref:hbase:usage-guide/index.adoc[]
** xref:hbase:usage-guide/listenerclass.adoc[]
** xref:hbase:usage-guide/security.adoc[]
** xref:hbase:usage-guide/resource-requests.adoc[]
** xref:hbase:usage-guide/phoenix.adoc[]
** xref:hbase:usage-guide/compression.adoc[]
Expand All @@ -19,4 +20,4 @@
*** {crd-docs}/hbase.stackable.tech/hbasecluster/v1alpha1/[HbaseCluster {external-link-icon}^]
** xref:hbase:reference/discovery.adoc[]
** xref:hbase:reference/commandline-parameters.adoc[]
** xref:hbase:reference/environment-variables.adoc[]
** xref:hbase:reference/environment-variables.adoc[]
Loading