Skip to content

Commit 8b7ffa1

Browse files
author
Rodrigo Valin
committed
5caf47418e1761f3e103746797fafc49783d0e27: update public repo contents
1 parent 8c87ad6 commit 8b7ffa1

17 files changed

+652
-55
lines changed

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ This Operator requires Ops Manager or Cloud Manager. In this document, when we r
3232

3333
## Installation ##
3434

35+
### Create CustomResourceDefinitions
36+
37+
The `CustomResourceDefinition` (or `crds`) should be installed before installing the operator into your Kubernetes cluster. To do this, make sure you have logged into your Kubernetes cluster and that you can perform Cluster level operations:
38+
39+
kubectl apply -f https://raw.githubusercontent.com/mongodb/mongodb-enterprise-kubernetes/master/crds.yaml
40+
41+
This will create three new `crds` in your cluster, `MongoDbStandalone`, `MongoDbReplicaSet` and `MongoDbShardedCluster`. These new objects will be the ones used by the operator to perform the MongoDb operations needed to prepare each one of the different MongoDb types of deployments.
42+
43+
### Operator Installation
44+
3545
This operator can also be installed using yaml files, in case you are not using Helm. You may apply the config directly from github clone this repo, and apply the file
3646

3747
kubectl apply -f https://raw.githubusercontent.com/mongodb/mongodb-enterprise-kubernetes/master/mongodb-enterprise.yaml
@@ -55,7 +65,9 @@ If you have an Helm installation in your Kubernetes cluster, you can run:
5565
For the Operator to work, you will need the following information:
5666

5767
* Base Url - the url of an Ops Manager instance
58-
* Project Id - the id of a Project which MongoDBs will be deployed into.
68+
* Project Name - the name of an Ops Manager Project where MongoDBs will be deployed into. It will be created by Operator
69+
if it doesn't exist (and this is the recommended way instead of reusing the project created in OpsManager directly)
70+
* (optionally) Organization Id - the id of organization to which Project belongs
5971
* User - an Ops Manager username
6072
* Public API Key - an Ops Manager Public API Key. Note that you must whitelist the IP range of your Kubernetes cluster so that the Operator may make requests to Ops Manager using this API Key.
6173

