Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove plaintext secret option #73

Merged
merged 8 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions deploy/crds/operator.ibm.com_mongodbs_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,10 @@ spec:
tag:
type: string
type: object
mongoDBPass:
type: string
mongoDBUser:
type: string
replicas:
type: integer
storageClass:
type: string
required:
- mongoDBPass
- mongoDBUser
type: object
status:
description: MongoDBStatus defines the observed state of MongoDB
Expand Down
2 changes: 0 additions & 2 deletions deploy/crds/operator.ibm.com_v1alpha1_mongodb_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ spec:
tag: 4.0.12-build.3
metricsImage:
tag: 3.4.0
mongoDBUser: ChangeMeAdmin
mongoDBPass: ChangeMePass
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ metadata:
"metricsImage": {
"tag": "3.4.0"
},
"mongoDBPass": "ChangeMePass",
"mongoDBUser": "ChangeMeAdmin",
"replicas": 3
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,10 @@ spec:
tag:
type: string
type: object
mongoDBPass:
type: string
mongoDBUser:
type: string
replicas:
type: integer
storageClass:
type: string
required:
- mongoDBPass
- mongoDBUser
type: object
status:
description: MongoDBStatus defines the observed state of MongoDB
Expand Down
2 changes: 0 additions & 2 deletions pkg/apis/operator/v1alpha1/mongodb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ type MongoDBSpec struct {
ImageRegistry string `json:"imageRegistry,omitempty"`
Replicas int `json:"replicas,omitempty"`
StorageClass string `json:"storageClass,omitempty"`
MongoDBUser string `json:"mongoDBUser"`
MongoDBPass string `json:"mongoDBPass"`
InitImage Image `json:"initImage,omitempty"`
BootstrapImage Image `json:"bootstrapImage,omitempty"`
MetricsImage Image `json:"metricsImage,omitempty"`
Expand Down
16 changes: 4 additions & 12 deletions pkg/controller/mongodb/mongodb_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,11 @@ func (r *ReconcileMongoDB) Reconcile(request reconcile.Request) (reconcile.Resul
return reconcile.Result{}, err
}

// Create admin user and password as random string
// TODO: allow user to give a Secret
var pass, user string
if instance.Spec.MongoDBPass == "" {
pass = createRandomAlphaNumeric(13)
} else {
pass = instance.Spec.MongoDBPass
}

if instance.Spec.MongoDBUser == "" {
user = createRandomAlphaNumeric(8)
} else {
user = instance.Spec.MongoDBUser
}

user = createRandomAlphaNumeric(8)
pass = createRandomAlphaNumeric(13)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how to make this consist during the mongodb operator restart?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenzhiwei the deployment supports changing the admin password on restarts, so it's ok for the admin secret to change

mongodbAdmin := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down