Skip to content

Commit de30978

Browse files
committed
Add HTTP Add-on controller
Signed-off-by: Mikhail Fedosin <[email protected]>
1 parent d5e451d commit de30978

File tree

13 files changed

+1406
-0
lines changed

13 files changed

+1406
-0
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
Copyright 2020 The KEDA Authors
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 v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
type KedaHTTPAddOnPhase string
24+
25+
const (
26+
HTTPAddOnPhaseNone KedaHTTPAddOnPhase = ""
27+
HTTPAddOnPhaseInstallSucceeded KedaHTTPAddOnPhase = "Installation Succeeded"
28+
HTTPAddOnPhaseIgnored KedaHTTPAddOnPhase = "Installation Ignored"
29+
HTTPAddOnPhaseFailed KedaHTTPAddOnPhase = "Installation Failed"
30+
)
31+
32+
// KedaHTTPAddOnSpec defines the desired state of KedaHTTPAddOn
33+
type KedaHTTPAddOnSpec struct {
34+
// Namespace that the add-on should watch; empty means all namespaces
35+
// +optional
36+
WatchNamespace string `json:"watchNamespace,omitempty"`
37+
38+
// Version (image tag) of the HTTP Add-on to deploy, e.g. "0.11.0"
39+
// If empty, uses the default version
40+
// +optional
41+
Version string `json:"version,omitempty"`
42+
43+
// Optional custom image for the HTTP Add-on operator
44+
// +optional
45+
OperatorImage string `json:"operatorImage,omitempty"`
46+
47+
// Optional custom image for the HTTP Add-on scaler
48+
// +optional
49+
ScalerImage string `json:"scalerImage,omitempty"`
50+
51+
// Optional custom image for the HTTP Add-on interceptor
52+
// +optional
53+
InterceptorImage string `json:"interceptorImage,omitempty"`
54+
}
55+
56+
// KedaHTTPAddOnStatus defines the observed state of KedaHTTPAddOn
57+
type KedaHTTPAddOnStatus struct {
58+
// Phase describes the current state of the HTTP Add-on installation
59+
// +optional
60+
Phase KedaHTTPAddOnPhase `json:"phase,omitempty"`
61+
62+
// Reason provides a human-readable message for the current phase
63+
// +optional
64+
Reason string `json:"reason,omitempty"`
65+
66+
// Version indicates the deployed HTTP Add-on version
67+
// +optional
68+
Version string `json:"version,omitempty"`
69+
}
70+
71+
// +kubebuilder:object:root=true
72+
// +kubebuilder:subresource:status
73+
// +kubebuilder:resource:path=kedahttpaddons,scope=Namespaced
74+
75+
// KedaHTTPAddOn is the Schema for the kedahttpaddons API
76+
type KedaHTTPAddOn struct {
77+
metav1.TypeMeta `json:",inline"`
78+
metav1.ObjectMeta `json:"metadata,omitempty"`
79+
80+
Spec KedaHTTPAddOnSpec `json:"spec,omitempty"`
81+
Status KedaHTTPAddOnStatus `json:"status,omitempty"`
82+
}
83+
84+
// +kubebuilder:object:root=true
85+
86+
// KedaHTTPAddOnList contains a list of KedaHTTPAddOn
87+
type KedaHTTPAddOnList struct {
88+
metav1.TypeMeta `json:",inline"`
89+
metav1.ListMeta `json:"metadata,omitempty"`
90+
Items []KedaHTTPAddOn `json:"items"`
91+
}
92+
93+
func init() {
94+
SchemeBuilder.Register(&KedaHTTPAddOn{}, &KedaHTTPAddOnList{})
95+
}
96+
97+
func (khs *KedaHTTPAddOnStatus) SetPhase(p KedaHTTPAddOnPhase) {
98+
khs.Phase = p
99+
}
100+
101+
func (khs *KedaHTTPAddOnStatus) SetReason(r string) {
102+
khs.Reason = r
103+
}
104+
105+
func (khs *KedaHTTPAddOnStatus) MarkIgnored(r string) {
106+
khs.Phase = HTTPAddOnPhaseIgnored
107+
khs.Reason = r
108+
}
109+
110+
func (khs *KedaHTTPAddOnStatus) MarkInstallSucceeded(r string) {
111+
khs.Phase = HTTPAddOnPhaseInstallSucceeded
112+
khs.Reason = r
113+
}
114+
115+
func (khs *KedaHTTPAddOnStatus) MarkInstallFailed(r string) {
116+
khs.Phase = HTTPAddOnPhaseFailed
117+
khs.Reason = r
118+
}

api/keda/v1alpha1/zz_generated.deepcopy.go

