Skip to content

Commit e79f95e

Browse files
authored
CLOUDP-78859: Rename Community CRD (#294)
* CLOUDP-78859: Rename Community CRD * Fix operator crash and test failures * Fix black formatting * Rename crs and fix docs * Fix missing mongodbcommunity_crd * Fix black formatting * Fix black formatting, the sequel
1 parent 7c55d29 commit e79f95e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+205
-205
lines changed

deploy/crds/arbitrary_statefulset_configuration/mongodb.com_v1_custom_volume_cr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: mongodb.com/v1
2-
kind: MongoDB
2+
kind: MongoDBCommunity
33
metadata:
44
name: example-mongodb
55
spec:

deploy/crds/mongodb.com_mongodb_crd.yaml renamed to deploy/crds/mongodb.com_mongodbcommunity_crd.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: apiextensions.k8s.io/v1beta1
22
kind: CustomResourceDefinition
33
metadata:
4-
name: mongodb.mongodb.com
4+
name: mongodbcommunity.mongodb.com
55
spec:
66
additionalPrinterColumns:
77
- JSONPath: .status.phase
@@ -14,18 +14,18 @@ spec:
1414
type: string
1515
group: mongodb.com
1616
names:
17-
kind: MongoDB
18-
listKind: MongoDBList
19-
plural: mongodb
17+
kind: MongoDBCommunity
18+
listKind: MongoDBCommunityList
19+
plural: mongodbcommunity
2020
shortNames:
21-
- mdb
22-
singular: mongodb
21+
- mdbc
22+
singular: mongodbcommunity
2323
scope: Namespaced
2424
subresources:
2525
status: {}
2626
validation:
2727
openAPIV3Schema:
28-
description: MongoDB is the Schema for the mongodbs API
28+
description: MongoDBCommunity is the Schema for the mongodbs API
2929
properties:
3030
apiVersion:
3131
description: 'APIVersion defines the versioned schema of this representation
@@ -40,7 +40,7 @@ spec:
4040
metadata:
4141
type: object
4242
spec:
43-
description: MongoDBSpec defines the desired state of MongoDB
43+
description: MongoDBCommunitySpec defines the desired state of MongoDB
4444
properties:
4545
featureCompatibilityVersion:
4646
description: FeatureCompatibilityVersion configures the feature compatibility
@@ -278,7 +278,7 @@ spec:
278278
- version
279279
type: object
280280
status:
281-
description: MongoDBStatus defines the observed state of MongoDB
281+
description: MongoDBCommunityStatus defines the observed state of MongoDB
282282
properties:
283283
currentMongoDBMembers:
284284
type: integer

deploy/crds/mongodb.com_v1_mongodb_cr.yaml renamed to deploy/crds/mongodb.com_v1_mongodbcommunity_cr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
apiVersion: mongodb.com/v1
3-
kind: MongoDB
3+
kind: MongoDBCommunity
44
metadata:
55
name: example-mongodb
66
spec:

deploy/crds/mongodb.com_v1_mongodb_custom_role.yaml renamed to deploy/crds/mongodb.com_v1_mongodbcommunity_custom_role.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
apiVersion: mongodb.com/v1
3-
kind: MongoDB
3+
kind: MongoDBCommunity
44
metadata:
55
name: custom-role-mongodb
66
spec:

deploy/crds/mongodb.com_v1_mongodb_openshift_cr.yaml renamed to deploy/crds/mongodb.com_v1_mongodbcommunity_openshift_cr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
apiVersion: mongodb.com/v1
3-
kind: MongoDB
3+
kind: MongoDBCommunity
44
metadata:
55
name: example-openshift-mongodb
66
spec:

deploy/crds/mongodb.com_v1_mongodb_tls_cr.yaml renamed to deploy/crds/mongodb.com_v1_mongodbcommunity_tls_cr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
apiVersion: mongodb.com/v1
3-
kind: MongoDB
3+
kind: MongoDBCommunity
44
metadata:
55
name: example-mongodb
66
spec:

deploy/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33
resources:
4-
- ./crds/mongodb.com_mongodb_crd.yaml
4+
- ./crds/mongodb.com_mongodbcommunity_crd.yaml
55
- ./operator/service_account.yaml
66
- ./operator/role.yaml
77
- ./operator/role_binding.yaml

docs/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ You create and update MongoDB resources by defining a MongoDB resource definitio
2828
- `automation-config` which is mounted from the previously generated ConfigMap to both the server and agent. Only lives as long as the pod.
2929
- `healthstatus` which contains the agent's current status. This is shared with the `mongod` container where it's used by the pre-stop hook. Only lives as long as the pod.
3030

31-
1. Initiates the MongoDB Agent, which in turn creates the database configuration and launches the `mongod` process according to your [MongoDB resource definition](../deploy/crds/mongodb.com_v1_mongodb_cr.yaml).
31+
1. Initiates the MongoDB Agent, which in turn creates the database configuration and launches the `mongod` process according to your [MongoDB resource definition](../deploy/crds/mongodb.com_v1_mongodbcommunity_cr.yaml).
3232

3333
<!--
3434
<img src="" alt="Architecure diagram of the MongoDB Community Kubernetes Operator">

docs/deploy-configure.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To deploy your first replica set:
1717

1818
1. Invoke the following `kubectl` command:
1919
```
20-
kubectl apply -f deploy/crds/mongodb.com_v1_mongodb_cr.yaml --namespace <my-namespace>
20+
kubectl apply -f deploy/crds/mongodb.com_v1_mongodbcommunity_cr.yaml --namespace <my-namespace>
2121
```
2222
2. Verify that the MongoDB resource deployed:
2323
```
@@ -129,7 +129,7 @@ To upgrade this resource from `4.0.6` to `4.2.7`:
129129

130130
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.
131131

132-
See [here](../deploy/crds/mongodb.com_v1_mongodb_openshift_cr.yaml) for
132+
See [here](../deploy/crds/mongodb.com_v1_mongodbcommunity_openshift_cr.yaml) for
133133
an example of how to provide the required configuration for a MongoDB
134134
replica set.
135135

docs/install-upgrade.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ To install the MongoDB Community Kubernetes Operator:
3232

3333
a. Invoke the following `kubectl` command:
3434
```
35-
kubectl create -f deploy/crds/mongodb.com_mongodb_crd.yaml
35+
kubectl create -f deploy/crds/mongodb.com_mongodbcommunity_crd.yaml
3636
```
3737
b. Verify that the Custom Resource Definitions installed successfully:
3838
```
39-
kubectl get crd/mongodb.mongodb.com
39+
kubectl get crd/mongodbcommunity.mongodb.com
4040
```
4141
3. Install the Operator.
4242
@@ -56,5 +56,5 @@ To upgrade the MongoDB Community Kubernetes Operator:
5656
1. Change to the directory in which you cloned the repository.
5757
2. Invoke the following `kubectl` command to upgrade the [Custom Resource Definitions](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/).
5858
```
59-
kubectl apply -f deploy/crds/mongodb.com_mongodb_crd.yaml
59+
kubectl apply -f deploy/crds/mongodb.com_mongodbcommunity_crd.yaml
6060
```

pkg/apis/mongodb/v1/mongodb_types.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const (
3535
defaultPasswordKey = "password"
3636
)
3737

38-
// MongoDBSpec defines the desired state of MongoDB
39-
type MongoDBSpec struct {
38+
// MongoDBCommunitySpec defines the desired state of MongoDB
39+
type MongoDBCommunitySpec struct {
4040
// Members is the number of members in the replica set
4141
// +optional
4242
Members int `json:"members"`
@@ -314,8 +314,8 @@ type Authentication struct {
314314
// +kubebuilder:validation:Enum=SCRAM
315315
type AuthMode string
316316

317-
// MongoDBStatus defines the observed state of MongoDB
318-
type MongoDBStatus struct {
317+
// MongoDBCommunityStatus defines the observed state of MongoDB
318+
type MongoDBCommunityStatus struct {
319319
MongoURI string `json:"mongoUri"`
320320
Phase Phase `json:"phase"`
321321

@@ -327,20 +327,20 @@ type MongoDBStatus struct {
327327

328328
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
329329

330-
// MongoDB is the Schema for the mongodbs API
330+
// MongoDBCommunity is the Schema for the mongodbs API
331331
// +kubebuilder:subresource:status
332-
// +kubebuilder:resource:path=mongodb,scope=Namespaced,shortName=mdb
332+
// +kubebuilder:resource:path=mongodbcommunity,scope=Namespaced,shortName=mdbc,singular=mongodbcommunity
333333
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase",description="Current state of the MongoDB deployment"
334334
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".status.version",description="Version of MongoDB server"
335-
type MongoDB struct {
335+
type MongoDBCommunity struct {
336336
metav1.TypeMeta `json:",inline"`
337337
metav1.ObjectMeta `json:"metadata,omitempty"`
338338

339-
Spec MongoDBSpec `json:"spec,omitempty"`
340-
Status MongoDBStatus `json:"status,omitempty"`
339+
Spec MongoDBCommunitySpec `json:"spec,omitempty"`
340+
Status MongoDBCommunityStatus `json:"status,omitempty"`
341341
}
342342

343-
func (m MongoDB) AutomationConfigMembersThisReconciliation() int {
343+
func (m MongoDBCommunity) AutomationConfigMembersThisReconciliation() int {
344344
// determine the correct number of automation config replica set members
345345
// based on our desired number, and our current number
346346
return scale.ReplicasThisReconciliation(automationConfigReplicasScaler{
@@ -350,7 +350,7 @@ func (m MongoDB) AutomationConfigMembersThisReconciliation() int {
350350
}
351351

352352
// MongoURI returns a mongo uri which can be used to connect to this deployment
353-
func (m MongoDB) MongoURI() string {
353+
func (m MongoDBCommunity) MongoURI() string {
354354
members := make([]string, m.Spec.Members)
355355
clusterDomain := "svc.cluster.local" // TODO: make this configurable
356356
for i := 0; i < m.Spec.Members; i++ {
@@ -359,7 +359,7 @@ func (m MongoDB) MongoURI() string {
359359
return fmt.Sprintf("mongodb://%s", strings.Join(members, ","))
360360
}
361361

362-
func (m MongoDB) Hosts() []string {
362+
func (m MongoDBCommunity) Hosts() []string {
363363
hosts := make([]string, m.Spec.Members)
364364
clusterDomain := "svc.cluster.local" // TODO: make this configurable
365365
for i := 0; i < m.Spec.Members; i++ {
@@ -370,42 +370,42 @@ func (m MongoDB) Hosts() []string {
370370

371371
// ServiceName returns the name of the Service that should be created for
372372
// this resource
373-
func (m MongoDB) ServiceName() string {
373+
func (m MongoDBCommunity) ServiceName() string {
374374
return m.Name + "-svc"
375375
}
376376

377-
func (m MongoDB) AutomationConfigSecretName() string {
377+
func (m MongoDBCommunity) AutomationConfigSecretName() string {
378378
return m.Name + "-config"
379379
}
380380

381381
// TLSConfigMapNamespacedName will get the namespaced name of the ConfigMap containing the CA certificate
382382
// As the ConfigMap will be mounted to our pods, it has to be in the same namespace as the MongoDB resource
383-
func (m MongoDB) TLSConfigMapNamespacedName() types.NamespacedName {
383+
func (m MongoDBCommunity) TLSConfigMapNamespacedName() types.NamespacedName {
384384
return types.NamespacedName{Name: m.Spec.Security.TLS.CaConfigMap.Name, Namespace: m.Namespace}
385385
}
386386

387387
// TLSSecretNamespacedName will get the namespaced name of the Secret containing the server certificate and key
388-
func (m MongoDB) TLSSecretNamespacedName() types.NamespacedName {
388+
func (m MongoDBCommunity) TLSSecretNamespacedName() types.NamespacedName {
389389
return types.NamespacedName{Name: m.Spec.Security.TLS.CertificateKeySecret.Name, Namespace: m.Namespace}
390390
}
391391

392392
// TLSOperatorSecretNamespacedName will get the namespaced name of the Secret created by the operator
393393
// containing the combined certificate and key.
394-
func (m MongoDB) TLSOperatorSecretNamespacedName() types.NamespacedName {
394+
func (m MongoDBCommunity) TLSOperatorSecretNamespacedName() types.NamespacedName {
395395
return types.NamespacedName{Name: m.Name + "-server-certificate-key", Namespace: m.Namespace}
396396
}
397397

398-
func (m MongoDB) NamespacedName() types.NamespacedName {
398+
func (m MongoDBCommunity) NamespacedName() types.NamespacedName {
399399
return types.NamespacedName{Name: m.Name, Namespace: m.Namespace}
400400
}
401401

402-
func (m *MongoDB) ScramCredentialsNamespacedName() types.NamespacedName {
402+
func (m *MongoDBCommunity) ScramCredentialsNamespacedName() types.NamespacedName {
403403
return types.NamespacedName{Name: fmt.Sprintf("%s-agent-scram-credentials", m.Name), Namespace: m.Namespace}
404404
}
405405

406406
// GetFCV returns the feature compatibility version. If no FeatureCompatibilityVersion is specified.
407407
// It uses the major and minor version for whichever version of MongoDB is configured.
408-
func (m MongoDB) GetFCV() string {
408+
func (m MongoDBCommunity) GetFCV() string {
409409
versionToSplit := m.Spec.FeatureCompatibilityVersion
410410
if versionToSplit == "" {
411411
versionToSplit = m.Spec.Version
@@ -415,15 +415,15 @@ func (m MongoDB) GetFCV() string {
415415
return strings.Join(parts[:minorIndex+1], ".")
416416
}
417417

418-
func (m MongoDB) DesiredReplicas() int {
418+
func (m MongoDBCommunity) DesiredReplicas() int {
419419
return m.Spec.Members
420420
}
421421

422-
func (m MongoDB) CurrentReplicas() int {
422+
func (m MongoDBCommunity) CurrentReplicas() int {
423423
return m.Status.CurrentStatefulSetReplicas
424424
}
425425

426-
func (m *MongoDB) StatefulSetReplicasThisReconciliation() int {
426+
func (m *MongoDBCommunity) StatefulSetReplicasThisReconciliation() int {
427427
return scale.ReplicasThisReconciliation(m)
428428
}
429429

@@ -441,13 +441,13 @@ func (a automationConfigReplicasScaler) CurrentReplicas() int {
441441

442442
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
443443

444-
// MongoDBList contains a list of MongoDB
445-
type MongoDBList struct {
444+
// MongoDBCommunityList contains a list of MongoDB
445+
type MongoDBCommunityList struct {
446446
metav1.TypeMeta `json:",inline"`
447447
metav1.ListMeta `json:"metadata,omitempty"`
448-
Items []MongoDB `json:"items"`
448+
Items []MongoDBCommunity `json:"items"`
449449
}
450450

451451
func init() {
452-
SchemeBuilder.Register(&MongoDB{}, &MongoDBList{})
452+
SchemeBuilder.Register(&MongoDBCommunity{}, &MongoDBCommunityList{})
453453
}

pkg/apis/mongodb/v1/mongodb_types_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ func TestGetScramCredentialsSecretName(t *testing.T) {
9797

9898
}
9999

100-
func newReplicaSet(members int, name, namespace string) MongoDB {
101-
return MongoDB{
100+
func newReplicaSet(members int, name, namespace string) MongoDBCommunity {
101+
return MongoDBCommunity{
102102
TypeMeta: metav1.TypeMeta{},
103103
ObjectMeta: metav1.ObjectMeta{
104104
Name: name,
105105
Namespace: namespace,
106106
},
107-
Spec: MongoDBSpec{
107+
Spec: MongoDBCommunitySpec{
108108
Members: members,
109109
},
110110
}

0 commit comments

Comments
 (0)