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

Update Ambassador and Traefik quick start examples #195

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 docs/ambassador.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Ambassador

** Note**
Ambassador uses `CustomResourceDefinition`s with `apiVersion` = `apiextensions.k8s.io/v1beta1` which was removed in Kubernetes version 1.22+. Please ensure your Kubernetes version is compatible with the version of Ambassador you're using

```shell
kusk ambassador --help
Generates Ambassador Mappings for your service
Expand Down
3 changes: 3 additions & 0 deletions docs/ambassador2.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Ambassador 2.0
**Warning**: Ambassador 2.0 is currently in Developer Preview and could change at any point, breaking the implementation here.

** Note**
Ambassador2 uses `CustomResourceDefinition`s with `apiVersion` = `apiextensions.k8s.io/v1` which is compatible with Kubernetes version 1.22+. Please ensure your Kubernetes version is compatible with the version of Ambassador you're using.


```shell
kusk ambassador2 --help
Expand Down
70 changes: 56 additions & 14 deletions examples/petstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,31 @@

Sample petstore application from Swagger.

## Create cluster
## Prerequisites
This example uses k3d version v5.0.1 and Kubernetes version v1.22.2
```shell
❯ k3d --version
k3d version v5.0.1
k3s version latest (default)
```

```shell
kubectl version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.4", GitCommit:"b695d79d4f967c403a96986f1750a35eb75e75f1", GitTreeState:"clean", BuildDate:"2021-11-17T15:41:42Z", GoVersion:"go1.16.10", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.2+k3s2", GitCommit:"3f5774b41eb475eb10c93bb0ce58459a6f777c5f", GitTreeState:"clean", BuildDate:"2021-10-05T20:29:33Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}
```

## Create cluster if not using Traefik
```shell
k3d cluster create cl1 \
-p 8080:80@loadbalancer \
-p 8443:443@loadbalancer \
--k3s-arg "--disable=traefik@server:0"
```
## Create cluster if using Traefik
```shell
k3d cluster create -p "8080:80@loadbalancer" -p "8443:443@loadbalancer" cl1
kubectl wait --for=condition=available --timeout=600s deployment/traefik -n kube-system
```

Apply Petstore manifest
Expand All @@ -17,28 +39,50 @@ kubectl apply -f examples/petstore/manifest.yaml
### Setup

```shell
kubectl apply -f https://www.getambassador.io/yaml/aes-crds.yaml && \
kubectl wait --for condition=established --timeout=90s crd -lproduct=aes && \
kubectl apply -f https://www.getambassador.io/yaml/aes.yaml && \
kubectl -n ambassador wait --for condition=available --timeout=90s deploy -lproduct=aes
kubectl create namespace emissary && \
kubectl apply -f https://app.getambassador.io/yaml/emissary/latest/emissary-crds.yaml && \
kubectl wait --for condition=established --timeout=90s crd -lapp.kubernetes.io/name=ambassador && \
kubectl apply -f https://app.getambassador.io/yaml/emissary/latest/emissary-ingress.yaml && \
kubectl -n emissary wait --for condition=available --timeout=90s deploy -lproduct=aes
```

```shell
kubectl apply -f - <<EOF
---
apiVersion: getambassador.io/v3alpha1
kind: Listener
metadata:
name: emissary-ingress-listener-8080
namespace: emissary
spec:
port: 8080
protocol: HTTP
securityModel: XFP
hostBinding:
namespace:
from: ALL
EOF
```

### Generate mappings and curl service

Root only
```shell
# This will allow you to resolve the swagger documentation in the browser at https://localhost:8443/
kusk ambassador -i examples/petstore/petstore.yaml --path.base="/petstore" --path.trim_prefix="/petstore" --service.name "petstore" | kubectl apply -f -
# This will allow you to resolve the swagger documentation in the browser at https://localhost:8080/
go run main.go ambassador2 -i examples/petstore/petstore.yaml --path.base="/petstore" --path.trim_prefix="/petstore" --service.name "petstore" --host "*" | kubectl apply -f -

curl -Li 'http://localhost:8080/petstore/api/v3/pet/findByStatus?status=available'
```

CQRS Pattern
```shell
# This will allow you to resolve the swagger documentation in the browser at https://localhost:8443/
kusk ambassador -i examples/petstore/petstore.yaml --path.base="/" --service.name "petstore" | kubectl apply -f -
# This will allow you to resolve the swagger documentation in the browser at https://localhost:8080/
go run main.go ambassador2 -i examples/petstore/petstore.yaml --path.base="/" --service.name "petstore" --host "*" | kubectl apply -f -

# This will create mappings for each route in the api
kusk ambassador -i examples/petstore/petstore.yaml --path.base="/petstore/api/v3" --path.trim_prefix="/petstore" --service.name "petstore" --path.split=true | kubectl apply -f -
curl -kLi 'https://localhost:8443/petstore/api/v3/pet/findByStatus?status=available'
go run main.go ambassador2 -i examples/petstore/petstore.yaml --path.base="/petstore/api/v3" --path.trim_prefix="/petstore" --service.name "petstore" --path.split=true --host "*" | kubectl apply -f -

curl -Li 'http://localhost:8080/petstore/api/v3/pet/findByStatus?status=available'
```

## Linkerd Service Profiles
Expand Down Expand Up @@ -85,8 +129,6 @@ rm ingress.yaml

## Traefik V2

Traefik is installed into K3s cluster by default, no need to setup anything.

### Generate the ingress resource from the specification

```shell
Expand All @@ -98,7 +140,7 @@ go run main.go traefik -i examples/petstore/petstore.yaml --path.base="/api/v3"
```shell
curl -kLi 'http://localhost:8080/api/v3/pet/findByStatus?status=available'
```

It may take a few seconds for Traefik to resolve the IngressRoutes so retry the command if it fails

## Cleanup

Expand Down