adding-conditionals
This commit is contained in:
parent
a9a8ee27ea
commit
a562d7a405
|
|
@ -66,10 +66,13 @@ func (r *MongoDBReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
|
|||
return ctrl.Result{RequeueAfter: time.Second * 10}, err
|
||||
}
|
||||
|
||||
if !k8sgo.CheckSecretExist(instance.Namespace, fmt.Sprintf("%s-%s", instance.ObjectMeta.Name, "standalone-monitoring")) {
|
||||
err = k8sgo.CreateMongoMonitoringSecret(instance)
|
||||
if err != nil {
|
||||
return ctrl.Result{RequeueAfter: time.Second * 10}, err
|
||||
if instance.Spec.MongoDBMonitoring != nil {
|
||||
|
||||
if !k8sgo.CheckSecretExist(instance.Namespace, fmt.Sprintf("%s-%s", instance.ObjectMeta.Name, "standalone-monitoring")) {
|
||||
err = k8sgo.CreateMongoMonitoringSecret(instance)
|
||||
if err != nil {
|
||||
return ctrl.Result{RequeueAfter: time.Second * 10}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -83,21 +86,24 @@ func (r *MongoDBReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
|
|||
if err != nil {
|
||||
return ctrl.Result{RequeueAfter: time.Second * 10}, err
|
||||
}
|
||||
// mongoDBSTS, err := k8sgo.GetStateFulSet(instance.Namespace, fmt.Sprintf("%s-%s", instance.ObjectMeta.Name, "standalone"))
|
||||
// if err != nil {
|
||||
// return ctrl.Result{RequeueAfter: time.Second * 10}, err
|
||||
// }
|
||||
// fmt.Print(mongoDBSTS)
|
||||
// if int(mongoDBSTS.Status.ReadyReplicas) != int(1) {
|
||||
// return ctrl.Result{RequeueAfter: time.Second * 60}, nil
|
||||
// } else {
|
||||
// if !k8sgo.CheckMonitoringUser(instance) {
|
||||
// err = k8sgo.CreateMongoDBMonitoringUser(instance)
|
||||
// if err != nil {
|
||||
// return ctrl.Result{RequeueAfter: time.Second * 10}, err
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if instance.Spec.MongoDBMonitoring != nil {
|
||||
mongoDBSTS, err := k8sgo.GetStateFulSet(instance.Namespace, fmt.Sprintf("%s-%s", instance.ObjectMeta.Name, "standalone"))
|
||||
if err != nil {
|
||||
return ctrl.Result{RequeueAfter: time.Second * 10}, err
|
||||
}
|
||||
fmt.Print(mongoDBSTS)
|
||||
if int(mongoDBSTS.Status.ReadyReplicas) != int(1) {
|
||||
return ctrl.Result{RequeueAfter: time.Second * 60}, nil
|
||||
} else {
|
||||
if !k8sgo.CheckMonitoringUser(instance) {
|
||||
err = k8sgo.CreateMongoDBMonitoringUser(instance)
|
||||
if err != nil {
|
||||
return ctrl.Result{RequeueAfter: time.Second * 10}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ctrl.Result{RequeueAfter: time.Second * 10}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
apiVersion: opstreelabs.in/v1alpha1
|
||||
kind: MongoDBCluster
|
||||
|
||||
metadata:
|
||||
name: mongodb
|
||||
spec:
|
||||
|
|
@ -18,7 +19,7 @@ spec:
|
|||
storage:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
storageSize: 1Gi
|
||||
storageClass: csi-cephfs-sc
|
||||
storageClass: civo-volume
|
||||
mongoDBSecurity:
|
||||
mongoDBAdminUser: admin
|
||||
secretRef:
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ metadata:
|
|||
spec:
|
||||
kubernetesConfig:
|
||||
|
||||
image: quay.io/opstree/mongo:v5.0.6
|
||||
image: quay.io/opstree/mongo:v5.0.6
|
||||
imagePullPolicy: IfNotPresent
|
||||
nodeSelector: {}
|
||||
# affinity: {}
|
||||
|
|
@ -44,7 +44,7 @@ spec:
|
|||
resources:
|
||||
requests:
|
||||
cpu: 101m
|
||||
memory: 328Mi
|
||||
memory: 328Mi
|
||||
limits:
|
||||
cpu: 101m
|
||||
memory: 328Mi
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ func getVolumeMount(name string, persistenceEnabled *bool, additionalConfig *str
|
|||
volumeMounts = []corev1.VolumeMount{
|
||||
{
|
||||
Name: name,
|
||||
MountPath: "/data/db",
|
||||
MountPath: "/data/db",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
opstreelabsinv1alpha1 "mongodb-operator/api/v1alpha1"
|
||||
|
||||
"github.com/thanhpk/randstr"
|
||||
"github.com/thanhpk/randstr"
|
||||
)
|
||||
|
||||
// CreateMongoStandaloneService is a method to create standalone service for MongoDB
|
||||
|
|
|
|||
Loading…
Reference in New Issue