diff --git a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml index 8b1679b4..5403f07b 100644 --- a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -10758,6 +10758,113 @@ spec: type: string storageClass: type: string + telemetry: + properties: + enabled: + default: true + type: boolean + template: + properties: + ceilometerCentral: + properties: + centralImage: + type: string + customServiceConfig: + default: '# add your customization here' + type: string + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + description: + default: A ceilometer agent + type: string + initImage: + type: string + networkAttachmentDefinitions: + items: + type: string + type: array + notificationImage: + type: string + passwordSelector: + default: + service: CeilometerPassword + properties: + service: + default: CeilometerPassword + type: string + type: object + secret: + default: osp-secret + type: string + serviceUser: + default: ceilometer + type: string + sgCoreImage: + type: string + transportURLSecret: + type: string + required: + - centralImage + - initImage + - notificationImage + - sgCoreImage + type: object + ceilometerCompute: + properties: + computeImage: + type: string + customServiceConfig: + default: '# add your customization here' + type: string + dataplaneInventoryConfigMap: + default: dataplanerole-edpm-compute + type: string + dataplaneSSHSecret: + default: dataplane-ansible-ssh-private-key-secret + type: string + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + description: + default: A ceilometer compute agent + type: string + initImage: + type: string + passwordSelector: + default: + service: CeilometerPassword + properties: + service: + default: CeilometerPassword + type: string + type: object + playbook: + default: deploy-ceilometer.yaml + type: string + secret: + default: osp-secret + type: string + serviceUser: + default: ceilometer + type: string + transportURLSecret: + type: string + type: object + description: + default: A ceilometer agent + type: string + rabbitMqClusterName: + default: rabbitmq + type: string + required: + - ceilometerCentral + - ceilometerCompute + - rabbitMqClusterName + type: object + type: object required: - secret - storageClass diff --git a/apis/core/v1beta1/conditions.go b/apis/core/v1beta1/conditions.go index 56844056..42703f90 100644 --- a/apis/core/v1beta1/conditions.go +++ b/apis/core/v1beta1/conditions.go @@ -72,6 +72,9 @@ const ( // OpenStackControlPlaneDNSReadyCondition Status=True condition which indicates if DNSMasq is configured and operational OpenStackControlPlaneDNSReadyCondition condition.Type = "OpenStackControlPlaneDNSReadyCondition" + // OpenStackControlPlaneTelemetryReadyCondition Status=True condition which indicates if OpenStack Telemetry services are configured and operational + OpenStackControlPlaneTelemetryReadyCondition condition.Type = "OpenStackControlPlaneTelemetryReady" + // OpenStackControlPlaneManilaReadyInitMessage OpenStackControlPlaneManilaReadyInitMessage = "OpenStackControlPlane Manila not started" @@ -276,4 +279,16 @@ const ( // OpenStackControlPlaneDNSReadyErrorMessage OpenStackControlPlaneDNSReadyErrorMessage = "OpenStackControlPlane DNS error occured %s" + + // OpenStackControlPlaneTelemetryReadyInitMessage + OpenStackControlPlaneTelemetryReadyInitMessage = "OpenStackControlPlane Telemetry not started" + + // OpenStackControlPlaneTelemetryReadyMessage + OpenStackControlPlaneTelemetryReadyMessage = "OpenStackControlPlane Telemetry completed" + + // OpenStackControlPlaneTelemetryReadyRunningMessage + OpenStackControlPlaneTelemetryReadyRunningMessage = "OpenStackControlPlane Telemetry in progress" + + // OpenStackControlPlaneTelemetryReadyErrorMessage + OpenStackControlPlaneTelemetryReadyErrorMessage = "OpenStackControlPlane Telemetry error occured %s" ) diff --git a/apis/core/v1beta1/openstackcontrolplane_types.go b/apis/core/v1beta1/openstackcontrolplane_types.go index f8216281..6ce0f94d 100644 --- a/apis/core/v1beta1/openstackcontrolplane_types.go +++ b/apis/core/v1beta1/openstackcontrolplane_types.go @@ -35,6 +35,7 @@ import ( ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1" ovsv1 "github.com/openstack-k8s-operators/ovs-operator/api/v1beta1" placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1" + telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1" rabbitmqv1 "github.com/rabbitmq/cluster-operator/api/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -132,6 +133,9 @@ type OpenStackControlPlaneSpec struct { Horizon HorizonSection `json:"horizon,omitempty"` // +kubebuilder:validation:Optional + // Telemetry - Parameters related to the OpenStack Telemetry services + Telemetry TelemetrySection `json:"telemetry,omitempty"` + // ExtraMounts containing conf files and credentials that should be provided // to the underlying operators. // This struct can be defined in the top level CR and propagated to the @@ -415,6 +419,20 @@ type HorizonSection struct { Template horizonv1.HorizonSpec `json:"template,omitempty"` } +// TelemetrySection defines the desired state of OpenStack Telemetry services +type TelemetrySection struct { + // +kubebuilder:validation:Optional + // +kubebuilder:default=true + // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"} + // Enabled - Whether OpenStack Telemetry services should be deployed and managed + Enabled bool `json:"enabled"` + + // +kubebuilder:validation:Optional + //+operator-sdk:csv:customresourcedefinitions:type=spec + // Template - Overrides to use when creating the OpenStack Telemetry services + Template telemetryv1.TelemetrySpec `json:"template,omitempty"` +} + // OpenStackControlPlaneStatus defines the observed state of OpenStackControlPlane type OpenStackControlPlaneStatus struct { //+operator-sdk:csv:customresourcedefinitions:type=status,xDescriptors={"urn:alm:descriptor:io.kubernetes.conditions"} @@ -500,6 +518,8 @@ func (instance OpenStackControlPlane) InitConditions() { condition.UnknownCondition(OpenStackControlPlaneManilaReadyCondition, condition.InitReason, OpenStackControlPlaneManilaReadyInitMessage), condition.UnknownCondition(OpenStackControlPlaneHorizonReadyCondition, condition.InitReason, OpenStackControlPlaneHorizonReadyInitMessage), condition.UnknownCondition(OpenStackControlPlaneDNSReadyCondition, condition.InitReason, OpenStackControlPlaneDNSReadyInitMessage), + condition.UnknownCondition(OpenStackControlPlaneTelemetryReadyCondition, condition.InitReason, OpenStackControlPlaneTelemetryReadyInitMessage), + // Also add the overall status condition as Unknown condition.UnknownCondition(condition.ReadyCondition, condition.InitReason, condition.ReadyInitMessage), ) diff --git a/apis/core/v1beta1/openstackcontrolplane_webhook.go b/apis/core/v1beta1/openstackcontrolplane_webhook.go index e788d9f9..e100d38c 100644 --- a/apis/core/v1beta1/openstackcontrolplane_webhook.go +++ b/apis/core/v1beta1/openstackcontrolplane_webhook.go @@ -310,4 +310,9 @@ func (r *OpenStackControlPlane) DefaultServices() { if r.Spec.DNS.Enabled { r.Spec.DNS.Template.Default() } + + // Telemetry + if r.Spec.Telemetry.Enabled { + r.Spec.Telemetry.Template.Default() + } } diff --git a/apis/core/v1beta1/zz_generated.deepcopy.go b/apis/core/v1beta1/zz_generated.deepcopy.go index 4e149dae..67d051a8 100644 --- a/apis/core/v1beta1/zz_generated.deepcopy.go +++ b/apis/core/v1beta1/zz_generated.deepcopy.go @@ -345,6 +345,7 @@ func (in *OpenStackControlPlaneSpec) DeepCopyInto(out *OpenStackControlPlaneSpec in.Ironic.DeepCopyInto(&out.Ironic) in.Manila.DeepCopyInto(&out.Manila) in.Horizon.DeepCopyInto(&out.Horizon) + in.Telemetry.DeepCopyInto(&out.Telemetry) if in.ExtraMounts != nil { in, out := &in.ExtraMounts, &out.ExtraMounts *out = make([]OpenStackExtraVolMounts, len(*in)) @@ -521,3 +522,19 @@ func (in *RabbitmqTemplate) DeepCopy() *RabbitmqTemplate { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TelemetrySection) DeepCopyInto(out *TelemetrySection) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TelemetrySection. +func (in *TelemetrySection) DeepCopy() *TelemetrySection { + if in == nil { + return nil + } + out := new(TelemetrySection) + in.DeepCopyInto(out) + return out +} diff --git a/apis/go.mod b/apis/go.mod index 33e1bbf6..3312b942 100644 --- a/apis/go.mod +++ b/apis/go.mod @@ -16,6 +16,7 @@ require ( github.com/openstack-k8s-operators/nova-operator/api v0.0.0-20230522134320-2f2ff8167e57 github.com/openstack-k8s-operators/ovn-operator/api v0.0.0-20230522062547-12905139513e github.com/openstack-k8s-operators/placement-operator/api v0.0.0-20230517142510-5ebb403dc2f7 + github.com/openstack-k8s-operators/telemetry-operator/api v0.0.0-20230518150301-7e9c6a99c4e8 github.com/rabbitmq/cluster-operator v1.14.0 k8s.io/apimachinery v0.26.3 sigs.k8s.io/controller-runtime v0.14.6 diff --git a/apis/go.sum b/apis/go.sum index ac2b6b19..74889da6 100644 --- a/apis/go.sum +++ b/apis/go.sum @@ -152,6 +152,8 @@ github.com/openstack-k8s-operators/ovs-operator/api v0.0.0-20230517053110-2821a8 github.com/openstack-k8s-operators/ovs-operator/api v0.0.0-20230517053110-2821a8dc05fd/go.mod h1:KiYMGv1D3BcCS6RGrJ69uzsRLz0/b12VL8JGxbwNrgM= github.com/openstack-k8s-operators/placement-operator/api v0.0.0-20230517142510-5ebb403dc2f7 h1:Y1y8ElTKnWM1JUX93xYRH5pL4pPI0gfIp9wFMfXq90E= github.com/openstack-k8s-operators/placement-operator/api v0.0.0-20230517142510-5ebb403dc2f7/go.mod h1:B8j7ZNmgxranbjtKk6jzt5p3x0rCsqOJItjO/8r5jok= +github.com/openstack-k8s-operators/telemetry-operator/api v0.0.0-20230518150301-7e9c6a99c4e8 h1:5ysH++xPJKmKWnyLrIx7XOO0QSCkzJaJ66o6kqPX138= +github.com/openstack-k8s-operators/telemetry-operator/api v0.0.0-20230518150301-7e9c6a99c4e8/go.mod h1:YOXMu9ifbPTMd/t/QnSjg82gw4uVITpedcvOkTpLwJk= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -181,8 +183,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= diff --git a/cmd/csv-merger/csv-merger.go b/cmd/csv-merger/csv-merger.go index f7b38ccb..276f3c15 100644 --- a/cmd/csv-merger/csv-merger.go +++ b/cmd/csv-merger/csv-merger.go @@ -107,6 +107,7 @@ var ( baremetalCsv = flag.String("baremetal-csv", "", "Baremetal CSV filename") manilaCsv = flag.String("manila-csv", "", "Manila CSV filename") placementCsv = flag.String("placement-csv", "", "Placement CSV filename") + telemetryCsv = flag.String("telemetry-csv", "", "Telemetry CSV filename") ovnCsv = flag.String("ovn-csv", "", "OVN CSV filename") ovsCsv = flag.String("ovs-csv", "", "OVS CSV filename") cinderCsv = flag.String("cinder-csv", "", "Cinder CSV filename") @@ -150,6 +151,7 @@ func main() { *ironicCsv, *baremetalCsv, *placementCsv, + *telemetryCsv, *ovnCsv, *ovsCsv, *cinderCsv, diff --git a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml index 8b1679b4..5403f07b 100644 --- a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -10758,6 +10758,113 @@ spec: type: string storageClass: type: string + telemetry: + properties: + enabled: + default: true + type: boolean + template: + properties: + ceilometerCentral: + properties: + centralImage: + type: string + customServiceConfig: + default: '# add your customization here' + type: string + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + description: + default: A ceilometer agent + type: string + initImage: + type: string + networkAttachmentDefinitions: + items: + type: string + type: array + notificationImage: + type: string + passwordSelector: + default: + service: CeilometerPassword + properties: + service: + default: CeilometerPassword + type: string + type: object + secret: + default: osp-secret + type: string + serviceUser: + default: ceilometer + type: string + sgCoreImage: + type: string + transportURLSecret: + type: string + required: + - centralImage + - initImage + - notificationImage + - sgCoreImage + type: object + ceilometerCompute: + properties: + computeImage: + type: string + customServiceConfig: + default: '# add your customization here' + type: string + dataplaneInventoryConfigMap: + default: dataplanerole-edpm-compute + type: string + dataplaneSSHSecret: + default: dataplane-ansible-ssh-private-key-secret + type: string + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + description: + default: A ceilometer compute agent + type: string + initImage: + type: string + passwordSelector: + default: + service: CeilometerPassword + properties: + service: + default: CeilometerPassword + type: string + type: object + playbook: + default: deploy-ceilometer.yaml + type: string + secret: + default: osp-secret + type: string + serviceUser: + default: ceilometer + type: string + transportURLSecret: + type: string + type: object + description: + default: A ceilometer agent + type: string + rabbitMqClusterName: + default: rabbitmq + type: string + required: + - ceilometerCentral + - ceilometerCompute + - rabbitMqClusterName + type: object + type: object required: - secret - storageClass diff --git a/config/manifests/bases/openstack-operator.clusterserviceversion.yaml b/config/manifests/bases/openstack-operator.clusterserviceversion.yaml index afbf0388..64c77bb1 100644 --- a/config/manifests/bases/openstack-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/openstack-operator.clusterserviceversion.yaml @@ -208,6 +208,19 @@ spec: path: storageClass x-descriptors: - urn:alm:descriptor:io.kubernetes:StorageClass + - description: Telemetry - Parameters related to the OpenStack Telemetry services + displayName: Telemetry + path: telemetry + - description: Enabled - Whether OpenStack Telemetry services should be deployed + and managed + displayName: Enabled + path: telemetry.enabled + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:booleanSwitch + - description: Template - Overrides to use when creating the OpenStack Telemetry + services + displayName: Template + path: telemetry.template statusDescriptors: - description: Conditions displayName: Conditions diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index e26c5e2d..717b14b8 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -247,3 +247,15 @@ rules: - patch - update - watch +- apiGroups: + - telemetry.openstack.org + resources: + - telemetries + verbs: + - create + - delete + - get + - list + - patch + - update + - watch diff --git a/config/samples/core_v1beta1_openstackcontrolplane.yaml b/config/samples/core_v1beta1_openstackcontrolplane.yaml index bb6c1fb1..6cc52765 100644 --- a/config/samples/core_v1beta1_openstackcontrolplane.yaml +++ b/config/samples/core_v1beta1_openstackcontrolplane.yaml @@ -117,3 +117,11 @@ spec: ironicNeutronAgent: replicas: 1 secret: osp-secret + telemetry: + template: + ceilometerCentral: + passwordSelector: + service: CeilometerPassword + secret: osp-secret + serviceUser: ceilometer + rabbitMqClusterName: rabbitmq diff --git a/config/samples/core_v1beta1_openstackcontrolplane_collapsed_cell.yaml b/config/samples/core_v1beta1_openstackcontrolplane_collapsed_cell.yaml index a64e5762..4b911ff5 100644 --- a/config/samples/core_v1beta1_openstackcontrolplane_collapsed_cell.yaml +++ b/config/samples/core_v1beta1_openstackcontrolplane_collapsed_cell.yaml @@ -105,3 +105,11 @@ spec: ironicNeutronAgent: replicas: 1 secret: osp-secret + telemetry: + template: + ceilometerCentral: + passwordSelector: + service: CeilometerPassword + secret: osp-secret + serviceUser: ceilometer + rabbitMqClusterName: rabbitmq diff --git a/config/samples/core_v1beta1_openstackcontrolplane_galera.yaml b/config/samples/core_v1beta1_openstackcontrolplane_galera.yaml index 7625c625..a9970ea2 100644 --- a/config/samples/core_v1beta1_openstackcontrolplane_galera.yaml +++ b/config/samples/core_v1beta1_openstackcontrolplane_galera.yaml @@ -118,3 +118,11 @@ spec: ironicNeutronAgent: replicas: 1 secret: osp-secret + telemetry: + template: + ceilometerCentral: + passwordSelector: + service: CeilometerPassword + secret: osp-secret + serviceUser: ceilometer + rabbitMqClusterName: rabbitmq diff --git a/config/samples/core_v1beta1_openstackcontrolplane_galera_3replicas.yaml b/config/samples/core_v1beta1_openstackcontrolplane_galera_3replicas.yaml index b66a4e89..53f1b78d 100644 --- a/config/samples/core_v1beta1_openstackcontrolplane_galera_3replicas.yaml +++ b/config/samples/core_v1beta1_openstackcontrolplane_galera_3replicas.yaml @@ -118,3 +118,11 @@ spec: ironicNeutronAgent: replicas: 1 secret: osp-secret + telemetry: + template: + ceilometerCentral: + passwordSelector: + service: CeilometerPassword + secret: osp-secret + serviceUser: ceilometer + rabbitMqClusterName: rabbitmq diff --git a/config/samples/core_v1beta1_openstackcontrolplane_network_isolation.yaml b/config/samples/core_v1beta1_openstackcontrolplane_network_isolation.yaml index d50ef399..a63093b6 100644 --- a/config/samples/core_v1beta1_openstackcontrolplane_network_isolation.yaml +++ b/config/samples/core_v1beta1_openstackcontrolplane_network_isolation.yaml @@ -175,3 +175,11 @@ spec: ironicNeutronAgent: replicas: 1 secret: osp-secret + telemetry: + template: + ceilometerCentral: + passwordSelector: + service: CeilometerPassword + secret: osp-secret + serviceUser: ceilometer + rabbitMqClusterName: rabbitmq diff --git a/config/samples/core_v1beta1_openstackcontrolplane_network_isolation_ceph.yaml b/config/samples/core_v1beta1_openstackcontrolplane_network_isolation_ceph.yaml index ec1a2a2d..4531e9ce 100644 --- a/config/samples/core_v1beta1_openstackcontrolplane_network_isolation_ceph.yaml +++ b/config/samples/core_v1beta1_openstackcontrolplane_network_isolation_ceph.yaml @@ -220,3 +220,11 @@ spec: ironicNeutronAgent: replicas: 1 secret: osp-secret + telemetry: + template: + ceilometerCentral: + passwordSelector: + service: CeilometerPassword + secret: osp-secret + serviceUser: ceilometer + rabbitMqClusterName: rabbitmq diff --git a/controllers/core/openstackcontrolplane_controller.go b/controllers/core/openstackcontrolplane_controller.go index 6fec9f19..59881279 100644 --- a/controllers/core/openstackcontrolplane_controller.go +++ b/controllers/core/openstackcontrolplane_controller.go @@ -38,6 +38,7 @@ import ( ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1" ovsv1 "github.com/openstack-k8s-operators/ovs-operator/api/v1beta1" placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1" + telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1" rabbitmqv1 "github.com/rabbitmq/cluster-operator/api/v1beta1" "k8s.io/apimachinery/pkg/runtime" @@ -80,6 +81,7 @@ type OpenStackControlPlaneReconciler struct { //+kubebuilder:rbac:groups=ovs.openstack.org,resources=ovs,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=rabbitmq.com,resources=rabbitmqclusters,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=network.openstack.org,resources=dnsmasqs,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=telemetry.openstack.org,resources=telemetries,verbs=get;list;watch;create;update;patch;delete // Reconcile is part of the main kubernetes reconciliation loop which aims to // move the current state of the cluster closer to the desired state. @@ -264,6 +266,13 @@ func (r *OpenStackControlPlaneReconciler) reconcileNormal(ctx context.Context, i return ctrlResult, nil } + ctrlResult, err = openstack.ReconcileTelemetry(ctx, instance, helper) + if err != nil { + return ctrl.Result{}, err + } else if (ctrlResult != ctrl.Result{}) { + return ctrlResult, nil + } + return ctrl.Result{}, nil } @@ -288,5 +297,6 @@ func (r *OpenStackControlPlaneReconciler) SetupWithManager(mgr ctrl.Manager) err Owns(&ironicv1.Ironic{}). Owns(&clientv1beta1.OpenStackClient{}). Owns(&horizonv1.Horizon{}). + Owns(&telemetryv1.Telemetry{}). Complete(r) } diff --git a/custom-bundle.Dockerfile b/custom-bundle.Dockerfile index 9fb2605d..bf66fb86 100644 --- a/custom-bundle.Dockerfile +++ b/custom-bundle.Dockerfile @@ -12,6 +12,7 @@ ARG DATAPLANE_BUNDLE=quay.io/openstack-k8s-operators/dataplane-operator-bundle:l ARG NOVA_BUNDLE=quay.io/openstack-k8s-operators/nova-operator-bundle:latest ARG IRONIC_BUNDLE=quay.io/openstack-k8s-operators/ironic-operator-bundle:latest ARG BAREMETAL_BUNDLE=quay.io/openstack-k8s-operators/openstack-baremetal-operator-bundle:latest +ARG TELEMETRY_BUNDLE=quay.io/openstack-k8s-operators/telemetry-operator-bundle:latest # we obtain the needed ENV vars containing defaults from storage operators ARG OPENSTACK_STORAGE_BUNDLE=quay.io/openstack-k8s-operators/openstack-operator-storage-bundle:latest ARG HORIZON_BUNDLE=quay.io/openstack-k8s-operators/horizon-operator-bundle:latest @@ -50,6 +51,7 @@ FROM $DATAPLANE_BUNDLE as dataplane-bundle FROM $NOVA_BUNDLE as nova-bundle FROM $IRONIC_BUNDLE as ironic-bundle FROM $BAREMETAL_BUNDLE as baremetal-bundle +FROM $TELEMETRY_BUNDLE as telemetry-bundle FROM $OPENSTACK_STORAGE_BUNDLE as openstack-storage-bundle FROM $HORIZON_BUNDLE as horizon-bundle @@ -74,6 +76,7 @@ COPY --from=dataplane-bundle /manifests/* /manifests/ COPY --from=nova-bundle /manifests/* /manifests/ COPY --from=ironic-bundle /manifests/* /manifests/ COPY --from=baremetal-bundle /manifests/* /manifests/ +COPY --from=telemetry-bundle /manifests/* /manifests/ COPY --from=openstack-storage-bundle /env-vars.yaml /storage-env-vars.yaml COPY --from=horizon-bundle /manifests/* /manifests/ @@ -93,6 +96,7 @@ RUN /workspace/csv-merger \ --ironic-csv=/manifests/ironic-operator.clusterserviceversion.yaml \ --baremetal-csv=/manifests/openstack-baremetal-operator.clusterserviceversion.yaml \ --horizon-csv=/manifests/horizon-operator.clusterserviceversion.yaml \ + --telemetry-csv=/manifests/telemetry-operator.clusterserviceversion.yaml \ --base-csv=/manifests/openstack-operator.clusterserviceversion.yaml | tee /openstack-operator.clusterserviceversion.yaml.new # remove all individual operator CSV's diff --git a/go.mod b/go.mod index af1d8361..be480b99 100644 --- a/go.mod +++ b/go.mod @@ -24,6 +24,7 @@ require ( github.com/openstack-k8s-operators/ovn-operator/api v0.0.0-20230522062547-12905139513e github.com/openstack-k8s-operators/ovs-operator/api v0.0.0-20230517053110-2821a8dc05fd github.com/openstack-k8s-operators/placement-operator/api v0.0.0-20230517142510-5ebb403dc2f7 + github.com/openstack-k8s-operators/telemetry-operator/api v0.0.0-20230518150301-7e9c6a99c4e8 github.com/operator-framework/api v0.17.3 github.com/rabbitmq/cluster-operator v1.14.0 go.uber.org/zap v1.24.0 diff --git a/go.sum b/go.sum index 63a206a4..8208cb6a 100644 --- a/go.sum +++ b/go.sum @@ -170,6 +170,8 @@ github.com/openstack-k8s-operators/ovs-operator/api v0.0.0-20230517053110-2821a8 github.com/openstack-k8s-operators/ovs-operator/api v0.0.0-20230517053110-2821a8dc05fd/go.mod h1:KiYMGv1D3BcCS6RGrJ69uzsRLz0/b12VL8JGxbwNrgM= github.com/openstack-k8s-operators/placement-operator/api v0.0.0-20230517142510-5ebb403dc2f7 h1:Y1y8ElTKnWM1JUX93xYRH5pL4pPI0gfIp9wFMfXq90E= github.com/openstack-k8s-operators/placement-operator/api v0.0.0-20230517142510-5ebb403dc2f7/go.mod h1:B8j7ZNmgxranbjtKk6jzt5p3x0rCsqOJItjO/8r5jok= +github.com/openstack-k8s-operators/telemetry-operator/api v0.0.0-20230518150301-7e9c6a99c4e8 h1:5ysH++xPJKmKWnyLrIx7XOO0QSCkzJaJ66o6kqPX138= +github.com/openstack-k8s-operators/telemetry-operator/api v0.0.0-20230518150301-7e9c6a99c4e8/go.mod h1:YOXMu9ifbPTMd/t/QnSjg82gw4uVITpedcvOkTpLwJk= github.com/operator-framework/api v0.17.3 h1:wddE1SLKTNiIzwt28DbBIO+vPG2GOV6dkB9xBkDfT3o= github.com/operator-framework/api v0.17.3/go.mod h1:34tb98EwTN5SZLkgoxwvRkhMJKLHUWHOrrcv1ZwvEeA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -206,8 +208,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= diff --git a/main.go b/main.go index 42041945..da839d4f 100644 --- a/main.go +++ b/main.go @@ -48,6 +48,7 @@ import ( ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1" ovsv1 "github.com/openstack-k8s-operators/ovs-operator/api/v1beta1" placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1" + telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1" rabbitmqclusterv1 "github.com/rabbitmq/cluster-operator/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client/config" @@ -92,6 +93,7 @@ func init() { utilruntime.Must(manilav1.AddToScheme(scheme)) utilruntime.Must(horizonv1.AddToScheme(scheme)) utilruntime.Must(networkv1.AddToScheme(scheme)) + utilruntime.Must(telemetryv1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } @@ -313,4 +315,16 @@ func setupServiceOperatorDefaults() { } networkv1.SetupDNSMasqDefaults(dnsDefaults) + + // Telemetry + telemetryDefaults := telemetryv1.TelemetryDefaults{ + CentralContainerImageURL: os.Getenv("CEILOMETER_CENTRAL_IMAGE_URL_DEFAULT"), + CentralInitContainerImageURL: os.Getenv("CEILOMETER_CENTRAL_INIT_IMAGE_URL_DEFAULT"), + ComputeContainerImageURL: os.Getenv("CEILOMETER_COMPUTE_IMAGE_URL_DEFAULT"), + ComputeInitContainerImageURL: os.Getenv("CEILOMETER_COMPUTE_INIT_IMAGE_URL_DEFAULT"), + NotificationContainerImageURL: os.Getenv("CEILOMETER_NOTIFICATION_IMAGE_URL_DEFAULT"), + SgCoreContainerImageURL: os.Getenv("CEILOMETER_SGCORE_IMAGE_URL_DEFAULT"), + } + + telemetryv1.SetupTelemetryDefaults(telemetryDefaults) } diff --git a/pkg/openstack/telemetry.go b/pkg/openstack/telemetry.go new file mode 100644 index 00000000..e0dda450 --- /dev/null +++ b/pkg/openstack/telemetry.go @@ -0,0 +1,84 @@ +package openstack + +import ( + "context" + "fmt" + + "github.com/openstack-k8s-operators/lib-common/modules/common/condition" + "github.com/openstack-k8s-operators/lib-common/modules/common/helper" + + corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" +) + +const ( + telemetryNamespaceLabel = "Telemetry.Namespace" + telemetryNameLabel = "Telemetry.Name" + telemetryName = "telemetry" +) + +// ReconcileTelemetry ... +func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, helper *helper.Helper) (ctrl.Result, error) { + telemetry := &telemetryv1.Telemetry{ + ObjectMeta: metav1.ObjectMeta{ + Name: telemetryName, + Namespace: instance.Namespace, + }, + } + + if !instance.Spec.Telemetry.Enabled { + if res, err := EnsureDeleted(ctx, helper, telemetry); err != nil { + return res, err + } + instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneTelemetryReadyCondition) + return ctrl.Result{}, nil + } + + helper.GetLogger().Info("Reconciling Telemetry", telemetryNamespaceLabel, instance.Namespace, telemetryNameLabel, telemetryName) + op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), telemetry, func() error { + instance.Spec.Telemetry.Template.DeepCopyInto(&telemetry.Spec) + + if telemetry.Spec.CeilometerCentral.Secret == "" { + telemetry.Spec.CeilometerCentral.Secret = instance.Spec.Secret + } + + if telemetry.Spec.CeilometerCompute.Secret == "" { + telemetry.Spec.CeilometerCompute.Secret = instance.Spec.Secret + } + + err := controllerutil.SetControllerReference(helper.GetBeforeObject(), telemetry, helper.GetScheme()) + if err != nil { + return err + } + return nil + }) + + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + corev1beta1.OpenStackControlPlaneTelemetryReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + corev1beta1.OpenStackControlPlaneTelemetryReadyErrorMessage, + err.Error())) + return ctrl.Result{}, err + } + if op != controllerutil.OperationResultNone { + helper.GetLogger().Info(fmt.Sprintf("%s %s - %s", telemetryName, telemetry.Name, op)) + } + + if telemetry.IsReady() { + instance.Status.Conditions.MarkTrue(corev1beta1.OpenStackControlPlaneTelemetryReadyCondition, corev1beta1.OpenStackControlPlaneTelemetryReadyMessage) + } else { + instance.Status.Conditions.Set(condition.FalseCondition( + corev1beta1.OpenStackControlPlaneTelemetryReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + corev1beta1.OpenStackControlPlaneTelemetryReadyRunningMessage)) + } + + return ctrl.Result{}, nil +}