Lines changed: 89 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.5
7+
name: kedahttpaddons.keda.sh
8+
spec:
9+
group: keda.sh
10+
names:
11+
kind: KedaHTTPAddOn
12+
listKind: KedaHTTPAddOnList
13+
plural: kedahttpaddons
14+
singular: kedahttpaddon
15+
scope: Namespaced
16+
versions:
17+
- name: v1alpha1
18+
schema:
19+
openAPIV3Schema:
20+
description: KedaHTTPAddOn is the Schema for the kedahttpaddons API
21+
properties:
22+
apiVersion:
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
28+
type: string
29+
kind:
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
description: KedaHTTPAddOnSpec defines the desired state of KedaHTTPAddOn
41+
properties:
42+
interceptorImage:
43+
description: Optional custom image for the HTTP Add-on interceptor
44+
type: string
45+
operatorImage:
46+
description: Optional custom image for the HTTP Add-on operator
47+
type: string
48+
scalerImage:
49+
description: Optional custom image for the HTTP Add-on scaler
50+
type: string
51+
version:
52+
description: |-
53+
Version (image tag) of the HTTP Add-on to deploy, e.g. "0.11.0"
54+
If empty, uses the default version
55+
type: string
56+
watchNamespace:
57+
description: Namespace that the add-on should watch; empty means all
58+
namespaces
59+
type: string
60+
type: object
61+
status:
62+
description: KedaHTTPAddOnStatus defines the observed state of KedaHTTPAddOn
63+
properties:
64+
phase:
65+
description: Phase describes the current state of the HTTP Add-on
66+
installation
67+
type: string
68+
reason:
69+
description: Reason provides a human-readable message for the current
70+
phase
71+
type: string
72+
version:
73+
description: Version indicates the deployed HTTP Add-on version
74+
type: string
75+
type: object
76+
type: object
77+
served: true
78+
storage: true
79+
subresources:
80+
status: {}

cmd/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ func main() {
123123
setupLog.Error(err, "unable to create controller", "controller", "Secret")
124124
os.Exit(1)
125125
}
126+
if err = (&kedacontrollers.KedaHTTPAddOnReconciler{
127+
Client: mgr.GetClient(),
128+
Log: ctrl.Log.WithName("controllers").WithName("KedaHTTPAddOn"),
129+
Scheme: mgr.GetScheme(),
130+
}).SetupWithManager(mgr, installNamespace, setupLog); err != nil {
131+
setupLog.Error(err, "unable to create controller", "controller", "KedaHTTPAddOn")
132+
os.Exit(1)
133+
}
126134
//+kubebuilder:scaffold:builder
127135

128136
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.5
7+
name: kedahttpaddons.keda.sh
8+
spec:
9+
group: keda.sh
10+
names:
11+
kind: KedaHTTPAddOn
12+
listKind: KedaHTTPAddOnList
13+
plural: kedahttpaddons
14+
singular: kedahttpaddon
15+
scope: Namespaced
16+
versions:
17+
- name: v1alpha1
18+
schema:
19+
openAPIV3Schema:
20+
description: KedaHTTPAddOn is the Schema for the kedahttpaddons API
21+
properties:
22+
apiVersion:
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
28+
type: string
29+
kind:
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
description: KedaHTTPAddOnSpec defines the desired state of KedaHTTPAddOn
41+
properties:
42+
interceptorImage:
43+
description: Optional custom image for the HTTP Add-on interceptor
44+
type: string
45+
operatorImage:
46+
description: Optional custom image for the HTTP Add-on operator
47+
type: string
48+
scalerImage:
49+
description: Optional custom image for the HTTP Add-on scaler
50+
type: string
51+
version:
52+
description: |-
53+
Version (image tag) of the HTTP Add-on to deploy, e.g. "0.11.0"
54+
If empty, uses the default version
55+
type: string
56+
watchNamespace:
57+
description: Namespace that the add-on should watch; empty means all
58+
namespaces
59+
type: string
60+
type: object
61+
status:
62+
description: KedaHTTPAddOnStatus defines the observed state of KedaHTTPAddOn
63+
properties:
64+
phase:
65+
description: Phase describes the current state of the HTTP Add-on
66+
installation
67+
type: string
68+
reason:
69+
description: Reason provides a human-readable message for the current
70+
phase
71+
type: string
72+
version:
73+
description: Version indicates the deployed HTTP Add-on version
74+
type: string
75+
type: object
76+
type: object
77+
served: true
78+
storage: true
79+
subresources:
80+
status: {}

config/crd/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# It should be run by config/default
44
resources:
55
- bases/keda.sh_kedacontrollers.yaml
6+
- bases/keda.sh_kedahttpaddons.yaml
67
- bases/keda.sh_scaledjobs.yaml
78
- bases/keda.sh_scaledobjects.yaml
89
- bases/keda.sh_triggerauthentications.yaml

0 commit comments

Comments
 (0)