Skip to content

Commit 7b0a173

Browse files
committed
Add Keptn SLI CRD and controller boilerplate
Signed-off-by: Eric Kim <[email protected]>
1 parent 7acaa5d commit 7b0a173

14 files changed

+411
-1
lines changed

keptn-operator/PROJECT

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,12 @@ resources:
8686
kind: KeptnInstance
8787
path: github.com/keptn-sandbox/keptn-gitops-operator/keptn-operator/api/v1
8888
version: v1
89+
- api:
90+
crdVersion: v1
91+
namespaced: true
92+
controller: true
93+
domain: keptn.sh
94+
kind: KeptnServiceLevelIndicator
95+
path: github.com/keptn-sandbox/keptn-gitops-operator/keptn-operator/api/v1
96+
version: v1
8997
version: "3"
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
Copyright 2021.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// KeptnServiceLevelIndicatorSpec defines the desired state of KeptnServiceLevelIndicator
27+
type KeptnServiceLevelIndicatorSpec struct {
28+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29+
// Important: Run "make" to regenerate code after modifying this file
30+
31+
// Foo is an example field of KeptnServiceLevelIndicator. Edit keptnservicelevelindicator_types.go to remove/update
32+
Provider string `json:"provider"`
33+
Indicators map[string]string `json:"indicators"`
34+
}
35+
36+
// KeptnServiceLevelIndicatorStatus defines the observed state of KeptnServiceLevelIndicator
37+
type KeptnServiceLevelIndicatorStatus struct {
38+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
39+
// Important: Run "make" to regenerate code after modifying this file
40+
}
41+
42+
//+kubebuilder:object:root=true
43+
//+kubebuilder:subresource:status
44+
45+
// KeptnServiceLevelIndicator is the Schema for the keptnservicelevelindicators API
46+
type KeptnServiceLevelIndicator struct {
47+
metav1.TypeMeta `json:",inline"`
48+
metav1.ObjectMeta `json:"metadata,omitempty"`
49+
50+
Spec KeptnServiceLevelIndicatorSpec `json:"spec,omitempty"`
51+
Status KeptnServiceLevelIndicatorStatus `json:"status,omitempty"`
52+
}
53+
54+
//+kubebuilder:object:root=true
55+
56+
// KeptnServiceLevelIndicatorList contains a list of KeptnServiceLevelIndicator
57+
type KeptnServiceLevelIndicatorList struct {
58+
metav1.TypeMeta `json:",inline"`
59+
metav1.ListMeta `json:"metadata,omitempty"`
60+
Items []KeptnServiceLevelIndicator `json:"items"`
61+
}
62+
63+
func init() {
64+
SchemeBuilder.Register(&KeptnServiceLevelIndicator{}, &KeptnServiceLevelIndicatorList{})
65+
}

keptn-operator/api/v1/zz_generated.deepcopy.go

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.7.0
8+
creationTimestamp: null
9+
name: keptnservicelevelindicators.keptn.sh
10+
spec:
11+
group: keptn.sh
12+
names:
13+
kind: KeptnServiceLevelIndicator
14+
listKind: KeptnServiceLevelIndicatorList
15+
plural: keptnservicelevelindicators
16+
singular: keptnservicelevelindicator
17+
scope: Namespaced
18+
versions:
19+
- name: v1
20+
schema:
21+
openAPIV3Schema:
22+
description: KeptnServiceLevelIndicator is the Schema for the keptnservicelevelindicators
23+
API
24+
properties:
25+
apiVersion:
26+
description: 'APIVersion defines the versioned schema of this representation
27+
of an object. Servers should convert recognized schemas to the latest
28+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
29+
type: string
30+
kind:
31+
description: 'Kind is a string value representing the REST resource this
32+
object represents. Servers may infer this from the endpoint the client
33+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
34+
type: string
35+
metadata:
36+
type: object
37+
spec:
38+
description: KeptnServiceLevelIndicatorSpec defines the desired state
39+
of KeptnServiceLevelIndicator
40+
properties:
41+
indicators:
42+
additionalProperties:
43+
type: string
44+
type: object
45+
provider:
46+
description: Foo is an example field of KeptnServiceLevelIndicator.
47+
Edit keptnservicelevelindicator_types.go to remove/update
48+
type: string
49+
required:
50+
- indicators
51+
- provider
52+
type: object
53+
status:
54+
description: KeptnServiceLevelIndicatorStatus defines the observed state
55+
of KeptnServiceLevelIndicator
56+
type: object
57+
type: object
58+
served: true
59+
storage: true
60+
subresources:
61+
status: {}
62+
status:
63+
acceptedNames:
64+
kind: ""
65+
plural: ""
66+
conditions: []
67+
storedVersions: []

