Skip to content

Commit a4fb535

Browse files
authored
CLOUDP-126494: Rename cluster to deployment in the code (#556)
* Change the name to "Deployment" in the code * Support any order of secrets in BD user test
1 parent ec4c4d3 commit a4fb535

File tree

67 files changed

+1316
-1316
lines changed

Some content is hidden

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

67 files changed

+1316
-1316
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The full documentation for the Operator can be found [here](https://docs.atlas.m
1717
kubectl apply -f https://raw.githubusercontent.com/mongodb/mongodb-atlas-kubernetes/main/deploy/all-in-one.yaml
1818
```
1919

20-
### Step 2. Create Atlas Cluster
20+
### Step 2. Create Atlas Deployment
2121

2222
**1.** Create an Atlas API Key Secret
2323

@@ -39,7 +39,7 @@ kubectl label secret mongodb-atlas-operator-api-key atlas.mongodb.com/type=crede
3939
**2.** Create an `AtlasProject` Custom Resource
4040

4141
The `AtlasProject` CustomResource represents Atlas Projects in our Kubernetes cluster. You need to specify
42-
`projectIpAccessList` with the IP addresses or CIDR blocks of any hosts that will connect to the Atlas Cluster.
42+
`projectIpAccessList` with the IP addresses or CIDR blocks of any hosts that will connect to the Atlas Deployment.
4343

4444
```
4545
cat <<EOF | kubectl apply -f -
@@ -59,7 +59,7 @@ EOF
5959

6060
**3.** Create an `AtlasDeployment` Custom Resource.
6161

62-
The example below is a minimal configuration to create an M10 Atlas cluster in the AWS US East region. For a full list
62+
The example below is a minimal configuration to create an M10 Atlas deployment in the AWS US East region. For a full list
6363
of properties, check
6464
`atlasdeployments.atlas.mongodb.com` [CRD specification](config/crd/bases/atlas.mongodb.com_atlasdeployments.yaml)):
6565

@@ -68,12 +68,12 @@ cat <<EOF | kubectl apply -f -
6868
apiVersion: atlas.mongodb.com/v1
6969
kind: AtlasDeployment
7070
metadata:
71-
name: my-atlas-cluster
71+
name: my-atlas-deployment
7272
spec:
7373
projectRef:
7474
name: my-project
75-
clusterSpec:
76-
name: "Test-cluster"
75+
deploymentSpec:
76+
name: Test Deployment
7777
providerSettings:
7878
instanceSizeName: M10
7979
providerName: AWS
@@ -93,7 +93,7 @@ kubectl label secret the-user-password atlas.mongodb.com/type=credentials
9393

9494
**5.** Create an `AtlasDatabaseUser` Custom Resource
9595

96-
In order to connect to an Atlas Cluster the database user needs to be created. `AtlasDatabaseUser` resource should
96+
In order to connect to an Atlas Deployment the database user needs to be created. `AtlasDatabaseUser` resource should
9797
reference the password Kubernetes Secret created in the previous step.
9898

9999
```
@@ -116,29 +116,29 @@ EOF
116116

117117
**6.** Wait for the `AtlasDatabaseUser` Custom Resource to be ready
118118

119-
Wait until the AtlasDatabaseUser resource gets to "ready" status (it will wait until the cluster is created that may
119+
Wait until the AtlasDatabaseUser resource gets to "ready" status (it will wait until the deployment is created that may
120120
take around 10 minutes):
121121

122122
```
123123
kubectl get atlasdatabaseusers my-database-user -o=jsonpath='{.status.conditions[?(@.type=="Ready")].status}'
124124
True
125125
```
126126

127-
### Step 3. Connect your application to the Atlas Cluster
127+
### Step 3. Connect your application to the Atlas Deployment
128128

129-
The Atlas Operator will create a Kubernetes Secret with the information necessary to connect to the Atlas Cluster
129+
The Atlas Operator will create a Kubernetes Secret with the information necessary to connect to the Atlas Deployment
130130
created in the previous step. An application in the same Kubernetes Cluster can mount and use the Secret:
131131

132132
```
133133
...
134134
containers:
135-
- name: test-app
136-
env:
137-
- name: "CONNECTION_STRING"
138-
valueFrom:
139-
secretKeyRef:
140-
name: test-atlas-operator-project-test-cluster-theuser
141-
key: connectionStringStandardSrv
135+
- name: test-app
136+
env:
137+
- name: "CONNECTION_STRING"
138+
valueFrom:
139+
secretKeyRef:
140+
name: test-atlas-operator-project-test-cluster-theuser
141+
key: connectionStringStandardSrv
142142
143143
```
144144

cmd/post-install/main.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func setupLogger() *zap.SugaredLogger {
3232
return log.Sugar()
3333
}
3434

35-
// createK8sClient creates an in cluster client which can be used to fetch the current state of the AtlasDeployment
35+
// createK8sClient creates a client which can be used to fetch the current state of the AtlasDeployment
3636
// resource.
3737
func createK8sClient() (client.Client, error) {
3838
restCfg, err := rest.InClusterConfig()
@@ -50,9 +50,9 @@ func createK8sClient() (client.Client, error) {
5050
return k8sClient, nil
5151
}
5252

53-
// isClusterReady returns a boolean indicating if the cluster has reached the ready state and is
53+
// isDeploymentReady returns a boolean indicating if the deployment has reached the ready state and is
5454
// ready to be used.
55-
func isClusterReady(logger *zap.SugaredLogger) (bool, error) {
55+
func isDeploymentReady(logger *zap.SugaredLogger) (bool, error) {
5656
k8sClient, err := createK8sClient()
5757
if err != nil {
5858
return false, err
@@ -61,7 +61,7 @@ func isClusterReady(logger *zap.SugaredLogger) (bool, error) {
6161
ticker := time.NewTicker(pollingInterval)
6262
defer ticker.Stop()
6363

64-
clusterName := os.Getenv("CLUSTER_NAME")
64+
deploymentName := os.Getenv("DEPLOYMENT_NAME")
6565
namespace := os.Getenv("NAMESPACE")
6666

6767
totalTime := time.Duration(0)
@@ -71,18 +71,18 @@ func isClusterReady(logger *zap.SugaredLogger) (bool, error) {
7171
}
7272
totalTime += pollingInterval
7373

74-
atlasCluster := mdbv1.AtlasDeployment{}
75-
if err := k8sClient.Get(context.TODO(), kube.ObjectKey(namespace, clusterName), &atlasCluster); err != nil {
74+
atlasDeployment := mdbv1.AtlasDeployment{}
75+
if err := k8sClient.Get(context.TODO(), kube.ObjectKey(namespace, deploymentName), &atlasDeployment); err != nil {
7676
return false, err
7777
}
7878

79-
// the atlas project has reached the ClusterReady state.
80-
for _, cond := range atlasCluster.Status.Conditions {
81-
if cond.Type == status.ClusterReadyType {
79+
// the atlas project has reached the DeploymentReady state.
80+
for _, cond := range atlasDeployment.Status.Conditions {
81+
if cond.Type == status.DeploymentReadyType {
8282
if cond.Status == corev1.ConditionTrue {
8383
return true, nil
8484
}
85-
logger.Infof("Atlas Cluster %s is not yet ready", atlasCluster.Name)
85+
logger.Infof("Atlas Deployment %s is not yet ready", atlasDeployment.Name)
8686
}
8787
}
8888
}
@@ -92,14 +92,14 @@ func isClusterReady(logger *zap.SugaredLogger) (bool, error) {
9292
func main() {
9393
logger := setupLogger()
9494

95-
clusterIsReady, err := isClusterReady(logger)
95+
deploymentIsReady, err := isDeploymentReady(logger)
9696
if err != nil {
9797
logger.Error(err)
9898
os.Exit(1)
9999
}
100100

101101
exitCode := 1
102-
if clusterIsReady {
102+
if deploymentIsReady {
103103
exitCode = 0
104104
}
105105
os.Exit(exitCode)

0 commit comments

Comments
 (0)