forked from metal3-io/baremetal-operator
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BMC subscription CRD and reconciler
This patch implements the fast eventing API: metal3-io/metal3-docs#167 We introduce a new CRD, and a new reconciler. We use the Ironic API to communicate with the BMC to manage node subscriptions.
- Loading branch information
Showing
19 changed files
with
756 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
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 v1alpha1 | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const ( | ||
|
||
// BMCEventSubscriptionFinalizer is the name of the finalizer added to | ||
// subscriptions to block delete operations until the subscription is removed | ||
// from the BMC. | ||
BMCEventSubscriptionFinalizer string = "bmceventsubscription.metal3.io" | ||
) | ||
|
||
type BMCEventSubscriptionSpec struct { | ||
// A reference to a BareMetalHost | ||
HostRef string `json:"hostRef,omitempty"` | ||
|
||
// A webhook URL to send events to | ||
Destination string `json:"destination,omitempty"` | ||
|
||
// Arbitrary user-provided context for the event | ||
Context string `json:"context,omitempty"` | ||
|
||
// Messages of which type we should pass along; defaults to ["Alert"] | ||
EventTypes []string `json:"eventTypes,omitempty"` | ||
|
||
// The BMC protocol to use; defaults to "Redfish" | ||
Protocol string `json:"protocol,omitempty"` | ||
|
||
// A secret containing HTTP headers which should be passed along to the Destination | ||
// when making a request | ||
HTTPHeadersRef *corev1.SecretReference `json:"httpHeadersRef,omitempty"` | ||
} | ||
|
||
type BMCEventSubscriptionStatus struct { | ||
SubscriptionID string `json:"subscriptionID,omitempty"` | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
// | ||
// BMCEventSubscription is the Schema for the fast eventing API | ||
// +k8s:openapi-gen=true | ||
// +kubebuilder:resource:shortName=bes;bmcevent | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:object:root=true | ||
type BMCEventSubscription struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec BMCEventSubscriptionSpec `json:"spec,omitempty"` | ||
Status BMCEventSubscriptionStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// BMCEventSubscriptionList contains a list of BMCEventSubscriptions | ||
type BMCEventSubscriptionList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []BMCEventSubscription `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&BMCEventSubscription{}, &BMCEventSubscriptionList{}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
|
||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.6.2 | ||
creationTimestamp: null | ||
name: bmceventsubscriptions.metal3.io | ||
spec: | ||
group: metal3.io | ||
names: | ||
kind: BMCEventSubscription | ||
listKind: BMCEventSubscriptionList | ||
plural: bmceventsubscriptions | ||
shortNames: | ||
- bes | ||
- bmcevent | ||
singular: bmceventsubscription | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: BMCEventSubscription is the Schema for the fast eventing 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: | ||
properties: | ||
context: | ||
description: Arbitrary user-provided context for the event | ||
type: string | ||
destination: | ||
description: A webhook URL to send events to | ||
type: string | ||
eventTypes: | ||
description: Messages of which type we should pass along; defaults | ||
to ["Alert"] | ||
items: | ||
type: string | ||
type: array | ||
hostRef: | ||
description: A reference to a BareMetalHost | ||
type: string | ||
httpHeadersRef: | ||
description: A secret containing HTTP headers which should be passed | ||
along to the Destination when making a request | ||
properties: | ||
name: | ||
description: Name is unique within a namespace to reference a | ||
secret resource. | ||
type: string | ||
namespace: | ||
description: Namespace defines the space within which the secret | ||
name must be unique. | ||
type: string | ||
type: object | ||
protocol: | ||
description: The BMC protocol to use; defaults to "Redfish" | ||
type: string | ||
type: object | ||
status: | ||
properties: | ||
subscriptionID: | ||
type: string | ||
type: object | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} | ||
status: | ||
acceptedNames: | ||
kind: "" | ||
plural: "" | ||
conditions: [] | ||
storedVersions: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.