Skip to content

Commit a5198db

Browse files
authored
Merge pull request #198950 from TheovanKraay/cassandra-ldap-docs
Cassandra mi ldap auth doc
2 parents 397990b + 446bc85 commit a5198db

File tree

6 files changed

+146
-12
lines changed

6 files changed

+146
-12
lines changed

articles/managed-instance-apache-cassandra/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
href: add-service-principal.md
4343
- name: Configure Customer-Managed Keys
4444
href: customer-managed-keys.md
45+
- name: Enable LDAP authentication
46+
href: ldap.md
4547
- name: Monitor Managed Instance
4648
href: monitor-clusters.md
4749
- name: Manage with Azure CLI

articles/managed-instance-apache-cassandra/dba-commands.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,19 @@ ms.author: thvankra
1313
Azure Managed Instance for Apache Cassandra provides automated deployment, scaling, and [management operations](management-operations.md) for open-source Apache Cassandra data centers. The automation in the service should be sufficient for many use cases. However, this article describes how to run DBA commands manually when the need arises.
1414

1515
> [!IMPORTANT]
16-
> Nodetool commands are in public preview.
16+
> Nodetool and sstable commands are in public preview.
1717
> This feature is provided without a service level agreement, and it's not recommended for production workloads.
1818
> For more information, see [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
1919
20-
<!-- ## DBA command support
21-
Azure Managed Instance for Apache Cassandra allows you to run `nodetool` and `sstable` commands via Azure CLI, for routine DBA administration. Not all commands are supported and there are some limitations. For supported commands, see the sections below. -->
22-
2320
## DBA command support
24-
Azure Managed Instance for Apache Cassandra allows you to run `nodetool` commands via Azure CLI, for routine DBA administration. Not all commands are supported and there are some limitations. For supported commands, see the sections below.
21+
Azure Managed Instance for Apache Cassandra allows you to run `nodetool` and `sstable` commands via Azure CLI, for routine DBA administration. Not all commands are supported and there are some limitations. For supported commands, see the sections below.
2522

2623
>[!WARNING]
2724
> Some of these commands can destabilize the cassandra cluster and should only be run carefully and after being tested in non-production environments. Where possible a `--dry-run` option should be deployed first. Microsoft cannot offer any SLA or support on issues with running commands which alter the default database configuration and/or tables.
2825
2926

3027

31-
## How to run a nodetool command
28+
## How to run a `nodetool` command
3229
Azure Managed Instance for Apache Cassandra provides the following Azure CLI command to run DBA commands:
3330

3431
```azurecli-interactive
@@ -59,9 +56,9 @@ Both will return a json of the following form:
5956
}
6057
```
6158

62-
<!-- ## How to run an sstable command
59+
## How to run an `sstable` command
6360

64-
The `sstable` commands require read/write access to the cassandra data directory and the cassandra database to be stopped. To accomodate this, two additional parameters `--cassandra-stop-start true` and `--readwrite true` need to be given:
61+
The `sstable` commands require read/write access to the cassandra data directory and the cassandra database to be stopped. To accommodate this, two extra parameters `--cassandra-stop-start true` and `--readwrite true` need to be given:
6562

6663
```azurecli-interactive
6764
az managed-cassandra cluster invoke-command --resource-group <test-rg> --cluster-name <test-cluster> --host <ip> --cassandra-stop-start true --readwrite true --command-name sstableutil --arguments "system"="peers"
@@ -73,9 +70,9 @@ The `sstable` commands require read/write access to the cassandra data directory
7370
"commandOutput": "Listing files...\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-CompressionInfo.db\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-Data.db\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-Digest.crc32\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-Filter.db\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-Index.db\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-Statistics.db\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-Summary.db\n/var/lib/cassandra/data/system/peers-37f71aca7dc2383ba70672528af04d4f/me-1-big-TOC.txt\n",
7471
"exitCode": 0
7572
}
76-
``` -->
73+
```
7774

78-
<!-- ## List of supported sstable commands
75+
## List of supported `sstable` commands
7976

8077
For more information on each command, see https://cassandra.apache.org/doc/latest/cassandra/tools/sstable/index.html
8178

@@ -87,9 +84,9 @@ For more information on each command, see https://cassandra.apache.org/doc/lates
8784
* `sstablesplit`
8885
* `sstablerepairedset`
8986
* `sstableofflinerelevel`
90-
* `sstableexpiredblockers` -->
87+
* `sstableexpiredblockers`
9188

92-
## List of supported nodetool commands
89+
## List of supported `nodetool` commands
9390

9491
For more information on each command, see https://cassandra.apache.org/doc/latest/cassandra/tools/nodetool/nodetool.html
9592

articles/managed-instance-apache-cassandra/index.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ landingContent:
6767
links:
6868
- text: Manage resources with Azure CLI
6969
url: manage-resources-cli.md
70+
- text: Enable LDAP Authentication
71+
url: ldap.md
7072
- text: Monitor cluster resources
7173
url: monitor-clusters.md
7274
- text: Configure Customer-Managed Keys
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
title: How to enable LDAP authentication in Azure Managed Instance for Apache Cassandra
3+
description: Learn how to enable LDAP authentication in Azure Managed Instance for Apache Cassandra
4+
author: TheovanKraay
5+
ms.author: thvankra
6+
ms.service: managed-instance-apache-cassandra
7+
ms.topic: how-to
8+
ms.date: 05/23/2022
9+
---
10+
11+
# How to enable LDAP authentication in Azure Managed Instance for Apache Cassandra
12+
13+
Azure Managed Instance for Apache Cassandra provides automated deployment and scaling operations for managed open-source Apache Cassandra data centers. This article discusses how to enable LDAP authentication to your clusters and data centers.
14+
15+
> [!IMPORTANT]
16+
> LDAP authentication is in public preview.
17+
> This feature is provided without a service level agreement, and it's not recommended for production workloads.
18+
> For more information, see [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
19+
20+
## Prerequisites
21+
22+
- If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
23+
- An Azure Managed Instance for Apache Cassandra cluster. Review how to [create an Azure Managed Instance for Apache Cassandra cluster from the Azure portal](create-cluster-portal.md).
24+
25+
## Deploy an LDAP Server in Azure
26+
In this section, we'll walk through creating a simple LDAP server on a Virtual Machine in Azure. If you already have an LDAP server running, you can skip this section and review [how to enable LDAP authentication](ldap.md#enable-ldap-authentication).
27+
28+
1. Deploy a Virtual Machine in Azure using Ubuntu Server 18.04 LTS. You can follow instructions [here](visualize-prometheus-grafana.md#deploy-an-ubuntu-server).
29+
30+
1. Give your server a DNS name:
31+
32+
:::image type="content" source="./media/ldap/dns.jpg" alt-text="Screenshot of virtual machine d n s name in Azure portal." lightbox="./media/ldap/dns.jpg" border="true":::
33+
34+
1. Install Docker on the virtual machine. We recommend [this](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04) tutorial.
35+
36+
1. In the home directory, copy and paste the following text and hit enter. This command will create a file containing a test LDAP user account.
37+
38+
```shell
39+
mkdir ldap-user && cd ldap-user && cat >> user.ldif <<EOL
40+
dn: uid=admin,dc=example,dc=org
41+
uid: admin
42+
cn: admin
43+
sn: 3
44+
objectClass: top
45+
objectClass: posixAccount
46+
objectClass: inetOrgPerson
47+
loginShell: /bin/bash
48+
homeDirectory: /home/admin
49+
uidNumber: 14583102
50+
gidNumber: 14564100
51+
userPassword: admin
52+
53+
gecos: admin
54+
EOL
55+
```
56+
57+
1. Navigate back up to home directory
58+
59+
```shell
60+
cd ..
61+
```
62+
63+
1. Run the below command, replacing `<dnsname>` with the dns name you created for your LDAP server earlier. This command will deploy an LDAP server with TLS enabled to a Docker container, and will also copy the user file you created earlier to the container.
64+
65+
```shell
66+
sudo docker run --hostname <dnsname>.uksouth.cloudapp.azure.com --name <dnsname> -v $(pwd)/ldap-user:/container/service/slapd/assets/test --detach osixia/openldap:1.5.0
67+
```
68+
69+
1. Now copy out the certificates folder from the container (replace `<dnsname>` with the dns name you created for your LDAP server):
70+
71+
```shell
72+
sudo docker cp <dnsname>:/container/service/slapd/assets/certs certs
73+
```
74+
75+
1. Verify that dns name is correct:
76+
77+
```shell
78+
openssl x509 -in certs/ldap.crt -text
79+
```
80+
:::image type="content" source="./media/ldap/dns-verify.jpg" alt-text="Screenshot of output from command to verify certificate." lightbox="./media/ldap/dns-verify.jpg" border="true":::
81+
82+
1. Copy the `ldap.crt` file to [clouddrive](../cloud-shell/persisting-shell-storage.md) in Azure CLI for use later.
83+
84+
1. Add the user to the ldap (replace `<dnsname>` with the dns name you created for your LDAP server):
85+
86+
```shell
87+
sudo docker container exec <dnsname> ldapadd -H ldap://<dnsname>.uksouth.cloudapp.azure.com -D "cn=admin,dc=example,dc=org" -w admin -f /container/service/slapd/assets/test/user.ldif
88+
```
89+
90+
## Enable LDAP authentication
91+
92+
> [!IMPORTANT]
93+
> If you skipped the above section because you already have an existing LDAP server, please ensure that it has server SSL certificates enabled. The `subject alternative name (dns name)` specified for the certificate must also match the domain of the server that LDAP is hosted on, or authentication will fail.
94+
95+
1. Currently, LDAP authentication is a public preview feature. Run the below command to add the required Azure CLI extension:
96+
97+
```azurecli-interactive
98+
az extension add --upgrade --name cosmosdb-preview
99+
```
100+
101+
1. Set authentication method to "Ldap" on the cluster, replacing `<resource group>` and `<cluster name>` with the appropriate values:
102+
103+
```azurecli-interactive
104+
az managed-cassandra cluster update -g <resource group> -c <cluster name> --authentication-method "Ldap"
105+
```
106+
107+
1. Now set properties at the data center level. Replace `<resource group>` and `<cluster name>` with the appropriate values, and `<dnsname>` with the dns name you created for your LDAP server.
108+
109+
> [!NOTE]
110+
> The below command is based on the LDAP setup in the earlier section. If you skipped that section because you already have an existing LDAP server, provide the corresponding values for that server instead. Ensure you have uploaded a certificate file like `ldap.crt` to your [clouddrive](../cloud-shell/persisting-shell-storage.md) in Azure CLI.
111+
112+
```azurecli-interactive
113+
ldap_search_base_distinguished_name='dc=example,dc=org'
114+
ldap_server_certificates='/usr/csuser/clouddrive/ldap.crt'
115+
ldap_server_hostname='<dnsname>.uksouth.cloudapp.azure.com'
116+
ldap_service_user_distinguished_name='cn=admin,dc=example,dc=org'
117+
ldap_service_user_password='admin'
118+
119+
az managed-cassandra datacenter update -g `<resource group>` -c `<cluster name>` -d datacenter-1 --ldap-search-base-dn $ldap_search_base_distinguished_name --ldap-server-certs $ldap_server_certificates --ldap-server-hostname $ldap_server_hostname --ldap-service-user-dn $ldap_service_user_distinguished_name --ldap-svc-user-pwd $ldap_service_user_password
120+
```
121+
122+
1. Once this command has completed, you should be able to use [CQLSH](https://cassandra.apache.org/doc/latest/cassandra/tools/cqlsh.html) (see below) or any Apache Cassandra open-source client driver to connect to your managed instance data center with the user added in the above step:
123+
124+
```shell
125+
export SSL_VALIDATE=false
126+
cqlsh --debug --ssl <data-node-ip> -u <user> -p <password>
127+
```
128+
129+
## Next steps
130+
131+
* [LDAP authentication with Azure Active Directory](../active-directory/fundamentals/auth-ldap.md)
132+
* [Manage Azure Managed Instance for Apache Cassandra resources using Azure CLI](manage-resources-cli.md)
133+
* [Deploy a Managed Apache Spark Cluster with Azure Databricks](deploy-cluster-databricks.md)
188 KB
Loading
115 KB
Loading

0 commit comments

Comments
 (0)