Skip to main content

Kubernetes Sidecar

The Inigo sidecar deployment for Kubernetes provides full observability and control over your GraphQL API.

Prerequisites

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

Kubernetes

Kubernetes Sidecar

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

⚠️ Important requirements:

  • Ensure that the Inigo sidecar container specifies a minimum memory request of 512Mi and a minimum CPU request of 1 in its configuration. For GraphQL endpoints with heavy traffic, higher values may be needed.
  • Avoiding setting the pod's CPU limit to fractional values like 1.5 and 1500m or avoid setting any cpu limit to the sidecar. Make sure k8s does not automatically arbitrarily assign limits to the sidecar. Check for any limits using kubectl describe pod after deploying.
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
resources:
requests:
memory: "512Mi"
cpu: 1
---
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
labels:
app: starwars
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.