3 min • read

Ambassador Edge Stack quick start

Contents

1. Installation

We'll start by installing Ambassador Edge Stack into your cluster.

We recommend using Helm but there are other options below to choose from.

shell
# Add the Repo:
helm repo add datawire https://app.getambassador.io
# Create Namespace and Install:
kubectl create namespace ambassador && \
helm install --devel edge-stack --namespace ambassador datawire/edge-stack && \
kubectl -n ambassador wait --for condition=available --timeout=90s deploy -lproduct=aes

2. 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 simple demo app and the AmbassadorMapping CRD, which is the core resource that you will use with Ambassador Edge Stack. It lets you route requests by host and URL path from the edge of your cluster to Kubernetes services.

  1. First, create an AmbassadorListener resources:
shell
kubectl apply -f - <<EOF
---
apiVersion: x.getambassador.io/v3alpha1
kind: AmbassadorListener
metadata:
name: edge-stack-listener-8080
namespace: ambassador
spec:
port: 8080
protocol: HTTP
securityModel: XFP
hostBinding:
namespace:
from: ALL
---
apiVersion: x.getambassador.io/v3alpha1
kind: AmbassadorListener
metadata:
name: edge-stack-listener-8443
namespace: ambassador
spec:
port: 8443
protocol: HTTPS
securityModel: XFP
hostBinding:
namespace:
from: ALL
EOF
  1. Apply the YAML for the “Quote of the Moment" service.

    shell
    kubectl apply -f https://app.getambassador.io/yaml/v2-docs/latest/quickstart/qotm.yaml
  2. Copy the configuration below and save it to a file called quote-backend.yaml so that you can create an AmbassadorMapping on your cluster. This AmbassadorMapping tells Ambassador Edge Stack to route all traffic inbound to the /backend/ path to the quote Service.

    yaml
    ---
    apiVersion: x.getambassador.io/v3alpha1
    kind: AmbassadorMapping
    metadata:
    name: quote-backend
    spec:
    hostname: "*"
    prefix: /backend/
    service: quote
  3. Apply the configuration to the cluster:

    shell
    kubectl apply -f quote-backend.yaml

    With our AmbassadorMapping created, now we need to access it!

  4. Store the Ambassador Edge Stack load balancer IP address to a local environment variable. You will use this variable to test accessing your service.

    shell
    export LB_ENDPOINT=$(kubectl -n ambassador get svc edge-stack \
    -o "go-template={{range .status.loadBalancer.ingress}}{{or .ip .hostname}}{{end}}")
  5. Test the configuration by accessing the service through the Ambassador Edge Stack load balancer:

    Terminal
    $ curl -Lki https://$LB_ENDPOINT/backend/
    HTTP/1.1 200 OK
    content-type: application/json
    date: Wed, 23 Jun 2021 16:49:46 GMT
    content-length: 163
    x-envoy-upstream-service-time: 0
    server: envoy
    {
    "server": "serene-grapefruit-gjd4yodo",
    "quote": "The last sentence you read is often sensible nonsense.",
    "time": "2021-06-23T16:49:46.613322198Z"
    }

What's next?

Explore some of the popular tutorials on Ambassador Edge Stack:

Ambassador Edge Stack has a comprehensive range of features to support the requirements of any edge microservice.

To learn more about how Ambassador Edge Stack works, read the Ambassador Edge Stack Story.