Docs
Launch GraphOS Studio

Reference Architecture

Reference for Enterprise Deployment of GraphOS


While you can run the Apollo regardless of your Apollo plan, connecting the router to requires an Enterprise plan. If your organization doesn't currently have an Enterprise plan, you can test out this functionality by signing up for a free Enterprise trial.

In this guide, learn about the fundamental concepts and configuration underlying Apollo's reference architecture for enterprise deployment of with a self-hosted . Use this guide as a companion reference to the Apollo reference architecture repositories.

About Apollo's reference architecture

In a modern cloud-native stack, your components must be scalable with high availability. The Apollo Router is built with this in mind. The is much faster and less resource-intensive than the Apollo Gateway, Apollo's original runtime.

Apollo provides a reference architecture for self-hosting the and s in an enterprise cloud environment using Kubernetes and Helm. This reference architecture includes autoscaling to suit the needs of a modern enterprise application. Continue reading to learn more about the reference architecture and how to use it.

💡 TIP

Check out our blog post, Deploying the Apollo Router at Apollo, to learn about Apollo's internal use of the , including the performance improvements and resource utilization reductions.

Reference architecture repositories

The reference architecture consists of the following GitHub repositories:

RepositoryDescription
build-a-supergraphThe main repository that contains a step-by-step guide to utilizing the architecture and deploying it to AWS or GCP
build-a-supergraph-infraThe template repository for Kubernetes deployment of the Apollo Router, OTel collector, Grafana, performance tests, and Zipkin
build-a-supergraph-subgraph-aTemplate repository for a subgraph used in the reference architecture
build-a-supergraph-subgraph-bTemplate repository for a subgraph used in the reference architecture

Getting started

To get started with the reference architecture, follow the README in the main build-a-supergraph repository. The README provides a how-to guide that walks you through building a with the reference architecture. It gives step-by-step instructions for setup, CI/CD, load testing, and more.

While you work through the steps of deploying the reference architecture, you can use this guide as a complementary reference of the architecture's organization and configuration.

Architecture overview

The reference architecture uses two Kubernetes clusters, one for a development environment and other for a production environment. Each cluster has pods for:

  • Hosting the
  • Hosting s
  • Collecting traces
  • Load testing K6 and viewing results with Grafana

For both environments, serves as a . Each publishes schema updates to the registry via CI/CD, and GraphOS validates and composes them into a schema. The regularly polls an endpoint called Apollo Uplink to get the latest and routing configurations from .

Apollo GraphOS
Your infrastructure
Publishes
schema
Publishes
schema
Updates
Polls for schema
and configuration changes
Schema
Registry
Apollo
Uplink
Subgraph A
Subgraph B
Router

The also pushes performance and utilization metrics to via Uplink so you can analyze them in GraphOS Studio.

Development environment

The development environment consists of the and s hosted in a Kubernetes cluster in either AWS or GCP. validates subgraph s using schema checks and makes them available to the via Uplink. The also reports usage metrics back to .

GitHub
Apollo GraphOS
Cloud (AWS or GCP)
Dev Cluster
Ingress
Subgraph CI/CD (GitHub Actions)
Schema Registry/Uplink
Schema Checks
Usage Metrics
Router
Subgraph A
Subgraph B
🔀
Developers

Production environment

The production environment is similar to the development environment with some additions.

  • The and s send their OpenTelemetry data to a collector. You can then view the data in Zipkin.
  • A K6 load tester sends traffic to the and stores load test results in InfluxDB for viewing in Grafana.
GitHub
Apollo GraphOS
Cloud (AWS or GCP)
Prod Cluster
Ingress
Subgraph CI/CD (GitHub Actions)
Schema Registry/Uplink
Schema Checks
Usage Metrics
Router
Subgraph A
Subgraph B
OTel Collector
Zipkin
K6 Load Tester
Grafana
InfluxDB
🔀
Applications / Consumers

Components

This section summarizes the various services and runtimes that comprise the reference architecture. These include the , s, OpenTelemetry, Zipkin, K6, and Grafana.

Router

The is deployed via GitHub Actions to Kubernetes using the Helm charts provided for deployments.

Chart.yaml
dependencies:
- name: router
version: 1.33.2
repository: oci://ghcr.io/apollographql/helm-charts

The values.yaml file in router.router.configuration provides configuration values at runtime.

values.yaml
router:
router:
configuration:
health_check:
listen: 0.0.0.0:8080
sandbox:
enabled: true
homepage:
enabled: false

This approach lets you run the in Kubernetes with minimal effort. The and configurations the router receives from Uplink have already been composed and validated.

