Skip to content

Commit

Permalink
Create empty WatcherApplier CRD and controller
Browse files Browse the repository at this point in the history
Intended to manage de watcher-applier component of watcher
service.

Using openstack-sdk:

$ operator-sdk create api \
                      --group watcher \
                      --version v1beta1 \
                      --kind WatcherApplier \
                      --resource \
                      --controller

JIRA: OSPRH-11485
  • Loading branch information
amoralej authored and openshift-merge-bot[bot] committed Nov 15, 2024
1 parent ed1e612 commit 953b0a8
Show file tree
Hide file tree
Showing 16 changed files with 459 additions and 0 deletions.
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,13 @@ resources:
kind: WatcherDecisionEngine
path: github.com/openstack-k8s-operators/watcher-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: openstack.org
group: watcher
kind: WatcherApplier
path: github.com/openstack-k8s-operators/watcher-operator/api/v1beta1
version: v1beta1
version: "3"
50 changes: 50 additions & 0 deletions api/bases/watcher.openstack.org_watcherappliers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.1
creationTimestamp: null
name: watcherappliers.watcher.openstack.org
spec:
group: watcher.openstack.org
names:
kind: WatcherApplier
listKind: WatcherApplierList
plural: watcherappliers
singular: watcherapplier
scope: Namespaced
versions:
- name: v1beta1
schema:
openAPIV3Schema:
description: WatcherApplier is the Schema for the watcherappliers API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: WatcherApplierSpec defines the desired state of WatcherApplier
properties:
foo:
description: Foo is an example field of WatcherApplier. Edit watcherapplier_types.go
to remove/update
type: string
type: object
status:
description: WatcherApplierStatus defines the observed state of WatcherApplier
type: object
type: object
served: true
storage: true
subresources:
status: {}
64 changes: 64 additions & 0 deletions api/v1beta1/watcherapplier_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta1

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.

// WatcherApplierSpec defines the desired state of WatcherApplier
type WatcherApplierSpec 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 WatcherApplier. Edit watcherapplier_types.go to remove/update
Foo string `json:"foo,omitempty"`
}

// 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
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// WatcherApplier is the Schema for the watcherappliers API
type WatcherApplier struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec WatcherApplierSpec `json:"spec,omitempty"`
Status WatcherApplierStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// WatcherApplierList contains a list of WatcherApplier
type WatcherApplierList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []WatcherApplier `json:"items"`
}

func init() {
SchemeBuilder.Register(&WatcherApplier{}, &WatcherApplierList{})
}
89 changes: 89 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

50 changes: 50 additions & 0 deletions config/crd/bases/watcher.openstack.org_watcherappliers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.1
creationTimestamp: null
name: watcherappliers.watcher.openstack.org
spec:
group: watcher.openstack.org
names:
kind: WatcherApplier
listKind: WatcherApplierList
plural: watcherappliers
singular: watcherapplier
scope: Namespaced
versions:
- name: v1beta1
schema:
openAPIV3Schema:
description: WatcherApplier is the Schema for the watcherappliers API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: WatcherApplierSpec defines the desired state of WatcherApplier
properties:
foo:
description: Foo is an example field of WatcherApplier. Edit watcherapplier_types.go
to remove/update
type: string
type: object
status:
description: WatcherApplierStatus defines the observed state of WatcherApplier
type: object
type: object
served: true
storage: true
subresources:
status: {}
3 changes: 3 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ resources:
- bases/watcher.openstack.org_watcherapis.yaml
- bases/watcher.openstack.org_watchers.yaml
- bases/watcher.openstack.org_watcherdecisionengines.yaml
- bases/watcher.openstack.org_watcherappliers.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patches:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
#- patches/webhook_in_watchers.yaml
#- patches/webhook_in_watcherdecisionengines.yaml
#- patches/webhook_in_watcherappliers.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
#- path: patches/cainjection_in_watcherapis.yaml
#- patches/cainjection_in_watchers.yaml
#- patches/cainjection_in_watcherdecisionengines.yaml
#- patches/cainjection_in_watcherappliers.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# [WEBHOOK] To enable webhook, uncomment the following section
Expand Down
7 changes: 7 additions & 0 deletions config/crd/patches/cainjection_in_watcherappliers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: watcherappliers.watcher.openstack.org
16 changes: 16 additions & 0 deletions config/crd/patches/webhook_in_watcherappliers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The following patch enables a conversion webhook for the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: watcherappliers.watcher.openstack.org
spec:
conversion:
strategy: Webhook
webhook:
clientConfig:
service:
namespace: system
name: webhook-service
path: /convert
conversionReviewVersions:
- v1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ spec:
kind: WatcherAPI
name: watcherapis.watcher.openstack.org
version: v1beta1
- description: WatcherApplier is the Schema for the watcherappliers API
displayName: Watcher Applier
kind: WatcherApplier
name: watcherappliers.watcher.openstack.org
version: v1beta1
- description: WatcherDecisionEngine is the Schema for the watcherdecisionengines
API
displayName: Watcher Decision Engine
Expand Down
26 changes: 26 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@ rules:
- get
- patch
- update
- apiGroups:
- watcher.openstack.org
resources:
- watcherappliers
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- watcher.openstack.org
resources:
- watcherappliers/finalizers
verbs:
- update
- apiGroups:
- watcher.openstack.org
resources:
- watcherappliers/status
verbs:
- get
- patch
- update
- apiGroups:
- watcher.openstack.org
resources:
Expand Down
Loading

0 comments on commit 953b0a8

Please sign in to comment.