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: introduce FlagService CRD with reconciliation #417

Closed
wants to merge 10 commits into from

Conversation

skyerus
Copy link
Contributor

@skyerus skyerus commented Mar 24, 2023

POC

This is a WIP implementation of the FlagService OFEP.

This PR introduces a CRD named FlagService. The creation of a FlagService CR (in OFO's namespace) triggers its reconciliation loop which does the following (in OFO's namespace):

  • Creates a Deployment of flagd
  • Creates a Service exposing the flagd deployment

How to run the POC

The demo aims to exemplify a legitimate end-to-end deployment scenario by using Kubernetes Gateway API (KGA) to ingest traffic to a demo application & the created flagd Service/Deployment.

Prerequisites:

  • Kind
  • Checkout OFO at this branch
  • istioctl (this can be substituted for any other KGA implementor but make sure to replace references to istio with the substitute)

Note: To get this to work locally I had to add hostnames to my hosts file to route them to localhost. Without this the browser doesn't send the appropriate Host header to the Gateway, preventing it from being able to route the request.

# build OFO
IMG=ghcr.io/open-feature/open-feature-operator:local ARCH=arm64 make docker-build
# create kind cluster
kind create cluster --config ./test/e2e/kind-cluster.yml
# load OFO into cluster
kind load docker-image ghcr.io/open-feature/open-feature-operator:local
# deploy OFO
IMG=ghcr.io/open-feature/open-feature-operator:local make deploy-operator
# install KGA CRDs
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.6.2/standard-install.yaml
# install istio gateway
istioctl install --set profile=minimal -y
# deploy resources
kubectl apply -f config/samples/dev.yaml
# add hostnames to hosts file (location of hosts file is macOS specific in this example)
sudo sh -c 'echo "127.0.0.1 ofoclientapp.com" >> /private/etc/hosts'
sudo sh -c 'echo "127.0.0.1 flagd.ofoclientapp.com" >> /private/etc/hosts'
# port forward 8080 to the gateway pod
kubectl port-forward $(kubectl get pods --selector=istio.io/gateway-name=clientsidegateway -o \
  jsonpath='{.items[*].metadata.name}') 8080:80

Go to http://ofoclientapp.com:8080/ in your browser and click the Update color button to verify that the traffic is routed to flagd correctly.

Further Steps

  • Handle update/delete of FlagService
  • Create ServiceSpec/DeploymentSpec fields in FlagService to passthrough configuration
  • Validation webhook to ensure FlagService is created in OFO's namespace
  • Use configured OFO namespace (currently hardcoded)
  • Testing
  • Documentation (including examples of how to use FlagService in conjunction with KGA/Ingress to route traffic to flagd)

Related Issues

#371

Notes

Follow-up Tasks

How to test

@skyerus skyerus force-pushed the issue-371/flagd-service branch from a2eab28 to 3977908 Compare March 24, 2023 14:30
@codecov
Copy link

codecov bot commented Mar 24, 2023

Codecov Report

Merging #417 (7ac9376) into main (29d7cf0) will decrease coverage by 1.13%.
The diff coverage is 88.23%.

@@            Coverage Diff             @@
##             main     #417      +/-   ##
==========================================
- Coverage   78.12%   77.00%   -1.13%     
==========================================
  Files          12       12              
  Lines         855      687     -168     
==========================================
- Hits          668      529     -139     
+ Misses        153      131      -22     
+ Partials       34       27       -7     
Impacted Files Coverage Δ
webhooks/pod_webhook.go 84.27% <86.66%> (+0.65%) ⬆️
webhooks/pod_webhook_deprecated.go 47.61% <100.00%> (ø)
Flag Coverage Δ
component-tests 78.99% <88.23%> (-1.30%) ⬇️
unit-tests 45.12% <0.00%> (+8.86%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@skyerus skyerus force-pushed the issue-371/flagd-service branch from 30376be to e6478be Compare March 27, 2023 09:19
skyerus added 10 commits March 27, 2023 16:32
Signed-off-by: Skye Gill <[email protected]>
Signed-off-by: Skye Gill <[email protected]>
Signed-off-by: Skye Gill <[email protected]>
Signed-off-by: Skye Gill <[email protected]>
Signed-off-by: Skye Gill <[email protected]>
Signed-off-by: Skye Gill <[email protected]>
Signed-off-by: Skye Gill <[email protected]>
Signed-off-by: Skye Gill <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants