Skip to content

Commit

Permalink
add a supergraph configmap option to the helm chart (#2119)
Browse files Browse the repository at this point in the history
Here's an example of values.yaml that you could use to mount this to
your container:

```
extraEnvVars:
  - name: APOLLO_ROUTER_SUPERGRAPH_PATH
    value: /data/supergraph-schema.graphql

extraVolumeMounts:
  - name: supergraph-schema
    mountPath: /data
    readOnly: true

extraVolumes:
  - name: supergraph-schema
    configMap:
      name: "{{ .Release.Name }}-supergraph"
      items:
        - key: supergraph-schema.graphql
          path: supergraph-schema.graphql

```

Note: This takes advantage of the fact that we `tpl` template the
extraVolumes in the deployment template, so {{ .Release.Name }} will be
templated into the release name at install. You don't have to do this,
you could just hard-code it, but this is neater.

Here's an example command line:

```
helm upgrade --install --create-namespace --namespace router-test --set-file supergraphFile=supergraph-schema.graphql router-test oci://ghcr.io/apollographql/helm-charts/router --version 1.0.0-rc.9 --values values.yaml
```

NB: rc.9 doesn't exist, so the command is purely illustrative to show
how this works.
  • Loading branch information
garypen authored Nov 17, 2022
1 parent 5306abe commit 519a52f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
32 changes: 32 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,38 @@ By [@USERNAME](https://github.com/USERNAME) in https://github.com/apollographql/
# [x.x.x] (unreleased) - 2022-mm-dd
## ❗ BREAKING ❗
## 🚀 Features

### Add a supergraph configmap option to the helm chart ([PR #2119](https://github.com/apollographql/router/pull/2119))

Adds the capability to create a configmap containing your supergraph schema. Here's an example of how you could make use of this from your values.yaml and with the `helm` install command.

```yaml
extraEnvVars:
- name: APOLLO_ROUTER_SUPERGRAPH_PATH
value: /data/supergraph-schema.graphql

extraVolumeMounts:
- name: supergraph-schema
mountPath: /data
readOnly: true

extraVolumes:
- name: supergraph-schema
configMap:
name: "{{ .Release.Name }}-supergraph"
items:
- key: supergraph-schema.graphql
path: supergraph-schema.graphql
```
With that values.yaml content, and with your supergraph schema in a file name supergraph-schema.graphql, you can execute:
```
helm upgrade --install --create-namespace --namespace router-test --set-file supergraphFile=supergraph-schema.graphql router-test oci://ghcr.io/apollographql/helm-charts/router --version 1.0.0-rc.9 --values values.yaml
```

By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/2119

## 🐛 Fixes
## 🛠 Maintenance
## 📚 Documentation
12 changes: 12 additions & 0 deletions helm/chart/router/templates/supergraph-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.supergraphFile }}
{{- $routerFullName := include "router.fullname" . -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $routerFullName }}-supergraph
labels:
{{- include "router.labels" . | nindent 4 }}
data:
supergraph-schema.graphql: |-
{{ .Values.supergraphFile | indent 4 }}
{{- end }}
4 changes: 4 additions & 0 deletions helm/chart/router/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ managedFederation:
# -- If using managed federation, the variant of which graph to use
graphRef: ""

# This should not be specified in values.yaml. It's much simpler to use --set-file from helm command line.
# e.g.: helm ... --set-file supergraphFile="location of your supergraph file"
supergraphFile:

# An array of extra environmental variables
# Example:
# extraEnvVars:
Expand Down

0 comments on commit 519a52f

Please sign in to comment.