DocsEdge StackAmbassador Edge Stack Tutorial
Ambassador Edge Stack Tutorial
In this article, you will explore some of the key features of Ambassador Edge Stack by walking through an example workflow and exploring the Edge Policy Console.
Prerequisites
You must have Ambassador Edge Stack installed in your Kubernetes cluster.
Routing Traffic from the Edge
Like any other Kubernetes object, Custom Resource Definitions (CRDs) are used to
declaratively define Ambassador Edge Stack’s desired state. The workflow you are going to
build uses a sample deployment and the Mapping
CRD, which is the core resource
that you will use with Ambassador Edge Stack to manage your edge. It enables you to route
requests by host and URL path from the edge of your cluster to Kubernetes services.
Copy the configuration below and save it to a file named
quote.yaml
so that you can deploy these resources to your cluster. This basic configuration creates thequote
deployment and a service to expose that deployment on port 80.Apply the configuration to the cluster with the command
kubectl apply -f quote.yaml
.Copy the configuration below and save it to a file called
quote-backend.yaml
so that you can create aMapping
on your cluster. ThisMapping
tells Ambassador Edge Stack to route all traffic inbound to the/backend/
path, on any host that can be used to reach Ambassador Edge Stack, to thequote
service.Apply the configuration to the cluster with the command
kubectl apply -f quote-backend.yaml
Store the Ambassador Edge Stack
LoadBalancer
address to a local environment variable. You will use this variable to test accessing your pod.Test the configuration by accessing the service through the Ambassador Edge Stack load balancer.
Success, you have created your first Ambassador Edge Stack Mapping
, routing a
request from your cluster's edge to a service!
Since the Mapping
you just created controls how requests are routed,
changing the Mapping
will immediately change the routing. To see this
in action, use kubectl
to edit the Mapping
:
Run
kubectl edit Mapping quote-backend
.Change
prefix: /backend/
toprefix: /quoteme/
.Save the file and let
kubectl
update yourMapping
.Run
kubectl get Mappings --namespace ambassador
. You will see thequote-backend
Mapping
has the updated prefix listed. Try to access the endpoint again viacurl
with the updated prefix.Change the prefix back to
/backend/
so that you can later use theMapping
with other tutorials.
Developer API Documentation
The quote
service you just deployed publishes its API as an
OpenAPI (formerly Swagger)
document. Ambassador Edge Stack automatically detects and publishes this documentation.
This can help with internal and external developer onboarding by serving as a
single point of reference for of all your microservice APIs.
In the Edge Policy Console, navigate to the APIs tab. You'll see the OpenAPI documentation there for the "Quote Service API." Click GET to expand out the documentation.
Navigate to
https://<load-balancer-endpoint>/docs/
to see the publicly visible Developer Portal. Make sure you include the trailing/
. This is a fully customizable portal that you can share with third parties who need information about your APIs.
Next Steps
Further explore some of the concepts you learned about in this article:
Mapping
resource: routes traffic from the edge of your cluster to a Kubernetes serviceHost
resource: sets the hostname by which Ambassador Edge Stack will be accessed and secured with TLS certificates- Developer Portal: publishes an API catalog and OpenAPI documentation
Ambassador Edge Stack has a comprehensive range of features to support the requirements of any edge microservice.
Learn more about how developers use Ambassador Edge Stack to manage edge policies.
Learn more about how site reliability engineers and operators run Ambassador Edge Stack in production environments.
To learn how Ambassador Edge Stack works, use cases, best practices, and more, check out the Quick Start or read the Ambassador Edge Stack Story.
For a custom configuration, you can install Ambassador Edge Stack manually.