Skip to main content

Kubernetes Sidecar

The Inigo plugin for Kubernetes provides full observability and controls on all individual subgraphs. Follow the instructions to get up and running.

Prerequisites

  • A working Kubernetes instance with kubectl. If not, see the Kubernetes documentation for installation instructions.
  • A working GraphQL Server instance.

Kubernetes

Get token

  • Set up a service and a token. If you still need one, follow Getting Started.

Integration

Note: this code snippet includes a starwars graphql example instance, make sure to replace with your own service.

  1. Create a deployment.yaml with the following content
apiVersion: apps/v1
kind: Deployment
metadata:
name: starwars
spec:
selector:
matchLabels:
app: starwars
template:
metadata:
labels:
app: starwars
spec:
containers:
- name: starwars
image: "inigohub/starwars:latest"
imagePullPolicy: Always
envFrom:
- configMapRef:
name: starwars
- name: sidecar
image: "inigohub/sidecar:latest"
imagePullPolicy: Always
envFrom:
- configMapRef:
name: starwars-sidecar
- secretRef:
name: starwars-sidecar-token
---
apiVersion: v1
kind: ConfigMap
metadata:
name: starwars
labels:
app: starwars
data:
#LOG_TYPE: "json"
#LOG_LEVEL: "debug"
SERVICE_LISTEN_PORT: "8888"
---
apiVersion: v1
kind: Secret
metadata:
name: starwars-sidecar-token
stringData:
INIGO_SERVICE_TOKEN: "YOUR-INIGO-SERVICE-TOKEN"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: starwars-sidecar
labels:
app: starwars
data:
#LOG_TYPE: "json"
#LOG_LEVEL: "debug"
INIGO_LISTEN_PORT: "80"
INIGO_ENABLE: "true"
INIGO_EGRESS_URL: http://localhost:8888/query
INIGO_GRAPHQL_PLAYGROUND_ROUTE: /playground
---
apiVersion: v1
kind: Service
metadata:
name: starwars
labels:
app: starwars
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
selector:
app: starwars
  1. Make sure to replace YOUR-INIGO-SERVICE-TOKEN with your own service token.

  2. Make sure to change starwars with your own service and its configurations.

  3. Make sure to correctly setup the INIGO_EGRESS_URL so that the ports are correctly configured.

  4. Apply the configuration using:

  kubectl apply -f deployment.yaml
  1. To test, you can port-forward using
  kubectl port-forward svc/starwars 8080:80
  1. In a browser, go to http://localhost:8080/playground which will take you to GraphiQL. You can execute some sample queries such as:
query people {
people {
name
}
}

Execute this query several times as desired.

  1. Go to the Inigo Analytics for the service that you created. You soon see people queries in the list of operations. If you do not see the queries immediately, click the Refresh button on the upper right part of the screen.