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 -

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.

minikube tunnel

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

kubectl get service ambassador -n ambassador
NAME         TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)                      AGE
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.

kubectl create deployment hello-minikube --image=kicbase/echo-server:1.0
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

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: ambassador
  name: test-ingress
spec:
  rules:
  - http:
      paths:
      - path: /hello/
        backend:
          serviceName: hello-minikube
          servicePort: 8080

Run the command:

kubectl apply -f hello-ingress.yaml

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

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 -

kubectl create deployment mapping-minikube --image=kicbase/echo-server:1.0
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

apiVersion: getambassador.io/v2
kind:  Mapping
metadata:
  name:  mapping-minikube
spec:
  prefix: /hello-mapping/
  service: mapping-minikube.default:8080

Run the command:

kubectl apply -f hello-mapping.yaml

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

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)