|
| 1 | +# Ambassador |
| 2 | +Ambassador is an open source API gateway for Kubernetes, built on the Envoy proxy. |
| 3 | + |
| 4 | +## 1. Installation |
| 5 | +This component uses Helm to install Ambassador. |
| 6 | +Ambassador is exposed by default as LoadBalancer service. While this resource can be requested on a cloud-provided cluster, this is generally not available on bare metal clusters (since LoadBalancers are lower-level network resources), such as minikube and |
| 7 | +microk8s. For those, Ambassador can be set to use NodePort. Alternatively, the component [metallb](https://github.com/data-mill-cloud/data-mill/tree/master/infrastructure/components/metallb) can be installed to allocate a local IP and a load balancer as requested |
| 8 | +by Ambassador. |
| 9 | + |
| 10 | +## 2. Getting started |
| 11 | +A getting started guide to Ambassador is provided [here](https://www.getambassador.io/user-guide/getting-started/). |
| 12 | +As mentioned in the example, every service that wants to be accessible through Ambassador from outside the cluster needs to define an annotation of kind: |
| 13 | +``` |
| 14 | +apiVersion: v1 |
| 15 | +kind: Service |
| 16 | +metadata: |
| 17 | + name: qotm |
| 18 | + annotations: |
| 19 | + getambassador.io/config: | |
| 20 | + --- |
| 21 | + apiVersion: ambassador/v0 |
| 22 | + kind: Mapping |
| 23 | + name: qotm_mapping |
| 24 | + prefix: /qotm/ |
| 25 | + service: qotm |
| 26 | +spec: |
| 27 | + selector: |
| 28 | + app: qotm |
| 29 | + ports: |
| 30 | + - port: 80 |
| 31 | + name: http-qotm |
| 32 | + targetPort: http-api |
| 33 | +``` |
| 34 | +Ambassador continuously monitors the cluster for those annotations and is able to add or change routing rules for annotated services. |
| 35 | + |
| 36 | +## 3. Ingress controllers Vs. Ambassador |
| 37 | +Distributing routing rules on the individual components as opposed to a centralised configuration, is in fact similar to the concept of [Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/), where a central [Ingress |
| 38 | +controller](https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-controllers) seeks for Ingress Resources, i.e. a Kubernetes resource that wraps a Service to specify its routing information. |
| 39 | +Although still in Beta, Ingress is a core Kubernetes concept, and as such it can benefit of kubectl and all other typical K8s resource management tools. |
| 40 | +In addition, certain cloud providers such as GCE/GKE deploy an Ingress controller on the master, while on on-premise clusters a controller should be explicitly deployed. |
| 41 | + |
| 42 | +There exist multiple Ingress controllers, such as based on [Istio](https://istio.io/docs/tasks/traffic-management/ingress/), [nginx](https://www.nginx.com/products/nginx/kubernetes-ingress-controller) and [Traefik](https://docs.traefik.io/user-guide/kubernetes/). |
| 43 | +As mentioned in the Ingress documentation, we can easily add an Ingress resource for a Service: |
| 44 | +``` |
| 45 | +apiVersion: extensions/v1beta1 |
| 46 | +kind: Ingress |
| 47 | +metadata: |
| 48 | + name: test-ingress |
| 49 | + annotations: |
| 50 | + nginx.ingress.kubernetes.io/rewrite-target: / |
| 51 | +spec: |
| 52 | + rules: |
| 53 | + - http: |
| 54 | + paths: |
| 55 | + - path: /testpath |
| 56 | + backend: |
| 57 | + serviceName: test |
| 58 | + servicePort: 80 |
| 59 | +``` |
| 60 | + |
| 61 | +A cluster can simultaneously run multiple ingress controllers. In this case, when creating an ingress the target ingress controller has to be specified using the specific `ingress.class`, or a default one may be used otherwise. |
| 62 | +Ideally, all Ingress controllers should respect the basic ingress resource definition, though they may operate slightly differently for certain functionalities. |
| 63 | + |
| 64 | +If you are looking for an Ingress controller, mind that Ambassador provides a superset of a typical controller's functionalities. |
| 65 | +[This blog post](https://blog.getambassador.io/kubernetes-ingress-nodeport-load-balancers-and-ingress-controllers-6e29f1c44f2d) explains differences, while [this section](https://www.getambassador.io/concepts/developers/#ingress-resources) of Ambassador |
| 66 | +documentation explains why Ambassador does not support Ingress resources. |
| 67 | + |
| 68 | +Among others, Ambassador is [used in the Kubeflow project](https://kubernetes.io/blog/2018/06/07/dynamic-ingress-in-kubernetes/) to manage routing with Kubernetes annotations. This way, Kubeflow redirects all external traffic to Ambassador that does forward to the |
| 69 | +individual service for each request. |
0 commit comments