Skip to content

Commit

Permalink
feat: add flagd CRD with ingress support (#633)
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Co-authored-by: odubajDT <93584209+odubajDT@users.noreply.github.com>
  • Loading branch information
bacherfl and odubajDT committed May 15, 2024
1 parent 65e20cf commit b0b99a7
Show file tree
Hide file tree
Showing 44 changed files with 3,485 additions and 51 deletions.
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/mockgen@v1.6.0
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 {
// 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"`

// 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

0 comments on commit b0b99a7

Please sign in to comment.