@@ -75,10 +87,13 @@ metadata:
7587
name: my-project
7688
namespace: mongodb
7789
data:
78-
projectId: my-project-id # get this from Ops Manager
90+
projectName: myProjectName
91+
orgId: 5b890e0feacf0b76ff3e7183 # this is an optional parameter
7992
baseUrl: https://my-ops-manager-or-cloud-manager-url
8093
```
81-
94+
> Note, that if `orgId` is skipped then the new organization named `projectName` will be automatically created and new
95+
project will be added there.
96+
8297
Apply this file to create the new `Project`:
8398

8499
kubectl apply -f my-project.yaml
@@ -115,8 +130,8 @@ users.
115130

116131
### Creating a MongoDB Object ###
117132

118-
A MongoDB object in Kubernetes can be a MongoDBStandalone, a MongoDBReplicaSet or a MongoDBShardedCluster. We are going to create a replica set to test that everything is working as expected. There is a MongoDBReplicaSet yaml file in `samples/minimal/replicaset.yaml`.
133+
A MongoDB object in Kubernetes can be a MongoDBStandalone, a MongoDBReplicaSet or a MongoDBShardedCluster. We are going to create a replica set to test that everything is working as expected. There is a MongoDBReplicaSet yaml file in `samples/minimal/replica-set.yaml`.
119134

120135
If you have a correctly created Project with the name `my-project` and Credentials stored in a secret called `my-credentials` then, after applying this file then everything should be running and a new Replica Set with 3 members should soon appear in Ops Manager UI.
121136

122-
kubectl apply -f samples/minimal/replicaset.yaml
137+
kubectl apply -f samples/minimal/replica-set.yaml

crds.yaml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
# Source: mongodb-enterprise-operator/templates/crds.yaml
3+
4+
5+
---
6+
apiVersion: apiextensions.k8s.io/v1beta1
7+
kind: CustomResourceDefinition
8+
metadata:
9+
name: mongodbstandalones.mongodb.com
10+
spec:
11+
group: mongodb.com
12+
version: v1
13+
scope: Namespaced
14+
names:
15+
kind: MongoDbStandalone
16+
plural: mongodbstandalones
17+
shortNames:
18+
- mst
19+
singular: mongodbstandalone
20+
validation:
21+
openAPIV3Schema:
22+
properties:
23+
spec:
24+
properties:
25+
spec:
26+
properties:
27+
credentials:
28+
type: string
29+
project:
30+
type: string
31+
version:
32+
type: string
33+
required:
34+
- credentials
35+
- project
36+
- version
37+
38+
---
39+
apiVersion: apiextensions.k8s.io/v1beta1
40+
kind: CustomResourceDefinition
41+
metadata:
42+
name: mongodbreplicasets.mongodb.com
43+
spec:
44+
group: mongodb.com
45+
version: v1
46+
scope: Namespaced
47+
names:
48+
kind: MongoDbReplicaSet
49+
singular: mongodbreplicaset
50+
plural: mongodbreplicasets
51+
shortNames:
52+
- mrs
53+
validation:
54+
openAPIV3Schema:
55+
properties:
56+
spec:
57+
properties:
58+
members:
59+
maximum: 50
60+
minimum: 1
61+
type: integer
62+
spec:
63+
properties:
64+
credentials:
65+
type: string
66+
project:
67+
type: string
68+
version:
69+
type: string
70+
required:
71+
- credentials
72+
- project
73+
- version
74+
- members
75+
76+
---
77+
apiVersion: apiextensions.k8s.io/v1beta1
78+
kind: CustomResourceDefinition
79+
metadata:
80+
name: mongodbshardedclusters.mongodb.com
81+
spec:
82+
group: mongodb.com
83+
version: v1
84+
scope: Namespaced
85+
names:
86+
kind: MongoDbShardedCluster
87+
plural: mongodbshardedclusters
88+
shortNames:
89+
- msc
90+
singular: mongodbshardedcluster
91+
validation:
92+
openAPIV3Schema:
93+
properties:
94+
spec:
95+
properties:
96+
configServerCount:
97+
maximum: 50
98+
minimum: 1
99+
type: integer
100+
mongodsPerShardCount:
101+
maximum: 50
102+
minimum: 1
103+
type: integer
104+
mongosCount:
105+
minimum: 1
106+
type: integer
107+
shardCount:
108+
minimum: 1
109+
type: integer
110+
spec:
111+
properties:
112+
credentials:
113+
type: string
114+
project:
115+
type: string
116+
version:
117+
type: string
118+
required:
119+
- credentials
120+
- project
121+
- version
122+
- shardCount
123+
- mongodsPerShardCount
124+
- mongosCount
125+
- configServerCount
126+
127+

helm_chart/templates/crds.yaml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{{ if eq .Values.createCrds true}}
2+
3+
---
4+
apiVersion: apiextensions.k8s.io/v1beta1
5+
kind: CustomResourceDefinition
6+
metadata:
7+
name: mongodbstandalones.mongodb.com
8+
spec:
9+
group: mongodb.com
10+
version: v1
11+
scope: Namespaced
12+
names:
13+
kind: MongoDbStandalone
14+
plural: mongodbstandalones
15+
shortNames:
16+
- mst
17+
singular: mongodbstandalone
18+
validation:
19+
openAPIV3Schema:
20+
properties:
21+
spec:
22+
properties:
23+
spec:
24+
properties:
25+
credentials:
26+
type: string
27+
project:
28+
type: string
29+
version:
30+
type: string
31+
required:
32+
- credentials
33+
- project
34+
- version
35+
36+
---
37+
apiVersion: apiextensions.k8s.io/v1beta1
38+
kind: CustomResourceDefinition
39+
metadata:
40+
name: mongodbreplicasets.mongodb.com
41+
spec:
42+
group: mongodb.com
43+
version: v1
44+
scope: Namespaced
45+
names:
46+
kind: MongoDbReplicaSet
47+
singular: mongodbreplicaset
48+
plural: mongodbreplicasets
49+
shortNames:
50+
- mrs
51+
validation:
52+
openAPIV3Schema:
53+
properties:
54+
spec:
55+
properties:
56+
members:
57+
maximum: 50
58+
minimum: 1
59+
type: integer
60+
spec:
61+
properties:
62+
credentials:
63+
type: string
64+
project:
65+
type: string
66+
version:
67+
type: string
68+
required:
69+
- credentials
70+
- project
71+
- version
72+
- members
73+
74+
---
75+
apiVersion: apiextensions.k8s.io/v1beta1
76+
kind: CustomResourceDefinition
77+
metadata:
78+
name: mongodbshardedclusters.mongodb.com
79+
spec:
80+
group: mongodb.com
81+
version: v1
82+
scope: Namespaced
83+
names:
84+
kind: MongoDbShardedCluster
85+
plural: mongodbshardedclusters
86+
shortNames:
87+
- msc
88+
singular: mongodbshardedcluster
89+
validation:
90+
openAPIV3Schema:
91+
properties:
92+
spec:
93+
properties:
94+
configServerCount:
95+
maximum: 50
96+
minimum: 1
97+
type: integer
98+
mongodsPerShardCount:
99+
maximum: 50
100+
minimum: 1
101+
type: integer
102+
mongosCount:
103+
minimum: 1
104+
type: integer
105+
shardCount:
106+
minimum: 1
107+
type: integer
108+
spec:
109+
properties:
110+
credentials:
111+
type: string
112+
project:
113+
type: string
114+
version:
115+
type: string
116+
required:
117+
- credentials
118+
- project
119+
- version
120+
- shardCount
121+
- mongodsPerShardCount
122+
- mongosCount
123+
- configServerCount
124+
125+
{{end}}

helm_chart/templates/operator.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@ spec:
1818
containers:
1919
- name: {{ .Values.operator.name }}
2020
image: {{ .Values.registry.repository }}/mongodb-enterprise-operator:{{ .Values.operator.version }}
21-
imagePullPolicy: {{ .Values.operator.pullPolicy }}
21+
imagePullPolicy: {{ .Values.registry.pullPolicy }}
2222
env:
2323
- name: OPERATOR_ENV
2424
value: {{ .Values.operator.env }}
25+
- name: WATCH_NAMESPACE
26+
valueFrom:
27+
fieldRef:
28+
fieldPath: metadata.namespace
29+
{{ if eq .Values.managedSecurityContext true}}
30+
- name: MANAGED_SECURITY_CONTEXT
31+
value: 'true'
32+
{{end}}
2533
- name: MONGODB_ENTERPRISE_DATABASE_IMAGE
2634
value: {{ .Values.registry.repository }}/mongodb-enterprise-database:{{ .Values.operator.version }}
2735
- name: IMAGE_PULL_POLICY

helm_chart/templates/roles.yaml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
2-
kind: ClusterRole
2+
kind: Role
33
apiVersion: rbac.authorization.k8s.io/v1
44
metadata:
55
name: {{ .Values.operator.name }}
6+
namespace: {{ .Values.namespace }}
67
rules:
78
- apiGroups:
89
- ""
@@ -21,16 +22,6 @@ rules:
2122
resources:
2223
- statefulsets
2324
verbs: ["*"]
24-
- apiGroups:
25-
- apiextensions.k8s.io
26-
resources:
27-
- customresourcedefinitions
28-
verbs:
29-
- get
30-
- list
31-
- watch
32-
- create
33-
- delete
3425
- apiGroups:
3526
- mongodb.com
3627
resources:
@@ -39,14 +30,14 @@ rules:
3930
- "*"
4031

4132
---
42-
kind: ClusterRoleBinding
33+
kind: RoleBinding
4334
apiVersion: rbac.authorization.k8s.io/v1
4435
metadata:
4536
name: {{ .Values.operator.name }}
4637
namespace: {{ .Values.namespace }}
4738
roleRef:
4839
apiGroup: rbac.authorization.k8s.io
49-
kind: ClusterRole
40+
kind: Role
5041
name: {{ .Values.operator.name }}
5142
subjects:
5243
- kind: ServiceAccount

0 commit comments

Comments
 (0)