Tech Talk: Developing APIs the Easy Way – Streamline your API process with an endpoint-focused approach on Dec 5 at 11 am EST! Register now

Argo Rollouts & Edge Stack API Gateway

Welcome to the comprehensive tutorial on configuring Argo Rollouts and Edge Stack API Gateway for seamless integration and efficient canary releases. All the necessary files for this guide can be found in the examples directory of the respective repository.

Prerequisites:


  • Kubernetes cluster
  • Argo-Rollouts installed within the cluster


Note: If you are using Edge Stack or Emissary-ingress 2.0+, it is essential to install Argo-Rollouts version v1.1+ and include the argument --ambassador-api-version getambassador.io/v3alpha1 to your argo-rollouts deployment.

Step 1: Installation and Configuration of Edge Stack API Gateway

If Edge Stack is not yet installed in your Kubernetes cluster, please refer to the Edge Stack documentation for detailed installation instructions.

By default, Edge Stack routes traffic through Kubernetes services. However, for optimal performance during canary releases, we recommend enabling endpoint routing. Follow the steps below to enable endpoint routing:


  • Create a file named resolver.yaml and save the provided configuration within it:

apiVersion: getambassador.io/v2

kind: KubernetesEndpointResolver

metadata:

name: endpoint

Apply the configuration to your cluster using the command: kubectl apply -f resolver.yaml

Step 2: Creation of Kubernetes Services

To proceed with canary releases, we need to create two Kubernetes services: echo-stable and echo-canary. Follow the instructions below and save the resulting configuration in the echo-service.yaml

apiVersion: v1

kind: Service

metadata:

labels:

app: echo

name: echo-stable

---

spec:

type: ClusterIP

ports:

- name: http

port: 80

protocol: TCP

targetPort: 8080

selector:

app: echo

---

apiVersion: v1

kind: Service

metadata:

labels:

app: echo

name: echo-canary

spec:

type: ClusterIP

ports:

- name: http

port: 80

protocol: TCP

targetPort: 8080

selector:

app: echo

Additionally, we need to create an Edge Stack route for these services. Save the following configuration to a file named echo-mapping.yaml

apiVersion: getambassador.io/v2

kind: Mapping

metadata:

name: echo

spec:

prefix: /echo

rewrite: /echo

service: echo-stable:80

resolver: endpoint

Step 3: Deploy the Echo Service

Create a Rollout resource by saving the configuration to a file named rollout.yaml. Take note of the trafficRouting attribute, which directs Argo to use Edge Stack API Gateway for routing.


apiVersion: argoproj.io/v1alpha1

kind: Rollout

metadata:

name: echo-rollout

spec:

selector:

matchLabels:

app: echo

template:

metadata:

labels:

app: echo

spec:

containers:

- image: hashicorp/http-echo

args:

- "-text=VERSION 1"

- -listen=:8080

imagePullPolicy: Always

name: echo-v1

ports:

- containerPort: 8080

strategy:

canary:

stableService: echo-stable

canaryService: echo-canary

trafficRouting:

ambassador:

mappings:

- echo

steps:

- setWeight: 30

- pause: {duration: 30s}

- setWeight: 60

- pause: {duration: 30s}

- setWeight: 100

- pause: {duration: 10}

Apply the rollout to your cluster using the command: kubectl apply -f rollout.yaml. Note that this is the initial deployment, and no canary rollout will occur.

Step 4: Testing the Service

To ensure the successful implementation of the rollout, follow these steps:

  1. Open a new terminal window.
  2. Obtain the external IP address for Edge Stack using the command:


export AMBASSADOR_LB_ENDPOINT=$(kubectl -n ambassador get svc ambassador -o "go-template={{range .status.loadBalancer.ingress}}{{or .ip .hostname}}{{end}}")


  • Send a request to the echo service using the following command:

curl -Lk "https://$AMBASSADOR_LB_ENDPOINT/echo/"

You should receive a response indicating "VERSION 1".

Step 5: Rolling Out a New Version

Now, let's roll out a new version of the service by updating the echo container in the rollout.yaml file. Replace the existing configuration with the following content, which displays "VERSION 2":


apiVersion: argoproj.io/v1alpha1

kind: Rollout

metadata:

name: echo-rollout

spec:

selector:

matchLabels:

app: echo

template:

metadata:

labels:

app: echo

spec:

containers:

- image: hashicorp/http-echo

args:

- "-text=VERSION 2"

- -listen=:8080

imagePullPolicy: Always

name: echo-v1

ports:

- containerPort: 8080

strategy:

canary:

stableService: echo-stable

canaryService: echo-canary

trafficRouting:

ambassador:

mappings:

- echo

Get Edge Stack API Gateway Now