Skip to content

Commit b0b99a7

Browse files
bacherflodubajDT
andauthored
feat: add flagd CRD with ingress support (#633)
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com> Co-authored-by: odubajDT <93584209+odubajDT@users.noreply.github.com>
1 parent 65e20cf commit b0b99a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3485
-51
lines changed

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ helm-package: set-helm-overlay generate release-manifests helm
257257
install-mockgen:
258258
go install github.com/golang/mock/mockgen@v1.6.0
259259
mockgen: install-mockgen
260-
mockgen -source=controllers/common/flagd-injector.go -destination=controllers/common/mock/flagd-injector.go -package=commonmock
260+
mockgen -source=./common/flagdinjector/flagdinjector.go -destination=./common/flagdinjector/mock/flagd-injector.go -package=commonmock
261+
mockgen -source=./controllers/core/flagd/controller.go -destination=controllers/core/flagd/mock/mock.go -package=commonmock
262+
mockgen -source=./controllers/core/flagd/resources/interface.go -destination=controllers/core/flagd/resources/mock/mock.go -package=commonmock
261263

262264
workspace-init: workspace-clean
263265
go work init

PROJECT

+9
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,13 @@ resources:
6767
kind: FeatureFlagSource
6868
path: github.com/open-feature/open-feature-operator/apis/core/v1beta1
6969
version: v1beta1
70+
- api:
71+
crdVersion: v1
72+
namespaced: true
73+
controller: true
74+
domain: openfeature.dev
75+
group: core
76+
kind: Flagd
77+
path: github.com/open-feature/open-feature-operator/apis/core/v1beta1
78+
version: v1beta1
7079
version: "3"

apis/core/v1beta1/flagd_types.go

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
Copyright 2022.
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 v1beta1
18+
19+
import (
20+
v1 "k8s.io/api/core/v1"
21+
networkingv1 "k8s.io/api/networking/v1"
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
)
24+
25+
// FlagdSpec defines the desired state of Flagd
26+
type FlagdSpec struct {
27+
// Replicas defines the number of replicas to create for the service.
28+
// Default: 1
29+
// +optional
30+
// +kubebuilder:default=1
31+
Replicas *int32 `json:"replicas,omitempty"`
32+
33+
// ServiceType represents the type of Service to create.
34+
// Must be one of: ClusterIP, NodePort, LoadBalancer, and ExternalName.
35+
// Default: ClusterIP
36+
// +optional
37+
// +kubebuilder:default=ClusterIP
38+
// +kubebuilder:validation:Enum:=ClusterIP;NodePort;LoadBalancer;ExternalName
39+
ServiceType v1.ServiceType `json:"serviceType,omitempty"`
40+
41+
// ServiceAccountName the service account name for the flagd deployment
42+
// +optional
43+
ServiceAccountName string `json:"serviceAccountName,omitempty"`
44+
45+
// FeatureFlagSource references to a FeatureFlagSource from which the created flagd instance retrieves
46+
// the feature flag configurations
47+
FeatureFlagSource string `json:"featureFlagSource"`
48+
49+
// Ingress
50+
// +optional
51+
Ingress IngressSpec `json:"ingress"`
52+
}
53+
54+
// IngressSpec defines the options to be used when deploying the ingress for flagd
55+
type IngressSpec struct {
56+
// Enabled enables/disables the ingress for flagd
57+
Enabled bool `json:"enabled,omitempty"`
58+
59+
// Annotations the annotations to be added to the ingress
60+
// +optional
61+
Annotations map[string]string `json:"annotations,omitempty"`
62+
63+
// Hosts list of hosts to be added to the ingress
64+
// +optional
65+
Hosts []string `json:"hosts,omitempty"`
66+
67+
// TLS configuration for the ingress
68+
TLS []networkingv1.IngressTLS `json:"tls,omitempty"`
69+
70+
// IngressClassName defines the name if the ingress class to be used for flagd
71+
// +optional
72+
IngressClassName *string `json:"ingressClassName,omitempty"`
73+
74+
// PathType is the path type to be used for the ingress rules
75+
// +optional
76+
PathType networkingv1.PathType `json:"pathType,omitempty"`
77+
78+
// FlagdPath is the path to be used for accessing the flagd flag evaluation API
79+
// +optional
80+
FlagdPath string `json:"flagdPath,omitempty"`
81+
82+
// OFREPPath is the path to be used for accessing the OFREP API
83+
// +optional
84+
OFREPPath string `json:"ofrepPath"`
85+
86+
// SyncPath is the path to be used for accessing the sync API
87+
// +optional
88+
SyncPath string `json:"syncPath"`
89+
}
90+
91+
// FlagdStatus defines the observed state of Flagd
92+
type FlagdStatus struct {
93+
}
94+
95+
//+kubebuilder:object:root=true
96+
//+kubebuilder:subresource:status
97+
98+
// Flagd is the Schema for the flagds API
99+
type Flagd struct {
100+
metav1.TypeMeta `json:",inline"`
101+
metav1.ObjectMeta `json:"metadata,omitempty"`
102+
103+
Spec FlagdSpec `json:"spec,omitempty"`
104+
Status FlagdStatus `json:"status,omitempty"`
105+
}
106+
107+
//+kubebuilder:object:root=true
108+
109+
// FlagdList contains a list of Flagd
110+
type FlagdList struct {
111+
metav1.TypeMeta `json:",inline"`
112+
metav1.ListMeta `json:"metadata,omitempty"`
113+
Items []Flagd `json:"items"`
114+
}
115+
116+
func init() {
117+
SchemeBuilder.Register(&Flagd{}, &FlagdList{})
118+
}

apis/core/v1beta1/zz_generated.deepcopy.go

+135
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chart/open-feature-operator/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ templates/crds/*.yaml
44
# the following files are not generated, they are special cases
55
!templates/namespace.yaml
66
!templates/admissionregistration.k8s.io_v1_validatingwebhookconfiguration_open-feature-operator-validating-webhook-configuration.yaml
7+
!templates/rbac.authorization.k8s.io_v1_clusterrole_open-feature-operator-manager-role.yaml

0 commit comments

Comments
 (0)