Skip to content

Commit

Permalink
Update cinderapi to use service override
Browse files Browse the repository at this point in the history
Removes creation of routes.Those get done in the openstack-operator.
Via service overrides the service can be customized. The service operator
adds annotation to the service which needs to be exposed as a route.

Jira: OSP-26690

Depends-On: openstack-k8s-operators/lib-common#332
  • Loading branch information
stuggi committed Sep 20, 2023
1 parent e8e5fb3 commit 16d83ab
Show file tree
Hide file tree
Showing 16 changed files with 393 additions and 284 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,16 @@ spec:
...
cinderAPI:
...
externalEndpoints:
- endpoint: internal
ipAddressPool: osp-internalapi
loadBalancerIPs:
- 172.17.0.202
sharedIP: true
sharedIPKey: ""
override:
service:
internal:
metadata:
annotations:
metallb.universe.tf/address-pool: osp-internalapi
metallb.universe.tf/allow-shared-ip: internalapi
metallb.universe.tf/loadBalancerIPs: 172.17.0.202
spec:
type: LoadBalancer
...
...
```
Expand Down
77 changes: 51 additions & 26 deletions api/bases/cinder.openstack.org_cinderapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,6 @@ spec:
additionalProperties:
type: string
type: object
externalEndpoints:
items:
properties:
endpoint:
enum:
- internal
- public
type: string
ipAddressPool:
minLength: 1
type: string
loadBalancerIPs:
items:
type: string
type: array
sharedIP:
default: true
type: boolean
sharedIPKey:
default: ""
type: string
required:
- endpoint
- ipAddressPool
type: object
type: array
extraMounts:
items:
properties:
Expand Down Expand Up @@ -853,6 +827,57 @@ spec:
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: CinderDatabasePassword
Expand Down
77 changes: 51 additions & 26 deletions api/bases/cinder.openstack.org_cinders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,6 @@ spec:
additionalProperties:
type: string
type: object
externalEndpoints:
items:
properties:
endpoint:
enum:
- internal
- public
type: string
ipAddressPool:
minLength: 1
type: string
loadBalancerIPs:
items:
type: string
type: array
sharedIP:
default: true
type: boolean
sharedIPKey:
default: ""
type: string
required:
- endpoint
- ipAddressPool
type: object
type: array
networkAttachments:
items:
type: string
Expand All @@ -90,6 +64,57 @@ spec:
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
replicas:
default: 1
format: int32
Expand Down
15 changes: 7 additions & 8 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ go 1.19
require (
github.com/onsi/ginkgo/v2 v2.12.0
github.com/onsi/gomega v1.27.10
github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230913075424-2680ce4b6ad2
github.com/openstack-k8s-operators/lib-common/modules/storage v0.1.1-0.20230913075424-2680ce4b6ad2
k8s.io/api v0.26.8
k8s.io/apimachinery v0.26.8
k8s.io/client-go v0.26.8
github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230919113507-d74c2f31d216
github.com/openstack-k8s-operators/lib-common/modules/storage v0.1.1-0.20230919113507-d74c2f31d216
k8s.io/api v0.26.9
k8s.io/apimachinery v0.26.9
k8s.io/client-go v0.26.9
sigs.k8s.io/controller-runtime v0.14.6
)

Expand Down Expand Up @@ -46,7 +46,6 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/openshift/api v3.9.0+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
Expand All @@ -67,8 +66,8 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.26.8 //indirect
k8s.io/component-base v0.26.8 //indirect
k8s.io/apiextensions-apiserver v0.26.9 //indirect
k8s.io/component-base v0.26.9 //indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230327201221-f5883ff37f0c //indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
Expand Down
30 changes: 14 additions & 16 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,10 @@ github.com/onsi/ginkgo/v2 v2.12.0 h1:UIVDowFPwpg6yMUpPjGkYvf06K3RAiJXUhCxEwQVHRI
github.com/onsi/ginkgo/v2 v2.12.0/go.mod h1:ZNEzXISYlqpb8S36iN71ifqLi3vVD1rVJGvWRCJOUpQ=
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 h1:rncLxJBpFGqBztyxCMwNRnMjhhIDOWHJowi6q8G6koI=
github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7/go.mod h1:ctXNyWanKEjGj8sss1KjjHQ3ENKFm33FFnS5BKaIPh4=
github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230913075424-2680ce4b6ad2 h1:/ez+9PSwtucQ9v1I5X72xlP5UJztTMPH4M5gDAJAatc=
github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230913075424-2680ce4b6ad2/go.mod h1:bG2JdbaO4bR4u8rtXZ7MgmMELuEseTkL2BPgk9JBYmY=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.1.1-0.20230913075424-2680ce4b6ad2 h1:WqquubnK/hLqeZpTnNjjBCloo3HgvKhCrhEDNyQg21I=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.1.1-0.20230913075424-2680ce4b6ad2/go.mod h1:UKzRiNlmYVIE7Ggc6+qd7MMrNBL20sgW46rhP+U0Ilc=
github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230919113507-d74c2f31d216 h1:arYbQA6bLyXJkHm+6M6gPc4YpWMFjs5qkG16Yii4UDo=
github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230919113507-d74c2f31d216/go.mod h1:Ge7Yf6AUmjEvJK9AIW2bT5udLzBIcK59b1QxqymncaQ=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.1.1-0.20230919113507-d74c2f31d216 h1:1dMwzjuZJSRgHcwblOo6jHrWAe2anwWu4w35Rukz1kw=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.1.1-0.20230919113507-d74c2f31d216/go.mod h1:DnsRBWOFEwecwrVAntM4lbgiHRvqfoz/gKYpDjkvCYE=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down Expand Up @@ -633,16 +631,16 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.26.8 h1:k2OtFmQPWfDUyAuYAwQPftVygF/vz4BMGSKnd15iddM=
k8s.io/api v0.26.8/go.mod h1:QaflR7cmG3V9lIz0VLBM+ylndNN897OAUAoJDcgwiQw=
k8s.io/apiextensions-apiserver v0.26.8 h1:ESVQ22MH6YfcpflpZMIvkgnHs/EwOgKKSCkS9AfxJOY=
k8s.io/apiextensions-apiserver v0.26.8/go.mod h1:ySo6rPc9ulNtKoZczw7ljCAdZN3DbyxLNat8wuYk4r8=
k8s.io/apimachinery v0.26.8 h1:SzpGtRX3/j/Ylg8Eg65Iobpxi9Jz4vOvI0qcBZyPVrM=
k8s.io/apimachinery v0.26.8/go.mod h1:qYzLkrQ9lhrZRh0jNKo2cfvf/R1/kQONnSiyB7NUJU0=
k8s.io/client-go v0.26.8 h1:pPuTYaVtLlg/7n6rqs3MsKLi4XgNaJ3rTMyS37Y5CKU=
k8s.io/client-go v0.26.8/go.mod h1:1sBQqKmdy9rWZYQnoedpc0gnRXG7kU3HrKZvBe2QbGM=
k8s.io/component-base v0.26.8 h1:j+W9y9id4CLW85+5GhRMgcYLaezw6bK+ZQ2eN3uZtJc=
k8s.io/component-base v0.26.8/go.mod h1:tOQmHjTJBLjzWLWqbxz7sVgX9XMMphEcy0tWhk+u2BI=
k8s.io/api v0.26.9 h1:s8Y+G1u2JM55b90+Yo2RVb3PGT/hkWNVPN4idPERxJg=
k8s.io/api v0.26.9/go.mod h1:W/W4fEWRVzPD36820LlVUQfNBiSbiq0VPWRFJKwzmUg=
k8s.io/apiextensions-apiserver v0.26.9 h1:aJqWRuBj9i9J6tIDniqUDYM5QCRajTKXK/GO+zEccGQ=
k8s.io/apiextensions-apiserver v0.26.9/go.mod h1:L1uysxOP2kC1vkZTlHGUlUl5WSpa7e4GHJmGEZY7yLg=
k8s.io/apimachinery v0.26.9 h1:5yAV9cFR7Z4gIorKcAjWnx4uxtxiFsERwq4Pvmx0CCg=
k8s.io/apimachinery v0.26.9/go.mod h1:qYzLkrQ9lhrZRh0jNKo2cfvf/R1/kQONnSiyB7NUJU0=
k8s.io/client-go v0.26.9 h1:TGWi/6guEjIgT0Hg871Gsmx0qFuoGyGFjlFedrk7It0=
k8s.io/client-go v0.26.9/go.mod h1:tU1FZS0bwAmAFyPYpZycUQrQnUMzQ5MHloop7EbX6ow=
k8s.io/component-base v0.26.9 h1:qQVdQgyEIUe8EUkB3EEuQ9l5sgVlG2KgOB519yWEBGw=
k8s.io/component-base v0.26.9/go.mod h1:3WmW9lH9tbjpuvpAc22cPF/6C3VxCjMxkOU1j2mpzr8=
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/kube-openapi v0.0.0-20230327201221-f5883ff37f0c h1:EFfsozyzZ/pggw5qNx7ftTVZdp7WZl+3ih89GEjYEK8=
Expand Down
12 changes: 10 additions & 2 deletions api/v1beta1/cinderapi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -33,8 +34,15 @@ type CinderAPITemplate struct {
Replicas *int32 `json:"replicas"`

// +kubebuilder:validation:Optional
// ExternalEndpoints, expose a VIP via MetalLB on the pre-created address pool
ExternalEndpoints []MetalLBConfig `json:"externalEndpoints,omitempty"`
// Override, provides the ability to override the generated manifest of several child resources.
Override APIOverrideSpec `json:"override,omitempty"`
}

// APIOverrideSpec to override the generated manifest of several child resources.
type APIOverrideSpec struct {
// Override configuration for the Service created to serve traffic to the cluster.
// The key must be the endpoint type (public, internal)
Service map[service.Endpoint]service.RoutedOverrideSpec `json:"service,omitempty"`
}

// CinderAPISpec defines the desired state of CinderAPI
Expand Down
30 changes: 0 additions & 30 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package v1beta1

import (
"github.com/openstack-k8s-operators/lib-common/modules/common/endpoint"
corev1 "k8s.io/api/core/v1"
)

Expand Down Expand Up @@ -119,32 +118,3 @@ type CinderServiceDebug struct {
// service enable debug
Service bool `json:"service"`
}

// MetalLBConfig to configure the MetalLB loadbalancer service
type MetalLBConfig struct {
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=internal;public
// Endpoint, OpenStack endpoint this service maps to
Endpoint endpoint.Endpoint `json:"endpoint"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
// IPAddressPool expose VIP via MetalLB on the IPAddressPool
IPAddressPool string `json:"ipAddressPool"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=true
// SharedIP if true, VIP/VIPs get shared with multiple services
SharedIP bool `json:"sharedIP"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=""
// SharedIPKey specifies the sharing key which gets set as the annotation on the LoadBalancer service.
// Services which share the same VIP must have the same SharedIPKey. Defaults to the IPAddressPool if
// SharedIP is true, but no SharedIPKey specified.
SharedIPKey string `json:"sharedIPKey"`

// +kubebuilder:validation:Optional
// LoadBalancerIPs, request given IPs from the pool if available. Using a list to allow dual stack (IPv4/IPv6) support
LoadBalancerIPs []string `json:"loadBalancerIPs,omitempty"`
}
Loading

0 comments on commit 16d83ab

Please sign in to comment.