Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add flagd CRD with ingress support #633

Merged
merged 46 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
854d484
feat: add flagd crd and controller to deploy flagd
bacherfl May 3, 2024
0dda209
extract deployment reconciler into separate component
bacherfl May 3, 2024
cdc2658
implement flagd deployment/service/ingress creation
bacherfl May 6, 2024
7c7cd90
update crd definition
bacherfl May 6, 2024
434c2bd
fix creation of resources
bacherfl May 6, 2024
3e12f20
fix creation of resources
bacherfl May 6, 2024
e850192
add unit tests for controller
bacherfl May 6, 2024
841454d
add mock
bacherfl May 6, 2024
15922b1
add unit tests
bacherfl May 6, 2024
2d04e04
add unit tests; support flagd grpc port
bacherfl May 7, 2024
bfa890b
clean up types, add unit tests
bacherfl May 7, 2024
f5f580a
clean up types, add unit tests
bacherfl May 7, 2024
4fd0820
fix linting
bacherfl May 7, 2024
a1c47cc
Merge remote-tracking branch 'upstream/main' into feat/615/flagd-crd2
bacherfl May 8, 2024
8e7e48f
adapt to changes from main branch
bacherfl May 8, 2024
b2b4bbd
update go deps
bacherfl May 8, 2024
efedc19
update crd docs
bacherfl May 8, 2024
b28788b
go mod tidy
bacherfl May 8, 2024
542ce1d
fix linting
bacherfl May 8, 2024
d6841cc
fix linting
bacherfl May 8, 2024
0539105
create ingress only if enabled
bacherfl May 8, 2024
2ee275d
refer to feature flag source in same namespace
bacherfl May 8, 2024
08cc258
refer to feature flag source in same namespace
bacherfl May 8, 2024
1f9b5e2
properties for customizing paths and pathtype for ingress rules
bacherfl May 8, 2024
bc45b9a
add kuttl tests
bacherfl May 8, 2024
66c30e0
fix unit tests
bacherfl May 8, 2024
28651e8
add description for new helm values
bacherfl May 8, 2024
75512ec
add helm value to enable/disable the flagd resource support
bacherfl May 8, 2024
5c2bae2
do not grant additional permissions if flagd resource is disabled
bacherfl May 8, 2024
8af732e
do not grant additional permissions if flagd resource is disabled
bacherfl May 8, 2024
11cf4d4
fix yaml
bacherfl May 8, 2024
aae9d25
update sample
bacherfl May 8, 2024
59f0d11
update mockgen commands
bacherfl May 8, 2024
faeb156
remove autogenerated placeholder comments
bacherfl May 13, 2024
b7a6238
revert out of scope change
bacherfl May 13, 2024
1ffdbe6
Merge remote-tracking branch 'origin/feat/615/flagd-crd2' into feat/6…
bacherfl May 13, 2024
9d68103
revert out of scope change
bacherfl May 13, 2024
6cfdcd4
update crd docs
bacherfl May 13, 2024
de74598
simplify condition
bacherfl May 13, 2024
b582619
Update apis/core/v1beta1/flagd_types.go
bacherfl May 13, 2024
8291d51
adapt to PR review comments
bacherfl May 14, 2024
a7d08bf
Merge remote-tracking branch 'upstream/main' into feat/615/flagd-crd2
bacherfl May 14, 2024
2d2ae2a
remove replace directive
bacherfl May 14, 2024
ba7722a
update CRD docs
bacherfl May 14, 2024
49bc4a0
update helm docs
bacherfl May 14, 2024
b1aed49
init workspace before linting
bacherfl May 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
go-version: ${{ env.GO_VERSION }}
check-latest: true

