Self-hosted mocks

Enterprise and uses: Insomnia

Insomnia allows Enterprise users to create self-hosted mock servers.

Find Configuration details and a Docker image on GitHub.

To run it locally, use NodeJS, Docker, or Kubernetes.

Create a self-hosted mock server with Kubernetes

Configure the deployment

Run the following command to create a deployment for your mock server:

echo "
  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: insomnia-mock
    namespace: mock
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: insomnia-mock
    template:
      metadata:
        labels:
          app: insomnia-mock
      spec:
        containers:
        - name: insomnia-mock
          image: ghcr.io/kong/insomnia-mockbin-self-hosted:latest
          ports:
          - containerPort: 9080
          env:
            - name: MOCKBIN_PORT
              value: '9080'
" | kubectl apply -f -

Configure the service

To create a service that exposes the Mockbin internally to the cluster, run the following command:

echo "
  apiVersion: v1
  kind: Service
  metadata:
    name: insomnia-mock
    namespace: mock
  spec:
    type: ClusterIP
    ports:
    - name: mock
      port: 9080
      targetPort: 9080
    selector:
      app: insomnia-mock
" | kubectl apply -f -

Configure the Ingress

To configure the Ingress to manage external access, first set your domain and TLS secret, and then apply the manifest. Your domain and TLS settings determine the host and secret of the configuration.

To export a domain and a TLS secret name as environment variables, run the following command:

export DOMAIN='your-domain'
export SECRET_NAME='your-tls-secret-name'

To apply the Ingress manifest, run the following command:

echo "
  apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    name: insomnia-mock-ingress
    namespace: mock
  spec:
    ingressClassName: nginx
    rules:
    - host: $DOMAIN
      http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: insomnia-mock
              port:
                number: 9080
    tls:
    - hosts:
      - $DOMAIN
      secretName: $SECRET_NAME
" | kubectl apply -f -

Validate

Use the following commands to check the status of your resources:

kubectl get deployments -n mock
kubectl get services -n mock
kubectl get ingress -n mock

Once you deploy your mock, point your front-end application to the mock URL.

Create an auto-generated mock server

Use Insomnia’s AI-assisted mock server generation to transform a short description, or an existing API source into a working self-hosted mock server.

You can generate a mock server from any of the following:

  • URL: Generate from a live endpoint response.
  • OpenAPI: Generate from a spec.
  • Text: Generate by providing a description of the API endpoints.

Note: AI-generated mock servers are only supported with self-hosted mocks.

To create an AI-generated mock server:

  1. In your Insomnia project, click Create.
  2. Click Mock Server.
  3. Click Auto-Generate.
  4. Select either URL, OpenAPI spec, or Text.
  5. (Optional) Select the Enable dynamic responses checkbox.
  6. (Optional) Click + Add Files to upload extra JSON files or YAML files.
  7. Insert an example mock-server URL.
  8. Click Create.

AI-assisted mocks and dynamic mocking: AI generation focuses on creating a complete mock structure from your input prompt or source. Dynamic mocking extends those generated mocks by making them request-aware.

Together, they enable rapid creation of realistic, responsive test environments without manual setup.

Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!