diff --git a/api/bases/telemetry.openstack.org_autoscalings.yaml b/api/bases/telemetry.openstack.org_autoscalings.yaml index 6b6d7c53b..f5702b288 100644 --- a/api/bases/telemetry.openstack.org_autoscalings.yaml +++ b/api/bases/telemetry.openstack.org_autoscalings.yaml @@ -70,6 +70,12 @@ spec: default: 60 description: APITimeout for Route and Apache type: integer + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/aodh/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: default: '# add your customization here' description: |- diff --git a/api/bases/telemetry.openstack.org_ceilometers.yaml b/api/bases/telemetry.openstack.org_ceilometers.yaml index 68c4de188..c17fe87a9 100644 --- a/api/bases/telemetry.openstack.org_ceilometers.yaml +++ b/api/bases/telemetry.openstack.org_ceilometers.yaml @@ -120,6 +120,12 @@ spec: type: string computeImage: type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/ceilometer/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: default: '# add your customization here' description: |- diff --git a/api/bases/telemetry.openstack.org_cloudkitties.yaml b/api/bases/telemetry.openstack.org_cloudkitties.yaml index 5b5b615ea..23eca9719 100644 --- a/api/bases/telemetry.openstack.org_cloudkitties.yaml +++ b/api/bases/telemetry.openstack.org_cloudkitties.yaml @@ -51,6 +51,12 @@ spec: description: ContainerImage - CloudKitty Container Image URL (will be set to environmental default if empty) type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/cloudkitty/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: description: |- CustomServiceConfig - customize the service config using this parameter to change service defaults, @@ -363,6 +369,12 @@ spec: description: ContainerImage - CloudKitty Container Image URL (will be set to environmental default if empty) type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/cloudkitty/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: description: |- CustomServiceConfig - customize the service config using this parameter to change service defaults, diff --git a/api/bases/telemetry.openstack.org_cloudkittyapis.yaml b/api/bases/telemetry.openstack.org_cloudkittyapis.yaml index 9cf9619d5..d26728cbd 100644 --- a/api/bases/telemetry.openstack.org_cloudkittyapis.yaml +++ b/api/bases/telemetry.openstack.org_cloudkittyapis.yaml @@ -43,6 +43,12 @@ spec: description: ContainerImage - CloudKitty Container Image URL (will be set to environmental default if empty) type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/cloudkitty/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: description: |- CustomServiceConfig - customize the service config using this parameter to change service defaults, diff --git a/api/bases/telemetry.openstack.org_cloudkittyprocs.yaml b/api/bases/telemetry.openstack.org_cloudkittyprocs.yaml index 1caddbd5c..4ca1cc422 100644 --- a/api/bases/telemetry.openstack.org_cloudkittyprocs.yaml +++ b/api/bases/telemetry.openstack.org_cloudkittyprocs.yaml @@ -57,6 +57,12 @@ spec: description: ContainerImage - CloudKitty Container Image URL (will be set to environmental default if empty) type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/cloudkitty/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: description: |- CustomServiceConfig - customize the service config using this parameter to change service defaults, diff --git a/api/bases/telemetry.openstack.org_telemetries.yaml b/api/bases/telemetry.openstack.org_telemetries.yaml index 5a78108cf..114989db9 100644 --- a/api/bases/telemetry.openstack.org_telemetries.yaml +++ b/api/bases/telemetry.openstack.org_telemetries.yaml @@ -73,6 +73,12 @@ spec: default: 60 description: APITimeout for Route and Apache type: integer + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/aodh/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: default: '# add your customization here' description: |- @@ -437,6 +443,12 @@ spec: type: string computeImage: type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/ceilometer/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: default: '# add your customization here' description: |- @@ -610,6 +622,12 @@ spec: description: ContainerImage - CloudKitty Container Image URL (will be set to environmental default if empty) type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/cloudkitty/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: description: |- CustomServiceConfig - customize the service config using this parameter to change service defaults, @@ -922,6 +940,12 @@ spec: description: ContainerImage - CloudKitty Container Image URL (will be set to environmental default if empty) type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/cloudkitty/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: description: |- CustomServiceConfig - customize the service config using this parameter to change service defaults, diff --git a/api/v1beta1/autoscaling_types.go b/api/v1beta1/autoscaling_types.go index f541155eb..4199cd475 100644 --- a/api/v1beta1/autoscaling_types.go +++ b/api/v1beta1/autoscaling_types.go @@ -136,6 +136,12 @@ type AodhCore struct { // TopologyRef to apply the Topology defined by the associated CR referenced // by name TopologyRef *topologyv1.TopoRef `json:"topologyRef,omitempty"` + + // +kubebuilder:validation:Optional + // A name of a secret containing custom configuration files. Files + // from this secret will get copied into /etc/aodh/ and they'll + // overwrite any default files already present there. + CustomConfigsSecretName string `json:"customConfigsSecretName,omitempty"` } // AutoscalingSpec defines the desired state of Autoscaling diff --git a/api/v1beta1/ceilometer_types.go b/api/v1beta1/ceilometer_types.go index e3545b3f7..d6d20995a 100644 --- a/api/v1beta1/ceilometer_types.go +++ b/api/v1beta1/ceilometer_types.go @@ -155,6 +155,12 @@ type CeilometerSpecCore struct { // TopologyRef to apply the Topology defined by the associated CR referenced // by name TopologyRef *topologyv1.TopoRef `json:"topologyRef,omitempty"` + + // +kubebuilder:validation:Optional + // A name of a secret containing custom configuration files. Files + // from this secret will get copied into /etc/ceilometer/ and they'll + // overwrite any default files already present there. + CustomConfigsSecretName string `json:"customConfigsSecretName,omitempty"` } // CeilometerStatus defines the observed state of Ceilometer diff --git a/api/v1beta1/cloudkittyapi_types.go b/api/v1beta1/cloudkittyapi_types.go index 3a71afb58..8e4e9ef2e 100644 --- a/api/v1beta1/cloudkittyapi_types.go +++ b/api/v1beta1/cloudkittyapi_types.go @@ -42,6 +42,12 @@ type CloudKittyAPITemplateCore struct { // +operator-sdk:csv:customresourcedefinitions:type=spec // TLS - Parameters related to the TLS TLS tls.API `json:"tls,omitempty"` + + // +kubebuilder:validation:Optional + // A name of a secret containing custom configuration files. Files + // from this secret will get copied into /etc/cloudkitty/ and they'll + // overwrite any default files already present there. + CustomConfigsSecretName string `json:"customConfigsSecretName,omitempty"` } // CloudKittyAPITemplate defines the input parameters for the CloudKitty API service diff --git a/api/v1beta1/cloudkittyproc_types.go b/api/v1beta1/cloudkittyproc_types.go index 83de10d14..ed07c978a 100644 --- a/api/v1beta1/cloudkittyproc_types.go +++ b/api/v1beta1/cloudkittyproc_types.go @@ -38,6 +38,12 @@ type CloudKittyProcTemplateCore struct { // +operator-sdk:csv:customresourcedefinitions:type=spec // TLS - Parameters related to the TLS TLS tls.SimpleService `json:"tls,omitempty"` + + // +kubebuilder:validation:Optional + // A name of a secret containing custom configuration files. Files + // from this secret will get copied into /etc/cloudkitty/ and they'll + // overwrite any default files already present there. + CustomConfigsSecretName string `json:"customConfigsSecretName,omitempty"` } // CloudKittyProcTemplate defines the input parameters for the CloudKitty Processor service diff --git a/config/crd/bases/telemetry.openstack.org_autoscalings.yaml b/config/crd/bases/telemetry.openstack.org_autoscalings.yaml index 6b6d7c53b..f5702b288 100644 --- a/config/crd/bases/telemetry.openstack.org_autoscalings.yaml +++ b/config/crd/bases/telemetry.openstack.org_autoscalings.yaml @@ -70,6 +70,12 @@ spec: default: 60 description: APITimeout for Route and Apache type: integer + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/aodh/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: default: '# add your customization here' description: |- diff --git a/config/crd/bases/telemetry.openstack.org_ceilometers.yaml b/config/crd/bases/telemetry.openstack.org_ceilometers.yaml index 68c4de188..c17fe87a9 100644 --- a/config/crd/bases/telemetry.openstack.org_ceilometers.yaml +++ b/config/crd/bases/telemetry.openstack.org_ceilometers.yaml @@ -120,6 +120,12 @@ spec: type: string computeImage: type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/ceilometer/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: default: '# add your customization here' description: |- diff --git a/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml b/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml index 5b5b615ea..23eca9719 100644 --- a/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml +++ b/config/crd/bases/telemetry.openstack.org_cloudkitties.yaml @@ -51,6 +51,12 @@ spec: description: ContainerImage - CloudKitty Container Image URL (will be set to environmental default if empty) type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/cloudkitty/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: description: |- CustomServiceConfig - customize the service config using this parameter to change service defaults, @@ -363,6 +369,12 @@ spec: description: ContainerImage - CloudKitty Container Image URL (will be set to environmental default if empty) type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/cloudkitty/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: description: |- CustomServiceConfig - customize the service config using this parameter to change service defaults, diff --git a/config/crd/bases/telemetry.openstack.org_cloudkittyapis.yaml b/config/crd/bases/telemetry.openstack.org_cloudkittyapis.yaml index 9cf9619d5..d26728cbd 100644 --- a/config/crd/bases/telemetry.openstack.org_cloudkittyapis.yaml +++ b/config/crd/bases/telemetry.openstack.org_cloudkittyapis.yaml @@ -43,6 +43,12 @@ spec: description: ContainerImage - CloudKitty Container Image URL (will be set to environmental default if empty) type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/cloudkitty/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: description: |- CustomServiceConfig - customize the service config using this parameter to change service defaults, diff --git a/config/crd/bases/telemetry.openstack.org_cloudkittyprocs.yaml b/config/crd/bases/telemetry.openstack.org_cloudkittyprocs.yaml index 1caddbd5c..4ca1cc422 100644 --- a/config/crd/bases/telemetry.openstack.org_cloudkittyprocs.yaml +++ b/config/crd/bases/telemetry.openstack.org_cloudkittyprocs.yaml @@ -57,6 +57,12 @@ spec: description: ContainerImage - CloudKitty Container Image URL (will be set to environmental default if empty) type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/cloudkitty/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: description: |- CustomServiceConfig - customize the service config using this parameter to change service defaults, diff --git a/config/crd/bases/telemetry.openstack.org_telemetries.yaml b/config/crd/bases/telemetry.openstack.org_telemetries.yaml index 5a78108cf..114989db9 100644 --- a/config/crd/bases/telemetry.openstack.org_telemetries.yaml +++ b/config/crd/bases/telemetry.openstack.org_telemetries.yaml @@ -73,6 +73,12 @@ spec: default: 60 description: APITimeout for Route and Apache type: integer + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/aodh/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: default: '# add your customization here' description: |- @@ -437,6 +443,12 @@ spec: type: string computeImage: type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/ceilometer/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: default: '# add your customization here' description: |- @@ -610,6 +622,12 @@ spec: description: ContainerImage - CloudKitty Container Image URL (will be set to environmental default if empty) type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/cloudkitty/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: description: |- CustomServiceConfig - customize the service config using this parameter to change service defaults, @@ -922,6 +940,12 @@ spec: description: ContainerImage - CloudKitty Container Image URL (will be set to environmental default if empty) type: string + customConfigsSecretName: + description: |- + A name of a secret containing custom configuration files. Files + from this secret will get copied into /etc/cloudkitty/ and they'll + overwrite any default files already present there. + type: string customServiceConfig: description: |- CustomServiceConfig - customize the service config using this parameter to change service defaults, diff --git a/internal/autoscaling/aodh_statefulset.go b/internal/autoscaling/aodh_statefulset.go index b5250b5d0..cd55c2c6a 100644 --- a/internal/autoscaling/aodh_statefulset.go +++ b/internal/autoscaling/aodh_statefulset.go @@ -83,11 +83,11 @@ func AodhStatefulSet( } // create Volume and VolumeMounts - volumes := getVolumes() - apiVolumeMounts := getVolumeMounts("aodh-api") - evaluatorVolumeMounts := getVolumeMounts("aodh-evaluator") - notifierVolumeMounts := getVolumeMounts("aodh-notifier") - listenerVolumeMounts := getVolumeMounts("aodh-listener") + volumes := getVolumes(instance) + apiVolumeMounts := getVolumeMounts(instance, "aodh-api") + evaluatorVolumeMounts := getVolumeMounts(instance, "aodh-evaluator") + notifierVolumeMounts := getVolumeMounts(instance, "aodh-notifier") + listenerVolumeMounts := getVolumeMounts(instance, "aodh-listener") // add openstack CA cert if defined if instance.Spec.Aodh.TLS.CaBundleSecretName != "" { diff --git a/internal/autoscaling/dbsync.go b/internal/autoscaling/dbsync.go index 6031d04aa..2642f4c91 100644 --- a/internal/autoscaling/dbsync.go +++ b/internal/autoscaling/dbsync.go @@ -35,8 +35,8 @@ func DbSyncJob(instance *autoscalingv1beta1.Autoscaling, labels map[string]strin args = append(args, dbSyncCommand) // create Volume and VolumeMounts - volumes := getVolumes() - volumeMounts := getVolumeMounts("aodh-dbsync") + volumes := getVolumes(instance) + volumeMounts := getVolumeMounts(instance, "aodh-dbsync") // add CA cert if defined if instance.Spec.Aodh.TLS.CaBundleSecretName != "" { volumes = append(volumes, instance.Spec.Aodh.TLS.CreateVolume()) diff --git a/internal/autoscaling/volumes.go b/internal/autoscaling/volumes.go index 09b0fe2fa..50f6fd85e 100644 --- a/internal/autoscaling/volumes.go +++ b/internal/autoscaling/volumes.go @@ -16,6 +16,7 @@ limitations under the License. package autoscaling import ( + telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1" corev1 "k8s.io/api/core/v1" ) @@ -33,8 +34,8 @@ var ( ) // getVolumes - service volumes -func getVolumes() []corev1.Volume { - return []corev1.Volume{ +func getVolumes(instance *telemetryv1.Autoscaling) []corev1.Volume { + vols := []corev1.Volume{ { Name: "scripts", VolumeSource: corev1.VolumeSource{ @@ -53,11 +54,24 @@ func getVolumes() []corev1.Volume { }, }, } + + if instance.Spec.Aodh.CustomConfigsSecretName != "" { + vols = append(vols, corev1.Volume{ + Name: "custom-config", + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + DefaultMode: &configMode, + SecretName: instance.Spec.Aodh.CustomConfigsSecretName, + }, + }, + }) + } + return vols } // getVolumeMounts - general VolumeMounts -func getVolumeMounts(serviceName string) []corev1.VolumeMount { - return []corev1.VolumeMount{ +func getVolumeMounts(instance *telemetryv1.Autoscaling, serviceName string) []corev1.VolumeMount { + volMounts := []corev1.VolumeMount{ { Name: "scripts", MountPath: "/var/lib/openstack/bin", @@ -75,6 +89,14 @@ func getVolumeMounts(serviceName string) []corev1.VolumeMount { ReadOnly: true, }, } + if instance.Spec.Aodh.CustomConfigsSecretName != "" { + volMounts = append(volMounts, corev1.VolumeMount{ + Name: "custom-config", + MountPath: "/var/lib/openstack/custom-config", + ReadOnly: true, + }) + } + return volMounts } // getCustomPrometheusCaVolume - Volume for CA certificate of user deployed Prometheus diff --git a/internal/ceilometer/statefulset.go b/internal/ceilometer/statefulset.go index 9b1774436..775fb8a7b 100644 --- a/internal/ceilometer/statefulset.go +++ b/internal/ceilometer/statefulset.go @@ -106,9 +106,9 @@ func StatefulSet( var replicas int32 = 1 - volumes := getVolumes() - centralVolumeMounts := getVolumeMounts("ceilometer-central") - notificationVolumeMounts := getVolumeMounts("ceilometer-notification") + volumes := getVolumes(instance) + centralVolumeMounts := getVolumeMounts(instance, "ceilometer-central") + notificationVolumeMounts := getVolumeMounts(instance, "ceilometer-notification") httpdVolumeMounts := getHttpdVolumeMounts() if instance.Spec.TLS.Enabled() { diff --git a/internal/ceilometer/volumes.go b/internal/ceilometer/volumes.go index b2e3af75b..3b8c0a8b5 100644 --- a/internal/ceilometer/volumes.go +++ b/internal/ceilometer/volumes.go @@ -16,6 +16,7 @@ limitations under the License. package ceilometer import ( + telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1" corev1 "k8s.io/api/core/v1" ) @@ -30,8 +31,8 @@ var ( scriptMode int32 = 0740 ) -func getVolumes() []corev1.Volume { - return []corev1.Volume{ +func getVolumes(instance *telemetryv1.Ceilometer) []corev1.Volume { + vols := []corev1.Volume{ { Name: "scripts", VolumeSource: corev1.VolumeSource{ @@ -74,11 +75,24 @@ func getVolumes() []corev1.Volume { }, }, } + + if instance.Spec.CustomConfigsSecretName != "" { + vols = append(vols, corev1.Volume{ + Name: "custom-config", + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + DefaultMode: &configMode, + SecretName: instance.Spec.CustomConfigsSecretName, + }, + }, + }) + } + return vols } // getVolumeMounts - general VolumeMounts -func getVolumeMounts(serviceName string) []corev1.VolumeMount { - return []corev1.VolumeMount{ +func getVolumeMounts(instance *telemetryv1.Ceilometer, serviceName string) []corev1.VolumeMount { + volMounts := []corev1.VolumeMount{ { Name: "scripts", MountPath: "/var/lib/openstack/bin", @@ -96,6 +110,14 @@ func getVolumeMounts(serviceName string) []corev1.VolumeMount { ReadOnly: true, }, } + if instance.Spec.CustomConfigsSecretName != "" { + volMounts = append(volMounts, corev1.VolumeMount{ + Name: "custom-config", + MountPath: "/var/lib/openstack/custom-config", + ReadOnly: true, + }) + } + return volMounts } // getSgCoreVolumeMounts - VolumeMounts for SGCore container diff --git a/internal/cloudkittyapi/statefulset.go b/internal/cloudkittyapi/statefulset.go index d14eb9655..c53263e54 100644 --- a/internal/cloudkittyapi/statefulset.go +++ b/internal/cloudkittyapi/statefulset.go @@ -74,8 +74,8 @@ func StatefulSet( } // create Volume and VolumeMounts - volumes := GetVolumes(cloudkitty.GetOwningCloudKittyName(instance), instance.Name) - volumeMounts := GetVolumeMounts() + volumes := GetVolumes(cloudkitty.GetOwningCloudKittyName(instance), instance.Name, instance) + volumeMounts := GetVolumeMounts(instance) // add CA cert if defined if instance.Spec.TLS.CaBundleSecretName != "" { diff --git a/internal/cloudkittyapi/volumes.go b/internal/cloudkittyapi/volumes.go index 86e891d58..d8798532c 100644 --- a/internal/cloudkittyapi/volumes.go +++ b/internal/cloudkittyapi/volumes.go @@ -1,12 +1,17 @@ package cloudkittyapi import ( + telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1" "github.com/openstack-k8s-operators/telemetry-operator/internal/cloudkitty" corev1 "k8s.io/api/core/v1" ) +var ( + configMode int32 = 0640 +) + // GetVolumes - -func GetVolumes(parentName string, name string) []corev1.Volume { +func GetVolumes(parentName string, name string, instance *telemetryv1.CloudKittyAPI) []corev1.Volume { var config0644AccessMode int32 = 0644 volumes := []corev1.Volume{ @@ -27,11 +32,23 @@ func GetVolumes(parentName string, name string) []corev1.Volume { }, } + if instance.Spec.CustomConfigsSecretName != "" { + volumes = append(volumes, corev1.Volume{ + Name: "custom-config", + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + DefaultMode: &configMode, + SecretName: instance.Spec.CustomConfigsSecretName, + }, + }, + }) + } + return append(cloudkitty.GetVolumes(parentName), volumes...) } // GetVolumeMounts - CloudKitty API VolumeMounts -func GetVolumeMounts() []corev1.VolumeMount { +func GetVolumeMounts(instance *telemetryv1.CloudKittyAPI) []corev1.VolumeMount { volumeMounts := []corev1.VolumeMount{ { Name: "config-data-custom", @@ -41,6 +58,14 @@ func GetVolumeMounts() []corev1.VolumeMount { GetLogVolumeMount(), } + if instance.Spec.CustomConfigsSecretName != "" { + volumeMounts = append(volumeMounts, corev1.VolumeMount{ + Name: "custom-config", + MountPath: "/var/lib/openstack/custom-config", + ReadOnly: true, + }) + } + return append(cloudkitty.GetVolumeMounts(cloudkitty.ServiceName+"-api"), volumeMounts...) } diff --git a/internal/cloudkittyproc/statefulset.go b/internal/cloudkittyproc/statefulset.go index cdcb1599a..132b00560 100644 --- a/internal/cloudkittyproc/statefulset.go +++ b/internal/cloudkittyproc/statefulset.go @@ -68,8 +68,8 @@ func StatefulSet( envVars["KOLLA_CONFIG_STRATEGY"] = env.SetValue("COPY_ALWAYS") envVars["CONFIG_HASH"] = env.SetValue(configHash) - volumes := GetVolumes(cloudkitty.GetOwningCloudKittyName(instance), instance.Name) - volumeMounts := GetVolumeMounts() + volumes := GetVolumes(cloudkitty.GetOwningCloudKittyName(instance), instance.Name, instance) + volumeMounts := GetVolumeMounts(instance) // Add the CA bundle if instance.Spec.TLS.CaBundleSecretName != "" { diff --git a/internal/cloudkittyproc/volumes.go b/internal/cloudkittyproc/volumes.go index 1329239b4..9186f8028 100644 --- a/internal/cloudkittyproc/volumes.go +++ b/internal/cloudkittyproc/volumes.go @@ -1,12 +1,17 @@ package cloudkittyproc import ( + telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1" "github.com/openstack-k8s-operators/telemetry-operator/internal/cloudkitty" corev1 "k8s.io/api/core/v1" ) +var ( + configMode int32 = 0640 +) + // GetVolumes - -func GetVolumes(parentName string, name string) []corev1.Volume { +func GetVolumes(parentName string, name string, instance *telemetryv1.CloudKittyProc) []corev1.Volume { var config0644AccessMode int32 = 0644 volumes := []corev1.Volume{ @@ -21,11 +26,23 @@ func GetVolumes(parentName string, name string) []corev1.Volume { }, } + if instance.Spec.CustomConfigsSecretName != "" { + volumes = append(volumes, corev1.Volume{ + Name: "custom-config", + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + DefaultMode: &configMode, + SecretName: instance.Spec.CustomConfigsSecretName, + }, + }, + }) + } + return append(cloudkitty.GetVolumes(parentName), volumes...) } -// GetVolumeMounts - CloudKitty API VolumeMounts -func GetVolumeMounts() []corev1.VolumeMount { +// GetVolumeMounts - CloudKitty Proc VolumeMounts +func GetVolumeMounts(instance *telemetryv1.CloudKittyProc) []corev1.VolumeMount { volumeMounts := []corev1.VolumeMount{ { Name: "config-data-custom", @@ -34,5 +51,13 @@ func GetVolumeMounts() []corev1.VolumeMount { }, } + if instance.Spec.CustomConfigsSecretName != "" { + volumeMounts = append(volumeMounts, corev1.VolumeMount{ + Name: "custom-config", + MountPath: "/var/lib/openstack/custom-config", + ReadOnly: true, + }) + } + return append(cloudkitty.GetVolumeMounts(cloudkitty.ServiceName+"-proc"), volumeMounts...) } diff --git a/internal/controller/autoscaling_controller.go b/internal/controller/autoscaling_controller.go index c92190ca9..769f83759 100644 --- a/internal/controller/autoscaling_controller.go +++ b/internal/controller/autoscaling_controller.go @@ -221,11 +221,12 @@ func (r *AutoscalingReconciler) Reconcile(ctx context.Context, req ctrl.Request) // fields to index to reconcile when change const ( - autoscalingPasswordSecretField = ".spec.aodh.secret" //nolint:gosec // G101: Not actual credentials, just field path - autoscalingCaBundleSecretNameField = ".spec.aodh.tls.caBundleSecretName" //nolint:gosec // G101: Not actual credentials, just field path - autoscalingTLSAPIInternalField = ".spec.aodh.tls.api.internal.secretName" - autoscalingTLSAPIPublicField = ".spec.aodh.tls.api.public.secretName" - topologyField = ".spec.aodh.topologyRef.Name" + autoscalingPasswordSecretField = ".spec.aodh.secret" //nolint:gosec // G101: Not actual credentials, just field path + autoscalingCaBundleSecretNameField = ".spec.aodh.tls.caBundleSecretName" //nolint:gosec // G101: Not actual credentials, just field path + autoscalingTLSAPIInternalField = ".spec.aodh.tls.api.internal.secretName" + autoscalingTLSAPIPublicField = ".spec.aodh.tls.api.public.secretName" + topologyField = ".spec.aodh.topologyRef.Name" + autoscalingCustomConfigsSecretField = ".spec.aodh.customConfigsSecretName" //nolint:gosec // G101: Not actual credentials, just field path ) var ( @@ -235,6 +236,7 @@ var ( autoscalingTLSAPIInternalField, autoscalingTLSAPIPublicField, topologyField, + autoscalingCustomConfigsSecretField, } ) @@ -598,6 +600,18 @@ func (r *AutoscalingReconciler) reconcileNormal( // all cert input checks out so report InputReady instance.Status.Conditions.MarkTrue(condition.TLSInputReadyCondition, condition.InputReadyMessage) + // + // check for custom configs secret holding custom configuration files + // + if instance.Spec.Aodh.CustomConfigsSecretName != "" { + _, hash, err := secret.GetSecret(ctx, helper, instance.Spec.Aodh.CustomConfigsSecretName, instance.Namespace) + if err != nil { + return ctrl.Result{}, err + } + configMapVars["custom-configs-secret"] = env.SetValue(hash) + } + // run check custom configs secret - end + inputHash, hashChanged, err := r.createHashOfInputHashes(ctx, instance, configMapVars) if err != nil { @@ -1008,6 +1022,18 @@ func (r *AutoscalingReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M return err } + // index autoscalingCustomConfigsSecretField + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &telemetryv1.Autoscaling{}, autoscalingCustomConfigsSecretField, func(rawObj client.Object) []string { + // Extract the secret name from the spec, if one is provided + cr := rawObj.(*telemetryv1.Autoscaling) + if cr.Spec.Aodh.CustomConfigsSecretName == "" { + return nil + } + return []string{cr.Spec.Aodh.CustomConfigsSecretName} + }); err != nil { + return err + } + return ctrl.NewControllerManagedBy(mgr). For(&telemetryv1.Autoscaling{}). Owns(&appsv1.StatefulSet{}). diff --git a/internal/controller/ceilometer_controller.go b/internal/controller/ceilometer_controller.go index 863829374..f39376c91 100644 --- a/internal/controller/ceilometer_controller.go +++ b/internal/controller/ceilometer_controller.go @@ -243,6 +243,7 @@ const ( ksmTLSField = ".spec.ksmTls.secretName" mysqldExporterCaBundleSecretNameField = ".spec.mysqldExporterTls.caBundleSecretName" //nolint:gosec // G101: Not actual credentials, just field path mysqldExporterTLSField = ".spec.mysqldExporterTls.secretName" + customConfigsSecretNameField = ".spec.customConfigsSecretName" //nolint:gosec // G101: Not actual credentials, just field path ) var ( @@ -255,6 +256,7 @@ var ( mysqldExporterCaBundleSecretNameField, mysqldExporterTLSField, topologyField, + customConfigsSecretNameField, } ) @@ -578,6 +580,18 @@ func (r *CeilometerReconciler) reconcileCeilometer( } // run check TransportURL secret - end + // + // check for custom configs secret secret holding custom configuration files + // + if instance.Spec.CustomConfigsSecretName != "" { + _, hash, err := secret.GetSecret(ctx, helper, instance.Spec.CustomConfigsSecretName, instance.Namespace) + if err != nil { + return ctrlResult, err + } + configMapVars["custom-configs-secret"] = env.SetValue(hash) + } + // run check custom configs secret - end + instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage) // @@ -1824,6 +1838,18 @@ func (r *CeilometerReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma return err } + // index customConfigsSecretNameField + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &telemetryv1.Ceilometer{}, customConfigsSecretNameField, func(rawObj client.Object) []string { + // Extract the secret name from the spec, if one is provided + cr := rawObj.(*telemetryv1.Ceilometer) + if cr.Spec.CustomConfigsSecretName == "" { + return nil + } + return []string{cr.Spec.CustomConfigsSecretName} + }); err != nil { + return err + } + return ctrl.NewControllerManagedBy(mgr). For(&telemetryv1.Ceilometer{}). Owns(&keystonev1.KeystoneService{}). diff --git a/internal/controller/cloudkitty_controller.go b/internal/controller/cloudkitty_controller.go index 80869014e..2daa7c9dc 100644 --- a/internal/controller/cloudkitty_controller.go +++ b/internal/controller/cloudkitty_controller.go @@ -237,10 +237,11 @@ func (r *CloudKittyReconciler) Reconcile(ctx context.Context, req ctrl.Request) const ( cloudKittyPasswordSecretField = ".spec.secret" //nolint:gosec // Not hardcoded credentials, just field name - cloudKittyCaBundleSecretNameField = ".spec.tls.caBundleSecretName" - cloudKittyTLSAPIInternalField = ".spec.tls.api.internal.secretName" - cloudKittyTLSAPIPublicField = ".spec.tls.api.public.secretName" - cloudKittyTopologyField = ".spec.topologyRef.Name" + cloudKittyCaBundleSecretNameField = ".spec.tls.caBundleSecretName" + cloudKittyTLSAPIInternalField = ".spec.tls.api.internal.secretName" + cloudKittyTLSAPIPublicField = ".spec.tls.api.public.secretName" + cloudKittyTopologyField = ".spec.topologyRef.Name" + cloudKittyCustomConfigsSecretField = ".spec.customConfigsSecretName" //nolint:gosec // G101: Not actual credentials, just field path ) var ( @@ -248,6 +249,7 @@ var ( cloudKittyPasswordSecretField, cloudKittyCaBundleSecretNameField, cloudKittyTopologyField, + cloudKittyCustomConfigsSecretField, } cloudKittyAPIWatchFields = []string{ cloudKittyPasswordSecretField, @@ -255,6 +257,7 @@ var ( cloudKittyTLSAPIInternalField, cloudKittyTLSAPIPublicField, cloudKittyTopologyField, + cloudKittyCustomConfigsSecretField, } ) diff --git a/internal/controller/cloudkittyapi_controller.go b/internal/controller/cloudkittyapi_controller.go index 140ffcc81..846c88c46 100644 --- a/internal/controller/cloudkittyapi_controller.go +++ b/internal/controller/cloudkittyapi_controller.go @@ -407,6 +407,18 @@ func (r *CloudKittyAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl return err } + // index cloudKittyCustomConfigsSecretField + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &telemetryv1.CloudKittyAPI{}, cloudKittyCustomConfigsSecretField, func(rawObj client.Object) []string { + // Extract the secret name from the spec, if one is provided + cr := rawObj.(*telemetryv1.CloudKittyAPI) + if cr.Spec.CustomConfigsSecretName == "" { + return nil + } + return []string{cr.Spec.CustomConfigsSecretName} + }); err != nil { + return err + } + return ctrl.NewControllerManagedBy(mgr). For(&telemetryv1.CloudKittyAPI{}). Owns(&keystonev1.KeystoneService{}). @@ -985,6 +997,18 @@ func (r *CloudKittyAPIReconciler) reconcileNormal(ctx context.Context, instance } configVars["client-cert"] = env.SetValue(clientCertHash) + // + // check for custom configs secret holding custom configuration files + // + if instance.Spec.CustomConfigsSecretName != "" { + _, hash, err := secret.GetSecret(ctx, helper, instance.Spec.CustomConfigsSecretName, instance.Namespace) + if err != nil { + return ctrl.Result{}, err + } + configVars["custom-configs-secret"] = env.SetValue(hash) + } + // run check custom configs secret - end + // // create hash over all the different input resources to identify if any those changed // and a restart/recreate is required. diff --git a/internal/controller/cloudkittyproc_controller.go b/internal/controller/cloudkittyproc_controller.go index d36dbf656..944acb2be 100644 --- a/internal/controller/cloudkittyproc_controller.go +++ b/internal/controller/cloudkittyproc_controller.go @@ -358,6 +358,18 @@ func (r *CloudKittyProcReconciler) SetupWithManager(ctx context.Context, mgr ctr return err } + // index cloudKittyCustomConfigsSecretField + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &telemetryv1.CloudKittyProc{}, cloudKittyCustomConfigsSecretField, func(rawObj client.Object) []string { + // Extract the secret name from the spec, if one is provided + cr := rawObj.(*telemetryv1.CloudKittyProc) + if cr.Spec.CustomConfigsSecretName == "" { + return nil + } + return []string{cr.Spec.CustomConfigsSecretName} + }); err != nil { + return err + } + return ctrl.NewControllerManagedBy(mgr). For(&telemetryv1.CloudKittyProc{}). Owns(&appsv1.StatefulSet{}). @@ -570,6 +582,18 @@ func (r *CloudKittyProcReconciler) reconcileNormal(ctx context.Context, instance } configVars["client-cert"] = env.SetValue(clientCertHash) + // + // check for custom configs secret holding custom configuration files + // + if instance.Spec.CustomConfigsSecretName != "" { + _, hash, err := secret.GetSecret(ctx, helper, instance.Spec.CustomConfigsSecretName, instance.Namespace) + if err != nil { + return ctrl.Result{}, err + } + configVars["custom-configs-secret"] = env.SetValue(hash) + } + // run check custom configs secret - end + // // create hash over all the different input resources to identify if any those changed // and a restart/recreate is required. diff --git a/templates/autoscaling/config/aodh-api-config.json b/templates/autoscaling/config/aodh-api-config.json index 5881b94c4..faef19c1a 100644 --- a/templates/autoscaling/config/aodh-api-config.json +++ b/templates/autoscaling/config/aodh-api-config.json @@ -7,6 +7,13 @@ "owner": "aodh", "perm": "0600" }, + { + "source": "/var/lib/openstack/custom-config/*", + "dest": "/etc/aodh/", + "owner": "aodh", + "perm": "0600", + "optional": true + }, { "source": "/var/lib/openstack/config/custom.conf", "dest": "/etc/aodh/aodh.conf.d/01-aodh-custom.conf", diff --git a/templates/autoscaling/config/aodh-dbsync-config.json b/templates/autoscaling/config/aodh-dbsync-config.json index 667e5a400..b76813089 100644 --- a/templates/autoscaling/config/aodh-dbsync-config.json +++ b/templates/autoscaling/config/aodh-dbsync-config.json @@ -7,6 +7,13 @@ "owner": "aodh", "perm": "0600" }, + { + "source": "/var/lib/openstack/custom-config/*", + "dest": "/etc/aodh/", + "owner": "aodh", + "perm": "0600", + "optional": true + }, { "source": "/var/lib/openstack/config/custom.conf", "dest": "/etc/aodh/aodh.conf.d/01-aodh-custom.conf", diff --git a/templates/autoscaling/config/aodh-evaluator-config.json b/templates/autoscaling/config/aodh-evaluator-config.json index d7912fd57..2d23e5dfb 100644 --- a/templates/autoscaling/config/aodh-evaluator-config.json +++ b/templates/autoscaling/config/aodh-evaluator-config.json @@ -7,6 +7,13 @@ "owner": "aodh", "perm": "0600" }, + { + "source": "/var/lib/openstack/custom-config/*", + "dest": "/etc/aodh/", + "owner": "aodh", + "perm": "0600", + "optional": true + }, { "source": "/var/lib/openstack/config/custom.conf", "dest": "/etc/aodh/aodh.conf.d/01-aodh-custom.conf", diff --git a/templates/autoscaling/config/aodh-listener-config.json b/templates/autoscaling/config/aodh-listener-config.json index e3df78780..d729f31f2 100644 --- a/templates/autoscaling/config/aodh-listener-config.json +++ b/templates/autoscaling/config/aodh-listener-config.json @@ -7,6 +7,13 @@ "owner": "aodh", "perm": "0600" }, + { + "source": "/var/lib/openstack/custom-config/*", + "dest": "/etc/aodh/", + "owner": "aodh", + "perm": "0600", + "optional": true + }, { "source": "/var/lib/openstack/config/custom.conf", "dest": "/etc/aodh/aodh.conf.d/01-aodh-custom.conf", diff --git a/templates/autoscaling/config/aodh-notifier-config.json b/templates/autoscaling/config/aodh-notifier-config.json index 0aece4559..0ec586866 100644 --- a/templates/autoscaling/config/aodh-notifier-config.json +++ b/templates/autoscaling/config/aodh-notifier-config.json @@ -7,6 +7,13 @@ "owner": "aodh", "perm": "0600" }, + { + "source": "/var/lib/openstack/custom-config/*", + "dest": "/etc/aodh/", + "owner": "aodh", + "perm": "0600", + "optional": true + }, { "source": "/var/lib/openstack/config/custom.conf", "dest": "/etc/aodh/aodh.conf.d/01-aodh-custom.conf", diff --git a/templates/ceilometercentral/config/ceilometer-central-config.json b/templates/ceilometercentral/config/ceilometer-central-config.json index 9c0fdf570..12a43fca1 100644 --- a/templates/ceilometercentral/config/ceilometer-central-config.json +++ b/templates/ceilometercentral/config/ceilometer-central-config.json @@ -13,6 +13,13 @@ "owner": "ceilometer", "perm": "0600" }, + { + "source": "/var/lib/openstack/custom-config/*", + "dest": "/etc/ceilometer/", + "owner": "ceilometer", + "perm": "0600", + "optional": true + }, { "source": "/var/lib/openstack/config/custom.conf", "dest": "/etc/ceilometer/ceilometer.conf.d/01-ceilometer-custom.conf", diff --git a/templates/ceilometercentral/config/ceilometer-notification-config.json b/templates/ceilometercentral/config/ceilometer-notification-config.json index f8de811cd..d27460ea2 100644 --- a/templates/ceilometercentral/config/ceilometer-notification-config.json +++ b/templates/ceilometercentral/config/ceilometer-notification-config.json @@ -13,6 +13,13 @@ "owner": "ceilometer", "perm": "0600" }, + { + "source": "/var/lib/openstack/custom-config/*", + "dest": "/etc/ceilometer/", + "owner": "ceilometer", + "perm": "0600", + "optional": true + }, { "source": "/var/lib/openstack/config/custom.conf", "dest": "/etc/ceilometer/ceilometer.conf.d/01-ceilometer-custom.conf", diff --git a/templates/cloudkitty/config/cloudkitty-api-config.json b/templates/cloudkitty/config/cloudkitty-api-config.json index 2c6917264..48b6b3b29 100644 --- a/templates/cloudkitty/config/cloudkitty-api-config.json +++ b/templates/cloudkitty/config/cloudkitty-api-config.json @@ -50,6 +50,13 @@ "owner": "cloudkitty", "perm": "0644" }, + { + "source": "/var/lib/openstack/custom-config/*", + "dest": "/etc/cloudkitty/", + "owner": "cloudkitty", + "perm": "0600", + "optional": true + }, { "source": "/var/lib/config-data/tls/certs/*", "dest": "/etc/pki/tls/certs/", diff --git a/templates/cloudkitty/config/cloudkitty-proc-config.json b/templates/cloudkitty/config/cloudkitty-proc-config.json index d27258dc2..adcca50d3 100644 --- a/templates/cloudkitty/config/cloudkitty-proc-config.json +++ b/templates/cloudkitty/config/cloudkitty-proc-config.json @@ -20,6 +20,13 @@ "owner": "cloudkitty", "perm": "0600" }, + { + "source": "/var/lib/openstack/custom-config/*", + "dest": "/etc/cloudkitty/", + "owner": "cloudkitty", + "perm": "0600", + "optional": true + }, { "source": "/var/lib/openstack/loki-certs/*", "dest": "/etc/cloudkitty/certs/", diff --git a/test/kuttl/tests/autoscaling/02-assert.yaml b/test/kuttl/tests/autoscaling/02-assert.yaml new file mode 100644 index 000000000..4fed38015 --- /dev/null +++ b/test/kuttl/tests/autoscaling/02-assert.yaml @@ -0,0 +1,84 @@ +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + service: aodh + name: aodh-0 + ownerReferences: + - kind: StatefulSet + name: aodh +spec: + containers: + - name: aodh-api + volumeMounts: + - mountPath: /var/lib/openstack/bin + name: scripts + - mountPath: /var/lib/openstack/config + name: config-data + - mountPath: /var/lib/kolla/config_files/config.json + name: config-data + subPath: aodh-api-config.json + - mountPath: /var/lib/openstack/custom-config + name: custom-config + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - name: aodh-evaluator + volumeMounts: + - mountPath: /var/lib/openstack/bin + name: scripts + - mountPath: /var/lib/openstack/config + name: config-data + - mountPath: /var/lib/kolla/config_files/config.json + name: config-data + subPath: aodh-evaluator-config.json + - mountPath: /var/lib/openstack/custom-config + name: custom-config + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - name: aodh-notifier + volumeMounts: + - mountPath: /var/lib/openstack/bin + name: scripts + - mountPath: /var/lib/openstack/config + name: config-data + - mountPath: /var/lib/kolla/config_files/config.json + name: config-data + subPath: aodh-notifier-config.json + - mountPath: /var/lib/openstack/custom-config + name: custom-config + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - name: aodh-listener + volumeMounts: + - mountPath: /var/lib/openstack/bin + name: scripts + - mountPath: /var/lib/openstack/config + name: config-data + - mountPath: /var/lib/kolla/config_files/config.json + name: config-data + subPath: aodh-listener-config.json + - mountPath: /var/lib/openstack/custom-config + name: custom-config + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + volumes: + - name: scripts + secret: + secretName: aodh-scripts + - name: config-data + secret: + secretName: aodh-config-data + - name: custom-config + secret: + secretName: custom-config + - projected: + defaultMode: 420 +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: + - script: > + test "$(oc -n $NAMESPACE rsh -c aodh-api aodh-0 cat /etc/aodh/policy.yaml)" = "custom config contents" + - script: > + test "$(oc -n $NAMESPACE rsh -c aodh-evaluator aodh-0 cat /etc/aodh/policy.yaml)" = "custom config contents" + - script: > + test "$(oc -n $NAMESPACE rsh -c aodh-listener aodh-0 cat /etc/aodh/policy.yaml)" = "custom config contents" + - script: > + test "$(oc -n $NAMESPACE rsh -c aodh-notifier aodh-0 cat /etc/aodh/policy.yaml)" = "custom config contents" diff --git a/test/kuttl/tests/autoscaling/02-custom-config-secret.yaml b/test/kuttl/tests/autoscaling/02-custom-config-secret.yaml new file mode 100644 index 000000000..e94eb2c51 --- /dev/null +++ b/test/kuttl/tests/autoscaling/02-custom-config-secret.yaml @@ -0,0 +1,23 @@ +--- +apiVersion: v1 +data: + # custom config contents + policy.yaml: Y3VzdG9tIGNvbmZpZyBjb250ZW50cwo= +kind: Secret +metadata: + name: custom-config +type: Opaque +--- +apiVersion: telemetry.openstack.org/v1beta1 +kind: Autoscaling +metadata: + name: telemetry-kuttl +spec: + aodh: + customConfigsSecretName: custom-config + secret: osp-secret + passwordSelectors: + databaseAccount: aodh + databaseInstance: openstack + memcachedInstance: memcached + heatInstance: heat diff --git a/test/kuttl/tests/ceilometer/01-assert.yaml b/test/kuttl/tests/ceilometer/01-assert.yaml new file mode 100644 index 000000000..f66732017 --- /dev/null +++ b/test/kuttl/tests/ceilometer/01-assert.yaml @@ -0,0 +1,67 @@ +apiVersion: v1 +kind: Pod +metadata: + labels: + service: ceilometer + name: ceilometer-0 + ownerReferences: + - kind: StatefulSet + name: ceilometer +spec: + containers: + - name: ceilometer-central-agent + volumeMounts: + - mountPath: /var/lib/openstack/bin + name: scripts + - mountPath: /var/lib/openstack/config + name: config-data + - mountPath: /var/lib/kolla/config_files/config.json + name: config-data + subPath: ceilometer-central-config.json + - mountPath: /var/lib/openstack/custom-config + name: custom-config + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - name: ceilometer-notification-agent + volumeMounts: + - mountPath: /var/lib/openstack/bin + name: scripts + - mountPath: /var/lib/openstack/config + name: config-data + - mountPath: /var/lib/kolla/config_files/config.json + name: config-data + subPath: ceilometer-notification-config.json + - mountPath: /var/lib/openstack/custom-config + name: custom-config + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + - name: sg-core + - name: proxy-httpd + volumes: + - name: scripts + secret: + secretName: ceilometer-scripts + - name: config-data + secret: + secretName: ceilometer-config-data + - name: sg-core-conf-yaml + secret: + items: + - key: sg-core.conf.yaml + path: sg-core.conf.yaml + secretName: ceilometer-config-data + - emptyDir: {} + name: run-httpd + - emptyDir: {} + name: log-httpd + - name: custom-config + secret: + secretName: custom-config + - projected: + defaultMode: 420 +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: +- script: > + test "$(oc -n $NAMESPACE rsh -c ceilometer-notification-agent ceilometer-0 cat /etc/ceilometer/polling.yaml)" = "custom config contents" +- script: > + test "$(oc -n $NAMESPACE rsh -c ceilometer-central-agent ceilometer-0 cat /etc/ceilometer/polling.yaml)" = "custom config contents" diff --git a/test/kuttl/tests/ceilometer/01-custom-config-secret.yaml b/test/kuttl/tests/ceilometer/01-custom-config-secret.yaml new file mode 100644 index 000000000..913719ef6 --- /dev/null +++ b/test/kuttl/tests/ceilometer/01-custom-config-secret.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: v1 +data: + # custom config contents + polling.yaml: Y3VzdG9tIGNvbmZpZyBjb250ZW50cwo= +kind: Secret +metadata: + name: custom-config +type: Opaque +--- +apiVersion: telemetry.openstack.org/v1beta1 +kind: Ceilometer +metadata: + name: telemetry-kuttl +spec: + customConfigsSecretName: custom-config + secret: osp-secret diff --git a/test/kuttl/tests/cloudkitty/03-assert.yaml b/test/kuttl/tests/cloudkitty/03-assert.yaml new file mode 100644 index 000000000..b549af186 --- /dev/null +++ b/test/kuttl/tests/cloudkitty/03-assert.yaml @@ -0,0 +1,115 @@ +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + component: cloudkitty-api + service: cloudkitty + name: telemetry-kuttl-cloudkitty-api-0 + ownerReferences: + - kind: StatefulSet + name: telemetry-kuttl-cloudkitty-api +spec: + containers: + - name: telemetry-kuttl-cloudkitty-api-log + - name: cloudkitty-api + volumeMounts: + - mountPath: /var/lib/openstack/bin + name: scripts + - mountPath: /var/lib/openstack/config + name: config-data + - mountPath: /var/lib/kolla/config_files/config.json + name: config-data + subPath: cloudkitty-api-config.json + - mountPath: /var/lib/openstack/loki-certs + name: certs + - mountPath: /var/lib/openstack/service-config/ + name: config-data-custom + - mountPath: /var/log/cloudkitty + name: logs + - mountPath: /var/lib/openstack/custom-config + name: custom-config + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + volumes: + - name: scripts + secret: + secretName: telemetry-kuttl-cloudkitty-scripts + - name: config-data + secret: + secretName: telemetry-kuttl-cloudkitty-config-data + - name: certs + projected: + sources: + - secret: + name: cert-cloudkitty-client-internal + - configMap: + name: telemetry-kuttl-cloudkitty-lokistack-gateway-ca-bundle + - name: config-data-custom + secret: + secretName: telemetry-kuttl-cloudkitty-api-config-data + - emptyDir: {} + name: logs + - name: custom-config + secret: + secretName: custom-config + - projected: + defaultMode: 420 +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + component: cloudkitty-proc + service: cloudkitty + name: telemetry-kuttl-cloudkitty-proc-0 + ownerReferences: + - kind: StatefulSet + name: telemetry-kuttl-cloudkitty-proc +spec: + containers: + - name: cloudkitty-proc + volumeMounts: + - mountPath: /var/lib/openstack/bin + name: scripts + - mountPath: /var/lib/openstack/config + name: config-data + - mountPath: /var/lib/kolla/config_files/config.json + name: config-data + subPath: cloudkitty-proc-config.json + - mountPath: /var/lib/openstack/loki-certs + name: certs + - mountPath: /var/lib/openstack/service-config/ + name: config-data-custom + - mountPath: /var/lib/openstack/custom-config + name: custom-config + - mountPath: /var/run/secrets/kubernetes.io/serviceaccount + volumes: + - name: scripts + secret: + secretName: telemetry-kuttl-cloudkitty-scripts + - name: config-data + secret: + secretName: telemetry-kuttl-cloudkitty-config-data + - name: certs + projected: + sources: + - secret: + name: cert-cloudkitty-client-internal + - configMap: + name: telemetry-kuttl-cloudkitty-lokistack-gateway-ca-bundle + - name: config-data-custom + secret: + secretName: telemetry-kuttl-cloudkitty-proc-config-data + - name: custom-config + secret: + secretName: custom-config + - projected: + defaultMode: 420 +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: + - script: > + test "$(oc -n $NAMESPACE rsh -c cloudkitty-api telemetry-kuttl-cloudkitty-api-0 cat /etc/cloudkitty/metrics.yaml)" = "custom config contents" + - script: > + test "$(oc -n $NAMESPACE rsh -c cloudkitty-proc telemetry-kuttl-cloudkitty-proc-0 cat /etc/cloudkitty/metrics.yaml)" = "custom config contents" diff --git a/test/kuttl/tests/cloudkitty/03-custom-config-secret.yaml b/test/kuttl/tests/cloudkitty/03-custom-config-secret.yaml new file mode 100644 index 000000000..ee8d83363 --- /dev/null +++ b/test/kuttl/tests/cloudkitty/03-custom-config-secret.yaml @@ -0,0 +1,63 @@ +--- +apiVersion: v1 +data: + # custom config contents + metrics.yaml: Y3VzdG9tIGNvbmZpZyBjb250ZW50cwo= +kind: Secret +metadata: + name: custom-config +type: Opaque +--- +apiVersion: telemetry.openstack.org/v1beta1 +kind: CloudKitty +metadata: + name: telemetry-kuttl-cloudkitty +spec: + apiTimeout: 0 + cloudKittyAPI: + customConfigsSecretName: custom-config + override: + service: + internal: + metadata: + labels: + osctlplane: "" + osctlplane-service: telemetry + public: + metadata: + labels: + osctlplane: "" + osctlplane-service: telemetry + replicas: 1 + resources: {} + tls: + api: + internal: {} + public: {} + caBundleSecretName: "" + cloudKittyProc: + customConfigsSecretName: custom-config + replicas: 1 + resources: {} + tls: + caBundleSecretName: "" + databaseAccount: cloudkitty + databaseInstance: openstack + memcachedInstance: memcached + passwordSelector: + aodhService: AodhPassword + ceilometerService: CeilometerPassword + cloudKittyService: CloudKittyPassword + period: 300 + preserveJobs: false + rabbitMqClusterName: rabbitmq + s3StorageConfig: + schemas: + - effectiveDate: "2024-11-18" + version: v13 + secret: + name: logging-loki-s3 + type: s3 + secret: osp-secret + serviceUser: cloudkitty + storageClass: local-storage