- name: Workspace Init
run: make workspace-init

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ helm-package: set-helm-overlay generate release-manifests helm
install-mockgen:
go install github.com/golang/mock/[email protected]
mockgen: install-mockgen
mockgen -source=controllers/common/flagd-injector.go -destination=controllers/common/mock/flagd-injector.go -package=commonmock
mockgen -source=./common/flagdinjector/flagdinjector.go -destination=./common/flagdinjector/mock/flagd-injector.go -package=commonmock
mockgen -source=./controllers/core/flagd/controller.go -destination=controllers/core/flagd/mock/mock.go -package=commonmock
mockgen -source=./controllers/core/flagd/resources/interface.go -destination=controllers/core/flagd/resources/mock/mock.go -package=commonmock

workspace-init: workspace-clean
go work init
Expand Down
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,13 @@ resources:
kind: FeatureFlagSource
path: github.com/open-feature/open-feature-operator/apis/core/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: openfeature.dev
group: core
kind: Flagd
path: github.com/open-feature/open-feature-operator/apis/core/v1beta1
version: v1beta1
version: "3"
118 changes: 118 additions & 0 deletions apis/core/v1beta1/flagd_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
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 v1beta1

import (
v1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// FlagdSpec defines the desired state of Flagd
type FlagdSpec struct {
bacherfl marked this conversation as resolved.
Show resolved Hide resolved
// Replicas defines the number of replicas to create for the service.
// Default: 1
// +optional
// +kubebuilder:default=1
Replicas *int32 `json:"replicas,omitempty"`

// ServiceType represents the type of Service to create.
// Must be one of: ClusterIP, NodePort, LoadBalancer, and ExternalName.
// Default: ClusterIP
// +optional
// +kubebuilder:default=ClusterIP
// +kubebuilder:validation:Enum:=ClusterIP;NodePort;LoadBalancer;ExternalName
ServiceType v1.ServiceType `json:"serviceType,omitempty"`
odubajDT marked this conversation as resolved.
Show resolved Hide resolved

// ServiceAccountName the service account name for the flagd deployment
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// FeatureFlagSource references to a FeatureFlagSource from which the created flagd instance retrieves
// the feature flag configurations
FeatureFlagSource string `json:"featureFlagSource"`

// Ingress
// +optional
Ingress IngressSpec `json:"ingress"`
}

// IngressSpec defines the options to be used when deploying the ingress for flagd
type IngressSpec struct {
// Enabled enables/disables the ingress for flagd
Enabled bool `json:"enabled,omitempty"`

// Annotations the annotations to be added to the ingress
// +optional
Annotations map[string]string `json:"annotations,omitempty"`

// Hosts list of hosts to be added to the ingress
// +optional
Hosts []string `json:"hosts,omitempty"`

// TLS configuration for the ingress
TLS []networkingv1.IngressTLS `json:"tls,omitempty"`

// IngressClassName defines the name if the ingress class to be used for flagd
// +optional
IngressClassName *string `json:"ingressClassName,omitempty"`

// PathType is the path type to be used for the ingress rules
// +optional
PathType networkingv1.PathType `json:"pathType,omitempty"`

// FlagdPath is the path to be used for accessing the flagd flag evaluation API
// +optional
FlagdPath string `json:"flagdPath,omitempty"`

// OFREPPath is the path to be used for accessing the OFREP API
// +optional
OFREPPath string `json:"ofrepPath"`

// SyncPath is the path to be used for accessing the sync API
// +optional
SyncPath string `json:"syncPath"`
}

// FlagdStatus defines the observed state of Flagd
type FlagdStatus struct {
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// Flagd is the Schema for the flagds API
type Flagd struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec FlagdSpec `json:"spec,omitempty"`
Status FlagdStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// FlagdList contains a list of Flagd
type FlagdList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Flagd `json:"items"`
}

func init() {
SchemeBuilder.Register(&Flagd{}, &FlagdList{})
}
135 changes: 135 additions & 0 deletions apis/core/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions chart/open-feature-operator/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ templates/crds/*.yaml
# the following files are not generated, they are special cases
!templates/namespace.yaml
!templates/admissionregistration.k8s.io_v1_validatingwebhookconfiguration_open-feature-operator-validating-webhook-configuration.yaml
!templates/rbac.authorization.k8s.io_v1_clusterrole_open-feature-operator-manager-role.yaml
Loading
Loading