Skip to content

Commit

Permalink
Create WatcherAPI deployment
Browse files Browse the repository at this point in the history
Create the WatcherAPI deployment. Adds new fields to the spec and status
related to the deployemnt, and modifies slightly the configuration files
templates.
  • Loading branch information
cescgina committed Jan 7, 2025
1 parent 20ecc51 commit ccbb45c
Show file tree
Hide file tree
Showing 21 changed files with 838 additions and 16 deletions.
86 changes: 86 additions & 0 deletions api/bases/watcher.openstack.org_watcherapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ spec:
description: MemcachedInstance is the name of the Memcached CR that
all watcher service will use.
type: string
nodeSelector:
additionalProperties:
type: string
description: |-
NodeSelector to target subset of worker nodes running this component. Setting here overrides
any global NodeSelector settings within the Watcher CR.
type: object
passwordSelectors:
default:
service: WatcherPassword
Expand All @@ -75,9 +82,78 @@ spec:
description: PreserveJobs - do not delete jobs after they finished
e.g. to check logs
type: boolean
replicas:
default: 1
description: Replicas of Watcher API to run
format: int32
maximum: 32
minimum: 0
type: integer
resources:
description: |-
Resources - Compute Resources required by this service (Limits/Requests).
https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
properties:
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
that are used by this container.
This is an alpha field and requires enabling the
DynamicResourceAllocation feature gate.
This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: |-
Name must match the name of one entry in pod.spec.resourceClaims of
the Pod where this field is used. It makes that resource available
inside a container.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Limits describes the maximum amount of compute resources allowed.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Requests describes the minimum amount of compute resources required.
If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
otherwise to an implementation-defined value. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
secret:
description: Secret containing all passwords / keys needed
type: string
serviceAccount:
description: |-
ServiceAccount - service account name used internally to provide
Watcher services the default SA name
type: string
serviceUser:
default: watcher
description: ServiceUser - optional username used for this service
Expand All @@ -86,6 +162,7 @@ spec:
required:
- databaseInstance
- secret
- serviceAccount
type: object
status:
description: WatcherAPIStatus defines the observed state of WatcherAPI
Expand Down Expand Up @@ -132,6 +209,11 @@ spec:
- type
type: object
type: array
hash:
additionalProperties:
type: string
description: Map of hashes to track e.g. job status
type: object
observedGeneration:
description: |-
ObservedGeneration - the most recent generation observed for this
Expand All @@ -140,6 +222,10 @@ spec:
the openstack-operator in the top-level CR (e.g. the ContainerImage)
format: int64
type: integer
readyCount:
description: ReadyCount of watcher API instances
format: int32
type: integer
type: object
type: object
served: true
Expand Down
78 changes: 78 additions & 0 deletions api/bases/watcher.openstack.org_watcherappliers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,84 @@ spec:
description: The service specific Container Image URL (will be set
to environmental default if empty)
type: string
nodeSelector:
additionalProperties:
type: string
description: |-
NodeSelector to target subset of worker nodes running this component. Setting here overrides
any global NodeSelector settings within the Watcher CR.
type: object
replicas:
default: 1
description: Replicas of Watcher API to run
format: int32
maximum: 32
minimum: 0
type: integer
resources:
description: |-
Resources - Compute Resources required by this service (Limits/Requests).
https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
properties:
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
that are used by this container.
This is an alpha field and requires enabling the
DynamicResourceAllocation feature gate.
This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: |-
Name must match the name of one entry in pod.spec.resourceClaims of
the Pod where this field is used. It makes that resource available
inside a container.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Limits describes the maximum amount of compute resources allowed.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Requests describes the minimum amount of compute resources required.
If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
otherwise to an implementation-defined value. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
serviceAccount:
description: |-
ServiceAccount - service account name used internally to provide
Watcher services the default SA name
type: string
required:
- serviceAccount
type: object
status:
description: WatcherApplierStatus defines the observed state of WatcherApplier
Expand Down
78 changes: 78 additions & 0 deletions api/bases/watcher.openstack.org_watcherdecisionengines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,84 @@ spec:
description: The service specific Container Image URL (will be set
to environmental default if empty)
type: string
nodeSelector:
additionalProperties:
type: string
description: |-
NodeSelector to target subset of worker nodes running this component. Setting here overrides
any global NodeSelector settings within the Watcher CR.
type: object
replicas:
default: 1
description: Replicas of Watcher API to run
format: int32
maximum: 32
minimum: 0
type: integer
resources:
description: |-
Resources - Compute Resources required by this service (Limits/Requests).
https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
properties:
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
that are used by this container.
This is an alpha field and requires enabling the
DynamicResourceAllocation feature gate.
This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: |-
Name must match the name of one entry in pod.spec.resourceClaims of
the Pod where this field is used. It makes that resource available
inside a container.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Limits describes the maximum amount of compute resources allowed.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: |-
Requests describes the minimum amount of compute resources required.
If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
otherwise to an implementation-defined value. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
serviceAccount:
description: |-
ServiceAccount - service account name used internally to provide
Watcher services the default SA name
type: string
required:
- serviceAccount
type: object
status:
description: WatcherDecisionEngineStatus defines the observed state of
Expand Down
2 changes: 1 addition & 1 deletion api/bases/watcher.openstack.org_watchers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ spec:
default: rabbitmq
description: |-
RabbitMQ instance name
Needed to request a transportURL that is created and used in Barbican
Needed to request a transportURL that is created and used in Watcher
type: string
secret:
default: osp-secret
Expand Down
31 changes: 28 additions & 3 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ limitations under the License.

