Skip to content

Commit 8492ec5

Browse files
(DOCSP-11424): Document SCRAM Auth (#196)
* (DOCSP-11424): Document SCRAM Auth * cleanup * rearrange * more cleanup * copy review * tech review * tech review 2
1 parent 5fc56be commit 8492ec5

File tree

10 files changed

+367
-249
lines changed

10 files changed

+367
-249
lines changed

.DS_Store

8 KB
Binary file not shown.

README.md

Lines changed: 18 additions & 249 deletions
Original file line numberDiff line numberDiff line change
@@ -8,274 +8,43 @@ If you are a MongoDB Enterprise customer, or need Enterprise features such as Ba
88

99
## Table of Contents
1010

11-
- [Install the Operator](#install-the-operator)
12-
- [Prerequisites](#prerequisites)
13-
- [Procedure](#procedure)
14-
- [Upgrade the Operator](#upgrade-the-operator)
15-
- [Deploy & Configure MongoDB Resources](#deploy-and-configure-a-mongodb-resource)
16-
- [Deploy a Replica Set](#deploy-a-replica-set)
17-
- [Upgrade MongoDB Version & FCV](#upgrade-your-mongodb-resource-version-and-feature-compatibility-version)
18-
- [Secure MongoDB Resource Connections using TLS](#secure-mongodb-resource-connections-using-tls)
19-
- [Prerequisites](#prerequisites-1)
20-
- [Procedure](#procedure-1)
11+
- [Documentation](#documentation)
2112
- [Supported Features](#supported-features)
2213
- [Contribute](#contribute)
2314
- [License](#license)
2415

25-
## Install the Operator
16+
## Documentation
2617

27-
### Prerequisites
18+
See the [documentation](/docs) to learn how to:
2819

29-
Before you install the MongoDB Community Kubernetes Operator, you must:
30-
31-
1. Install [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/).
32-
2. Have a Kubernetes solution available to use.
33-
If you need a Kubernetes solution, see the [Kubernetes documentation on picking the right solution](https://kubernetes.io/docs/setup). For testing, MongoDB recommends [Kind](https://kind.sigs.k8s.io/).
34-
3. Clone this repository.
35-
```
36-
git clone https://github.com/mongodb/mongodb-kubernetes-operator.git
37-
```
38-
39-
### Procedure
40-
41-
The MongoDB Community Kubernetes Operator is a [Custom Resource Definition](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) and a controller.
42-
43-
To install the MongoDB Community Kubernetes Operator:
44-
45-
1. Change to the directory in which you cloned the repository.
46-
2. Install the [Custom Resource Definitions](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/).
47-
48-
a. Invoke the following `kubectl` command:
49-
```
50-
kubectl create -f deploy/crds/mongodb.com_mongodb_crd.yaml
51-
```
52-
b. Verify that the Custom Resource Definitions installed successfully:
53-
```
54-
kubectl get crd/mongodb.mongodb.com
55-
```
56-
3. Install the Operator.
57-
58-
a. Invoke the following `kubectl` command to install the Operator in the specified namespace:
59-
```
60-
kubectl create -f deploy/ --namespace <my-namespace>
61-
```
62-
b. Verify that the Operator installed successsfully:
63-
```
64-
kubectl get pods --namespace <my-namespace>
65-
```
66-
67-
## Upgrade the Operator
68-
69-
To upgrade the MongoDB Community Kubernetes Operator:
70-
71-
1. Change to the directory in which you cloned the repository.
72-
2. Invoke the following `kubectl` command to upgrade the [Custom Resource Definitions](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/).
73-
```
74-
kubectl apply -f deploy/crds/mongodb.com_mongodb_crd.yaml
75-
```
76-
77-
## Deploy and Configure a MongoDB Resource
78-
79-
The [`/deploy/crds`](deploy/crds) directory contains example MongoDB resources that you can modify and deploy.
80-
81-
### Deploy a Replica Set
82-
83-
To deploy your first replica set:
84-
85-
1. Invoke the following `kubectl` command:
86-
```
87-
kubectl apply -f deploy/crds/mongodb.com_v1_mongodb_cr.yaml --namespace <my-namespace>
88-
```
89-
2. Verify that the MongoDB resource deployed:
90-
```
91-
kubectl get mongodb --namespace <my-namespace>
92-
```
93-
3. connect clients to MongoDB replica set:
94-
```
95-
mongodb://<metadata.name of the MongoDB resource>-svc.<namespace>.svc.cluster.local:27017/?replicaSet=<replica set name>
96-
```
97-
98-
### Upgrade your MongoDB Resource Version and Feature Compatibility Version
99-
100-
You can upgrade the major, minor, and/or feature compatibility versions of your MongoDB resource. These settings are configured in your resource definition YAML file.
101-
102-
- To upgrade your resource's major and/or minor versions, set the `spec.version` setting to the desired MongoDB version.
103-
104-
- To modify your resource's [feature compatibility version](https://docs.mongodb.com/manual/reference/command/setFeatureCompatibilityVersion/), set the `spec.featureCompatibilityVersion` setting to the desired version.
105-
106-
If you update `spec.version` to a later version, consider setting `spec.featureCompatibilityVersion` to the current working MongoDB version to give yourself the option to downgrade if necessary. To learn more about feature compatibility, see [`setFeatureCompatibilityVersion`](https://docs.mongodb.com/manual/reference/command/setFeatureCompatibilityVersion/) in the MongoDB Manual.
107-
108-
### Deploying on OpenShift
109-
110-
If you want to deploy the operator on OpenShift you will have to provide the environment variable `MANAGED_SECURITY_CONTEXT` set to `true` for both the mongodb and mongodb agent containers, as well as the operator deployment.
111-
112-
See [here](deploy/crds/mongodb.com_v1_mongodb_openshift_cr.yaml) for an example of how to provide the required configuration for a MongoDB ReplicaSet.
113-
114-
See [here](deploy/openshift/operator_openshift.yaml) for an example of how to configure the Operator deployment.
115-
116-
#### Example
117-
118-
Consider the following example MongoDB resource definition:
119-
120-
```yaml
121-
apiVersion: mongodb.com/v1
122-
kind: MongoDB
123-
metadata:
124-
name: example-mongodb
125-
spec:
126-
members: 3
127-
type: ReplicaSet
128-
version: "4.0.6"
129-
```
130-
To upgrade this resource from `4.0.6` to `4.2.7`:
131-
132-
1. Edit the resource definition.
133-
134-
a. Update `spec.version` to `4.2.7`.
135-
136-
b. Update `spec.featureCompatibilityVersion` to `4.0`.
137-
138-
```yaml
139-
apiVersion: mongodb.com/v1
140-
kind: MongoDB
141-
metadata:
142-
name: example-mongodb
143-
spec:
144-
members: 3
145-
type: ReplicaSet
146-
version: "4.2.7"
147-
featureCompatibilityVersion: "4.0"
148-
```
149-
150-
**NOTE:** Setting `featureCompatibilityVersion` to `4.0` disables [4.2 features incompatible with MongoDB 4.0](https://docs.mongodb.com/manual/release-notes/4.2-compatibility/#compatibility-enabled).
151-
152-
2. Reapply the configuration to Kubernetes:
153-
```
154-
kubectl apply -f <example>.yaml --namespace <my-namespace>
155-
```
156-
157-
## Secure MongoDB Resource Connections using TLS
158-
159-
You can configure the MongoDB Community Kubernetes Operator to use TLS certificates to encrypt traffic between:
160-
161-
- MongoDB hosts in a replica set, and
162-
- Client applications and MongoDB deployments.
163-
164-
### Prerequisites
165-
166-
Before you secure MongoDB resource connections using TLS, you must:
167-
168-
1. Create a PEM-encoded TLS certificate for the servers in the MongoDB resource using your own Certificate Authority (CA). The certificate must have one of the following:
169-
170-
- A wildcard `Common Name` that matches the domain name of all of the replica set members:
171-
172-
```
173-
*.<metadata.name of the MongoDB resource>-svc.<namespace>.svc.cluster.local
174-
```
175-
- The domain name for each of the replica set members as `Subject Alternative Names` (SAN):
176-
177-
```
178-
<metadata.name of the MongoDB resource>-0.<metadata.name of the MongoDB resource>-svc.<namespace>.svc.cluster.local
179-
<metadata.name of the MongoDB resource>-1.<metadata.name of the MongoDB resource>-svc.<namespace>.svc.cluster.local
180-
<metadata.name of the MongoDB resource>-2.<metadata.name of the MongoDB resource>-svc.<namespace>.svc.cluster.local
181-
```
182-
183-
1. Create a Kubernetes ConfigMap that contains the certificate for the CA that signed your server certificate. The key in the ConfigMap that references the certificate must be named `ca.crt`. Kubernetes configures this automatically if the certificate file is named `ca.crt`:
184-
```
185-
kubectl create configmap <tls-ca-configmap-name> --from-file=ca.crt --namespace <namespace>
186-
```
187-
188-
For a certificate file with any other name, you must define the `ca.crt` key manually:
189-
```
190-
kubectl create configmap <tls-ca-configmap-name> --from-file=ca.crt=<certificate-file-name>.crt --namespace <namespace>
191-
```
192-
193-
1. Create a Kubernetes secret that contains the server certificate and key for the members of your replica set. For a server certificate named `server.crt` and key named `server.key`:
194-
```
195-
kubectl create secret tls <tls-secret-name> --cert=server.crt --key=server.key --namespace <namespace>
196-
```
197-
198-
### Procedure
199-
200-
To secure connections to MongoDB resources using TLS:
201-
202-
1. Add the following fields to the MongoDB resource definition:
203-
204-
- `spec.security.tls.enabled`: Encrypts communications using TLS certificates between MongoDB hosts in a replica set and client applications and MongoDB deployments. Set to `true`.
205-
- `spec.security.tls.optional`: (**Optional**) Enables the members of the replica set to accept both TLS and non-TLS client connections. Equivalent to setting the MongoDB[`net.tls.mode`](https://docs.mongodb.com/manual/reference/configuration-options/#net.tls.mode) setting to `preferSSL`. If omitted, defaults to `false`.
206-
207-
---
208-
**NOTE**
209-
210-
When you enable TLS on an existing replica set deployment:
211-
212-
a. Set `spec.security.tls.optional` to `true`.
213-
214-
b. Apply the configuration to Kubernetes.
215-
216-
c. Upgrade your existing clients to use TLS.
217-
218-
d. Remove the `spec.security.tls.optional` field.
219-
220-
e. Complete the remaining steps in the procedure.
221-
222-
---
223-
- `spec.security.tls.certificateKeySecretRef.name`: Name of the Kubernetes secret that contains the server certificate and key that you created in the [prerequisites](#prerequisites-1).
224-
- `spec.security.tls.caConfigMapRef.name`: Name of the Kubernetes ConfigMap that contains the Certificate Authority certificate used to sign the server certificate that you created in the [prerequisites](#prerequisites-1).
225-
226-
```yaml
227-
apiVersion: mongodb.com/v1
228-
kind: MongoDB
229-
metadata:
230-
name: example-mongodb
231-
spec:
232-
members: 3
233-
type: ReplicaSet
234-
version: "4.2.7"
235-
security:
236-
tls:
237-
enabled: true
238-
certificateKeySecretRef:
239-
name: <tls-secret-name>
240-
caConfigMapRef:
241-
name: <tls-ca-configmap-name>
242-
```
243-
244-
1. Apply the configuration to Kubernetes:
245-
```
246-
kubectl apply -f <example>.yaml --namespace <my-namespace>
247-
```
248-
1. From within the Kubernetes cluster, connect to the MongoDB resource.
249-
- If `spec.security.tls.optional` is omitted or `false`: clients must
250-
establish TLS connections to the MongoDB servers in the replica set.
251-
- If `spec.security.tls.optional` is true, clients can establish TLS or
252-
non-TLS connections to the MongoDB servers in the replica set.
253-
254-
See the documentation for your connection method to learn how to establish a TLS connection to a MongoDB server.
20+
1. [Install or upgrade](/docs/install-upgrade.md) the Operator.
21+
1. [Deploy and configure](/docs/deploy-configure.md) MongoDB resources.
22+
1. [Create a database user](/docs/users.md) with SCRAM authentication.
23+
1. [Secure MongoDB resource connections](/docs/secure.md) using TLS.
25524

25625
## Supported Features
25726

25827
The MongoDB Community Kubernetes Operator supports the following features:
25928

260-
- MongoDB Topology: [replica sets](https://docs.mongodb.com/manual/replication/)
261-
- Upgrading and downgrading MongoDB server version
262-
- Scaling replica sets up and down
263-
- Reading from and writing to the replica set while scaling, upgrading, and downgrading. These operations are done in an "always up" manner.
264-
- Reporting of MongoDB server state via the [MongoDB resource](/deploy/crds/mongodb.com_mongodb_crd.yaml) `status` field
265-
- Use of any of the available [Docker MongoDB images](https://hub.docker.com/_/mongo/)
266-
- Clients inside the Kubernetes cluster can connect to the replica set (no external connectivity)
267-
- TLS support for client-to-server and server-to-server communication
29+
- Create [replica sets](https://docs.mongodb.com/manual/replication/)
30+
- Upgrade and downgrade MongoDB server version
31+
- Scale replica sets up and down
32+
- Read from and write to the replica set while scaling, upgrading, and downgrading. These operations are done in an "always up" manner.
33+
- Report MongoDB server state via the [MongoDB resource](/deploy/crds/mongodb.com_mongodb_crd.yaml) `status` field
34+
- Use any of the available [Docker MongoDB images](https://hub.docker.com/_/mongo/)
35+
- Connect to the replica set from inside the Kubernetes cluster (no external connectivity)
36+
- Secure client-to-server and server-to-server connections with TLS
37+
- Create users with [SCRAM](https://docs.mongodb.com/manual/core/security-scram/) authentication
26838

26939
### Planned Features
27040
- Server internal authentication via keyfile
271-
- Creating users with SCRAM-SHA authentication
27241

27342
## Contribute
27443

27544
Before you contribute to the MongoDB Community Kubernetes Operator, please read:
27645

277-
- [MongoDB Community Kubernetes Operator Architecture](architecture.md)
278-
- [Contributing to MongoDB Community Kubernetes Operator](contributing.md)
46+
- [MongoDB Community Kubernetes Operator Architecture](/docs/architecture.md)
47+
- [Contributing to MongoDB Community Kubernetes Operator](/docs/contributing.md)
27948

28049
Please file issues before filing PRs. For PRs to be accepted, contributors must sign our [CLA](https://www.mongodb.com/legal/contributor-agreement).
28150

deploy/.DS_Store

6 KB
Binary file not shown.

docs/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# MongoDB Community Kubernetes Operator Documentation #
2+
3+
## Table of Contents
4+
5+
- [Contribute to the MongoDB Kubernetes Operator](/docs/contributing.md)
6+
- [MongoDB Community Kubernetes Operator Architecture](/docs/architecutre.md)
7+
- [Install and Upgrade the Community Kubernetes Operator](/docs/install-upgrade.md)
8+
- [Deploy and Configure MongoDB Resources](/docs/deploy-configure.md)
9+
- [Create Database Users](/docs/users.md)
10+
- [Secure MongoDB Resources](/docs/secure.md)
File renamed without changes.
File renamed without changes.

docs/deploy-configure.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Deploy and Configure a MongoDB Resource #
2+
3+
The [`/deploy/crds`](deploy/crds) directory contains example MongoDB resources that you can modify and deploy.
4+
5+
## Table of Contents
6+
7+
- [Deploy a Replica Set](#deploy-a-replica-set)
8+
- [Upgrade MongoDB Version & FCV](#upgrade-your-mongodb-resource-version-and-feature-compatibility-version)
9+
- [Deploying on Openshift](#deploying-on-openshift)
10+
11+
## Deploy a Replica Set
12+
13+
To deploy your first replica set:
14+
15+
1. Invoke the following `kubectl` command:
16+
```
17+
kubectl apply -f deploy/crds/mongodb.com_v1_mongodb_cr.yaml --namespace <my-namespace>
18+
```
19+
2. Verify that the MongoDB resource deployed:
20+
```
21+
kubectl get mongodb --namespace <my-namespace>
22+
```
23+
3. Connect clients to the MongoDB replica set:
24+
```
25+
mongodb://<metadata.name of the MongoDB resource>-svc.<namespace>.svc.cluster.local:27017/?replicaSet=<replica set name>
26+
```
27+
28+
## Upgrade your MongoDB Resource Version and Feature Compatibility Version
29+
30+
You can upgrade the major, minor, and/or feature compatibility versions of your MongoDB resource. These settings are configured in your resource definition YAML file.
31+
32+
- To upgrade your resource's major and/or minor versions, set the `spec.version` setting to the desired MongoDB version.
33+
34+
- To modify your resource's [feature compatibility version](https://docs.mongodb.com/manual/reference/command/setFeatureCompatibilityVersion/), set the `spec.featureCompatibilityVersion` setting to the desired version.
35+
36+
If you update `spec.version` to a later version, consider setting `spec.featureCompatibilityVersion` to the current working MongoDB version to give yourself the option to downgrade if necessary. To learn more about feature compatibility, see [`setFeatureCompatibilityVersion`](https://docs.mongodb.com/manual/reference/command/setFeatureCompatibilityVersion/) in the MongoDB Manual.
37+
38+
## Deploying on OpenShift
39+
40+
If you want to deploy the operator on OpenShift you will have to provide the environment variable `MANAGED_SECURITY_CONTEXT` set to `true` for both the mongodb and mongodb agent containers, as well as the operator deployment.
41+
42+
See [here](deploy/crds/mongodb.com_v1_mongodb_openshift_cr.yaml) for an example of how to provide the required configuration for a MongoDB ReplicaSet.
43+
44+
See [here](deploy/operator_openshift.yaml) for an example of how to configure the Operator deployment.
45+
46+
### Example
47+
48+
Consider the following example MongoDB resource definition:
49+
50+
```yaml
51+
apiVersion: mongodb.com/v1
52+
kind: MongoDB
53+
metadata:
54+
name: example-mongodb
55+
spec:
56+
members: 3
57+
type: ReplicaSet
58+
version: "4.0.6"
59+
```
60+
To upgrade this resource from `4.0.6` to `4.2.7`:
61+
62+
1. Edit the resource definition.
63+
64+
a. Update `spec.version` to `4.2.7`.
65+
66+
b. Update `spec.featureCompatibilityVersion` to `4.0`.
67+
68+
```yaml
69+
apiVersion: mongodb.com/v1
70+
kind: MongoDB
71+
metadata:
72+
name: example-mongodb
73+
spec:
74+
members: 3
75+
type: ReplicaSet
76+
version: "4.2.7"
77+
featureCompatibilityVersion: "4.0"
78+
```
79+
80+
**NOTE:** Setting `featureCompatibilityVersion` to `4.0` disables [4.2 features incompatible with MongoDB 4.0](https://docs.mongodb.com/manual/release-notes/4.2-compatibility/#compatibility-enabled).
81+
82+
2. Reapply the configuration to Kubernetes:
83+
```
84+
kubectl apply -f <example>.yaml --namespace <my-namespace>
85+
```

0 commit comments

Comments
 (0)