Service Preview Quick Start
Service Preview is installed as an addon to the Ambassador Edge Stack.
There are two main mechanisms for installing Service Preview
edgectl install
will boot strap your cluster with the Ambassador Edge Stack and Service Preview and only works when doing a fresh install of Ambassador.YAML Install
will work with an existing installation of Ambassador Edge Stack.
Prerequisites
Install with Edgectl
If you are a new user, or you are looking to start using Ambassador Edge Stack with Service Preview on a fresh installation, the edgectl install
command will get you up and running in no time with a pre-configured Traffic Manager and Traffic Agent supported by automatic sidecar injection.
Run the following command to let edgectl
bootstrap your cluster with Ambassador and Service Preview
$ edgectl install
Install with YAML
Two extra Deployments are required to install Service Preview:
- The Traffic Manager responsible for managing communication between your Kubernetes Cluster and your local machine
- The Ambassador Injector which automates injecting the Traffic Agent sidecar responsible for routing requests to either the container in the cluster or on your local machine
1. Install the Traffic Manager and Ambassador Injector
The Traffic Manager is what is responsible for managing communications between your Kubernetes cluster and your local machine.
Services in your cluster opt-in to using Service Preview by injecting the Traffic Agent sidecar. Service Preview includes an automatic sidecar injection feature which simplifies the process of injecting the Traffic Agent as sidecars to your services.
If you used the edgectl install
command, the Traffic Manager and the Ambassador Injector have already been installed and configured for you. Otherwise, deploy the Traffic Manager and Ambassador Injector in the ambassador
namespace with kubectl
kubectl apply -f https://getambassador.io/yaml/traffic-manager.yamlkubectl apply -f https://getambassador.io/yaml/ambassador-injector.yaml
The above will deploy:
ServiceAccount
,ClusterRole
, andClusterRoleBinding
namedtraffic-manager
to grant the Traffic Manager the necessary RBAC permissions.- A
Service
andDeployment
namedtelepresence-proxy
which is the name for the Traffic Manager in the cluster. - The Ambassador Injector with a
MutatingWebhookConfiguration
that allows injection of the Traffic Agent sidecar in newly created pods.
See the Traffic Manager reference for more information on this deployment.
The traffic manager is now installed in the Ambassador namespace in your cluster and is ready to connect your cluster to your local machine.
2. Connect to your Cluster
Now that you installed the Traffic Manager, you can connect to your cluster using edgectl
.
First, start the daemon on your local machine to prime your local machine for connecting to your cluster
$ sudo edgectl daemonLaunching Edge Control Daemon v1.6.1 (api v1)
The daemon is now running and your local machine is ready to connect to your laptop. See the edgectl daemon
reference for more information on how edgectl
stages your local machine for connecting to your cluster.
After starting the daemon, you are ready to connect to the Traffic Manager.
Connect your local machine to the cluster with edgectl
:
$ edgectl connectConnecting to traffic manager in namespace ambassador...Connected to context default (https://34.72.18.227)
edgectl
will now attempt to connect to the Traffic Manager in your cluster and bridge your cluster and local networks.
Verify that you are connected to your cluster:
$ edgectl statusConnectedContext: default (https://34.72.18.227)Proxy: ON (networking to the cluster is enabled)Interceptable: 0 deploymentsIntercepts: 0 total, 0 local
3. Inject the Traffic Agent Sidecar
The Traffic Agent sidecar is required in order to intercept requests to a service and route them to your local machine.
At the moment, you can see that no sidecars are currently available with edgectl
:
$ edgectl intercept availableNo interceptable deployments
The Traffic Agent sidecar needs to be added to any service that you would like to use with Service Preview.
With the automatic injector, we can simply add it to our services by annotating the pod with getambassador.io/inject-traffic-agent: enabled
.
First, you need to create the RBAC resources required for the Traffic Agent to run in the namespace you want to intercept.
kubectl apply -f https://getambassador.io/yaml/traffic-agent-rbac.yaml
Then, apply the Hello
service manifest that is annotated to inject the Traffic Agent.
kubectl apply -f - <<EOF---apiVersion: v1kind: Servicemetadata:name: hellonamespace: defaultlabels:app: hellospec:selector:app: helloports:- protocol: TCPport: 80targetPort: http---apiVersion: getambassador.io/v2kind: Mappingmetadata:name: hellonamespace: defaultlabels:app: hellospec:prefix: /hello/service: hello:80---apiVersion: apps/v1kind: Deploymentmetadata:name: hellonamespace: defaultlabels:app: hellospec:replicas: 1selector:matchLabels:app: hellotemplate:metadata:annotations:getambassador.io/inject-traffic-agent: enabled # Enable automatic Traffic Agent sidecar injectionlabels:app: hellospec:containers:- name: helloimage: docker.io/datawire/hello-world:latestports:- name: httpcontainerPort: 8000EOFservice/hello createdmapping.getambassador.io/hello createddeployment.apps/hello created
After applying the above manifest, you can see that there is now an available service to intercept.
$ edgectl intercept availableFound 1 interceptable deployment(s):1. hello in namespace default
Take a look at the Traffic Agent reference for more information on how to connect your services to Service Preview.
Service Preview is now installed in your cluster and ready to intercept traffic sent to the Hello
service!
Next Steps
Now that you have Service Preview installed, let's see how you can use it to intercept traffic sent to services in your Kubernetes cluster!
Take a look at the Service Preview Tutorial to get Service Preview working for the Hello
service we installed!
Questions?
We’re here to help. If you have questions, join our Slack or contact us.