Ambassador API Gateway doesn't pickup services

1/22/2019

I'm a new Ambassador user here. I have walked thru the tutorial, in an effort to understand how use ambassador gateway. I am attempting to run this locally via Docker Compose until it's ready for deployment to K8s in production.

My use case is that all http traffic comes in on port 80, and then directed to the appropriate service. Is it considered best practice to have a docker-compose.yaml file in the working directory that refers to services in the /config directory? I ask because this doesn't appear to actually pickup my files (the postgres startup doesn't show in console). And when I run "docker ps" I only show:

CONTAINER ID        IMAGE                                PORTS                NAMES
8bc8393ac04c        05a916199684                         k8s_statsd_ambassador-8564bfb874-q97l9_default_e775d686-a93c-11e8-9caa-025000000001_0
1c00f2341caf        d7cf7cf837f9                         k8s_ambassador_ambassador-8564bfb874-q97l9_default_e775d686-a93c-11e8-9caa-025000000001_0
fe20c4819514        05a916199684                         k8s_statsd_ambassador-8564bfb874-xzvkl_default_e775ffe6-a93c-11e8-9caa-025000000001_0
ba6415b028ba        d7cf7cf837f9                         k8s_ambassador_ambassador-8564bfb874-xzvkl_default_e775ffe6-a93c-11e8-9caa-025000000001_0
9df07dc5083d        05a916199684                         k8s_statsd_ambassador-8564bfb874-w5vsq_default_e773ed53-a93c-11e8-9caa-025000000001_0
682e1f9902a0        d7cf7cf837f9                         k8s_ambassador_ambassador-8564bfb874-w5vsq_default_e773ed53-a93c-11e8-9caa-025000000001_0
bb6d2f749491        quay.io/datawire/ambassador:0.40.2   0.0.0.0:80->80/tcp   apigateway_ambassador_1

I have a docker-compose.yaml:

version: '3.1'

# Define the services/containers to be run
services:
  ambassador:
    image: quay.io/datawire/ambassador:0.40.2
    ports:
      - 80:80
    volumes:
      # mount a volume where we can inject configuration files
      - ./config:/ambassador/config
  postgres:
    image: my-postgresql
    ports:
    - '5432:5432'

and in /config/mapping-postgres.yaml:

---
apiVersion: ambassador/v0
kind: Mapping
name: postgres_mapping
rewrite: ""
service: postgres:5432
volumes:
  - ../my-postgres:/docker-entrypoint-initdb.d
environment:
  - POSTGRES_MULTIPLE_DATABASES=db1, db2, db3
  - POSTGRES_USER=<>
  - POSTGRES_PASSWORD=<>
-- sonoerin
api-gateway
docker-compose
kubernetes

1 Answer

1/22/2019

volumes and environment are not valid configs for Ambassador Mappings. Ambassador lets you proxy to postgres but the authentication has to be handled by your application.

Having said that, it looks like your Postgres container is not starting. (Perhaps because it needs an initial config). You can check for errors with:

$ docker ps -a | grep postgres
$ docker logs <container-id-from-previous-step>

You can also check a postgres docker compose example here.

Is it considered best practice to have a docker-compose.yaml file in the working directory that refers to services in the /config directory?

It's pretty standard, but you can use any directory you like for this.

-- Rico
Source: StackOverflow