Skip to content

Commit

Permalink
Merge branch 'main' into laurent/k8s-manifest-input
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentluce committed Jul 10, 2024
2 parents 2714cbe + ad42d22 commit 5a0302a
Show file tree
Hide file tree
Showing 15 changed files with 641 additions and 45 deletions.
37 changes: 35 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ jobs:
run: |
nix develop --command test -z $(gofmt -l .)
build_and_test_nix:
name: Test and build
build_publish_images:
name: Test, build and publish images
needs: check_nix
runs-on: ubuntu-22.04
steps:
Expand Down Expand Up @@ -83,3 +83,36 @@ jobs:
nix run ./#publish-kardinal-manager-container
nix run ./#publish-kardinal-cli-container
nix run ./#publish-redis-proxy-overlay-container
build_clis:
name: Test and build cross-compiled clis
needs: check_nix
runs-on: ubuntu-22.04
strategy:
matrix:
os: [linux, darwin, windows]
arch: [amd64, arm64]

steps:
- name: git checkout
uses: actions/checkout@v3

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

- name: Magic cache
uses: DeterminateSystems/magic-nix-cache-action@main

- name: Build cli
run: |
result=$(nix build ./#cross-compiled-cli.x86_64-linux.${{ matrix.os }}.${{ matrix.arch }} --no-link --print-out-paths)
path=$(find $result -name 'kardinal.cli*' -type f | head -n 1)
if [[ "${{ matrix.os }}" == "windows" ]]; then
binout="/tmp/kardinal-${{ matrix.os }}-${{ matrix.arch }}.exe"
else
binout="/tmp/kardinal-${{ matrix.os }}-${{ matrix.arch }}"
fi
ls -lah $path
ln -s $path $binout
ls -lah $binout
[ -s $binout ]
39 changes: 39 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ jobs:
release-please:
runs-on: ubuntu-latest
# skip releases on forks
outputs:
tag_name: ${{ steps.release.outputs.tag_name }}
release_created: ${{ steps.release.outputs.release_created }}
if: github.repository == 'kurtosis-tech/kardinal'
steps:
- name: Run Release Please
id: release
uses: googleapis/release-please-action@v3
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
Expand All @@ -24,3 +28,38 @@ jobs:
bump-minor-pre-major: true
bump-patch-for-minor-pre-major: true
include-v-in-tag: false

build-and-publish-clis:
needs: release-please
runs-on: ubuntu-22.04
if: ${{ needs.release-please.outputs.release_created }}
strategy:
matrix:
os: [linux, darwin, windows]
arch: [amd64, arm64]

steps:
- name: git checkout
uses: actions/checkout@v3

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

- name: Magic cache
uses: DeterminateSystems/magic-nix-cache-action@main

- name: Upload Release CLI Artifact
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
result=$(nix build ./#cross-compiled-cli.x86_64-linux.${{ matrix.os }}.${{ matrix.arch }} --no-link --print-out-paths)
path=$(find $result -name 'kardinal.cli*' -type f | head -n 1)
if [[ "${{ matrix.os }}" == "windows" ]]; then
binout="/tmp/kardinal-${{ matrix.os }}-${{ matrix.arch }}.exe"
else
binout="/tmp/kardinal-${{ matrix.os }}-${{ matrix.arch }}"
fi
ls -lah $path
ln -s $path $binout
ls -lah $binout
gh release upload ${{ needs.release-please.outputs.tag_name }} $binout --clobber
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Changelog

## [0.1.2](https://github.com/kurtosis-tech/kardinal/compare/0.1.1...0.1.2) (2024-07-09)


### Bug Fixes

* upload clis ([#24](https://github.com/kurtosis-tech/kardinal/issues/24)) ([dfff91b](https://github.com/kurtosis-tech/kardinal/commit/dfff91b67770dcb99b456158188a6b62a7cc39d2))

## [0.1.1](https://github.com/kurtosis-tech/kardinal/compare/v0.1.0...0.1.1) (2024-07-08)


### Features

* add js and nix package to cli-kontrol-api ([#11](https://github.com/kurtosis-tech/kardinal/issues/11)) ([d007773](https://github.com/kurtosis-tech/kardinal/commit/d0077735972bccdc40e48cd1b03a9d7122429d73))
* add more info to docs ([#17](https://github.com/kurtosis-tech/kardinal/issues/17)) ([54400fb](https://github.com/kurtosis-tech/kardinal/commit/54400fb9d65ad9edb01b2e76edb6ef3680b79a29))
* added release please ([#6](https://github.com/kurtosis-tech/kardinal/issues/6)) ([7c38358](https://github.com/kurtosis-tech/kardinal/commit/7c3835830b2616bffb5bbe5a64166154a5953314))
* adding multi tenant support ([#8](https://github.com/kurtosis-tech/kardinal/issues/8)) ([75b736f](https://github.com/kurtosis-tech/kardinal/commit/75b736fe24adce93b5fff7ee7eef9f7f5ead461c))
* adding the `kardinal manager deploy` and `kardinal manager remove` CLI commands ([#10](https://github.com/kurtosis-tech/kardinal/issues/10)) ([af8843c](https://github.com/kurtosis-tech/kardinal/commit/af8843cc3f08f8151741465b1e678b6ec76e80f6))
* adding the health check endpoint for the API ([#14](https://github.com/kurtosis-tech/kardinal/issues/14)) ([15a1b0d](https://github.com/kurtosis-tech/kardinal/commit/15a1b0d2bfb89c01e960657f7209cd1abf59b6c1))
* DRY ref to main branch in CI ([#12](https://github.com/kurtosis-tech/kardinal/issues/12)) ([f32ef8c](https://github.com/kurtosis-tech/kardinal/commit/f32ef8c3d04d24f2aeacec41d89bf627d9221c89))
* publish cli binaries and add install script ([#22](https://github.com/kurtosis-tech/kardinal/issues/22)) ([e1e27e4](https://github.com/kurtosis-tech/kardinal/commit/e1e27e4d0511ac613f66fb71b84cd135cf55e4c5))
* quickstart docs added ([#16](https://github.com/kurtosis-tech/kardinal/issues/16)) ([9f1a759](https://github.com/kurtosis-tech/kardinal/commit/9f1a759a7f1d50778f0a5ee6f17c843566f18356))
* removing kardinal-cli binary ([#13](https://github.com/kurtosis-tech/kardinal/issues/13)) ([31325f1](https://github.com/kurtosis-tech/kardinal/commit/31325f144d60802968572b71e8e997eecd391c52))
* update topology API ([#9](https://github.com/kurtosis-tech/kardinal/issues/9)) ([2e96ff8](https://github.com/kurtosis-tech/kardinal/commit/2e96ff810e4a05ef1e7eb0ed52f6cff07c6fde4a))


### Bug Fixes

* fix some typos in README.md ([#23](https://github.com/kurtosis-tech/kardinal/issues/23)) ([2be7f55](https://github.com/kurtosis-tech/kardinal/commit/2be7f5544559148448daef072b9b39cf3c3ba403))
* update images pulls ([#18](https://github.com/kurtosis-tech/kardinal/issues/18)) ([212cfe8](https://github.com/kurtosis-tech/kardinal/commit/212cfe810f9c4bc21a25f9ac19751768cf6fcda4))
138 changes: 132 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

Kardinal is a traffic control and data isolation layer that enables engineers to safely do development and QA work directly in production. Say goodbye to maintaining multiple environments and hello to faster, more efficient development workflows.

## Quick install

```bash
curl get.kardinal.dev -sL | sh
```

## What is Kardinal?

Kardinal injects production data and service dependencies into your dev and test workflows safely and securely. Instead of spinning up ephemeral environments with mocked services, fake traffic, and fake data, developers using Kardinal can put their service directly into the production environment to see how it works... without risking the stability of that environment.
Expand Down Expand Up @@ -81,7 +87,7 @@ The Kardinal Manager retrieves the latest user services topology from the Kardin

You will need the following tools installed (they will be already available if you are using the nix shell provided by this repository):

- A local Kubernetes cluster ([Minikube](https://minikube.sigs.k8s.io/docs/start/?arch=%2Fmacos%2Fx86-64%2Fstable%2Fbinary+download) used in this example
- A local Kubernetes cluster ([Minikube](https://minikube.sigs.k8s.io/docs/start/?arch=%2Fmacos%2Fx86-64%2Fstable%2Fbinary+download) used in this example)
- Istio resources installed in the local cluster (use the [getting started doc](https://istio.io/latest/docs/setup/getting-started/#download))

```bash
Expand Down Expand Up @@ -121,14 +127,14 @@ INFO[0000] Using tenant UUID 58d33536-3c9e-4110-aa83-bf112ae94a49
3. Deploy the voting-app application with Kardinal

```bash
kardinal deploy --docker-compose ../examples/voting-app/docker-compose.yaml
kardinal deploy --docker-compose ./examples/voting-app/docker-compose.yaml
```

4. Check the current topology in the cloud Kontrol FE using this URL: https://app.kardinal.dev/{use-your-tenant-UUID-here}/traffic-configuration
5. Start the tunnel to access the services (you may have to provide you password for the underlying sudo access)

```bash
minukube tunnel
minikube tunnel
```

6. Open the [production page in the browser](http://prod.app.localhost/) to see the production `voting-app`
Expand All @@ -138,7 +144,7 @@ minukube tunnel
1. Create a new flow to test a development `voting-app-ui-v2` version in production

```bash
kardinal flow create voting-app-ui voting-app-ui-v2 --docker-compose ../examples/voting-app/docker-compose.yaml
kardinal flow create voting-app-ui voting-app-ui-v2 --docker-compose ./examples/voting-app/docker-compose.yaml
```

2. Check how the topology has changed, to reflect both prod and the dev version, in the cloud Kontrol FE using this URL: https://app.kardinal.dev/{use-your-tenant-UUID-here}/traffic-configuration
Expand All @@ -149,7 +155,7 @@ kardinal flow create voting-app-ui voting-app-ui-v2 --docker-compose ../examples
1. Remove the flow created for the `voting-app-ui-v2`

```bash
kardinal flow delete --docker-compose ../examples/voting-app/docker-compose.yaml
kardinal flow delete --docker-compose ./examples/voting-app/docker-compose.yaml
```

2. Check the topology again to, it's showing only the production version as the beginning, in the cloud Kontrol FE using this URL: https://app.kardinal.dev/{use-your-tenant-UUID-here}/traffic-configuration
Expand All @@ -170,6 +176,127 @@ kardinal manager remove
kubectl delete ns prod
```

## Deploying Kardinal on a Kubernetes Cluster

These instructions provide a guide for deploying Kardinal on any Kubernetes cluster, whether it's a local setup like Minikube, a managed cloud service, or your own self-hosted cluster. We'll use kubectl port-forwarding to access the services, which works universally across different Kubernetes setups.

### Prerequisites

- A Kubernetes cluster (e.g., Minikube, EKS, GKE, AKS, or any other Kubernetes distribution)
- kubectl installed and configured to access your cluster

### Steps

1. Install the Kardinal CLI:

```bash
curl https://raw.githubusercontent.com/kurtosis-tech/kardinal/main/scripts/install_cli.sh -s | sh
```

2. Install Istio (if not already installed):

If you don't already have Istio installed in your cluster, follow these steps to install it:

```bash
curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.22.1 TARGET_ARCH=x86_64 sh -
cd istio-1.22.1
export PATH=$PWD/bin:$PATH
echo 'export PATH=$PATH:'"$PWD/bin" >> ~/.bashrc
istioctl install --set profile=demo -y
cd ..
```

If you already have Istio installed, you can skip this step.

3. Deploy the Kardinal Manager:

```bash
kardinal manager deploy kloud-kontrol
```

4. Note the tenant UUID generated during this process. You'll need this to check your traffic configuration.

5. Clone the Kardinal Playground repository to get the voting app demo:

```bash
git clone https://github.com/kurtosis-tech/kardinal-playground.git
cd kardinal-playground/voting-app-demo
```

6. Deploy the voting-app application with Kardinal:

```bash
kardinal deploy --docker-compose docker-compose.yaml
```

7. Check the initial Kardinal traffic configuration:
Visit https://app.kardinal.dev/{your-tenant-id} (replace {your-tenant-id} with the UUID from step 4)
You should see only the production version of your application in the traffic configuration.

8. Download the port-forwarding script:

```bash
curl -o kardinal-port-forward.sh https://raw.githubusercontent.com/kurtosis-tech/kardinal/main/scripts/kardinal-port-forward.sh
```

This script sets up port-forwarding for accessing the services.

9. Make the script executable:

```bash
chmod +x kardinal-port-forward.sh
```

10. Run the script to set up port-forwarding for the production version:

```bash
./kardinal-port-forward.sh prod
```

This will set up port-forwarding for the production version of the voting app.

11. Access the production application:
- Production version: http://localhost:8090

12. To create a new development flow:

```bash
kardinal flow create voting-app-ui voting-app-ui-dev -d compose.yml
```

13. After creating the development flow, check the Kardinal traffic configuration again:
Visit https://app.kardinal.dev/{your-tenant-id}
You should now see both the production and development versions of your application in the traffic configuration.

14. Run the port-forwarding script again to include the new development version:

```bash
./kardinal-port-forward.sh all
```

Now you can access both the production and development versions:
- Production version: http://localhost:8090
- Development version: http://localhost:8091

15. To remove the development flow:

```bash
kardinal flow delete -d compose.yml
```

16. After deleting the development flow, check the Kardinal traffic configuration once more:
Visit https://app.kardinal.dev/{your-tenant-id}
You should now see only the production version of your application in the traffic configuration, confirming that the development flow has been removed.

17. Clean up:
- Stop the port-forwarding: `pkill -f "kubectl port-forward.*voting-app"`
- Remove Kardinal Manager: `kardinal manager remove`
- Remove the voting-app: `kubectl delete ns prod`

By following these steps, you can deploy and manage Kardinal on any Kubernetes cluster, using kubectl port-forwarding to access the services. This method works universally across different Kubernetes setups, including Minikube, cloud-managed Kubernetes services, and self-hosted clusters.

Remember to check the Kardinal traffic configuration at https://app.kardinal.dev/{your-tenant-id} before and after creating or deleting development flows to verify the changes in your application's topology.

## Development instructions

1. Enter the dev shell and start the local cluster:
Expand Down Expand Up @@ -279,4 +406,3 @@ gomod2nix generate
<!--------------- ONLY LINKS BELOW THIS POINT ---------------------->
[run-build-cli]: #running-kardinal-cli
25 changes: 25 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,31 @@
in
pkgs.lib.foldl' (set: acc: pkgs.lib.recursiveUpdate acc set) {}
all;

cross-compiled-cli = let
all =
pkgs.lib.mapCartesianProduct ({
arch,
os,
}: {
"${os}" = {
"${toString arch}" = packages.kardinal-cli.overrideAttrs (old:
old
// {
GOOS = os;
GOARCH = arch;
# CGO_ENABLED = disabled breaks the CLI compilation
# CGO_ENABLED = 0;
doCheck = false;
});
};
}) {
arch = architectures;
os = ["linux" "darwin" "windows"];
};
in
pkgs.lib.foldl' (set: acc: pkgs.lib.recursiveUpdate acc set) {}
all;
};
# Add containers matching architecture with local system as toplevel packages
# this means calling `nix build .#<SERVICE_NAME>-container` will build the container matching the local system.
Expand Down
Loading

0 comments on commit 5a0302a

Please sign in to comment.