@@ -18,11 +18,198 @@ package v1beta1
1818
1919import (
2020 condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
21+ corev1 "k8s.io/api/core/v1"
22+ "k8s.io/apimachinery/pkg/api/resource"
2123 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2224)
2325
26+ const (
27+ OpenStackOperatorName = "openstack"
28+ BarbicanOperatorName = "barbican"
29+ CinderOperatorName = "cinder"
30+ DesignateOperatorName = "designate"
31+ GlanceOperatorName = "glance"
32+ HeatOperatorName = "heat"
33+ HorizonOperatorName = "horizon"
34+ InfraOperatorName = "infra"
35+ IronicOperatorName = "ironic"
36+ KeystoneOperatorName = "keystone"
37+ ManilaOperatorName = "manila"
38+ MariaDBOperatorName = "mariadb"
39+ NeutronOperatorName = "neutron"
40+ NovaOperatorName = "nova"
41+ OctaviaOperatorName = "octavia"
42+ OpenStackBaremetalOperatorName = "openstack-baremetal"
43+ OvnOperatorName = "ovn"
44+ PlacementOperatorName = "placement"
45+ RabbitMQOperatorName = "rabbitmq-cluster"
46+ SwiftOperatorName = "swift"
47+ TelemetryOperatorName = "telemetry"
48+ TestOperatorName = "test"
49+ // ReplicasEnabled - default replicas count when enabled
50+ ReplicasEnabled int32 = 1
51+ // ReplicasDisabled - replicas when disabled
52+ ReplicasDisabled int32 = 0
53+ )
54+
55+ var (
56+ // DefaultManagerCPULimit - Default controller manager container CPU limit
57+ DefaultManagerCPULimit resource.Quantity = resource .MustParse ("500m" )
58+ // DefaultManagerCPURequests - Default controller manager container CPU requests
59+ DefaultManagerCPURequests resource.Quantity = resource .MustParse ("10m" )
60+ // DefaultManagerMemoryLimit - Default controller manager container memory limit
61+ DefaultManagerMemoryLimit resource.Quantity = resource .MustParse ("256Mi" )
62+ // DefaultManagerMemoryRequests - Default controller manager container memory requests
63+ DefaultManagerMemoryRequests resource.Quantity = resource .MustParse ("128Mi" )
64+ // DefaultRbacProxyCPULimit - Default kube rbac proxy container CPU limit
65+ DefaultRbacProxyCPULimit resource.Quantity = resource .MustParse ("500m" )
66+ // DefaultRbacProxyCPURequests - Default kube rbac proxy container CPU requests
67+ DefaultRbacProxyCPURequests resource.Quantity = resource .MustParse ("5m" )
68+ // DefaultRbacProxyMemoryLimit - Default kube rbac proxy container memory limit
69+ DefaultRbacProxyMemoryLimit resource.Quantity = resource .MustParse ("128Mi" )
70+ // DefaultRbacProxyMemoryRequests - Default kube rbac proxy container memory requests
71+ DefaultRbacProxyMemoryRequests resource.Quantity = resource .MustParse ("64Mi" )
72+ // OperatorList - list of all operators with optional different defaults then the above.
73+ // NOTE: test-operator was deployed as a independant package so it may or may not be installed
74+ // NOTE: depending on how watcher-operator is released for FR2 and then in FR3 it may need to be
75+ // added into this list in the future
76+ // IMPORTANT: have this list in sync with the Enum in OperatorSpec.Name parameter
77+ OperatorList []OperatorSpec = []OperatorSpec {
78+ {
79+ Name : OpenStackOperatorName ,
80+ ControllerManager : ContainerSpec {
81+ Resources : corev1.ResourceRequirements {
82+ Requests : corev1.ResourceList {
83+ corev1 .ResourceMemory : resource .MustParse ("512Mi" ),
84+ },
85+ Limits : corev1.ResourceList {
86+ corev1 .ResourceMemory : resource .MustParse ("1Gi" ),
87+ },
88+ },
89+ },
90+ },
91+ {
92+ Name : BarbicanOperatorName ,
93+ },
94+ {
95+ Name : CinderOperatorName ,
96+ },
97+ {
98+ Name : DesignateOperatorName ,
99+ },
100+ {
101+ Name : GlanceOperatorName ,
102+ },
103+ {
104+ Name : HeatOperatorName ,
105+ },
106+ {
107+ Name : HorizonOperatorName ,
108+ },
109+ {
110+ Name : InfraOperatorName ,
111+ ControllerManager : ContainerSpec {
112+ Resources : corev1.ResourceRequirements {
113+ Requests : corev1.ResourceList {
114+ corev1 .ResourceMemory : resource .MustParse ("512Mi" ),
115+ },
116+ Limits : corev1.ResourceList {
117+ corev1 .ResourceMemory : resource .MustParse ("1Gi" ),
118+ },
119+ },
120+ },
121+ },
122+ {
123+ Name : IronicOperatorName ,
124+ },
125+ {
126+ Name : KeystoneOperatorName ,
127+ },
128+ {
129+ Name : ManilaOperatorName ,
130+ },
131+ {
132+ Name : MariaDBOperatorName ,
133+ },
134+ {
135+ Name : NeutronOperatorName ,
136+ },
137+ {
138+ Name : NovaOperatorName ,
139+ },
140+ {
141+ Name : OctaviaOperatorName ,
142+ },
143+ {
144+ Name : OpenStackBaremetalOperatorName ,
145+ },
146+ {
147+ Name : OvnOperatorName ,
148+ },
149+ {
150+ Name : PlacementOperatorName ,
151+ },
152+ {
153+ Name : RabbitMQOperatorName ,
154+ ControllerManager : ContainerSpec {
155+ Resources : corev1.ResourceRequirements {
156+ Requests : corev1.ResourceList {
157+ corev1 .ResourceCPU : resource .MustParse ("5m" ),
158+ corev1 .ResourceMemory : resource .MustParse ("64Mi" ),
159+ },
160+ Limits : corev1.ResourceList {
161+ corev1 .ResourceCPU : resource .MustParse ("200m" ),
162+ corev1 .ResourceMemory : resource .MustParse ("500Mi" ),
163+ },
164+ },
165+ },
166+ },
167+ {
168+ Name : SwiftOperatorName ,
169+ },
170+ {
171+ Name : TelemetryOperatorName ,
172+ },
173+ {
174+ Name : TestOperatorName ,
175+ },
176+ }
177+ )
178+
24179// OpenStackSpec defines the desired state of OpenStack
25180type OpenStackSpec struct {
181+ // +kubebuilder:validation:Optional
182+ // +listType=map
183+ // +listMapKey=name
184+ // OperatorOverrides - list of OperatorSpec which allows to customize operator deployments
185+ OperatorOverrides []OperatorSpec `json:"operatorOverrides"`
186+ }
187+
188+ // OperatorSpec - customization for the operator deployment
189+ type OperatorSpec struct {
190+ // +kubebuilder:validation:Required
191+ // +kubebuilder:validation:MinLength=1
192+ // +kubebuilder:validation:Enum:=openstack;barbican;cinder;designate;glance;heat;horizon;infra;ironic;keystone;manila;mariadb;neutron;nova;octavia;openstack-baremetal;ovn;placement;rabbitmq-cluster;swift;telemetry;test
193+ // Name of the service operators.
194+ Name string `json:"name"`
195+
196+ // +kubebuilder:validation:Optional
197+ // +kubebuilder:validation:Maximum=1
198+ // +kubebuilder:validation:Minimum=0
199+ // Replicas of the operator deployment
200+ Replicas * int32 `json:"replicas,omitempty"`
201+
202+ // +kubebuilder:validation:Optional
203+ // ControllerManager - tunings for the controller manager container
204+ ControllerManager ContainerSpec `json:"controllerManager,omitempty"`
205+ }
206+
207+ // ContainerSpec - customization for the container spec
208+ type ContainerSpec struct {
209+ // +kubebuilder:validation:Optional
210+ // Resources - Compute Resources for the service operator controller manager
211+ // https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
212+ Resources corev1.ResourceRequirements `json:"resources,omitempty"`
26213}
27214
28215// OpenStackStatus defines the observed state of OpenStack
@@ -35,6 +222,15 @@ type OpenStackStatus struct {
35222 // DeployedOperatorCount - the number of operators deployed
36223 DeployedOperatorCount * int `json:"deployedOperatorCount,omitempty"`
37224
225+ // DisabledOperatorCount - the number of operators which has replicas set to 0
226+ DisabledOperatorCount * int `json:"disabledOperatorCount,omitempty"`
227+
228+ // EnabledOperatorCount - the number of operators which has replicas set to 1
229+ EnabledOperatorCount * int `json:"enabledOperatorCount,omitempty"`
230+
231+ // TotalOperatorCount - the number all operators available
232+ TotalOperatorCount * int `json:"totalOperatorCount,omitempty"`
233+
38234 // ObservedGeneration - the most recent generation observed for this object.
39235 ObservedGeneration int64 `json:"observedGeneration,omitempty"` // no spec yet so maybe we don't need this
40236
0 commit comments