This repository has been archived by the owner on Aug 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66d7ac9
commit df02398
Showing
43 changed files
with
204 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
TAG?=latest | ||
VERSION?=$(shell grep 'VERSION' cmd/kxds/main.go | awk '{ print $$4 }' | tr -d '"' | head -n1) | ||
NAME:=kxds | ||
VERSION?=$(shell grep 'VERSION' cmd/appmesh-gateway/main.go | awk '{ print $$4 }' | tr -d '"' | head -n1) | ||
NAME:=appmesh-gateway | ||
DOCKER_REPOSITORY:=stefanprodan | ||
DOCKER_IMAGE_NAME:=$(DOCKER_REPOSITORY)/$(NAME) | ||
|
||
build: | ||
go build -o bin/kxds cmd/kxds/*.go | ||
go build -o bin/appmesh-gateway cmd/appmesh-gateway/*.go | ||
|
||
test: | ||
go test -v -race ./... | ||
|
||
run: | ||
go run cmd/kxds/*.go kubernetes --kubeconfig=$$HOME/.kube/config \ | ||
go run cmd/appmesh-gateway/*.go kubernetes --kubeconfig=$$HOME/.kube/config \ | ||
--port-name=http | ||
|
||
appmesh: | ||
go run cmd/kxds/*.go appmesh --kubeconfig=$$HOME/.kube/config \ | ||
go run cmd/appmesh-gateway/*.go appmesh --kubeconfig=$$HOME/.kube/config \ | ||
--gateway-mesh=appmesh --gateway-name=gateway --gateway-namespace=appmesh-gateway | ||
|
||
envoy: | ||
envoy -c envoy.yaml -l info | ||
|
||
build-container: | ||
docker build -t $(DOCKER_IMAGE_NAME):$(VERSION) . | ||
docker build -t $(DOCKER_IMAGE_NAME):v$(VERSION) . | ||
|
||
push-container: build-container | ||
docker push $(DOCKER_IMAGE_NAME):$(VERSION) | ||
docker push $(DOCKER_IMAGE_NAME):v$(VERSION) | ||
|
||
version-set: | ||
@next="$(TAG)" && \ | ||
current="$(VERSION)" && \ | ||
sed -i '' "s/$$current/$$next/g" cmd/kxds/main.go && \ | ||
sed -i '' "s/kxds:v$$current/kxds:v$$next/g" kustomize/base/gateway/deployment.yaml && \ | ||
sed -i '' "s/$$current/$$next/g" cmd/appmesh-gateway/main.go && \ | ||
sed -i '' "s/appmesh-gateway:v$$current/appmesh-gateway:v$$next/g" kustomize/base/appmesh-gateway/deployment.yaml && \ | ||
echo "Version $$next set in code and kustomization" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,63 @@ | ||
# KxDS | ||
[](https://github.com/stefanprodan/kxds/actions) | ||
[](https://goreportcard.com/report/github.com/stefanprodan/kxds) | ||
# appmesh-gateway | ||
[](https://github.com/stefanprodan/appmesh-gateway/actions) | ||
[](https://goreportcard.com/report/github.com/stefanprodan/appmesh-gateway) | ||
|
||
KxDS is an [Envoy](https://www.envoyproxy.io/) discovery service implementation for Kubernetes. | ||
It runs as a sidecar next to Envoy and configures the proxy to expose Kubernetes services. | ||
App Mesh Gateway is an edge load balancer that exposes applications outside the mesh. | ||
|
||
### Features | ||
The gateway is composed of: | ||
* [Envoy](https://www.envoyproxy.io/) proxy | ||
* Envoy data plane API (CDS/RDS/LDS) | ||
* Kubernetes controller | ||
|
||
* **Kubernetes Service Discovery** KxDS watches Kubernetes for services with a `http` named port | ||
* **App Mesh Service Discovery** KxDS watches Kubernetes for App Mesh virtual services | ||
* **Envoy Clusters (CDS)** are generated for each Kubernetes service or App Mesh virtual services | ||
* **Envoy Routes (RDS)** are generated for each cluster and configured with timeouts and retry policies | ||
* **Envoy Weighted Clusters** are generated based on Kubernetes service annotations | ||
* **Envoy Listeners (LDS)** KxDS configures Envoy to listen on port `8080` | ||
An App Mesh virtual service can be exposed outside the mesh by annotating the object with: | ||
|
||
### Internal Kubernetes Gateway | ||
|
||
Install the API Gateway as NodePort scoped to a namespace: | ||
|
||
```sh | ||
kubectl create ns test | ||
kubectl -n test apply -k github.com/stefanprodan/kxds//kustomize/ns-gateway | ||
```yaml | ||
apiVersion: appmesh.k8s.aws/v1beta1 | ||
kind: VirtualService | ||
metadata: | ||
name: frontend.test | ||
annotations: | ||
gateway.appmesh.k8s.aws/expose: "true" | ||
gateway.appmesh.k8s.aws/domain: "frontend.example.com" | ||
``` | ||
The above gateway will expose all Kubernetes services in the test namespace that have a `http` named port. | ||
|
||
Deploy podinfo in the `test` namespace: | ||
|
||
If you want to expose the service inside the Kubernetes cluster you can omit the domain annotation. | ||
By default the gateway exposes a virtual service by its name, | ||
a service can be accessed by setting the host HTTP header e.g.: | ||
```sh | ||
kubectl -n test apply -k github.com/stefanprodan/kxds//kustomize/podinfo | ||
curl -H 'Host: frontend.test' http://<gateway-host>/ | ||
``` | ||
Port forward to the gateway: | ||
The gateway registers/de-registers virtual services automatically as they come and go in the cluster. | ||
```sh | ||
kubectl -n test port-forward svc/gateway 8080:80 | ||
``` | ||
### Install | ||
Access the podinfo API by setting the host header to `podinfo.test`: | ||
Install the API Gateway as NLB in `appmesh-gateway` namespace: | ||
|
||
```sh | ||
curl -vH 'Host: podinfo.test' localhost:8080 | ||
kubectl apply -k github.com/stefanprodan/appmesh-gateway//kustomize/appmesh-gateway | ||
``` | ||
|
||
### External Kubernetes Gateway | ||
|
||
Install the API Gateway as LoadBalancer in `envoy-gateway` namespace: | ||
Deploy podinfo in the `test` namespace: | ||
|
||
```sh | ||
kubectl apply -k github.com/stefanprodan/kxds//kustomize/envoy-gateway | ||
kubectl -n test apply -k github.com/stefanprodan/appmesh-gateway//kustomize/test | ||
``` | ||
|
||
The above gateway will expose all Kubernetes services in the cluster that have a `http` named port. | ||
|
||
### Annotations | ||
Port forward to the gateway: | ||
|
||
Kubernetes service exposed on an external domain: | ||
```yaml | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: frontend | ||
namespace: demo | ||
annotations: | ||
envoy.gateway.kubernetes.io/expose: "true" | ||
envoy.gateway.kubernetes.io/timeout: "25s" | ||
envoy.gateway.kubernetes.io/retries: "5" | ||
envoy.gateway.kubernetes.io/domain: "frontend.example.com" | ||
spec: | ||
ports: | ||
- name: http | ||
port: 9898 | ||
protocol: TCP | ||
```sh | ||
kubectl -n appmesh-gateway port-forward svc/appmesh-gateway 8080:80 | ||
``` | ||
|
||
Traffic split with weighted destinations: | ||
Access the podinfo API by setting the host header to `podinfo.test`: | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: backend | ||
namespace: demo | ||
annotations: | ||
envoy.gateway.kubernetes.io/domain: "backend.demo" | ||
envoy.gateway.kubernetes.io/primary: "backend-primary-demo-9898" | ||
envoy.gateway.kubernetes.io/canary: "backend-canary-demo-9898" | ||
envoy.gateway.kubernetes.io/canary-weight: "50" | ||
```sh | ||
curl -vH 'Host: podinfo.test' localhost:8080 | ||
``` | ||
|
||
The primary and canary name format is `<service-name>-<namespace>-<port>`. | ||
Note that both Kubernetes services must exist or Envoy will reject the configuration. | ||
|
||
### App Mesh Gateway | ||
|
||
Install the API Gateway as NLB in `appmesh-gateway` namespace: | ||
Access podinfo on its custom domain: | ||
|
||
```sh | ||
kubectl apply -k github.com/stefanprodan/kxds//kustomize/envoy-gateway | ||
curl -vH 'Host: podinfo.internal' localhost:8080 | ||
``` | ||
|
||
The above gateway will expose all App Mesh virtual services in the cluster. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module github.com/stefanprodan/kxds | ||
module github.com/stefanprodan/appmesh-gateway | ||
|
||
go 1.13 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
kustomize/base/gateway/account.yaml → kustomize/base/appmesh-gateway/account.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: gateway | ||
name: appmesh-gateway |
Oops, something went wrong.