Skip to content

Commit

Permalink
Add TopologySpreadConstraint to GlanceAPI statefulset
Browse files Browse the repository at this point in the history
For each GlanceAPI, as part of the StatefulSet generated by
GlanceAPITemplate, it is possible to specify a TopologySpreadConstraint,
which is now included in the API. However, if not specified, it can be
inherited from the top-level Glance CR.

Signed-off-by: Francesco Pantano <[email protected]>
  • Loading branch information
fmount committed Nov 20, 2024
1 parent 6e15249 commit fce2951
Show file tree
Hide file tree
Showing 11 changed files with 443 additions and 26 deletions.
52 changes: 52 additions & 0 deletions api/bases/glance.openstack.org_glanceapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,58 @@ spec:
caBundleSecretName:
type: string
type: object
topologySpreadConstraint:
items:
properties:
labelSelector:
properties:
matchExpressions:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
type: object
type: object
x-kubernetes-map-type: atomic
matchLabelKeys:
items:
type: string
type: array
x-kubernetes-list-type: atomic
maxSkew:
format: int32
type: integer
minDomains:
format: int32
type: integer
nodeAffinityPolicy:
type: string
nodeTaintsPolicy:
type: string
topologyKey:
type: string
whenUnsatisfiable:
type: string
required:
- maxSkew
- topologyKey
- whenUnsatisfiable
type: object
type: array
type:
default: split
enum:
Expand Down
104 changes: 104 additions & 0 deletions api/bases/glance.openstack.org_glances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,58 @@ spec:
caBundleSecretName:
type: string
type: object
topologySpreadConstraint:
items:
properties:
labelSelector:
properties:
matchExpressions:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
type: object
type: object
x-kubernetes-map-type: atomic
matchLabelKeys:
items:
type: string
type: array
x-kubernetes-list-type: atomic
maxSkew:
format: int32
type: integer
minDomains:
format: int32
type: integer
nodeAffinityPolicy:
type: string
nodeTaintsPolicy:
type: string
topologyKey:
type: string
whenUnsatisfiable:
type: string
required:
- maxSkew
- topologyKey
- whenUnsatisfiable
type: object
type: array
type:
default: split
enum:
Expand Down Expand Up @@ -777,6 +829,58 @@ spec:
storageRequest:
type: string
type: object
topologySpreadConstraint:
items:
properties:
labelSelector:
properties:
matchExpressions:
items:
properties:
key:
type: string
operator:
type: string
values:
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
type: object
type: object
x-kubernetes-map-type: atomic
matchLabelKeys:
items:
type: string
type: array
x-kubernetes-list-type: atomic
maxSkew:
format: int32
type: integer
minDomains:
format: int32
type: integer
nodeAffinityPolicy:
type: string
nodeTaintsPolicy:
type: string
topologyKey:
type: string
whenUnsatisfiable:
type: string
required:
- maxSkew
- topologyKey
- whenUnsatisfiable
type: object
type: array
required:
- containerImage
- databaseInstance
Expand Down
22 changes: 18 additions & 4 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ type GlanceAPITemplate struct {
// Glance Container Image URL (will be set to environmental default if empty)
ContainerImage string `json:"containerImage"`

// +kubebuilder:validation:Optional
// NodeSelector to target subset of worker nodes running this service
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// +kubebuilder:validation:Optional
// CustomServiceConfig - customize the service config using this parameter to change service defaults,
// or overwrite rendered information using raw OpenStack config format. The content gets added to
Expand Down Expand Up @@ -106,6 +102,24 @@ type GlanceAPITemplate struct {
// +kubebuilder:validation:Minimum=1
// APITimeout for HAProxy and Apache defaults to GlanceSpecCore APITimeout
APITimeout int `json:"apiTimeout,omitempty"`

// +kubebuilder:validation:Optional
// Topology - The struct that contains the Topology related information to
// provide hints to k8s scheduler
Topology `json:",inline"`
}

// Topology defines the information exposed in the API to provide hints to k8s
// scheduler
type Topology struct {
// +kubebuilder:validation:Optional
// NodeSelector to target subset of worker nodes running this service
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// +kubebuilder:validation:Optional
// APITopologySpreadConstraint exposes topologySpreadConstraint that are applied
// to the StatefulSet
TopologySpreadConstraint *[]corev1.TopologySpreadConstraint `json:"topologySpreadConstraint,omitempty"`
}

// Storage -
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const (
// GlanceAPIReadyCondition Status=True condition which indicates if the GlanceAPI is configured and operational
GlanceAPIReadyCondition condition.Type = "GlanceAPIReady"
// CinderCondition
CinderCondition= "CinderReady"
CinderCondition = "CinderReady"
// GlanceLayoutUpdateErrorMessage
GlanceLayoutUpdateErrorMessage = "The GlanceAPI layout (type) cannot be modified. To proceed, please add a new API with the desired layout and then decommission the previous API"
// KeystoneEndpointErrorMessage
Expand Down
9 changes: 5 additions & 4 deletions api/v1beta1/glance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ type GlanceSpecCore struct {
// PasswordSelectors - Selectors to identify the DB and ServiceUser password from the Secret
PasswordSelectors PasswordSelector `json:"passwordSelectors"`

// +kubebuilder:validation:Optional
// NodeSelector to target subset of worker nodes running this service
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=false
// PreserveJobs - do not delete jobs after they finished e.g. to check logs
Expand Down Expand Up @@ -126,6 +122,11 @@ type GlanceSpecCore struct {
// +kubebuilder:validation:Minimum=1
// Default APITimeout for HAProxy and Apache, defaults to 60 seconds
APITimeout int `json:"apiTimeout"`

// +kubebuilder:validation:Optional
// Topology - The struct that contains the Topology related information to
// provide hints to k8s scheduler
Topology `json:",inline"`
}

// GlanceSpec defines the desired state of Glance
Expand Down
6 changes: 3 additions & 3 deletions api/v1beta1/glanceapi_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ limitations under the License.
package v1beta1

import (
"fmt"
"github.com/google/go-cmp/cmp"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"fmt"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
"github.com/google/go-cmp/cmp"
apierrors "k8s.io/apimachinery/pkg/api/errors"
)

// GlanceAPIDefaults -
Expand Down
50 changes: 36 additions & 14 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fce2951

Please sign in to comment.