From 8b4ad2b851f6b4fae405a3108094ee29241cfaed Mon Sep 17 00:00:00 2001 From: dkehn Date: Wed, 11 Oct 2023 21:39:57 +0000 Subject: [PATCH] Designate-operator integration --- ....openstack.org_openstackcontrolplanes.yaml | 769 ++++++++++++++++++ apis/core/v1beta1/conditions.go | 18 + .../v1beta1/openstackcontrolplane_types.go | 24 + apis/core/v1beta1/zz_generated.deepcopy.go | 18 + apis/go.mod | 1 + apis/go.sum | 2 + ....openstack.org_openstackcontrolplanes.yaml | 769 ++++++++++++++++++ ...nstack-operator.clusterserviceversion.yaml | 13 + config/rbac/role.yaml | 12 + .../core_v1beta1_openstackcontrolplane.yaml | 14 + ...enstackcontrolplane_network_isolation.yaml | 30 + .../core/openstackcontrolplane_controller.go | 10 + go.mod | 1 + go.sum | 2 + main.go | 5 + pkg/openstack/designate.go | 134 +++ 16 files changed, 1822 insertions(+) create mode 100644 pkg/openstack/designate.go diff --git a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml index 97723274d..5458d6967 100644 --- a/apis/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/apis/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -1341,6 +1341,775 @@ spec: - secret type: object type: object + designate: + properties: + apiOverride: + properties: + route: + properties: + metadata: + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + type: object + spec: + properties: + alternateBackends: + items: + properties: + kind: + enum: + - Service + - "" + type: string + name: + type: string + weight: + format: int32 + maximum: 256 + minimum: 0 + type: integer + type: object + maxItems: 3 + type: array + host: + maxLength: 253 + pattern: ^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$ + type: string + path: + pattern: ^/ + type: string + port: + properties: + targetPort: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - targetPort + type: object + subdomain: + maxLength: 253 + pattern: ^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$ + type: string + tls: + properties: + caCertificate: + type: string + certificate: + type: string + destinationCACertificate: + type: string + insecureEdgeTerminationPolicy: + type: string + key: + type: string + termination: + enum: + - edge + - reencrypt + - passthrough + type: string + required: + - termination + type: object + to: + properties: + kind: + enum: + - Service + - "" + type: string + name: + type: string + weight: + format: int32 + maximum: 256 + minimum: 0 + type: integer + type: object + wildcardPolicy: + enum: + - None + - Subdomain + - "" + type: string + type: object + type: object + type: object + enabled: + default: false + type: boolean + template: + properties: + None: + type: string + backendMdnsServerProtocol: + type: string + backendWorkerServerProtocol: + type: string + customServiceConfig: + default: '# add your customization here' + type: string + databaseInstance: + type: string + databaseUser: + default: designate + type: string + debug: + properties: + dbInitContainer: + default: false + type: boolean + dbSync: + default: false + type: boolean + type: object + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + designateAPI: + properties: + None: + type: string + backendMdnsServerProtocol: + type: string + backendWorkerServerProtocol: + type: string + containerImage: + type: string + customServiceConfig: + type: string + customServiceConfigSecrets: + items: + type: string + type: array + databaseHostname: + type: string + databaseUser: + default: designate + type: string + debug: + properties: + initContainer: + default: false + type: boolean + service: + default: false + type: boolean + type: object + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + networkAttachments: + items: + type: string + type: array + nodeSelector: + additionalProperties: + type: string + type: object + override: + properties: + service: + additionalProperties: + properties: + endpointURL: + type: string + metadata: + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + type: object + spec: + properties: + externalName: + type: string + externalTrafficPolicy: + type: string + internalTrafficPolicy: + type: string + ipFamilyPolicy: + type: string + loadBalancerClass: + type: string + loadBalancerSourceRanges: + items: + type: string + type: array + sessionAffinity: + type: string + sessionAffinityConfig: + properties: + clientIP: + properties: + timeoutSeconds: + format: int32 + type: integer + type: object + type: object + type: + type: string + type: object + type: object + type: object + type: object + passwordSelectors: + default: + database: DesignateDatabasePassword + service: DesignatePassword + properties: + database: + default: DesignateDatabasePassword + type: string + service: + default: DesignatePassword + type: string + type: object + replicas: + default: 1 + format: int32 + maximum: 32 + minimum: 0 + type: integer + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + secret: + type: string + serviceAccount: + type: string + serviceUser: + default: designate + type: string + transportURLSecret: + type: string + required: + - containerImage + type: object + designateCentral: + properties: + None: + type: string + backendMdnsServerProtocol: + type: string + backendWorkerServerProtocol: + type: string + containerImage: + type: string + customServiceConfig: + type: string + customServiceConfigSecrets: + items: + type: string + type: array + databaseHostname: + type: string + databaseUser: + default: designate + type: string + debug: + properties: + initContainer: + default: false + type: boolean + service: + default: false + type: boolean + type: object + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + networkAttachments: + items: + type: string + type: array + nodeSelector: + additionalProperties: + type: string + type: object + passwordSelectors: + default: + database: DesignateDatabasePassword + service: DesignatePassword + properties: + database: + default: DesignateDatabasePassword + type: string + service: + default: DesignatePassword + type: string + type: object + replicas: + default: 1 + format: int32 + maximum: 32 + minimum: 0 + type: integer + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + secret: + type: string + serviceAccount: + type: string + serviceUser: + default: designate + type: string + transportURLSecret: + type: string + required: + - containerImage + type: object + designateMdns: + properties: + None: + type: string + backendMdnsServerProtocol: + type: string + backendWorkerServerProtocol: + type: string + containerImage: + type: string + customServiceConfig: + type: string + customServiceConfigSecrets: + items: + type: string + type: array + databaseHostname: + type: string + databaseUser: + default: designate + type: string + debug: + properties: + initContainer: + default: false + type: boolean + service: + default: false + type: boolean + type: object + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + networkAttachments: + items: + type: string + type: array + nodeSelector: + additionalProperties: + type: string + type: object + passwordSelectors: + default: + database: DesignateDatabasePassword + service: DesignatePassword + properties: + database: + default: DesignateDatabasePassword + type: string + service: + default: DesignatePassword + type: string + type: object + replicas: + default: 1 + format: int32 + maximum: 32 + minimum: 0 + type: integer + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + secret: + type: string + serviceAccount: + type: string + serviceUser: + default: designate + type: string + transportURLSecret: + type: string + required: + - containerImage + type: object + designateProducer: + properties: + None: + type: string + backendMdnsServerProtocol: + type: string + backendWorkerServerProtocol: + type: string + containerImage: + type: string + customServiceConfig: + type: string + customServiceConfigSecrets: + items: + type: string + type: array + databaseHostname: + type: string + databaseUser: + default: designate + type: string + debug: + properties: + initContainer: + default: false + type: boolean + service: + default: false + type: boolean + type: object + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + networkAttachments: + items: + type: string + type: array + nodeSelector: + additionalProperties: + type: string + type: object + passwordSelectors: + default: + database: DesignateDatabasePassword + service: DesignatePassword + properties: + database: + default: DesignateDatabasePassword + type: string + service: + default: DesignatePassword + type: string + type: object + replicas: + default: 1 + format: int32 + maximum: 32 + minimum: 0 + type: integer + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + secret: + type: string + serviceAccount: + type: string + serviceUser: + default: designate + type: string + transportURLSecret: + type: string + required: + - containerImage + type: object + designateWorker: + properties: + None: + type: string + backendMdnsServerProtocol: + type: string + backendWorkerServerProtocol: + type: string + containerImage: + type: string + customServiceConfig: + type: string + customServiceConfigSecrets: + items: + type: string + type: array + databaseHostname: + type: string + databaseUser: + default: designate + type: string + debug: + properties: + initContainer: + default: false + type: boolean + service: + default: false + type: boolean + type: object + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + networkAttachments: + items: + type: string + type: array + nodeSelector: + additionalProperties: + type: string + type: object + passwordSelectors: + default: + database: DesignateDatabasePassword + service: DesignatePassword + properties: + database: + default: DesignateDatabasePassword + type: string + service: + default: DesignatePassword + type: string + type: object + replicas: + default: 1 + format: int32 + maximum: 32 + minimum: 0 + type: integer + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + secret: + type: string + serviceAccount: + type: string + serviceUser: + default: designate + type: string + transportURLSecret: + type: string + required: + - containerImage + type: object + nodeSelector: + additionalProperties: + type: string + type: object + passwordSelectors: + default: + database: DesignateDatabasePassword + service: DesignatePassword + properties: + database: + default: DesignateDatabasePassword + type: string + service: + default: DesignatePassword + type: string + type: object + preserveJobs: + default: false + type: boolean + rabbitMqClusterName: + default: rabbitmq + type: string + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + secret: + type: string + serviceUser: + default: designate + type: string + required: + - designateAPI + - designateCentral + - designateMdns + - designateProducer + - designateWorker + - rabbitMqClusterName + - secret + type: object + type: object dns: properties: enabled: diff --git a/apis/core/v1beta1/conditions.go b/apis/core/v1beta1/conditions.go index 900b30888..1e416f9b1 100644 --- a/apis/core/v1beta1/conditions.go +++ b/apis/core/v1beta1/conditions.go @@ -141,11 +141,17 @@ const ( // OpenStackControlPlaneOctaviaReadyCondition Status=True condition which indicates if Octavia is configured and operational OpenStackControlPlaneOctaviaReadyCondition condition.Type = "OpenStackControlPlaneOctaviaReady" + // OpenStackControlPlaneDesignateReadyCondition Status=True condition which indicates if Designate is configured and operational + OpenStackControlPlaneDesignateReadyCondition condition.Type = "OpenStackControlPlaneDesignateReady" + // OpenStackControlPlaneRedisReadyCondition Status=True condition which indicates if Redis is configured and operational OpenStackControlPlaneRedisReadyCondition condition.Type = "OpenStackControlPlaneRedisReady" // OpenStackControlPlaneExposeOctaviaReadyCondition Status=True condition which indicates if Octavia is exposed via a route OpenStackControlPlaneExposeOctaviaReadyCondition condition.Type = "OpenStackControlPlaneExposeOctaviaReady" + + // OpenStackControlPlaneExposeDesignateReadyCondition Status=True condition which indicates if Designate is exposed via a route + OpenStackControlPlaneExposeDesignateReadyCondition condition.Type = "OpenStackControlPlaneExposeDesignateReady" ) // OpenStackControlPlane Reasons used by API objects. @@ -364,6 +370,18 @@ const ( // OpenStackControlPlaneOctaviaReadyErrorMessage OpenStackControlPlaneOctaviaReadyErrorMessage = "OpenStackControlPlane Octavia error occured %s" + // OpenStackControlPlaneDesignateReadyInitMessage + OpenStackControlPlaneDesignateReadyInitMessage = "OpenStackControlPlane Designate not started" + + // OpenStackControlPlaneDesignateReadyMessage + OpenStackControlPlaneDesignateReadyMessage = "OpenStackControlPlane Designate completed" + + // OpenStackControlPlaneDesignateReadyRunningMessage + OpenStackControlPlaneDesignateReadyRunningMessage = "OpenStackControlPlane Designate in progress" + + // OpenStackControlPlaneDesignateReadyErrorMessage + OpenStackControlPlaneDesignateReadyErrorMessage = "OpenStackControlPlane Designate error occured %s" + // OpenStackControlPlaneRedisReadyInitMessage OpenStackControlPlaneRedisReadyInitMessage = "OpenStackControlPlane Redis not started" diff --git a/apis/core/v1beta1/openstackcontrolplane_types.go b/apis/core/v1beta1/openstackcontrolplane_types.go index dde7f7e87..e91b2668c 100644 --- a/apis/core/v1beta1/openstackcontrolplane_types.go +++ b/apis/core/v1beta1/openstackcontrolplane_types.go @@ -34,6 +34,7 @@ import ( neutronv1 "github.com/openstack-k8s-operators/neutron-operator/api/v1beta1" novav1 "github.com/openstack-k8s-operators/nova-operator/api/v1beta1" octaviav1 "github.com/openstack-k8s-operators/octavia-operator/api/v1beta1" + designatev1 "github.com/openstack-k8s-operators/designate-operator/api/v1beta1" ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1" placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1" swiftv1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1" @@ -155,6 +156,9 @@ type OpenStackControlPlaneSpec struct { // Octavia - Parameters related to the Octavia service Octavia OctaviaSection `json:"octavia,omitempty"` + // Designate - Parameters related to the Designate service + Designate DesignateSection `json:"designate,omitempty"` + // Redis - Parameters related to the Redis service Redis RedisSection `json:"redis,omitempty"` @@ -547,6 +551,25 @@ type OctaviaSection struct { APIOverride Override `json:"apiOverride,omitempty"` } +// DesignateSection defines the desired state of the Designate service +type DesignateSection struct { + // +kubebuilder:validation:Optional + // Enabled - Whether the Designate service should be deployed and managed + // +kubebuilder:default=false + // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"} + Enabled bool `json:"enabled"` + + // +kubebuilder:valdiation:Optional + // +operator-sdk:csv:customresourcedefinitions:type=spec + // Template - Overrides to use when creating Designate Resources + Template designatev1.DesignateSpec `json:"template,omitempty"` + + // +kubebuilder:validation:Optional + // +operator-sdk:csv:customresourcedefinitions:type=spec + // APIOverride, provides the ability to override the generated manifest of several child resources. + APIOverride Override `json:"apiOverride,omitempty"` +} + // RedisSection defines the desired state of the Redis service type RedisSection struct { // +kubebuilder:validation:Optional @@ -641,6 +664,7 @@ func (instance *OpenStackControlPlane) InitConditions() { condition.UnknownCondition(OpenStackControlPlaneHeatReadyCondition, condition.InitReason, OpenStackControlPlaneHeatReadyInitMessage), condition.UnknownCondition(OpenStackControlPlaneSwiftReadyCondition, condition.InitReason, OpenStackControlPlaneSwiftReadyInitMessage), condition.UnknownCondition(OpenStackControlPlaneOctaviaReadyCondition, condition.InitReason, OpenStackControlPlaneOctaviaReadyInitMessage), + condition.UnknownCondition(OpenStackControlPlaneDesignateReadyCondition, condition.InitReason, OpenStackControlPlaneDesignateReadyInitMessage), condition.UnknownCondition(OpenStackControlPlaneRedisReadyCondition, condition.InitReason, OpenStackControlPlaneRedisReadyInitMessage), // Also add the overall status condition as Unknown diff --git a/apis/core/v1beta1/zz_generated.deepcopy.go b/apis/core/v1beta1/zz_generated.deepcopy.go index bbe5b7cdc..2c7985df3 100644 --- a/apis/core/v1beta1/zz_generated.deepcopy.go +++ b/apis/core/v1beta1/zz_generated.deepcopy.go @@ -81,6 +81,23 @@ func (in *DNSMasqSection) DeepCopy() *DNSMasqSection { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DesignateSection) DeepCopyInto(out *DesignateSection) { + *out = *in + in.Template.DeepCopyInto(&out.Template) + in.APIOverride.DeepCopyInto(&out.APIOverride) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DesignateSection. +func (in *DesignateSection) DeepCopy() *DesignateSection { + if in == nil { + return nil + } + out := new(DesignateSection) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GaleraSection) DeepCopyInto(out *GaleraSection) { *out = *in @@ -428,6 +445,7 @@ func (in *OpenStackControlPlaneSpec) DeepCopyInto(out *OpenStackControlPlaneSpec in.Ceilometer.DeepCopyInto(&out.Ceilometer) in.Swift.DeepCopyInto(&out.Swift) in.Octavia.DeepCopyInto(&out.Octavia) + in.Designate.DeepCopyInto(&out.Designate) in.Redis.DeepCopyInto(&out.Redis) if in.ExtraMounts != nil { in, out := &in.ExtraMounts, &out.ExtraMounts diff --git a/apis/go.mod b/apis/go.mod index 07a10826d..3e5bdeef7 100644 --- a/apis/go.mod +++ b/apis/go.mod @@ -7,6 +7,7 @@ require ( github.com/onsi/gomega v1.28.0 github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20231006133827-ce89e0fd01f2 github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20231010130554-ab1baca2edc1 + github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20231005181456-cbf92d9662db github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20231009062722-38938dcb2b5b github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20231009062721-cda11ea96e2b github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20231001103054-f74a88ed4971 diff --git a/apis/go.sum b/apis/go.sum index 0f517b874..c46341a74 100644 --- a/apis/go.sum +++ b/apis/go.sum @@ -136,6 +136,8 @@ github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20231009062722-389 github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20231009062722-38938dcb2b5b/go.mod h1:WPQCwaFKWwIEgqXjZRvJ7+bRUXF5Y/eAqKpBiCEe/Q4= github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20231009062721-cda11ea96e2b h1:nA/cI+2fPqcBvM0jCo/WsrngfQQEd8RSGBY7xdFMC+o= github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20231009062721-cda11ea96e2b/go.mod h1:fzzPZamjlU4RmXNBkTdV3zmuXQhRhzebC45OakaOZA0= +github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20231005181456-cbf92d9662db h1:p30j9aOE336NfA/cTvyd+d0t1B/PTzcyghwtVCKN3OQ= +github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20231005181456-cbf92d9662db/go.mod h1:fNgVy3LvqYF2jTelcaJKaWT0agEwBtJ++MXSdPT/BF4= github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20231001103054-f74a88ed4971 h1:5kNS+gseixkgRhYPukQVJyewPTM0lfUOmKP0A03wFFY= github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20231001103054-f74a88ed4971/go.mod h1:zqFs5MrBKeaE4HQroUgMWwIkBwmmcygg6sghcidSdCA= github.com/openstack-k8s-operators/ironic-operator/api v0.3.1-0.20231006045519-4d73854cb09a h1:22mc3Inf0bn4RYy6lnx4rT/wb21KVF8O6bFwyf+sTU8= diff --git a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml index 97723274d..5458d6967 100644 --- a/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml +++ b/config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml @@ -1341,6 +1341,775 @@ spec: - secret type: object type: object + designate: + properties: + apiOverride: + properties: + route: + properties: + metadata: + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + type: object + spec: + properties: + alternateBackends: + items: + properties: + kind: + enum: + - Service + - "" + type: string + name: + type: string + weight: + format: int32 + maximum: 256 + minimum: 0 + type: integer + type: object + maxItems: 3 + type: array + host: + maxLength: 253 + pattern: ^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$ + type: string + path: + pattern: ^/ + type: string + port: + properties: + targetPort: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - targetPort + type: object + subdomain: + maxLength: 253 + pattern: ^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$ + type: string + tls: + properties: + caCertificate: + type: string + certificate: + type: string + destinationCACertificate: + type: string + insecureEdgeTerminationPolicy: + type: string + key: + type: string + termination: + enum: + - edge + - reencrypt + - passthrough + type: string + required: + - termination + type: object + to: + properties: + kind: + enum: + - Service + - "" + type: string + name: + type: string + weight: + format: int32 + maximum: 256 + minimum: 0 + type: integer + type: object + wildcardPolicy: + enum: + - None + - Subdomain + - "" + type: string + type: object + type: object + type: object + enabled: + default: false + type: boolean + template: + properties: + None: + type: string + backendMdnsServerProtocol: + type: string + backendWorkerServerProtocol: + type: string + customServiceConfig: + default: '# add your customization here' + type: string + databaseInstance: + type: string + databaseUser: + default: designate + type: string + debug: + properties: + dbInitContainer: + default: false + type: boolean + dbSync: + default: false + type: boolean + type: object + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + designateAPI: + properties: + None: + type: string + backendMdnsServerProtocol: + type: string + backendWorkerServerProtocol: + type: string + containerImage: + type: string + customServiceConfig: + type: string + customServiceConfigSecrets: + items: + type: string + type: array + databaseHostname: + type: string + databaseUser: + default: designate + type: string + debug: + properties: + initContainer: + default: false + type: boolean + service: + default: false + type: boolean + type: object + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + networkAttachments: + items: + type: string + type: array + nodeSelector: + additionalProperties: + type: string + type: object + override: + properties: + service: + additionalProperties: + properties: + endpointURL: + type: string + metadata: + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + type: object + spec: + properties: + externalName: + type: string + externalTrafficPolicy: + type: string + internalTrafficPolicy: + type: string + ipFamilyPolicy: + type: string + loadBalancerClass: + type: string + loadBalancerSourceRanges: + items: + type: string + type: array + sessionAffinity: + type: string + sessionAffinityConfig: + properties: + clientIP: + properties: + timeoutSeconds: + format: int32 + type: integer + type: object + type: object + type: + type: string + type: object + type: object + type: object + type: object + passwordSelectors: + default: + database: DesignateDatabasePassword + service: DesignatePassword + properties: + database: + default: DesignateDatabasePassword + type: string + service: + default: DesignatePassword + type: string + type: object + replicas: + default: 1 + format: int32 + maximum: 32 + minimum: 0 + type: integer + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + secret: + type: string + serviceAccount: + type: string + serviceUser: + default: designate + type: string + transportURLSecret: + type: string + required: + - containerImage + type: object + designateCentral: + properties: + None: + type: string + backendMdnsServerProtocol: + type: string + backendWorkerServerProtocol: + type: string + containerImage: + type: string + customServiceConfig: + type: string + customServiceConfigSecrets: + items: + type: string + type: array + databaseHostname: + type: string + databaseUser: + default: designate + type: string + debug: + properties: + initContainer: + default: false + type: boolean + service: + default: false + type: boolean + type: object + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + networkAttachments: + items: + type: string + type: array + nodeSelector: + additionalProperties: + type: string + type: object + passwordSelectors: + default: + database: DesignateDatabasePassword + service: DesignatePassword + properties: + database: + default: DesignateDatabasePassword + type: string + service: + default: DesignatePassword + type: string + type: object + replicas: + default: 1 + format: int32 + maximum: 32 + minimum: 0 + type: integer + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + secret: + type: string + serviceAccount: + type: string + serviceUser: + default: designate + type: string + transportURLSecret: + type: string + required: + - containerImage + type: object + designateMdns: + properties: + None: + type: string + backendMdnsServerProtocol: + type: string + backendWorkerServerProtocol: + type: string + containerImage: + type: string + customServiceConfig: + type: string + customServiceConfigSecrets: + items: + type: string + type: array + databaseHostname: + type: string + databaseUser: + default: designate + type: string + debug: + properties: + initContainer: + default: false + type: boolean + service: + default: false + type: boolean + type: object + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + networkAttachments: + items: + type: string + type: array + nodeSelector: + additionalProperties: + type: string + type: object + passwordSelectors: + default: + database: DesignateDatabasePassword + service: DesignatePassword + properties: + database: + default: DesignateDatabasePassword + type: string + service: + default: DesignatePassword + type: string + type: object + replicas: + default: 1 + format: int32 + maximum: 32 + minimum: 0 + type: integer + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + secret: + type: string + serviceAccount: + type: string + serviceUser: + default: designate + type: string + transportURLSecret: + type: string + required: + - containerImage + type: object + designateProducer: + properties: + None: + type: string + backendMdnsServerProtocol: + type: string + backendWorkerServerProtocol: + type: string + containerImage: + type: string + customServiceConfig: + type: string + customServiceConfigSecrets: + items: + type: string + type: array + databaseHostname: + type: string + databaseUser: + default: designate + type: string + debug: + properties: + initContainer: + default: false + type: boolean + service: + default: false + type: boolean + type: object + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + networkAttachments: + items: + type: string + type: array + nodeSelector: + additionalProperties: + type: string + type: object + passwordSelectors: + default: + database: DesignateDatabasePassword + service: DesignatePassword + properties: + database: + default: DesignateDatabasePassword + type: string + service: + default: DesignatePassword + type: string + type: object + replicas: + default: 1 + format: int32 + maximum: 32 + minimum: 0 + type: integer + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + secret: + type: string + serviceAccount: + type: string + serviceUser: + default: designate + type: string + transportURLSecret: + type: string + required: + - containerImage + type: object + designateWorker: + properties: + None: + type: string + backendMdnsServerProtocol: + type: string + backendWorkerServerProtocol: + type: string + containerImage: + type: string + customServiceConfig: + type: string + customServiceConfigSecrets: + items: + type: string + type: array + databaseHostname: + type: string + databaseUser: + default: designate + type: string + debug: + properties: + initContainer: + default: false + type: boolean + service: + default: false + type: boolean + type: object + defaultConfigOverwrite: + additionalProperties: + type: string + type: object + networkAttachments: + items: + type: string + type: array + nodeSelector: + additionalProperties: + type: string + type: object + passwordSelectors: + default: + database: DesignateDatabasePassword + service: DesignatePassword + properties: + database: + default: DesignateDatabasePassword + type: string + service: + default: DesignatePassword + type: string + type: object + replicas: + default: 1 + format: int32 + maximum: 32 + minimum: 0 + type: integer + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + secret: + type: string + serviceAccount: + type: string + serviceUser: + default: designate + type: string + transportURLSecret: + type: string + required: + - containerImage + type: object + nodeSelector: + additionalProperties: + type: string + type: object + passwordSelectors: + default: + database: DesignateDatabasePassword + service: DesignatePassword + properties: + database: + default: DesignateDatabasePassword + type: string + service: + default: DesignatePassword + type: string + type: object + preserveJobs: + default: false + type: boolean + rabbitMqClusterName: + default: rabbitmq + type: string + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + secret: + type: string + serviceUser: + default: designate + type: string + required: + - designateAPI + - designateCentral + - designateMdns + - designateProducer + - designateWorker + - rabbitMqClusterName + - secret + type: object + type: object dns: properties: enabled: diff --git a/config/manifests/bases/openstack-operator.clusterserviceversion.yaml b/config/manifests/bases/openstack-operator.clusterserviceversion.yaml index f9e92873d..3f7044a69 100644 --- a/config/manifests/bases/openstack-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/openstack-operator.clusterserviceversion.yaml @@ -50,6 +50,19 @@ spec: - description: Template - Overrides to use when creating Cinder Resources displayName: Template path: cinder.template + - description: APIOverride, provides the ability to override the generated manifest + of several child resources. + displayName: APIOverride + path: designate.apiOverride + - description: Enabled - Whether the Designate service should be deployed and + managed + displayName: Enabled + path: designate.enabled + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:booleanSwitch + - description: Template - Overrides to use when creating Designate Resources + displayName: Template + path: designate.template - description: DNS - Parameters related to the DNSMasq service displayName: DNS path: dns diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 6c13715fa..f6ca00ddc 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -114,6 +114,18 @@ rules: - get - patch - update +- apiGroups: + - designate.openstack.org + resources: + - designates + verbs: + - create + - delete + - get + - list + - patch + - update + - watch - apiGroups: - glance.openstack.org resources: diff --git a/config/samples/core_v1beta1_openstackcontrolplane.yaml b/config/samples/core_v1beta1_openstackcontrolplane.yaml index 8ad4d51cd..9f7cf0fe5 100644 --- a/config/samples/core_v1beta1_openstackcontrolplane.yaml +++ b/config/samples/core_v1beta1_openstackcontrolplane.yaml @@ -152,3 +152,17 @@ spec: secret: osp-secret redis: enabled: false + cwdesignate: + template: + databaseInstance: openstack + secret: osp-secret + designateAPI: + replicas: 1 + designateCentral: + replicas: 0 # backend needs to be configured + designateWorker: + replicas: 0 # backend needs to be configured + designateProducer: + replicas: 0 # backend needs to be configured + designateMdns: + replicas: 0 # backend needs to be configured diff --git a/config/samples/core_v1beta1_openstackcontrolplane_network_isolation.yaml b/config/samples/core_v1beta1_openstackcontrolplane_network_isolation.yaml index 0619f35d2..de50e7540 100644 --- a/config/samples/core_v1beta1_openstackcontrolplane_network_isolation.yaml +++ b/config/samples/core_v1beta1_openstackcontrolplane_network_isolation.yaml @@ -310,3 +310,33 @@ spec: secret: osp-secret redis: enabled: false + cinder: + enabled: false + apiOverride: + route: {} + template: + databaseInstance: openstack + secret: osp-secret + desiganteAPI: + override: + service: + internal: + metadata: + annotations: + metallb.universe.tf/address-pool: internalapi + metallb.universe.tf/allow-shared-ip: internalapi + metallb.universe.tf/loadBalancerIPs: 172.17.0.80 + spec: + type: LoadBalancer + designateCentral: + replicas: 1 + designateWorker: + replicas: 0 + networkAttachements: + - designate + designateProducer: + replicas: 0 + designateMdn: + replicas: 0 + networkAttachements: + - designate diff --git a/controllers/core/openstackcontrolplane_controller.go b/controllers/core/openstackcontrolplane_controller.go index 2ce0515f1..b02200e66 100644 --- a/controllers/core/openstackcontrolplane_controller.go +++ b/controllers/core/openstackcontrolplane_controller.go @@ -32,6 +32,7 @@ import ( condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" "github.com/openstack-k8s-operators/lib-common/modules/common/helper" + designatev1 "github.com/openstack-k8s-operators/designate-operator/api/v1beta1" manilav1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1" mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" neutronv1 "github.com/openstack-k8s-operators/neutron-operator/api/v1beta1" @@ -90,6 +91,7 @@ type OpenStackControlPlaneReconciler struct { //+kubebuilder:rbac:groups=telemetry.openstack.org,resources=ceilometers,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=swift.openstack.org,resources=swifts,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=octavia.openstack.org,resources=octavias,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=designate.openstack.org,resources=designates,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=redis.openstack.org,resources=redises,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=route.openshift.io,resources=routes,verbs=get;list;watch;create;update;patch;delete; //+kubebuilder:rbac:groups=route.openshift.io,resources=routes/custom-host,verbs=create;update;patch @@ -311,6 +313,13 @@ func (r *OpenStackControlPlaneReconciler) reconcileNormal(ctx context.Context, i return ctrlResult, nil } + ctrlResult, err = openstack.ReconcileDesignate(ctx, instance, helper) + if err != nil { + return ctrl.Result{}, err + } else if (ctrlResult != ctrl.Result{}) { + return ctrlResult, nil + } + return ctrl.Result{}, nil } @@ -339,6 +348,7 @@ func (r *OpenStackControlPlaneReconciler) SetupWithManager(mgr ctrl.Manager) err Owns(&telemetryv1.Ceilometer{}). Owns(&redisv1.Redis{}). Owns(&octaviav1.Octavia{}). + Owns(&designatev1.Designate{}). Owns(&routev1.Route{}). Complete(r) } diff --git a/go.mod b/go.mod index c0f7ca06d..e65941b12 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20231006133827-ce89e0fd01f2 github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20231012070625-9e18aa48308d github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20231010130554-ab1baca2edc1 + github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20231005181456-cbf92d9662db github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20231009062722-38938dcb2b5b github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20231009062721-cda11ea96e2b github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20231001103054-f74a88ed4971 diff --git a/go.sum b/go.sum index aee3c5f15..e99c8c172 100644 --- a/go.sum +++ b/go.sum @@ -145,6 +145,8 @@ github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20231009062722-389 github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20231009062722-38938dcb2b5b/go.mod h1:WPQCwaFKWwIEgqXjZRvJ7+bRUXF5Y/eAqKpBiCEe/Q4= github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20231009062721-cda11ea96e2b h1:nA/cI+2fPqcBvM0jCo/WsrngfQQEd8RSGBY7xdFMC+o= github.com/openstack-k8s-operators/horizon-operator/api v0.3.1-0.20231009062721-cda11ea96e2b/go.mod h1:fzzPZamjlU4RmXNBkTdV3zmuXQhRhzebC45OakaOZA0= +github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20231005181456-cbf92d9662db h1:p30j9aOE336NfA/cTvyd+d0t1B/PTzcyghwtVCKN3OQ= +github.com/openstack-k8s-operators/designate-operator/api v0.0.0-20231005181456-cbf92d9662db/go.mod h1:fNgVy3LvqYF2jTelcaJKaWT0agEwBtJ++MXSdPT/BF4= github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20231001103054-f74a88ed4971 h1:5kNS+gseixkgRhYPukQVJyewPTM0lfUOmKP0A03wFFY= github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20231001103054-f74a88ed4971/go.mod h1:zqFs5MrBKeaE4HQroUgMWwIkBwmmcygg6sghcidSdCA= github.com/openstack-k8s-operators/ironic-operator/api v0.3.1-0.20231006045519-4d73854cb09a h1:22mc3Inf0bn4RYy6lnx4rT/wb21KVF8O6bFwyf+sTU8= diff --git a/main.go b/main.go index 8d2816934..24fda0ae1 100644 --- a/main.go +++ b/main.go @@ -30,6 +30,7 @@ import ( cinderv1 "github.com/openstack-k8s-operators/cinder-operator/api/v1beta1" dataplanev1beta1 "github.com/openstack-k8s-operators/dataplane-operator/api/v1beta1" + designatev1 "github.com/openstack-k8s-operators/designate-operator/api/v1beta1" glancev1 "github.com/openstack-k8s-operators/glance-operator/api/v1beta1" heatv1 "github.com/openstack-k8s-operators/heat-operator/api/v1beta1" horizonv1 "github.com/openstack-k8s-operators/horizon-operator/api/v1beta1" @@ -91,6 +92,7 @@ func init() { utilruntime.Must(ovnv1.AddToScheme(scheme)) utilruntime.Must(neutronv1.AddToScheme(scheme)) utilruntime.Must(octaviav1.AddToScheme(scheme)) + utilruntime.Must(designatev1.AddToScheme(scheme)) utilruntime.Must(dataplanev1beta1.AddToScheme(scheme)) utilruntime.Must(ansibleeev1.AddToScheme(scheme)) utilruntime.Must(rabbitmqv1.AddToScheme(scheme)) @@ -281,4 +283,7 @@ func setupServiceOperatorDefaults() { // Octavia octaviav1.SetupDefaults() + + // Designate + designatev1.SetupDefaults() } diff --git a/pkg/openstack/designate.go b/pkg/openstack/designate.go new file mode 100644 index 000000000..58374e1ad --- /dev/null +++ b/pkg/openstack/designate.go @@ -0,0 +1,134 @@ +package openstack + +import ( + "context" + "fmt" + + "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/helper" + "github.com/openstack-k8s-operators/lib-common/modules/common/service" + + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + "sigs.k8s.io/controller-runtime/pkg/reconcile" + + designatev1 "github.com/openstack-k8s-operators/designate-operator/api/v1beta1" + corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + k8s_errors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + ctrl "sigs.k8s.io/controller-runtime" +) + +// ReconcileDesignate - +func ReconcileDesignate(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, helper *helper.Helper) (ctrl.Result, error) { + designate := &designatev1.Designate{ + ObjectMeta: metav1.ObjectMeta{ + Name: "designate", + Namespace: instance.Namespace, + }, + } + + if !instance.Spec.Designate.Enabled { + if res, err := EnsureDeleted(ctx, helper, designate); err != nil { + return res, err + } + instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneDesignateReadyCondition) + instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneExposeDesignateReadyCondition) + return ctrl.Result{}, nil + } + + // add selector to service overrides + for _, endpointType := range []service.Endpoint{service.EndpointPublic, service.EndpointInternal} { + if instance.Spec.Designate.Template.DesignateAPI.Override.Service == nil { + instance.Spec.Designate.Template.DesignateAPI.Override.Service = map[service.Endpoint]service.RoutedOverrideSpec{} + } + instance.Spec.Designate.Template.DesignateAPI.Override.Service[endpointType] = + AddServiceComponentLabel( + instance.Spec.Designate.Template.DesignateAPI.Override.Service[endpointType], + designate.Name) + } + + // When component services got created check if there is the need to create a route + if err := helper.GetClient().Get(ctx, types.NamespacedName{Name: "designate", Namespace: instance.Namespace}, designate); err != nil { + if !k8s_errors.IsNotFound(err) { + return ctrl.Result{}, err + } + } + + if designate.Status.Conditions.IsTrue(designatev1.DesignateAPIReadyCondition) { + svcs, err := service.GetServicesListWithLabel( + ctx, + helper, + instance.Namespace, + map[string]string{common.AppSelector: designate.Name}, + ) + if err != nil { + return ctrl.Result{}, err + } + + var ctrlResult reconcile.Result + instance.Spec.Designate.Template.DesignateAPI.Override.Service, ctrlResult, err = EnsureRoute( + ctx, + instance, + helper, + designate, + svcs, + instance.Spec.Designate.Template.DesignateAPI.Override.Service, + instance.Spec.Designate.APIOverride.Route, + corev1beta1.OpenStackControlPlaneExposeDesignateReadyCondition, + ) + if err != nil { + return ctrlResult, err + } else if (ctrlResult != ctrl.Result{}) { + return ctrlResult, nil + } + } + + helper.GetLogger().Info("Reconciling Designate", "Designate.Namespace", instance.Namespace, "Designate.Name", "designate") + op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), designate, func() error { + instance.Spec.Designate.Template.DeepCopyInto(&designate.Spec) + + if designate.Spec.Secret == "" { + designate.Spec.Secret = instance.Spec.Secret + } + if designate.Spec.NodeSelector == nil && instance.Spec.NodeSelector != nil { + designate.Spec.NodeSelector = instance.Spec.NodeSelector + } + if designate.Spec.DatabaseInstance == "" { + //designate.Spec.DatabaseInstance = instance.Name // name of MariaDB we create here + designate.Spec.DatabaseInstance = "openstack" //FIXME: see above + } + err := controllerutil.SetControllerReference(helper.GetBeforeObject(), designate, helper.GetScheme()) + if err != nil { + return err + } + return nil + }) + + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + corev1beta1.OpenStackControlPlaneDesignateReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + corev1beta1.OpenStackControlPlaneDesignateReadyErrorMessage, + err.Error())) + return ctrl.Result{}, err + } + if op != controllerutil.OperationResultNone { + helper.GetLogger().Info(fmt.Sprintf("Designate %s - %s", designate.Name, op)) + } + + if designate.IsReady() { + instance.Status.Conditions.MarkTrue(corev1beta1.OpenStackControlPlaneDesignateReadyCondition, corev1beta1.OpenStackControlPlaneDesignateReadyMessage) + } else { + instance.Status.Conditions.Set(condition.FalseCondition( + corev1beta1.OpenStackControlPlaneDesignateReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + corev1beta1.OpenStackControlPlaneDesignateReadyRunningMessage)) + } + + return ctrl.Result{}, nil + +}