package v1beta1

import "github.com/openstack-k8s-operators/lib-common/modules/common/util"
import (
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
corev1 "k8s.io/api/core/v1"
)

// Container image fall-back defaults
const (
Expand Down Expand Up @@ -68,7 +71,7 @@ type WatcherTemplate struct {
// +kubebuilder:validation:Required
// +kubebuilder:default=rabbitmq
// RabbitMQ instance name
// Needed to request a transportURL that is created and used in Barbican
// Needed to request a transportURL that is created and used in Watcher
RabbitMqClusterName string `json:"rabbitMqClusterName"`

// +kubebuilder:validation:Optional
Expand All @@ -90,6 +93,28 @@ type WatcherSubCrsCommon struct {
// +kubebuilder:validation:Optional
// The service specific 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 component. Setting here overrides
// any global NodeSelector settings within the Watcher CR.
NodeSelector *map[string]string `json:"nodeSelector,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=1
// +kubebuilder:validation:Maximum=32
// +kubebuilder:validation:Minimum=0
// Replicas of Watcher API to run
Replicas *int32 `json:"replicas"`

// +kubebuilder:validation:Optional
// Resources - Compute Resources required by this service (Limits/Requests).
// https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// +kubebuilder:validation:Required
// ServiceAccount - service account name used internally to provide
// Watcher services the default SA name
ServiceAccount string `json:"serviceAccount"`
}

type WatcherImages struct {
Expand Down Expand Up @@ -121,7 +146,7 @@ func (r *WatcherImages) Default(defaults WatcherDefaults) {
// SetupDefaults - initializes any CRD field defaults based on environment variables (the defaulting mechanism itself is implemented via webhooks)

func SetupDefaults() {
// Acquire environmental defaults and initialize Nova defaults with them
// Acquire environmental defaults and initialize Watcher defaults with them
watcherDefaults := WatcherDefaults{
APIContainerImageURL: util.GetEnvVar("WATCHER_API_IMAGE_URL_DEFAULT", WatcherAPIContainerImage),
ApplierContainerImageURL: util.GetEnvVar("WATCHER_APPLIER_IMAGE_URL_DEFAULT", WatcherApplierContainerImage),
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/watcherapi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ type WatcherAPIStatus struct {
// then the controller has not processed the latest changes injected by
// the openstack-operator in the top-level CR (e.g. the ContainerImage)
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// ReadyCount of watcher API instances
ReadyCount int32 `json:"readyCount,omitempty"`

// Map of hashes to track e.g. job status
Hash map[string]string `json:"hash,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
Loading

0 comments on commit ccbb45c

Please sign in to comment.