Skip to content

Commit

Permalink
Add initial OpenStackVersionUpdate CRD/Controller
Browse files Browse the repository at this point in the history
  • Loading branch information
dprince committed Jan 17, 2024
1 parent e1bb01e commit d38f2cc
Show file tree
Hide file tree
Showing 13 changed files with 653 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# To re-generate a bundle for another specific version without changing the standard setup, you can:
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
VERSION ?= 0.0.1
VERSION ?= 0.0.2

# CHANNELS define the bundle channels used in the bundle.
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
Expand Down
80 changes: 80 additions & 0 deletions apis/bases/core.openstack.org_openstackversions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.1
creationTimestamp: null
name: openstackversions.core.openstack.org
spec:
group: core.openstack.org
names:
kind: OpenStackVersion
listKind: OpenStackVersionList
plural: openstackversions
singular: openstackversion
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.targetVersion
name: Target Version
type: string
- jsonPath: .status.availableVersion
name: Available Version
type: string
name: v1beta1
schema:
openAPIV3Schema:
properties:
apiVersion:
type: string
kind:
type: string
metadata:
type: object
spec:
properties:
cinderVolumeExcludes:
items:
type: string
type: array
openstackControlPlaneName:
default: openstack
type: string
serviceExcludes:
items:
type: string
type: array
targetVersion:
type: string
type: object
status:
properties:
availableService:
items:
type: string
type: array
availableVersion:
type: string
targetVersion:
type: string
updateApplied:
items:
properties:
name:
type: string
type: object
type: array
updateNeeded:
items:
properties:
name:
type: string
type: object
type: array
type: object
type: object
served: true
storage: true
subresources:
status: {}
63 changes: 52 additions & 11 deletions apis/core/v1beta1/openstackversion_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2022.
Copyright 2023.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -20,28 +20,69 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// OpenStackVersionSpec defines the desired state of OpenStackVersion
type OpenStackVersionSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of OpenStackVersion. Edit openstackversion_types.go to remove/update
Foo string `json:"foo,omitempty"`
// Strategy -
//Strategy UpdateStrategy `json:"strategy,omitempty"`

// 1.0.1 --> 1.0.2
TargetVersion string `json:"targetVersion,omitempty"`

// +kubebuilder:default="openstack"
OpenStackControlPlaneName string `json:"openstackControlPlaneName,omitempty"`

// ServiceExcludes is a list of services to exclude from the update. Any named service here will be excluded from the update.
ServiceExcludes []string `json:"serviceExcludes,omitempty"`

// CinderVolumeExcludes is a list of cinder volumes to exclude from the update. Any named Cinder volume instance here will be excluded.
CinderVolumeExcludes []string `json:"cinderVolumeExcludes,omitempty"`

//FIXME: add parameters for other custom service maps (Neutron, etc)
}

// UpdateStrategy defines the strategy used to roll out updates to the OpenStack services
/*
type UpdateStrategy struct {
// +kubebuilder:default="automatic"
UpdateType string `json:"updateType,omitempty"`
// Type serial or parallel
// +kubebuilder:default="serial"
//Type string `json:"type"`
}*/

type ServiceVersionURL struct {
ServiceName string `json:"name,omitempty"`
ContainerImageUrl string `json:"containerImageUrl,omitempty"`
}

type OpenStackService struct {
ServiceName string `json:"name,omitempty"`
}

// OpenStackVersionStatus defines the observed state of OpenStackVersion
type OpenStackVersionStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
ServicesNeedingUpdates []OpenStackService `json:"updateNeeded,omitempty"`

DeployedVersions []OpenStackService `json:"updateApplied,omitempty"`

TargetVersion string `json:"targetVersion,omitempty"`

AvailableVersion string `json:"availableVersion,omitempty"`

AvailableServices []string `json:"availableService,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// +operator-sdk:csv:customresourcedefinitions:displayName="OpenStack Version"
// +kubebuilder:printcolumn:name="Target Version",type=string,JSONPath=`.spec.targetVersion`
// +kubebuilder:printcolumn:name="Available Version",type=string,JSONPath=`.status.availableVersion`

// OpenStackVersion is the Schema for the openstackversions API
// OpenStackVersion is the Schema for the openstackversionupdates API
type OpenStackVersion struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
59 changes: 57 additions & 2 deletions apis/core/v1beta1/zz_generated.deepcopy.go

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

80 changes: 80 additions & 0 deletions config/crd/bases/core.openstack.org_openstackversions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.1
creationTimestamp: null
name: openstackversions.core.openstack.org
spec:
group: core.openstack.org
names:
kind: OpenStackVersion
listKind: OpenStackVersionList
plural: openstackversions
singular: openstackversion
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.targetVersion
name: Target Version
type: string
- jsonPath: .status.availableVersion
name: Available Version
type: string
name: v1beta1
schema:
openAPIV3Schema:
properties:
apiVersion:
type: string
kind:
type: string
metadata:
type: object
spec:
properties:
cinderVolumeExcludes:
items:
type: string
type: array
openstackControlPlaneName:
default: openstack
type: string
serviceExcludes:
items:
type: string
type: array
targetVersion:
type: string
type: object
status:
properties:
availableService:
items:
type: string
type: array
availableVersion:
type: string
targetVersion:
type: string
updateApplied:
items:
properties:
name:
type: string
type: object
type: array
updateNeeded:
items:
properties:
name:
type: string
type: object
type: array
type: object
type: object
served: true
storage: true
subresources:
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,12 @@ spec:
x-descriptors:
- urn:alm:descriptor:io.kubernetes.conditions
version: v1beta1
- description: OpenStackVersion is the Schema for the openstackversionupdates
API
displayName: Open Stack Version
kind: OpenStackVersion
name: openstackversions.core.openstack.org
version: v1beta1
description: Install and configure OpenStack
displayName: OpenStack
icon:
Expand Down
26 changes: 26 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,32 @@ rules:
- get
- patch
- update
- apiGroups:
- core.openstack.org
resources:
- openstackversions
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- core.openstack.org
resources:
- openstackversions/finalizers
verbs:
- update
- apiGroups:
- core.openstack.org
resources:
- openstackversions/status
verbs:
- get
- patch
- update
- apiGroups:
- designate.openstack.org
resources:
Expand Down
Loading

0 comments on commit d38f2cc

Please sign in to comment.