Using the Ambassador Addon

Overview

Ambassador allows access to Kubernetes services running inside minikube. Ambassador can be configured via both, Ingress resources and Mapping resources.

Prerequisites

  • Minikube version higher than v1.10.1
  • kubectl

Configuring Ambassador

Installing Ambassador

Ambassador is available as a Minikube addon Install it by running -

  1. minikube addons enable ambassador

This will install Ambassador in the namespace ambassador.

Accessing Ambassador via minikube tunnel

The service ambassador is of type LoadBalancer. To access this service, run a Minikube tunnel in a separate terminal.

  1. minikube tunnel

You can now access Ambassador at the external IP allotted to the ambassador service. Get the external IP with the following command:

  1. kubectl get service ambassador -n ambassador
  2. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  3. ambassador LoadBalancer 10.104.86.124 10.104.86.124 80:31287/TCP,443:31934/TCP 77m

Configuring via Ingress resource

In this tutorial, we’ll configure Ambassador via an Ingress resource. To configure via IngressClass resource, read this post.

First, let’s create a Kubernetes deployment and service which we will talk to via Ambassador.

  1. kubectl create deployment hello-minikube --image=kicbase/echo-server:1.0
  2. kubectl expose deployment hello-minikube --port=8080

This service hello-minikube is of type ClusterIP and is not accessible from outside the cluster.

Now, create an Ingress resource which exposes this service at the path /hello/

Note: The Ingress resource must have the annotation kubernetes.io/ingress.class: ambassador for Ambassador to pick it up.

hello-ingress.yaml

  1. apiVersion: networking.k8s.io/v1
  2. kind: Ingress
  3. metadata:
  4. annotations:
  5. kubernetes.io/ingress.class: ambassador
  6. name: test-ingress
  7. spec:
  8. rules:
  9. - http:
  10. paths:
  11. - path: /hello/
  12. backend:
  13. serviceName: hello-minikube
  14. servicePort: 8080

Run the command:

  1. kubectl apply -f hello-ingress.yaml

That’s it! You can now access your service via Ambassador:

  1. curl http://<Ambassdor's External IP'/hello/>

Note: For more advanced Ingress configurations with Ambassador, like TLS termination and name-based virtual hosting, see Ambassador’s documentation.

Configuring via Mapping resource

While Ambassador understands the Ingress spec, the Ingress spec does not leverage all of Ambassador’s features. The Mapping resource is Ambassador’s core resource that maps a target backend service to a given host or prefix.

Let’s create another Kubernetes deployment and service that we will expose via Ambassador -

  1. kubectl create deployment mapping-minikube --image=kicbase/echo-server:1.0
  2. kubectl expose deployment mapping-minikube --port=8080

This service mapping-minikube is of type ClusterIP and is not accessible from outside the cluster.

Now, let’s create a mapping that exposes this service via Ambassador at the path /hello-mapping/

hello-mapping.yaml

  1. apiVersion: getambassador.io/v2
  2. kind: Mapping
  3. metadata:
  4. name: mapping-minikube
  5. spec:
  6. prefix: /hello-mapping/
  7. service: mapping-minikube.default:8080

Run the command:

  1. kubectl apply -f hello-mapping.yaml

That’s it! You can now access your service via Ambassador:

  1. curl http://<Ambassdor's External IP'/hello-mapping/>

Note: Read more about mappings in Ambassador’s

Last modified July 7, 2023: Add addon readmes to website (cf976f6dd)