diff --git a/api/bases/octavia.openstack.org_octaviaamphoracontrollers.yaml b/api/bases/octavia.openstack.org_octaviaamphoracontrollers.yaml index 6a8e5d8d..3d3c5ef7 100644 --- a/api/bases/octavia.openstack.org_octaviaamphoracontrollers.yaml +++ b/api/bases/octavia.openstack.org_octaviaamphoracontrollers.yaml @@ -138,6 +138,11 @@ spec: from the Secret type: string type: object + redisHostIPs: + description: List of Redis Host IP addresses + items: + type: string + type: array resources: description: Resources - Compute Resources required by this service (Limits/Requests). https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ diff --git a/api/bases/octavia.openstack.org_octavias.yaml b/api/bases/octavia.openstack.org_octavias.yaml index 9f9ca882..5be32bb9 100644 --- a/api/bases/octavia.openstack.org_octavias.yaml +++ b/api/bases/octavia.openstack.org_octavias.yaml @@ -523,6 +523,11 @@ spec: from the Secret type: string type: object + redisHostIPs: + description: List of Redis Host IP addresses + items: + type: string + type: array resources: description: Resources - Compute Resources required by this service (Limits/Requests). https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ @@ -708,6 +713,11 @@ spec: from the Secret type: string type: object + redisHostIPs: + description: List of Redis Host IP addresses + items: + type: string + type: array resources: description: Resources - Compute Resources required by this service (Limits/Requests). https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ @@ -893,6 +903,11 @@ spec: from the Secret type: string type: object + redisHostIPs: + description: List of Redis Host IP addresses + items: + type: string + type: array resources: description: Resources - Compute Resources required by this service (Limits/Requests). https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ @@ -1106,6 +1121,11 @@ spec: description: ReadyCount of octavia Housekeeping instances format: int32 type: integer + redisHostIPs: + description: List of Redis Host IP addresses + items: + type: string + type: array transportURLSecret: description: TransportURLSecret - Secret containing RabbitMQ transportURL type: string diff --git a/api/v1beta1/amphoracontroller_types.go b/api/v1beta1/amphoracontroller_types.go index ec17c306..3fd994ae 100644 --- a/api/v1beta1/amphoracontroller_types.go +++ b/api/v1beta1/amphoracontroller_types.go @@ -134,6 +134,10 @@ type OctaviaAmphoraControllerSpec struct { // +kubebuilder:validation:Optional // +kubebuilder:default={manageLbMgmtNetworks: true, subnetIpVersion: 4} LbMgmtNetworks OctaviaLbMgmtNetworks `json:"lbMgmtNetwork"` + + // +kubebuilder:validation:Optional + // List of Redis Host IP addresses + RedisHostIPs []string `json:"redisHostIPs,omitempty"` } // OctaviaAmphoraControllerStatus defines the observed state of the Octavia Amphora Controller diff --git a/api/v1beta1/octavia_types.go b/api/v1beta1/octavia_types.go index a6f0690a..6ff833f3 100644 --- a/api/v1beta1/octavia_types.go +++ b/api/v1beta1/octavia_types.go @@ -186,6 +186,9 @@ type OctaviaStatus struct { // ReadyCount of octavia HealthManager instances OctaviaHealthManagerReadyCount int32 `json:"healthmanagerreadyCount,omitempty"` + + // List of Redis Host IP addresses + RedisHostIPs []string `json:"redisHostIPs,omitempty"` } //+kubebuilder:object:root=true diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index c1fd657c..bfab2f75 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -305,6 +305,11 @@ func (in *OctaviaAmphoraControllerSpec) DeepCopyInto(out *OctaviaAmphoraControll copy(*out, *in) } out.LbMgmtNetworks = in.LbMgmtNetworks + if in.RedisHostIPs != nil { + in, out := &in.RedisHostIPs, &out.RedisHostIPs + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OctaviaAmphoraControllerSpec. @@ -475,6 +480,11 @@ func (in *OctaviaStatus) DeepCopyInto(out *OctaviaStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.RedisHostIPs != nil { + in, out := &in.RedisHostIPs, &out.RedisHostIPs + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OctaviaStatus. diff --git a/config/crd/bases/octavia.openstack.org_octaviaamphoracontrollers.yaml b/config/crd/bases/octavia.openstack.org_octaviaamphoracontrollers.yaml index 6a8e5d8d..3d3c5ef7 100644 --- a/config/crd/bases/octavia.openstack.org_octaviaamphoracontrollers.yaml +++ b/config/crd/bases/octavia.openstack.org_octaviaamphoracontrollers.yaml @@ -138,6 +138,11 @@ spec: from the Secret type: string type: object + redisHostIPs: + description: List of Redis Host IP addresses + items: + type: string + type: array resources: description: Resources - Compute Resources required by this service (Limits/Requests). https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ diff --git a/config/crd/bases/octavia.openstack.org_octavias.yaml b/config/crd/bases/octavia.openstack.org_octavias.yaml index 9f9ca882..5be32bb9 100644 --- a/config/crd/bases/octavia.openstack.org_octavias.yaml +++ b/config/crd/bases/octavia.openstack.org_octavias.yaml @@ -523,6 +523,11 @@ spec: from the Secret type: string type: object + redisHostIPs: + description: List of Redis Host IP addresses + items: + type: string + type: array resources: description: Resources - Compute Resources required by this service (Limits/Requests). https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ @@ -708,6 +713,11 @@ spec: from the Secret type: string type: object + redisHostIPs: + description: List of Redis Host IP addresses + items: + type: string + type: array resources: description: Resources - Compute Resources required by this service (Limits/Requests). https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ @@ -893,6 +903,11 @@ spec: from the Secret type: string type: object + redisHostIPs: + description: List of Redis Host IP addresses + items: + type: string + type: array resources: description: Resources - Compute Resources required by this service (Limits/Requests). https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ @@ -1106,6 +1121,11 @@ spec: description: ReadyCount of octavia Housekeeping instances format: int32 type: integer + redisHostIPs: + description: List of Redis Host IP addresses + items: + type: string + type: array transportURLSecret: description: TransportURLSecret - Secret containing RabbitMQ transportURL type: string diff --git a/controllers/amphoracontroller_controller.go b/controllers/amphoracontroller_controller.go index 428cc2c4..4ce288a7 100644 --- a/controllers/amphoracontroller_controller.go +++ b/controllers/amphoracontroller_controller.go @@ -19,6 +19,7 @@ package controllers import ( "context" "fmt" + "strings" "time" "github.com/go-logr/logr" @@ -485,6 +486,7 @@ func (r *OctaviaAmphoraControllerReconciler) generateServiceConfigMaps( } // TODO(gthiemonge) store keys/passwords/passphrases in a specific config file stored in a secret templateParameters["HeartbeatKey"] = string(ospSecret.Data["OctaviaHeartbeatKey"]) + templateParameters["JobboardBackendHosts"] = strings.Join(spec.RedisHostIPs[:], ",") // TODO(beagles): populate the template parameters cms := []util.Template{ diff --git a/controllers/octavia_controller.go b/controllers/octavia_controller.go index b3e3a864..366f3c8b 100644 --- a/controllers/octavia_controller.go +++ b/controllers/octavia_controller.go @@ -23,6 +23,7 @@ import ( "github.com/go-logr/logr" rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" + redisv1 "github.com/openstack-k8s-operators/infra-operator/apis/redis/v1beta1" "github.com/openstack-k8s-operators/lib-common/modules/common" "github.com/openstack-k8s-operators/lib-common/modules/common/condition" "github.com/openstack-k8s-operators/lib-common/modules/common/configmap" @@ -202,6 +203,7 @@ func (r *OctaviaReconciler) SetupWithManager(mgr ctrl.Manager) error { Owns(&rbacv1.Role{}). Owns(&rbacv1.RoleBinding{}). Owns(&rabbitmqv1.TransportURL{}). + Owns(&redisv1.Redis{}). Complete(r) } @@ -243,58 +245,78 @@ func (r *OctaviaReconciler) reconcileInit( // // create service DB instance // - db := mariadbv1.NewDatabase( - instance.Name, + octaviaDb := mariadbv1.NewDatabase( + octavia.DatabaseName, instance.Spec.DatabaseUser, instance.Spec.Secret, map[string]string{ "dbName": instance.Spec.DatabaseInstance, }, ) - // create or patch the DB - ctrlResult, err := db.CreateOrPatchDB( - ctx, - helper, + // Using WithNamespace to explicitly set a name that is not "octavia" + // If name is not set, it's set automatically to the name of the service ("octavia"), + // and it triggers a conflict in the mariadbdatabase functions when two DBs + // share the same "name" + persistentDb := mariadbv1.NewDatabaseWithNamespace( + octavia.PersistenceDatabaseName, + instance.Spec.DatabaseUser, + instance.Spec.Secret, + map[string]string{ + "dbName": instance.Spec.DatabaseInstance, + }, + "octavia-persistence", + instance.Namespace, ) - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.DBReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - condition.DBReadyErrorMessage, - err.Error())) - return ctrl.Result{}, err - } - if (ctrlResult != ctrl.Result{}) { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.DBReadyCondition, - condition.RequestedReason, - condition.SeverityInfo, - condition.DBReadyRunningMessage)) - return ctrlResult, nil - } - // wait for the DB to be setup - ctrlResult, err = db.WaitForDBCreated(ctx, helper) - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.DBReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - condition.DBReadyErrorMessage, - err.Error())) - return ctrlResult, err - } - if (ctrlResult != ctrl.Result{}) { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.DBReadyCondition, - condition.RequestedReason, - condition.SeverityInfo, - condition.DBReadyRunningMessage)) - return ctrlResult, nil + dbs := []*mariadbv1.Database{octaviaDb, persistentDb} + + for _, db := range dbs { + // create or patch the DB + ctrlResult, err := db.CreateOrPatchDB( + ctx, + helper, + ) + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.DBReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + condition.DBReadyErrorMessage, + err.Error())) + return ctrl.Result{}, err + } + if (ctrlResult != ctrl.Result{}) { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.DBReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + condition.DBReadyRunningMessage)) + return ctrlResult, nil + } + + // wait for the DB to be setup + ctrlResult, err = db.WaitForDBCreated(ctx, helper) + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.DBReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + condition.DBReadyErrorMessage, + err.Error())) + return ctrlResult, err + } + if (ctrlResult != ctrl.Result{}) { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.DBReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + condition.DBReadyRunningMessage)) + return ctrlResult, nil + } } + // update Status.DatabaseHostname, used to bootstrap/config the service - instance.Status.DatabaseHostname = db.GetDatabaseHostname() + instance.Status.DatabaseHostname = dbs[0].GetDatabaseHostname() instance.Status.Conditions.MarkTrue(condition.DBReadyCondition, condition.DBReadyMessage) // create service DB - end @@ -312,7 +334,7 @@ func (r *OctaviaReconciler) reconcileInit( time.Duration(5)*time.Second, dbSyncHash, ) - ctrlResult, err = dbSyncjob.DoJob( + ctrlResult, err := dbSyncjob.DoJob( ctx, helper, ) @@ -395,6 +417,15 @@ func (r *OctaviaReconciler) reconcileNormal(ctx context.Context, instance *octav // ConfigMap configMapVars := make(map[string]env.Setter) + redis, op, err := r.redisCreateOrUpdate(ctx, instance, helper) + if err != nil { + // TODO(gthiemonge) Set conditions? + return ctrl.Result{}, err + } + if op != controllerutil.OperationResultNone { + Log.Info(fmt.Sprintf("Redis %s successfully reconciled - operation: %s", redis.Name, string(op))) + } + transportURL, op, err := r.transportURLCreateOrUpdate(instance) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( @@ -795,6 +826,54 @@ func (r *OctaviaReconciler) transportURLCreateOrUpdate( return transportURL, op, err } +func getRedisServiceIPs( + ctx context.Context, + instance *octaviav1.Octavia, + helper *helper.Helper, + redis *redisv1.Redis, +) ([]string, error) { + getOptions := metav1.GetOptions{} + service, err := helper.GetKClient().CoreV1().Services(instance.Namespace).Get(ctx, "redis", getOptions) + if err != nil { + return []string{}, err + } + // TODO Ensure that the correct port is exposed + return service.Spec.ClusterIPs, nil +} + +func (r *OctaviaReconciler) redisCreateOrUpdate( + ctx context.Context, + instance *octaviav1.Octavia, + helper *helper.Helper, +) (*redisv1.Redis, controllerutil.OperationResult, error) { + redis := &redisv1.Redis{ + // Use the "global" redis instance. + ObjectMeta: metav1.ObjectMeta{ + Name: "redis", + Namespace: instance.Namespace, + }, + } + + op, err := controllerutil.CreateOrUpdate(context.TODO(), r.Client, redis, func() error { + // We probably don't want to own the redis instance. + //err := controllerutil.SetControllerReference(instance, redis, r.Scheme) + //return err + return nil + }) + if err != nil { + return nil, op, err + } + + hostIPs, err := getRedisServiceIPs(ctx, instance, helper, redis) + if err != nil { + return redis, op, err + } + + instance.Status.RedisHostIPs = hostIPs + + return redis, op, err +} + func (r *OctaviaReconciler) amphoraControllerDaemonSetCreateOrUpdate( instance *octaviav1.Octavia, controllerSpec octaviav1.OctaviaAmphoraControllerSpec, @@ -824,6 +903,7 @@ func (r *OctaviaReconciler) amphoraControllerDaemonSetCreateOrUpdate( daemonset.Spec.LoadBalancerCerts = instance.Spec.LoadBalancerCerts daemonset.Spec.LoadBalancerSSHPrivKey = instance.Spec.LoadBalancerSSHPrivKey daemonset.Spec.LoadBalancerSSHPubKey = instance.Spec.LoadBalancerSSHPubKey + daemonset.Spec.RedisHostIPs = instance.Status.RedisHostIPs if len(daemonset.Spec.NodeSelector) == 0 { daemonset.Spec.NodeSelector = instance.Spec.NodeSelector } diff --git a/main.go b/main.go index d7c1067c..c9973dc2 100644 --- a/main.go +++ b/main.go @@ -42,6 +42,7 @@ import ( networkv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1" + redisv1 "github.com/openstack-k8s-operators/infra-operator/apis/redis/v1beta1" keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1" mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" ovn1beta1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1" @@ -64,6 +65,7 @@ func init() { utilruntime.Must(octaviav1.AddToScheme(scheme)) utilruntime.Must(ovn1beta1.AddToScheme(scheme)) utilruntime.Must(networkv1.AddToScheme(scheme)) + utilruntime.Must(redisv1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } diff --git a/pkg/octavia/const.go b/pkg/octavia/const.go index c6d1fe06..105c7578 100644 --- a/pkg/octavia/const.go +++ b/pkg/octavia/const.go @@ -22,6 +22,8 @@ const ( ServiceType = "load-balancer" // DatabaseName - DatabaseName = "octavia" + // PersistenceDatabaseName - + PersistenceDatabaseName = "octavia_persistence" // OctaviaPublicPort - OctaviaPublicPort int32 = 9876 diff --git a/pkg/octavia/dbsync.go b/pkg/octavia/dbsync.go index 82b8eca1..79039e15 100644 --- a/pkg/octavia/dbsync.go +++ b/pkg/octavia/dbsync.go @@ -81,14 +81,15 @@ func DbSyncJob( } initContainerDetails := APIDetails{ - ContainerImage: instance.Spec.OctaviaAPI.ContainerImage, - DatabaseHost: instance.Status.DatabaseHostname, - DatabaseUser: instance.Spec.DatabaseUser, - DatabaseName: DatabaseName, - OSPSecret: instance.Spec.Secret, - DBPasswordSelector: instance.Spec.PasswordSelectors.Database, - UserPasswordSelector: instance.Spec.PasswordSelectors.Service, - VolumeMounts: initVolumeMounts, + ContainerImage: instance.Spec.OctaviaAPI.ContainerImage, + DatabaseHost: instance.Status.DatabaseHostname, + DatabaseUser: instance.Spec.DatabaseUser, + DatabaseName: DatabaseName, + PersistenceDatabaseName: PersistenceDatabaseName, + OSPSecret: instance.Spec.Secret, + DBPasswordSelector: instance.Spec.PasswordSelectors.Database, + UserPasswordSelector: instance.Spec.PasswordSelectors.Service, + VolumeMounts: initVolumeMounts, } job.Spec.Template.Spec.InitContainers = InitContainer(initContainerDetails) diff --git a/pkg/octavia/initcontainer.go b/pkg/octavia/initcontainer.go index dff67b1c..b83b6439 100644 --- a/pkg/octavia/initcontainer.go +++ b/pkg/octavia/initcontainer.go @@ -23,15 +23,16 @@ import ( // APIDetails information type APIDetails struct { - ContainerImage string - DatabaseHost string - DatabaseUser string - DatabaseName string - TransportURLSecret string - OSPSecret string - DBPasswordSelector string - UserPasswordSelector string - VolumeMounts []corev1.VolumeMount + ContainerImage string + DatabaseHost string + DatabaseUser string + DatabaseName string + PersistenceDatabaseName string + TransportURLSecret string + OSPSecret string + DBPasswordSelector string + UserPasswordSelector string + VolumeMounts []corev1.VolumeMount } const ( diff --git a/templates/octavia/bin/bootstrap.sh b/templates/octavia/bin/bootstrap.sh index d7948cde..ccf446d2 100755 --- a/templates/octavia/bin/bootstrap.sh +++ b/templates/octavia/bin/bootstrap.sh @@ -17,5 +17,6 @@ set -ex OPTS="--config-file /etc/octavia/octavia.conf" octavia-db-manage ${OPTS} upgrade head +octavia-db-manage ${OPTS} upgrade_persistence exit 0 diff --git a/templates/octavia/bin/init.sh b/templates/octavia/bin/init.sh index 783e8c49..65ca8c52 100755 --- a/templates/octavia/bin/init.sh +++ b/templates/octavia/bin/init.sh @@ -24,6 +24,7 @@ export DBHOST=${DatabaseHost:?"Please specify a DatabaseHost variable."} export DBUSER=${DatabaseUser:?"Please specify a DatabaseUser variable."} export DBPASSWORD=${DatabasePassword:?"Please specify a DatabasePassword variable."} export DB=${DatabaseName:-"octavia"} +export PERSISTENCE_DB=${PersistenceDatabaseName:-"octavia_persistence"} export TRANSPORTURL=${TransportURL:-""} SVC_CFG=/etc/octavia/octavia.conf @@ -47,3 +48,11 @@ if [ -n "$TRANSPORTURL" ]; then fi crudini --set ${SVC_CFG_MERGED} database connection mysql+pymysql://${DBUSER}:${DBPASSWORD}@${DBHOST}/${DB} crudini --set ${SVC_CFG_MERGED} keystone_authtoken password $PASSWORD + +# mariadb-operators registers the new database with the "databaseName" +# user and not "databaseUsername" +# https://github.com/openstack-k8s-operators/mariadb-operator/issues/36 +# TODO(gthiemonge) Use the octavia user when the bug is fixed +PERSISTENCE_DBUSER=${PERSISTENCE_DB} +#PERSISTENCE_DBUSER=${DBUSER} +crudini --set ${SVC_CFG_MERGED} task_flow persistence_connection mysql+pymysql://${PERSISTENCE_DBUSER}:${DBPASSWORD}@${DBHOST}/${PERSISTENCE_DB} diff --git a/templates/octavia/config/octavia.conf b/templates/octavia/config/octavia.conf index 58a21c88..2ff1d28d 100644 --- a/templates/octavia/config/octavia.conf +++ b/templates/octavia/config/octavia.conf @@ -54,6 +54,11 @@ amp_timezone=UTC amp_boot_network_list= client_ca=/etc/octavia/certs/ca_01.pem [task_flow] +jobboard_enabled = True +#jobboard_backend_hosts = +#jobboard_backend_port = 26379 +#jobboard_backend_password = "" +#jobboard_redis_sentinel = redis [oslo_messaging] # topic=octavia-rpc [oslo_middleware] diff --git a/templates/octaviaamphoracontroller/bin/init.sh b/templates/octaviaamphoracontroller/bin/init.sh index 4c412b7a..ffa45ed0 100755 --- a/templates/octaviaamphoracontroller/bin/init.sh +++ b/templates/octaviaamphoracontroller/bin/init.sh @@ -24,6 +24,7 @@ export DBHOST=${DatabaseHost:?"Please specify a DatabaseHost variable."} export DBUSER=${DatabaseUser:?"Please specify a DatabaseUser variable."} export DBPASSWORD=${DatabasePassword:?"Please specify a DatabasePassword variable."} export DB=${DatabaseName:-"octavia"} +export PERSISTENCE_DB=${PersistenceDatabaseName:-"octavia_persistence"} export TRANSPORTURL=${TransportURL:-""} SVC_CFG=/etc/octavia/octavia.conf @@ -49,3 +50,11 @@ fi crudini --set ${SVC_CFG_MERGED} database connection mysql+pymysql://${DBUSER}:${DBPASSWORD}@${DBHOST}/${DB} crudini --set ${SVC_CFG_MERGED} keystone_authtoken password $PASSWORD crudini --set ${SVC_CFG_MERGED} service_auth password $PASSWORD + +# mariadb-operators registers the new database with the "databaseName" +# user and not "databaseUsername" +# https://github.com/openstack-k8s-operators/mariadb-operator/issues/36 +# TODO(gthiemonge) Use the octavia user when the bug is fixed +PERSISTENCE_DBUSER=${PERSISTENCE_DB} +#PERSISTENCE_DBUSER=${DBUSER} +crudini --set ${SVC_CFG_MERGED} task_flow persistence_connection mysql+pymysql://${PERSISTENCE_DBUSER}:${DBPASSWORD}@${DBHOST}/${PERSISTENCE_DB} diff --git a/templates/octaviaamphoracontroller/config/octavia.conf b/templates/octaviaamphoracontroller/config/octavia.conf index e83e7ca4..2025c3f2 100644 --- a/templates/octaviaamphoracontroller/config/octavia.conf +++ b/templates/octaviaamphoracontroller/config/octavia.conf @@ -39,6 +39,12 @@ amp_image_tag=amphora-image amp_ssh_key_name={{ .NovaSshKeyPair }} client_ca = /etc/octavia/certs/client_ca.cert.pem [task_flow] +jobboard_enabled = True +jobboard_backend_hosts = {{ .JobboardBackendHosts }} +# TODO(gthiemonge) enable sentinel when it is exposed in the redis service. +#jobboard_backend_port = 26379 +#jobboard_backend_password = "" +#jobboard_redis_sentinel = redis [oslo_messaging] topic=octavia-rpc [oslo_middleware] diff --git a/templates/octaviaapi/bin/bootstrap.sh b/templates/octaviaapi/bin/bootstrap.sh index d7948cde..ccf446d2 100755 --- a/templates/octaviaapi/bin/bootstrap.sh +++ b/templates/octaviaapi/bin/bootstrap.sh @@ -17,5 +17,6 @@ set -ex OPTS="--config-file /etc/octavia/octavia.conf" octavia-db-manage ${OPTS} upgrade head +octavia-db-manage ${OPTS} upgrade_persistence exit 0 diff --git a/templates/octaviaapi/bin/init.sh b/templates/octaviaapi/bin/init.sh index 4c412b7a..ffa45ed0 100755 --- a/templates/octaviaapi/bin/init.sh +++ b/templates/octaviaapi/bin/init.sh @@ -24,6 +24,7 @@ export DBHOST=${DatabaseHost:?"Please specify a DatabaseHost variable."} export DBUSER=${DatabaseUser:?"Please specify a DatabaseUser variable."} export DBPASSWORD=${DatabasePassword:?"Please specify a DatabasePassword variable."} export DB=${DatabaseName:-"octavia"} +export PERSISTENCE_DB=${PersistenceDatabaseName:-"octavia_persistence"} export TRANSPORTURL=${TransportURL:-""} SVC_CFG=/etc/octavia/octavia.conf @@ -49,3 +50,11 @@ fi crudini --set ${SVC_CFG_MERGED} database connection mysql+pymysql://${DBUSER}:${DBPASSWORD}@${DBHOST}/${DB} crudini --set ${SVC_CFG_MERGED} keystone_authtoken password $PASSWORD crudini --set ${SVC_CFG_MERGED} service_auth password $PASSWORD + +# mariadb-operators registers the new database with the "databaseName" +# user and not "databaseUsername" +# https://github.com/openstack-k8s-operators/mariadb-operator/issues/36 +# TODO(gthiemonge) Use the octavia user when the bug is fixed +PERSISTENCE_DBUSER=${PERSISTENCE_DB} +#PERSISTENCE_DBUSER=${DBUSER} +crudini --set ${SVC_CFG_MERGED} task_flow persistence_connection mysql+pymysql://${PERSISTENCE_DBUSER}:${DBPASSWORD}@${DBHOST}/${PERSISTENCE_DB}