Apollo GraphOS
Prod Cluster
Ingress
Schema Registry/Uplink
Usage Metrics
Router
Subgraph A
Subgraph B
🔀
Application/Consumers

Subgraphs

Each is deployed via GitHub Actions to Kubernetes using a Helm chart. Each also uses GitHub Actions to publish its updates to the . Each subgraph is deployed to its own Kubernetes namespace. The subgraphs use a HorizontalPodAutoscaler to automatically scale up service instances based on CPU or memory utilization.

values.yaml
autoscaling:
enabled: false
targetCPUUtilizationPercentage: 80
minReplicas: 1
maxReplicas: 100
hpa.yaml
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}

The queries s directly.

Prod Cluster
Ingress
Router
Subgraph A
Subgraph B
🔀
Application/Consumers

OpenTelemetry and Zipkin

The OpenTelemetry Collector is deployed via GitHub Actions to Kubernetes using the otel/opentelemetry-collector-contrib Docker image.

values.yml
image:
repository: otel/opentelemetry-collector-contrib
pullPolicy: IfNotPresent
tag: '0.59.0'

The collector is configured to export trace metrics to the Zipkin spans endpoint.

configmap.yml
exporters:
zipkin:
endpoint: 'http://zipkin.zipkin.svc.cluster.local:9411/api/v2/spans'

Zipkin is deployed via GitHub Actions to Kubernetes using the https://openzipkin.github.io/zipkin Helm chart.

Chart.yaml
dependencies:
- name: zipkin
version: 0.3.0
repository: https://openzipkin.github.io/zipkin
Prod Cluster
Router
OTel Collector
Subgraph A
Subgraph B
Zipkin

K6 and Grafana

The K6 Operator is deployed via GitHub Actions to Kubernetes. The operator exports test results to InfluxDB for viewing in Grafana.

_run-loadtest-aws.yaml
spec:
parallelism: ${{ inputs.parallelism }}
arguments: '--out influxdb=http://influxdb.monitoring:8086/db'
script:
configMap:
name: tests
file: ${{ inputs.test }}.js
value.yaml
datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: InfluxDB
type: influxdb
access: proxy
url: http://influxdb.monitoring:8086
Prod Cluster
Router
Subgraph A
Subgraph B
K6 Load Tester
InfluxDB
Grafana

CI/CD

The reference architecture uses GitHub Actions for its CI/CD. These actions include:

  • PR-level
  • Building containers using Docker
  • Publishing s to Apollo Uplink
  • deployment to the Kubernetes cluster
  • OTel collector deployment
  • Grafana deployment
  • Running load tests

Development actions

When a PR is submitted to one of the s, GitHub Actions uses to validate changes using .

When the PR is merged, GitHub Actions publishes updates to Uplink, and validates them using before making them available to the . Additionally, the service is deployed.

Apollo Graphos
Dev Cluster
GitHub Actions
Schema Checks
Schema Uplink
Router
Subgraph
Job: Schema Checks
Job: Build + Deploy Subgraph, Schema Publish
Submit PR
Merge PR

Production deploy

When you manually trigger a production deployment, GitHub Actions publishes updates to Uplink and validates them using before making them available to the . Additionally, the service is deployed.

Apollo Graphos
Production Cluster
GitHub Actions
Schema Checks
Schema Uplink
Router
Subgraph
Job: Build + Deploy Subgraph, Schema Publish
Trigger Production Deployment

Deploy router

When you manually trigger a deployment, GitHub Actions deploys the router to the Kubernetes cluster.

Dev/Production Cluster
GitHub Actions
Router
Job: Deploy Router
Trigger Deployment

Deploy OpenTelemetry collector

When you manually trigger an OpenTelemetry deployment, GitHub Actions deploys the OpenTelemetry Collector and Zipkin to the Kubernetes cluster.

Production Cluster
GitHub Actions
OTel Collector
Zipkin
Job: Deploy OTel
Trigger Deployment

Deploy load test infrastructure

When you manually trigger a load test infrastructure deployment, GitHub Actions deploys the K6 Load Tester, Grafana, the load tests, and InfluxDB to the Kubernetes cluster.

Production Cluster
GitHub Actions
K6 Load Tester
Grafana
Load Tests
InfluxDB
Job: Deploy Load Test Infrastructure
Trigger Production Deployment

Run load tests

When you manually trigger a load test run, GitHub Actions triggers the K6 Load Tester to pull the Load Tests from the environment, run the tests against the , and store the results in InfluxDB.

Production Cluster
GitHub Actions
Router
Subgraphs
K6 Load Tester
Load Tests
InfluxDB
Job: Run Load Tests
Trigger Load Tests

Further reading

Previous
Supergraph Architecture Framework
Edit on GitHubEditForumsDiscord