Skip to content

Commit

Permalink
Initial commit to add barbican to openstack-operator
Browse files Browse the repository at this point in the history
  • Loading branch information
vakwetu committed Oct 23, 2023
1 parent c1ac26e commit 1d46422
Show file tree
Hide file tree
Showing 26 changed files with 1,100 additions and 1 deletion.
351 changes: 351 additions & 0 deletions apis/bases/core.openstack.org_openstackcontrolplanes.yaml

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions apis/core/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ const (

// OpenStackControlPlaneExposeOctaviaReadyCondition Status=True condition which indicates if Octavia is exposed via a route
OpenStackControlPlaneExposeOctaviaReadyCondition condition.Type = "OpenStackControlPlaneExposeOctaviaReady"

// OpenStackControlPlaneBarbicanReadyCondition Status=True condition which indicates if Barbican is configured and operational
OpenStackControlPlaneBarbicanReadyCondition condition.Type = "OpenStackControlPlaneBarbicanReady"

// OpenStackControlPlaneExposeBarbicanReadyCondition Status=True condition which indicates if Barbican is exposed via a route
OpenStackControlPlaneExposeBarbicanReadyCondition condition.Type = "OpenStackControlPlaneExposeBarbicanReady"
)

// OpenStackControlPlane Reasons used by API objects.
Expand Down Expand Up @@ -384,4 +390,16 @@ const (

// OpenStackControlPlaneExposeServiceReadyMessage
OpenStackControlPlaneExposeServiceReadyMessage = "OpenStackControlPlane %s service exposed"

// OpenStackControlPlaneBarbicanReadyInitMessage
OpenStackControlPlaneBarbicanReadyInitMessage = "OpenStackControlPlane Barbican not started"

// OpenStackControlPlaneBarbicanReadyMessage
OpenStackControlPlaneBarbicanReadyMessage = "OpenStackControlPlane Barbican completed"

// OpenStackControlPlaneBarbicanReadyRunningMessage
OpenStackControlPlaneBarbicanReadyRunningMessage = "OpenStackControlPlane Barbican in progress"

// OpenStackControlPlaneBarbicanReadyErrorMessage
OpenStackControlPlaneBarbicanReadyErrorMessage = "OpenStackControlPlane Barbican error occured %s"
)
28 changes: 27 additions & 1 deletion apis/core/v1beta1/openstackcontrolplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ limitations under the License.
package v1beta1

import (
barbicanv1 "github.com/openstack-k8s-operators/barbican-operator/api/v1beta1"
cinderv1 "github.com/openstack-k8s-operators/cinder-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"
memcachedv1 "github.com/openstack-k8s-operators/infra-operator/apis/memcached/v1beta1"
networkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1"
redisv1 "github.com/openstack-k8s-operators/infra-operator/apis/redis/v1beta1"
ironicv1 "github.com/openstack-k8s-operators/ironic-operator/api/v1beta1"
keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
Expand All @@ -39,7 +41,6 @@ import (
swiftv1 "github.com/openstack-k8s-operators/swift-operator/api/v1beta1"
telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1"
rabbitmqv2 "github.com/rabbitmq/cluster-operator/v2/api/v1beta1"
redisv1 "github.com/openstack-k8s-operators/infra-operator/apis/redis/v1beta1"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -158,6 +159,11 @@ type OpenStackControlPlaneSpec struct {
// Redis - Parameters related to the Redis service
Redis RedisSection `json:"redis,omitempty"`

// +kubebuilder:validation:Optional
//+operator-sdk:csv:customresourcedefinitions:type=spec
// Barbican - Parameters related to the Barbican service
Barbican BarbicanSection `json:"barbican,omitempty"`

// ExtraMounts containing conf files and credentials that should be provided
// to the underlying operators.
// This struct can be defined in the top level CR and propagated to the
Expand Down Expand Up @@ -561,6 +567,25 @@ type RedisSection struct {
Templates map[string]redisv1.RedisSpec `json:"templates,omitempty"`
}

// BarbicanSection defines the desired state of Barbican service
type BarbicanSection struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default=true
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
// Enabled - Whether Barbican service should be deployed and managed
Enabled bool `json:"enabled"`

// +kubebuilder:validation:Optional
//+operator-sdk:csv:customresourcedefinitions:type=spec
// Template - Overrides to use when creating the Barbican Service
Template barbicanv1.BarbicanSpec `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"`
}

// OpenStackControlPlaneStatus defines the observed state of OpenStackControlPlane
type OpenStackControlPlaneStatus struct {
//+operator-sdk:csv:customresourcedefinitions:type=status,xDescriptors={"urn:alm:descriptor:io.kubernetes.conditions"}
Expand Down Expand Up @@ -641,6 +666,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(OpenStackControlPlaneBarbicanReadyCondition, condition.InitReason, OpenStackControlPlaneBarbicanReadyInitMessage),
condition.UnknownCondition(OpenStackControlPlaneRedisReadyCondition, condition.InitReason, OpenStackControlPlaneRedisReadyInitMessage),

// Also add the overall status condition as Unknown
Expand Down
13 changes: 13 additions & 0 deletions apis/core/v1beta1/openstackcontrolplane_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ func (r *OpenStackControlPlane) checkDepsEnabled(name string) string {
r.Spec.Ovn.Enabled) {
reqs = "MariaDB or Galera, Memcached, RabbitMQ, Keystone, Glance, Neutron, Nova, OVN"
}
case "Barbican":
if !((r.Spec.Mariadb.Enabled || r.Spec.Galera.Enabled) && r.Spec.Memcached.Enabled && r.Spec.Keystone.Enabled) {
reqs = "MariaDB or Galera, Memcached, Keystone"
}
}

// If "reqs" is not the empty string, we have missing requirements
Expand Down Expand Up @@ -291,6 +295,12 @@ func (r *OpenStackControlPlane) ValidateServiceDependencies(basePath *field.Path
}
}

if r.Spec.Barbican.Enabled {
if depErrorMsg := r.checkDepsEnabled("Barbican"); depErrorMsg != "" {
err := field.Invalid(basePath.Child("barbican").Child("enabled"), r.Spec.Barbican.Enabled, depErrorMsg)
allErrs = append(allErrs, err)
}
}
return allErrs
}