keptn-operator/config/crd/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ resources:
1212
- bases/keptn.sh_keptnservicedeployments.yaml
1313
- bases/keptn.sh_keptndeploymentcontexts.yaml
1414
- bases/keptn.sh_keptninstances.yaml
15+
- bases/keptn.sh_keptnservicelevelindicators.yaml
1516
#+kubebuilder:scaffold:crdkustomizeresource
1617

1718
patchesStrategicMerge:
@@ -27,6 +28,7 @@ patchesStrategicMerge:
2728
#- patches/webhook_in_keptnservicedeployments.yaml
2829
#- patches/webhook_in_keptndeploymentcontexts.yaml
2930
#- patches/webhook_in_keptninstances.yaml
31+
#- patches/webhook_in_keptnservicelevelindicators.yaml
3032
#+kubebuilder:scaffold:crdkustomizewebhookpatch
3133

3234
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
@@ -41,6 +43,7 @@ patchesStrategicMerge:
4143
#- patches/cainjection_in_keptnservicedeployments.yaml
4244
#- patches/cainjection_in_keptndeploymentcontexts.yaml
4345
#- patches/cainjection_in_keptninstances.yaml
46+
#- patches/cainjection_in_keptnservicelevelindicators.yaml
4447
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
4548

4649
# the following config is for teaching kustomize how to do kustomization for CRDs.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# The following patch adds a directive for certmanager to inject CA into the CRD
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
7+
name: keptnservicelevelindicators.keptn.sh
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The following patch enables a conversion webhook for the CRD
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
name: keptnservicelevelindicators.keptn.sh
6+
spec:
7+
conversion:
8+
strategy: Webhook
9+
webhook:
10+
clientConfig:
11+
service:
12+
namespace: system
13+
name: webhook-service
14+
path: /convert
15+
conversionReviewVersions:
16+
- v1
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# permissions for end users to edit keptnservicelevelindicators.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: keptnservicelevelindicator-editor-role
6+
rules:
7+
- apiGroups:
8+
- keptn.sh
9+
resources:
10+
- keptnservicelevelindicators
11+
verbs:
12+
- create
13+
- delete
14+
- get
15+
- list
16+
- patch
17+
- update
18+
- watch
19+
- apiGroups:
20+
- keptn.sh
21+
resources:
22+
- keptnservicelevelindicators/status
23+
verbs:
24+
- get
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# permissions for end users to view keptnservicelevelindicators.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: keptnservicelevelindicator-viewer-role
6+
rules:
7+
- apiGroups:
8+
- keptn.sh
9+
resources:
10+
- keptnservicelevelindicators
11+
verbs:
12+
- get
13+
- list
14+
- watch
15+
- apiGroups:
16+
- keptn.sh
17+
resources:
18+
- keptnservicelevelindicators/status
19+
verbs:
20+
- get

keptn-operator/config/rbac/role.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,32 @@ rules:
236236
- get
237237
- patch
238238
- update
239+
- apiGroups:
240+
- keptn.sh
241+
resources:
242+
- keptnservicelevelindicators
243+
verbs:
244+
- create
245+
- delete
246+
- get
247+
- list
248+
- patch
249+
- update
250+
- watch
251+
- apiGroups:
252+
- keptn.sh
253+
resources:
254+
- keptnservicelevelindicators/finalizers
255+
verbs:
256+
- update
257+
- apiGroups:
258+
- keptn.sh
259+
resources:
260+
- keptnservicelevelindicators/status
261+
verbs:
262+
- get
263+
- patch
264+
- update
239265
- apiGroups:
240266
- keptn.sh
241267
resources:

0 commit comments

Comments
 (0)