Skip to content

Commit

Permalink
Add initial reconciler methods for WatcherApplier
Browse files Browse the repository at this point in the history
Adds initial logic for reconciler on Watcher Applier controller,
including inputs, serviceConfig and memcached configurations.
  • Loading branch information
viroel committed Jan 24, 2025
1 parent c8c1dfc commit 55bf155
Show file tree
Hide file tree
Showing 11 changed files with 893 additions and 6 deletions.
98 changes: 98 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,35 @@ spec:
description: The service specific Container Image URL (will be set
to environmental default if empty)
type: string
memcachedInstance:
default: memcached
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
description: PasswordSelectors - Selectors to identify the ServiceUser
password from the Secret
properties:
service:
default: WatcherPassword
description: Service - Selector to get the watcher service user
password from the Secret
type: string
type: object
preserveJobs:
default: false
description: PreserveJobs - do not delete jobs after they finished
e.g. to check logs
type: boolean
replicas:
default: 1
description: Replicas of Watcher service to run
Expand Down Expand Up @@ -107,16 +136,85 @@ spec:
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
to register in keystone
type: string
required:
- secret
- serviceAccount
type: object
status:
description: WatcherApplierStatus defines the observed state of WatcherApplier
properties:
conditions:
description: Conditions
items:
description: Condition defines an observation of a API resource
operational state.
properties:
lastTransitionTime:
description: |-
Last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when
the API field changed is acceptable.
format: date-time
type: string
message:
description: A human readable message indicating details about
the transition.
type: string
reason:
description: The reason for the condition's last transition
in CamelCase.
type: string
severity:
description: |-
Severity provides a classification of Reason code, so the current situation is immediately
understandable and could act accordingly.
It is meant for situations where Status=False and it should be indicated if it is just
informational, warning (next reconciliation might fix it) or an error (e.g. DB create issue
and no actions to automatically resolve the issue can/should be done).
For conditions where Status=Unknown or Status=True the Severity should be SeverityNone.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of condition in CamelCase.
type: string
required:
- lastTransitionTime
- status
- 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
service. If the observed generation is less than the spec generation,
then the controller has not processed the latest changes injected by
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
22 changes: 22 additions & 0 deletions api/v1beta1/watcherapplier_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1beta1

import (
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -28,13 +29,34 @@ type WatcherApplierSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

WatcherCommon `json:",inline"`

// +kubebuilder:validation:Required
// Secret containing all passwords / keys needed
Secret string `json:"secret"`

WatcherSubCrsCommon `json:",inline"`
}

// WatcherApplierStatus defines the observed state of WatcherApplier
type WatcherApplierStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Conditions
Conditions condition.Conditions `json:"conditions,omitempty" optional:"true"`

// ObservedGeneration - the most recent generation observed for this
// service. If the observed generation is less than the spec generation,
// 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
17 changes: 16 additions & 1 deletion api/v1beta1/zz_generated.deepcopy.go

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

98 changes: 98 additions & 0 deletions config/crd/bases/watcher.openstack.org_watcherappliers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,35 @@ spec:
description: The service specific Container Image URL (will be set
to environmental default if empty)
type: string
memcachedInstance:
default: memcached
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
description: PasswordSelectors - Selectors to identify the ServiceUser
password from the Secret
properties:
service:
default: WatcherPassword
description: Service - Selector to get the watcher service user
password from the Secret
type: string
type: object
preserveJobs:
default: false
description: PreserveJobs - do not delete jobs after they finished
e.g. to check logs
type: boolean
replicas:
default: 1
description: Replicas of Watcher service to run
Expand Down Expand Up @@ -107,16 +136,85 @@ spec:
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
to register in keystone
type: string
required:
- secret
- serviceAccount
type: object
status:
description: WatcherApplierStatus defines the observed state of WatcherApplier
properties:
conditions:
description: Conditions
items:
description: Condition defines an observation of a API resource
operational state.
properties:
lastTransitionTime:
description: |-
Last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when
the API field changed is acceptable.
format: date-time
type: string
message:
description: A human readable message indicating details about
the transition.
type: string
reason:
description: The reason for the condition's last transition
in CamelCase.
type: string
severity:
description: |-
Severity provides a classification of Reason code, so the current situation is immediately
understandable and could act accordingly.
It is meant for situations where Status=False and it should be indicated if it is just
informational, warning (next reconciliation might fix it) or an error (e.g. DB create issue
and no actions to automatically resolve the issue can/should be done).
For conditions where Status=Unknown or Status=True the Severity should be SeverityNone.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of condition in CamelCase.
type: string
required:
- lastTransitionTime
- status
- 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
service. If the observed generation is less than the spec generation,
then the controller has not processed the latest changes injected by
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
4 changes: 3 additions & 1 deletion config/samples/watcher_v1beta1_watcherapplier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ metadata:
app.kubernetes.io/created-by: watcher-operator
name: watcherapplier-sample
spec:
# TODO(user): Add fields here
secret: "watcher"
memcachedInstance: "memcached"
serviceAccount: "watcher-watcher"
6 changes: 6 additions & 0 deletions controllers/watcher_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ var (
apiWatchFields = []string{
passwordSecretField,
}
applierWatchFields = []string{
passwordSecretField,
}
)

const (
Expand All @@ -49,6 +52,9 @@ const (
// WatcherAPILabelPrefix - a unique, service binary specific prefix for the
// labels the WatcherAPI controller uses on children objects
WatcherAPILabelPrefix = "watcher-api"
// WatcherApplierLabelPrefix - a unique, service binary specific prefix for the
// labels the WatcherApplier controller uses on children objects
WatcherApplierLabelPrefix = "watcher-applier"
)

// GetLogger returns a logger object with a prefix of "controller.name" and additional controller context fields
Expand Down
Loading

0 comments on commit 55bf155

Please sign in to comment.