Expand Down Expand Up @@ -426,4 +436,7 @@ func (r *OpenStackControlPlane) DefaultServices() {
// By-value copy, need to update
r.Spec.Redis.Templates[key] = template
}

// Barbican
r.Spec.Barbican.Template.Default()
}
18 changes: 18 additions & 0 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.

1 change: 1 addition & 0 deletions apis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.19
require (
github.com/onsi/ginkgo/v2 v2.13.0
github.com/onsi/gomega v1.28.0
github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20231005125104-ed7f9a3d2080
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20231018031823-48a662e6dcfe
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20231013112543-a07d8273b82d
github.com/openstack-k8s-operators/heat-operator/api v0.3.1-0.20231016213913-eacfd44e505f
Expand Down
2 changes: 2 additions & 0 deletions apis/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ github.com/onsi/gomega v1.28.0 h1:i2rg/p9n/UqIDAMFUJ6qIUUMcsqOuUHgbpbu235Vr1c=
github.com/onsi/gomega v1.28.0/go.mod h1:A1H2JE76sI14WIP57LMKj7FVfCHx3g3BcZVjJG8bjX8=
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/barbican-operator/api v0.0.0-20231005125104-ed7f9a3d2080 h1:h/d16mT+ufQEeDZenS+EGqvQgkoOnzV3IW06AQzOdX8=
github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20231005125104-ed7f9a3d2080/go.mod h1:B1Bkb3EZJL/5s8cAHQmIo9vFFwDnkLMBdMjoWFbGtNE=
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20231018031823-48a662e6dcfe h1:5lAcgOSjDrh0HrJa2w3l9rOJBaH8iSP6Bth169XI7Nw=
github.com/openstack-k8s-operators/cinder-operator/api v0.3.1-0.20231018031823-48a662e6dcfe/go.mod h1:8NFIyjXZeC+T2UBcmTDTfSatRdhi2eaZlaAuzcT2rNk=
github.com/openstack-k8s-operators/glance-operator/api v0.3.1-0.20231013112543-a07d8273b82d h1:WEG0KPgsujhwVh7W/IbJ8I8JTDUuJj6V5rWD6L+KzbI=
Expand Down
2 changes: 2 additions & 0 deletions cmd/csv-merger/csv-merger.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ var (
horizonCsv = flag.String("horizon-csv", "", "Horizon CSV filename")
swiftCsv = flag.String("swift-csv", "", "Swift CSV filename")
octaviaCsv = flag.String("octavia-csv", "", "Octavia CSV filename")
barbicanCsv = flag.String("barbican-csv", "", "Barbican CSV filename")
csvOverrides = flag.String("csv-overrides", "", "CSV like string with punctual changes that will be recursively applied (if possible)")
importEnvFiles = flag.String("import-env-files", "", "Comma separated list of file names to read default operator ENVs from. Used for inter-bundle ENV merging.")
exportEnvFile = flag.String("export-env-file", "", "Name the external file to write operator ENVs to. Used for inter-bundle ENV merging.")
Expand Down Expand Up @@ -140,6 +141,7 @@ func main() {
*heatCsv,
*swiftCsv,
*octaviaCsv,
*barbicanCsv,
}

csvVersion := os.Getenv("CSV_VERSION")
Expand Down
Loading

0 comments on commit 1d46422

Please sign in to comment.