diff --git a/README.md b/README.md index 64cdca6..e0ada14 100644 --- a/README.md +++ b/README.md @@ -12,18 +12,13 @@ We'll be adding more applications over time, so check back often! - [Chatbot](./chatbot/README.md) - A set of tutorials on how to use Flipt in different scenarios, based on the idea of releasing an AI-powered chatbot. - [Cup](./cup/README.md) - A tutorial demonstrating the [Cup project](https://github.com/flipt-io/cup) managing different configuration formats. - -## Prerequisites - -- [Node.js](https://nodejs.org/en/download/) (v16 or higher) -- [Docker](https://docs.docker.com/get-docker/) -- [Docker Compose](https://docs.docker.com/compose/install/) +- [Sidecar](./sidecar/README.md) - Demonstrates how to use Flipt as a sidecar to your application for fast evaluations in various configurations. ## Usage 1. Clone this repository 1. `cd` into a subdirectory (e.g. `cd chatbot`) -1. Run `./scripts/start` +1. Run `./scripts/start` or similar scripts to start the application ## Troubleshooting diff --git a/chatbot/scripts/start b/chatbot/scripts/start index cd524a8..a9bd3ae 100755 --- a/chatbot/scripts/start +++ b/chatbot/scripts/start @@ -1,7 +1,8 @@ #!/bin/bash - set -e +cd "$(dirname "$0")/.." + pushd frontend npm i && npm run start popd \ No newline at end of file diff --git a/cup/argo/README.md b/cup/argo/README.md index 2aca057..38ea131 100644 --- a/cup/argo/README.md +++ b/cup/argo/README.md @@ -5,22 +5,22 @@ This labs section explores configuring an end-to-end CD pipeline with Argo and C ![Cup with ArgoCD Diagram](./diagram.svg) -https://github.com/flipt-io/labs/assets/1253326/4dfb87ec-446c-40dc-84d1-2764bd600fd1 + The project deploys a simple application via Argo, which responds with a JSON payload containing its environment variables. It also configures an instance of Cup and a source Git repository hosted via Gitea. Once deployed to a local `kind` cluster, you can experiment with reading and reconfiguring the deployment configuration via the `cup` CLI. -### Requirements +## Prerequisites - Go -- Kubectl -- Docker +- [Docker](https://www.docker.com/) +- [Kubectl](https://kubernetes.io/docs/reference/kubectl/) - [Cup CLI](https://github.com/flipt-io/cup#cli) -- Dagger (Optional) +- [Dagger](https://dagger.io/) (Optional) -### Running +## Running ```console # clone the labs repository @@ -33,7 +33,7 @@ cd labs/cup/argo ./scripts/start ``` -### Experiment! +## Experiment This process can take a while for the first time. @@ -47,8 +47,8 @@ It will: - Port-forward the various services - [ArgoCD](http://localhost:8080) (Skip the TLS warning check output from previous step for username and password) - [Gitea](http://localhost:3000) (Username: `cup` Password: `password`) - - Cupd API is forwarded to http://localhost:8181 - - Demo app API is forwarded to http://localhost:8282 + - Cupd API is forwarded to + - Demo app API is forwarded to The end result is an entire CD pipeline in your local Docker instance. From here you can leverage the `cup` CLI to interface with `cupd`. diff --git a/cup/argo/scripts/start b/cup/argo/scripts/start index e90435e..05fd784 100755 --- a/cup/argo/scripts/start +++ b/cup/argo/scripts/start @@ -1,4 +1,7 @@ #!/bin/bash +set -e + +cd "$(dirname "$0")/.." if command -v dagger > /dev/null; then dagger run go run ./cmd/provision/main.go diff --git a/sidecar/README.md b/sidecar/README.md index 3a87077..d67b121 100644 --- a/sidecar/README.md +++ b/sidecar/README.md @@ -1,7 +1,7 @@ Flipt as a Sidecar ------------ -The intent of this lab is to explore the ways that clients can achieve fast evaluations from Flipt for their feature flags. The use case here is that users would like data locality for their feature flag state, so they do not have to worry about network latency to evaluate a feature, especially for their most critical application paths. +The intent of this lab is to explore the ways that clients can achieve fast evaluations from Flipt for their feature flags. The use case here is that users want data locality for their feature flag state, so they do not have to worry about network latency to evaluate a feature, especially for their most critical application paths. ## Replication @@ -9,7 +9,8 @@ This project is housed under the `replication` directory. The purpose is for a u Lets get started! -Prerequisites: +## Prerequisites + - [Docker](https://www.docker.com/) - [Kubectl](https://kubernetes.io/docs/reference/kubectl/) - [Minikube](https://minikube.sigs.k8s.io/docs/) @@ -21,6 +22,7 @@ Run the deploy script `scripts/start-object-store` to provision the cluster and Object Store Replication This above script deploys the following to Kubernetes: + - `minio`: Object store that has an S3 compatible API - `flipt-master`: Serves as the main Flipt application, this is where users will be accessing the UI to make relevant changes - `sample-app`: Serves as the pod with Flipt running as a sidecar, `flipt-sidecar`. There is also a container called `evaluation-client` that will make evaluation calls to the sidecar @@ -45,16 +47,15 @@ Here are the steps to do so: 1. Access the frontend for the `sample-app` via Kubernetes port-forward ```bash -$ kubectl port-forward svc/sample-app --namespace default 8000:8000 +kubectl port-forward svc/sample-app --namespace default 8000:8000 ``` 2. Switch between `Sidecar` and `Master` and choose a flag `flag_001 - flag_010` and evaluate the time difference - You can also access the `flipt-master` via Kubernetes port-forward and make changes to the state via the UI: ```bash -$ kubectl port-forward svc/flipt-master --namespace default 8080:8080 +kubectl port-forward svc/flipt-master --namespace default 8080:8080 ``` ### cURL @@ -64,13 +65,13 @@ For users of the terminal you can also hit an endpoint to see the differences of 1. Port forward `sample-app` ```bash -$ kubectl port-forward svc/sample-app --namespace default 8000:8000 +kubectl port-forward svc/sample-app --namespace default 8000:8000 ``` 2. Make request with `curl` ```bash -$ curl localhost:8000/cli/backend/{backend}/evaluation/{flagKey} +curl localhost:8000/cli/backend/{backend}/evaluation/{flagKey} ``` -The backend should be of either type (`sidecar` or `master`), and the `flagKey` should be between `flag_001 - flag_010`. \ No newline at end of file +The backend should be of either type (`sidecar` or `master`), and the `flagKey` should be between `flag_001 - flag_010`. diff --git a/sidecar/replication/go/Dockerfile b/sidecar/replication/go/Dockerfile index 4332a3d..d199a75 100644 --- a/sidecar/replication/go/Dockerfile +++ b/sidecar/replication/go/Dockerfile @@ -3,7 +3,7 @@ FROM golang:1.21-alpine WORKDIR /app COPY go.* . -COPY index.tmpl . +COPY index.html.tmpl . COPY main.go . RUN go build -o /evaluation-client diff --git a/sidecar/replication/go/index.tmpl b/sidecar/replication/go/index.html.tmpl similarity index 100% rename from sidecar/replication/go/index.tmpl rename to sidecar/replication/go/index.html.tmpl diff --git a/sidecar/replication/go/main.go b/sidecar/replication/go/main.go index 73e756e..87612f8 100644 --- a/sidecar/replication/go/main.go +++ b/sidecar/replication/go/main.go @@ -21,7 +21,7 @@ import ( "google.golang.org/grpc/status" ) -//go:embed index.tmpl +//go:embed index.html.tmpl var indexTmplContent string var t = template.Must(template.New("").Parse(indexTmplContent))