Skip to content

Commit

Permalink
Update glanceapi 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 11, 2023
1 parent 0adffaa commit 11d8449
Show file tree
Hide file tree
Showing 19 changed files with 556 additions and 329 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ sh-5.1# ip a
## Example: expose Glance to an isolated network

The Glance spec can be used to configure Glance to register e.g.
the internal endpoint to an isolated network. MetalLB is used for this
the internal endpoint to an isolated network. MetalLB can be used for this
scenario.

As a pre requisite, MetalLB needs to be installed and worker nodes
Expand Down Expand Up @@ -413,13 +413,15 @@ spec:
...
glanceAPIInternal:
...
externalEndpoints:
- endpoint: internal
ipAddressPool: osp-internalapi
loadBalancerIPs:
- "172.17.0.202"
sharedIP: true
sharedIPKey: ""
override:
service:
metadata:
annotations:
metallb.universe.tf/address-pool: internalapi
metallb.universe.tf/allow-shared-ip: internalapi
metallb.universe.tf/loadBalancerIPs: 172.17.0.202
spec:
type: LoadBalancer
...
...
```
Expand Down
75 changes: 49 additions & 26 deletions api/bases/glance.openstack.org_glanceapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,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 @@ -859,6 +833,55 @@ spec:
additionalProperties:
type: string
type: object
override:
properties:
service:
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
passwordSelectors:
default:
database: GlanceDatabasePassword
Expand Down
150 changes: 98 additions & 52 deletions api/bases/glance.openstack.org_glances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -835,32 +835,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 @@ -869,6 +843,55 @@ spec:
additionalProperties:
type: string
type: object
override:
properties:
service:
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
pvc:
type: string
replicas:
Expand Down Expand Up @@ -931,32 +954,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 @@ -965,6 +962,55 @@ spec:
additionalProperties:
type: string
type: object
override:
properties:
service:
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
pvc:
type: string
replicas:
Expand Down
6 changes: 6 additions & 0 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,9 @@ require (
// mschuppert: map to latest commit from release-4.13 tag
// must consistent within modules and service operators
replace github.com/openshift/api => github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 //allow-merging

replace github.com/openstack-k8s-operators/lib-common/modules/common => github.com/stuggi/lib-common/modules/common v0.0.0-20230907061102-0705359fc344

replace github.com/openstack-k8s-operators/lib-common/modules/openstack => github.com/stuggi/lib-common/modules/openstack v0.0.0-20230907061102-0705359fc344

replace github.com/openstack-k8s-operators/keystone-operator/api => github.com/stuggi/keystone-operator/api v0.0.0-20230907062239-b15a4b6cfdb6
12 changes: 6 additions & 6 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,6 @@ github.com/onsi/ginkgo/v2 v2.12.0/go.mod h1:ZNEzXISYlqpb8S36iN71ifqLi3vVD1rVJGvW
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
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/keystone-operator/api v0.1.1-0.20230830083045-d73d07cca617 h1:+Sz5kbF6QzXgKROXp3S+X22ZHdt68zvj1tBOu94OGKU=
github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20230830083045-d73d07cca617/go.mod h1:CmUe4tHh990eRUj6Ou8gD9JE0PQ38LGnUu3kaaP8K50=
github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230824094610-976b18ca2875 h1:pj22n6PQy/XAmV5m6XaarMY6X1lvxAh16oVT5ZSVoNI=
github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20230824094610-976b18ca2875/go.mod h1:Mqg9hyHpWPda62750vqmk5TajxP3zbYPDP1rtSH7mg0=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.20230824094610-976b18ca2875 h1:aUlwELsLYWQ3FL+/nRG/1uGVNW86c3MhtLrHNVDd57k=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.20230824094610-976b18ca2875/go.mod h1:Vng+vqdTJUuZ+AEzSAaU0I7bn3qwYMMFEUHHhiH0440=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.1.1-0.20230824094610-976b18ca2875 h1:lC8Nw4PF2Lcqc7BJAdlBvYPyLqyaKa9R1e15dM9b3BY=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.1.1-0.20230824094610-976b18ca2875/go.mod h1:lazDTPD8BYde2yyzZ3HbOfG51Sf87vSr4KXwpF57hDs=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down Expand Up @@ -287,6 +281,12 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
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/stuggi/keystone-operator/api v0.0.0-20230907062239-b15a4b6cfdb6 h1:5VrV9yQtmT7Bj9XM7TFMDgfZprgqPfw2AqK+khEwjjs=
github.com/stuggi/keystone-operator/api v0.0.0-20230907062239-b15a4b6cfdb6/go.mod h1:xVGf/an6HspP2PmYvTxJG07kq4hOX/f2nRx9tMK2k7A=
github.com/stuggi/lib-common/modules/common v0.0.0-20230907061102-0705359fc344 h1:NZDTBuxxyFn6JJN1nHHknhzD6k/m2AwDdv0z/lRaKWQ=
github.com/stuggi/lib-common/modules/common v0.0.0-20230907061102-0705359fc344/go.mod h1:Mqg9hyHpWPda62750vqmk5TajxP3zbYPDP1rtSH7mg0=
github.com/stuggi/lib-common/modules/openstack v0.0.0-20230907061102-0705359fc344 h1:4weE9v4QOKHQCnDHbcTq6JLSPk3ROdWGa7i73QeY68A=
github.com/stuggi/lib-common/modules/openstack v0.0.0-20230907061102-0705359fc344/go.mod h1:23mreeTSn4rWUv3gNh1hryBfwBY/YAs7wS4NbIxDCfc=
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=
Expand Down
40 changes: 9 additions & 31 deletions api/v1beta1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ package v1beta1

import (
"context"
"time"

"github.com/gophercloud/gophercloud"
keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
"github.com/openstack-k8s-operators/lib-common/modules/common/endpoint"
"github.com/openstack-k8s-operators/lib-common/modules/common/helper"
"github.com/openstack-k8s-operators/lib-common/modules/common/secret"
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
openstack "github.com/openstack-k8s-operators/lib-common/modules/openstack"
corev1 "k8s.io/api/core/v1"
ctrl "sigs.k8s.io/controller-runtime"
"time"
)

const (
Expand Down Expand Up @@ -91,38 +93,14 @@ type GlanceAPITemplate struct {
// NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network
NetworkAttachments []string `json:"networkAttachments,omitempty"`

// +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"`
}

// 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"`
// 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.
Service *service.OverrideSpec `json:"service,omitempty"`
}

// SetupDefaults - initializes any CRD field defaults based on environment variables (the defaulting mechanism itself is implemented via webhooks)
Expand Down
Loading

0 comments on commit 11d8449

Please sign in to comment.