-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(alertchannels): Add AlertChannels resources (#24)
AlertChannels can be added to groups, they currently support OpsGenie and Email configuration.
- Loading branch information
Showing
25 changed files
with
1,192 additions
and
9 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
Copyright 2022. | ||
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 ( | ||
"github.com/checkly/checkly-go-sdk" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// AlertChannelSpec defines the desired state of AlertChannel | ||
type AlertChannelSpec struct { | ||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
|
||
// SendRecovery determines if the Recovery event should be sent to the alert channel | ||
SendRecovery bool `json:"sendrecovery,omitempty"` | ||
|
||
// SendFailure determines if the Failure event should be sent to the alerting channel | ||
SendFailure bool `json:"sendfailure,omitempty"` | ||
|
||
// OpsGenie holds information about the Opsgenie alert configuration | ||
OpsGenie AlertChannelOpsGenie `json:"opsgenie,omitempty"` | ||
|
||
// Email holds information about the Email alert configuration | ||
Email checkly.AlertChannelEmail `json:"email,omitempty"` | ||
} | ||
|
||
type AlertChannelOpsGenie struct { | ||
// APISecret determines where the secret ref is to pull the OpsGenie API key from | ||
APISecret corev1.ObjectReference `json:"apisecret"` | ||
|
||
// Region holds information about the OpsGenie region (EU or US) | ||
Region string `json:"region,omitempty"` | ||
|
||
// Priority assigned to the alerts sent from checklyhq.com | ||
Priority string `json:"priority,omitempty"` | ||
} | ||
|
||
// AlertChannelStatus defines the observed state of AlertChannel | ||
type AlertChannelStatus struct { | ||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
ID int64 `json:"id"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
//+kubebuilder:resource:scope=Cluster | ||
|
||
// AlertChannel is the Schema for the alertchannels API | ||
type AlertChannel struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec AlertChannelSpec `json:"spec,omitempty"` | ||
Status AlertChannelStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// AlertChannelList contains a list of AlertChannel | ||
type AlertChannelList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []AlertChannel `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&AlertChannel{}, &AlertChannelList{}) | ||
} |
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
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,121 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.9.0 | ||
creationTimestamp: null | ||
name: alertchannels.k8s.checklyhq.com | ||
spec: | ||
group: k8s.checklyhq.com | ||
names: | ||
kind: AlertChannel | ||
listKind: AlertChannelList | ||
plural: alertchannels | ||
singular: alertchannel | ||
scope: Cluster | ||
versions: | ||
- name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: AlertChannel is the Schema for the alertchannels 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: AlertChannelSpec defines the desired state of AlertChannel | ||
properties: | ||
email: | ||
description: Email holds information about the Email alert configuration | ||
properties: | ||
address: | ||
type: string | ||
required: | ||
- address | ||
type: object | ||
opsgenie: | ||
description: OpsGenie holds information about the Opsgenie alert configuration | ||
properties: | ||
apisecret: | ||
description: APISecret determines where the secret ref is to pull | ||
the OpsGenie API key from | ||
properties: | ||
apiVersion: | ||
description: API version of the referent. | ||
type: string | ||
fieldPath: | ||
description: 'If referring to a piece of an object instead | ||
of an entire object, this string should contain a valid | ||
JSON/Go field access statement, such as desiredState.manifest.containers[2]. | ||
For example, if the object reference is to a container within | ||
a pod, this would take on a value like: "spec.containers{name}" | ||
(where "name" refers to the name of the container that triggered | ||
the event) or if no container name is specified "spec.containers[2]" | ||
(container with index 2 in this pod). This syntax is chosen | ||
only to have some well-defined way of referencing a part | ||
of an object. TODO: this design is not final and this field | ||
is subject to change in the future.' | ||
type: string | ||
kind: | ||
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' | ||
type: string | ||
name: | ||
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' | ||
type: string | ||
namespace: | ||
description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' | ||
type: string | ||
resourceVersion: | ||
description: 'Specific resourceVersion to which this reference | ||
is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency' | ||
type: string | ||
uid: | ||
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' | ||
type: string | ||
type: object | ||
priority: | ||
description: Priority assigned to the alerts sent from checklyhq.com | ||
type: string | ||
region: | ||
description: Region holds information about the OpsGenie region | ||
(EU or US) | ||
type: string | ||
required: | ||
- apisecret | ||
type: object | ||
sendfailure: | ||
description: SendFailure determines if the Failure event should be | ||
sent to the alerting channel | ||
type: boolean | ||
sendrecovery: | ||
description: SendRecovery determines if the Recovery event should | ||
be sent to the alert channel | ||
type: boolean | ||
type: object | ||
status: | ||
description: AlertChannelStatus defines the observed state of AlertChannel | ||
properties: | ||
id: | ||
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state | ||
of cluster Important: Run "make" to regenerate code after modifying | ||
this file' | ||
format: int64 | ||
type: integer | ||
required: | ||
- id | ||
type: object | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} |
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
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,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: alertchannels.checkly.checklyhq.com |
Oops, something went wrong.