Giter Site home page Giter Site logo

jonathanbeber / ambassador-demo Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 9 KB

Kubernetes resources used to present an Ambassador demo during the DevOps meetup Berlin @ Onefootball

Home Page: https://getambassador.io/

License: Apache License 2.0

ambassador kubernetes api-gateway demo

ambassador-demo's Introduction

Setup

This demo expects a running kubernetes environment with helm installed. To setup it fast and easily (non-production), the following commands can be used:

minikube start --kubernetes-version=v1.14.2 -p ambassador
kubectl apply -f 01_rbac_helm.yaml
helm init

In this example, we're using minikube. You can check kubernetes official docs, for more details on how to install it.

Ambassador installation

The following steps install Ambassador using the official helm charts:

kubectl create namespace ambassador
helm upgrade --install --namespace=ambassador --values=02_ambassador_values.yaml ambassador stable/ambassador

To check ambassador deployment status, you can check for the resources status:

kubectl get all -n ambassador

The following command will map ambassador admin ui for your computer:

kubectl port-forward -n ambassador svc/ambassador-admins 8877

The interface is accessible now here and it's used mainly for debugging purposes.

Simple Service v1

We're going to deploy a simple-service and its mappings for ambassador:

kubectl apply -f 03_deploy_v1.yaml
kubectl apply -f 04_mapping_v1.yaml

Again, in the admin ui address is possible to see Ambassador created mapping resources.

In order to access the simple-service trough Ambassador it's necessary to map its service to our computer as well. The following command it's just necessary because this demo it's not running on a cloud environment. On a cloud environment we'd be accessing it trough a Cloud Load Balancer solution.

kubectl port-forward svc/ambassador -n ambassador 8000:80

Test the access to simple-service with a simple http request: curl http://localhost:8000/simple-service/v1/

Simple Service v2

Now, we're going to create a new version of the same service and its mappings:

kubectl apply -f 05_deploy_v2.yaml
kubectl apply -f 06_mapping_v2.yaml

Again, in the admin ui address is possible to see Ambassador created mapping resources. Test the access to simple-service v2 with a simple http request: curl http://localhost:8000/simple-service/v2/

Simple Service Canary

This example, try to represent a simple and manually Canary Release:

kubectl apply -f 07_mapping_weight.yaml

The admin ui will present to mappings with its defined weights. We can test it making multiple http requests to the mapped endpoint:

for i in {1..20}; do curl http://localhost:8000/simple-service/; echo; done

Change weights

Let's edit the file 07_mapping_weight.yaml changing the mapping weights. This action could be performed since the team is confident with the change, increasing the percentage of clients accessing it. After it, apply this changes running kubectl apply -f 07_mapping_weight.yaml again.

Then check if the applied configs are reflected on the admin ui. Once again, it's possible to check the configuration running multiple requests to the service:

for i in {1..20}; do curl http://localhost:8000/simple-service/; echo; done

Headers

As a final example, it's possible to route traffic based on the request's headers. Apply the following mapping example:

kubectl apply -f 08_mapping_header.yaml

Check if the mapping is on the admin ui and modify your http request to include the header defined on 08_mapping_header.yaml:

for i in {1..20}; do curl -H "am-i-a-test: true" http://localhost:8000/simple-service/; echo; done

Next steps

Refer to the Ambassador official documentation for more features and details using Ambassador.

Cleaning up

minikube delete -p ambassador

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.