Skip to content
Install the CLI

Tutorial 06

Use a local package and service-to-service dependency

These docs describe Kix's main branch, which can include changes not yet released. Read the docs for the latest release.

So far, each tutorial cluster has had one service. This tutorial adds the first service-to-service relationship.

You will run the 06-service-dep example from kix-examples: an nginx gateway proxies to a backend echo-server. The gateway package asks Kix for a backend dependency, then uses the backend’s public out values to build its nginx config. You will use and inspect the local package here; the next tutorial will spend more time on package anatomy.

This tutorial returns to a checked-in example, so you do not need to keep the files from tutorial 04 staged.

Open:

tutorials/06-service-dep/cluster.nix
tutorials/06-service-dep/reverse-proxy-package.nix

The cluster has two instances in the tutorial-06 namespace:

InstancePackageJob
backendpackages.echo-serveranswers HTTP with a fixed message
gatewaylocal reverse-proxy-package.nixproxies HTTP traffic to backend

When you curl the gateway, the request path is:

localhost:8080 -> gateway pod -> backend Service -> backend pod

No Ingress or LoadBalancer is involved. This is just two ClusterIP Services and one dependency edge.

The previous tutorials used a catalog package from the kix input: packages.echo-server.

This example also imports a package from the example folder:

tutorials/06-service-dep/cluster.nix
let
reverseProxyPackage = import ./reverse-proxy-package.nix;
in

View source on GitHub ↗

let ... in ... creates a local binding. Here it means: evaluate ./reverse-proxy-package.nix once, call it reverseProxyPackage, and use that name later in the cluster definition.

This keeps cluster composition and package implementation separate:

  • cluster.nix says which package instances are installed;
  • reverse-proxy-package.nix says how the local package builds Kubernetes resources.

The cluster installs two package instances:

tutorials/06-service-dep/cluster.nix
# Backend: a plain echo-server. Named `backend` because the
# gateway's package (see ./reverse-proxy-package.nix) takes an
# arg called `backend` — Kix matches the two up by name.
backend = {
package = packages.echo-server;
config = {
message = "Hello from the backend!";
};
};
# Gateway: nginx proxying to `backend`. Nothing here points at
# the backend explicitly. The package declares the need for a
# `backend` instance, and Kix resolves that to the instance
# above because the names match.
#
# If you'd rather make the wiring explicit, write it out
# explicitly using `ref`:
#
# gateway = {
# package = reverseProxyPackage;
# deps.backend = ref.tutorial-06.backend;
# };
gateway = {
package = reverseProxyPackage;
};

View source on GitHub ↗

The backend instance is a normal echo-server. The gateway instance uses the local reverse-proxy package.

Notice what the gateway instance does not say: it does not include a Service name, namespace, DNS name, or port for the backend. The package asks for a backend dependency, and Kix resolves that request to the instance named backend in the same namespace.

That same-namespace name match is the first dependency resolution rule you need to learn. Later tutorials will make cross-namespace dependencies explicit.

Open tutorials/06-service-dep/reverse-proxy-package.nix. The package’s build function receives named arguments from Kix:

tutorials/06-service-dep/reverse-proxy-package.nix
build =
{
self,
scope,
kix,
backend,
...
}:

View source on GitHub ↗

Do not try to unpack every argument yet. The important new one is backend. That is the dependency. Inside the package, backend exposes an out API with values the package can use safely.

For now, treat out as the public interface another instance exposes. It gives you names, DNS names, ports, selectors, and similar values without hardcoding them.

The reverse proxy writes an nginx config into a ConfigMap:

tutorials/06-service-dep/reverse-proxy-package.nix
configmap = scope.mkResource {
apiVersion = "v1";
kind = "ConfigMap";
inherit name;
data."default.conf" = ''
server {
listen 80;
location /healthz {
default_type text/plain;
return 200 'ok\n';
}
location / {
proxy_pass http://${backend.out.fqdn}:${backend.out.port}/;
}
}
'';
};

View source on GitHub ↗

The important line is the proxy_pass target:

proxy_pass http://${backend.out.fqdn}:${backend.out.port}/;

That line does two jobs:

  • it builds a real nginx upstream URL using the backend Service DNS name and port;
  • it consumes the backend’s public values instead of repeating Kubernetes names by hand.

You do not need to hand-copy the backend Service name into the gateway config. The package dependency creates the relationship; the package code reads the backend’s public interface.

Before deploying, ask Kix to evaluate and check the cluster:

kix-examples/
❱ kix check 06-service-dep
 TOOL       RESULT  DETAILS                      
 eval       pass    13 manifests evaluated       
 scorecard  pass    0 errors, 6 warnings, 1 info 

governance.hasOwner (warning), 1:
  tutorial-06/gateway: package 'gateway' has no meta.owner

reliability.boundedResources (warning), 1:
  tutorial-06/gateway/gateway: container 'nginx' is missing resource settings: requests.cpu, requests.memory, limits.cpu, limits.memory. Set CPU and memory requests and limits. Without a memory limit, a workload can exhaust the node's memory.

reliability.hasProbes (warning), 1:
  tutorial-06/gateway/gateway: container 'nginx' has no livenessProbe

security.hasNetworkPolicy (warning), 1:
  tutorial-06: namespace 'tutorial-06' has workloads but no network policy

security.nonRoot (warning), 1:
  tutorial-06/gateway/gateway: container 'nginx' may run as root: neither it nor the pod sets securityContext.runAsNonRoot, and no non-zero runAsUser resolves for it

security.readOnlyRootfs (warning), 1:
  tutorial-06/gateway/gateway: container 'nginx' does not set readOnlyRootFilesystem

1 info finding(s) not listed; run with -v to list them.

Deploy the example:

kix-examples/ live capture
❱ kix deploy 06-service-dep -y
Show outputHide output · 63 lines
Building cluster '06-service-dep'...
Cluster 06-service-dep: 13 manifests
Connecting to context kind-kix-docs (https://127.0.0.1:39863)...
No previous deployment record on the cluster. First deploy.
Note: Cluster '06-service-dep' does not set `cluster.kubernetes.uid`, so Kix continues without checking that context kind-kix-docs (https://127.0.0.1:39863) is the right Kubernetes cluster.
  If this is the right cluster, set `cluster.kubernetes.uid = "30309af6-078a-421d-ae40-61d8919c6b89";` in the '06-service-dep' cluster definition. Once set, Kix refuses to deploy '06-service-dep' to any other cluster. See https://kix.run/docs/how-to/operate-a-cluster/bind-a-cluster-definition-to-its-kubernetes-cluster/.

  _cluster
    ~ cluster-level resources (1 added)
  kube-system
    + platform-dns (0 resources)
    + platform-storage (0 resources)
  tutorial-06
    + backend 1.30.6 (3 resources)
    + gateway 0.0.1 (3 resources)

  Plan: 4 added, plus cluster-level changes
  Resources: 1 changed in content, 0 tracking annotation only (no spec change or restart)

Not checked by the dry run (8); their changes come from comparing builds:
  ? 8 is in a Namespace created by this deploy:
      ConfigMap/backend@tutorial-06
      ConfigMap/gateway@tutorial-06
      Deployment.apps/backend@tutorial-06
      Deployment.apps/gateway@tutorial-06
      PackageInstance.kix.run/backend@tutorial-06
      and 3 more (-o json lists them)

Not checked by any preview: whether Pods start, pull their images, and pass their readiness probes.

Objects: 13 to write, 0 to delete (sha256:d556253e3d68ceb70a5c1c44a8717dc3bad91e09077a6ec09859f20fdb8f7382)
  ↻ 3 unchanged object(s) will be reapplied because Kix has no recorded applied hash for them
plan: 13 nodes
  + Namespace/tutorial-06 created
  ✔ Namespace/tutorial-06 ready
  ~ Namespace/kube-system configured
  ✔ Namespace/kube-system ready
  + ConfigMap/backend@tutorial-06 created
  ✔ ConfigMap/backend@tutorial-06 ready
  ~ PackageInstance.kix.run/platform-storage@kube-system configured
  ~ PackageInstance.kix.run/platform-dns@kube-system configured
  ✔ PackageInstance.kix.run/platform-storage@kube-system ready
  + Deployment.apps/backend@tutorial-06 created
  ✔ PackageInstance.kix.run/platform-dns@kube-system ready
  ✔ Deployment.apps/backend@tutorial-06 ready
  + Service/backend@tutorial-06 created
  ✔ Service/backend@tutorial-06 ready
  + ConfigMap/gateway@tutorial-06 created
  ✔ ConfigMap/gateway@tutorial-06 ready
  + PackageInstance.kix.run/backend@tutorial-06 created
  ✔ PackageInstance.kix.run/backend@tutorial-06 ready
  + Deployment.apps/gateway@tutorial-06 created
  … Deployment.apps/gateway@tutorial-06 waiting: Deployment/gateway: 0/1 updated pods ready; pod gateway-849d84ff95-4p9lk/nginx is waiting: ContainerCreating (idle 8s) (10s of 180s); 3 objects wait for it: Service/gateway@tutorial-06 and 2 more
  ✔ Deployment.apps/gateway@tutorial-06 ready
  + Service/gateway@tutorial-06 created
  ✔ Service/gateway@tutorial-06 ready
  + PackageInstance.kix.run/gateway@tutorial-06 created
  ✔ PackageInstance.kix.run/gateway@tutorial-06 ready
  ~ Activation.kix.run/06-service-dep-lfd9ky97bhsb configured
  ✔ Activation.kix.run/06-service-dep-lfd9ky97bhsb ready
  • activation '06-service-dep-lfd9ky97bhsb' → Active

Deploy complete: 9 created, 4 configured, 0 unchanged, 0 failed

Port-forward to the gateway:

kix-examples/
❱ kix port-forward 06-service-dep gateway 8080:80

In another terminal:

❱ curl http://localhost:8080/
Hello from the backend!

The response comes from the backend pod. The gateway only proxies the request.

Stop the port-forward with Ctrl-C.

Ask Kix to show the dependency graph:

kix-examples/ offline capture
❱ kix graph 06-service-dep -o tree
Show outputHide output · 54 lines
Namespace/kube-system
├── PackageInstance.kix.run/platform-storage@kube-system (import)
│   └── Activation.kix.run/06-service-dep-lfd9ky97bhsb
└── PackageInstance.kix.run/platform-dns@kube-system (import)
    ├── Activation.kix.run/06-service-dep-lfd9ky97bhsb
    └── Deployment.apps/gateway@tutorial-06
        └── Service/gateway@tutorial-06
            └── PackageInstance.kix.run/gateway@tutorial-06
                └── Activation.kix.run/06-service-dep-lfd9ky97bhsb
Namespace/tutorial-06
├── Service/gateway@tutorial-06
│   └── PackageInstance.kix.run/gateway@tutorial-06
│       └── Activation.kix.run/06-service-dep-lfd9ky97bhsb
├── Service/backend@tutorial-06
│   ├── ConfigMap/gateway@tutorial-06
│   │   └── Deployment.apps/gateway@tutorial-06
│   │       └── Service/gateway@tutorial-06
│   │           └── PackageInstance.kix.run/gateway@tutorial-06
│   │               └── Activation.kix.run/06-service-dep-lfd9ky97bhsb
│   └── PackageInstance.kix.run/backend@tutorial-06
│       └── Activation.kix.run/06-service-dep-lfd9ky97bhsb
├── ConfigMap/gateway@tutorial-06
│   └── Deployment.apps/gateway@tutorial-06
│       └── Service/gateway@tutorial-06
│           └── PackageInstance.kix.run/gateway@tutorial-06
│               └── Activation.kix.run/06-service-dep-lfd9ky97bhsb
├── ConfigMap/backend@tutorial-06
│   └── Deployment.apps/backend@tutorial-06
│       └── Service/backend@tutorial-06
│           ├── ConfigMap/gateway@tutorial-06
│           │   └── Deployment.apps/gateway@tutorial-06
│           │       └── Service/gateway@tutorial-06
│           │           └── PackageInstance.kix.run/gateway@tutorial-06
│           │               └── Activation.kix.run/06-service-dep-lfd9ky97bhsb
│           └── PackageInstance.kix.run/backend@tutorial-06
│               └── Activation.kix.run/06-service-dep-lfd9ky97bhsb
├── PackageInstance.kix.run/gateway@tutorial-06
│   └── Activation.kix.run/06-service-dep-lfd9ky97bhsb
├── PackageInstance.kix.run/backend@tutorial-06
│   └── Activation.kix.run/06-service-dep-lfd9ky97bhsb
├── Deployment.apps/gateway@tutorial-06
│   └── Service/gateway@tutorial-06
│       └── PackageInstance.kix.run/gateway@tutorial-06
│           └── Activation.kix.run/06-service-dep-lfd9ky97bhsb
└── Deployment.apps/backend@tutorial-06
    └── Service/backend@tutorial-06
        ├── ConfigMap/gateway@tutorial-06
        │   └── Deployment.apps/gateway@tutorial-06
        │       └── Service/gateway@tutorial-06
        │           └── PackageInstance.kix.run/gateway@tutorial-06
        │               └── Activation.kix.run/06-service-dep-lfd9ky97bhsb
        └── PackageInstance.kix.run/backend@tutorial-06
            └── Activation.kix.run/06-service-dep-lfd9ky97bhsb
13 resources, 22 dependencies

Look for the gateway instance and the backend resources it depends on.

You can also render the manifests and inspect the generated nginx config:

kix-examples/ offline capture
❱ kix build 06-service-dep
Show outputHide output · 363 lines
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kix.run/depends-on: 1wz2372bgznyyc56m28alsibkgfcq4dc,2pnlgcwav17xaaaqpmrcs4r2c4fqj6h7
    kix.run/identity-hash: hw0cg9y57iini1fbjbsajk31fgi96h1q
    kix.run/package: backend
    kix.run/package-namespace: tutorial-06
  labels:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/managed-by: kix
    app.kubernetes.io/name: backend
  name: backend
  namespace: tutorial-06
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/instance: backend
      app.kubernetes.io/name: backend
  template:
    metadata:
      annotations:
        checksum/config: db3c0d944bc776f81aec6e6a81d498a231bc5fffe30e034f5ea25add6752d5c0
      labels:
        app.kubernetes.io/instance: backend
        app.kubernetes.io/name: backend
    spec:
      containers:
      - image: docker.io/nginxinc/nginx-unprivileged:1.30.6-alpine@sha256:f5116ed4606f3eb015dd4a8e28cb9b351476dc0ad4bc6e9f93b19cec130cdf03
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /healthz
            port: 8080
          periodSeconds: 10
        name: nginx
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP
        readinessProbe:
          failureThreshold: 1
          httpGet:
            path: /healthz
            port: 8080
          periodSeconds: 5
        resources:
          limits:
            cpu: 100m
            memory: 64Mi
          requests:
            cpu: 50m
            memory: 32Mi
        securityContext:
          allowPrivilegeEscalation: false
          capabilities:
            drop:
            - ALL
          readOnlyRootFilesystem: true
          runAsNonRoot: true
          seccompProfile:
            type: RuntimeDefault
        volumeMounts:
        - mountPath: /etc/nginx/conf.d
          name: config
          readOnly: true
        - mountPath: /tmp
          name: tmp
      terminationGracePeriodSeconds: 30
      volumes:
      - configMap:
          name: backend
        name: config
      - emptyDir: {}
        name: tmp
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kix.run/depends-on: 1wz2372bgznyyc56m28alsibkgfcq4dc,xr2f84lrr9mf397kk79fkdr0k5ccmnw3,requires:mkgdf3yajj0a92l7fspcy7ciykw4dsl1
    kix.run/identity-hash: bfik31lsc8881b55n01wcwyjy2d4i53c
    kix.run/package: gateway
    kix.run/package-namespace: tutorial-06
  labels:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/managed-by: kix
    app.kubernetes.io/name: gateway
  name: gateway
  namespace: tutorial-06
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/instance: gateway
      app.kubernetes.io/name: gateway
  template:
    metadata:
      labels:
        app.kubernetes.io/instance: gateway
        app.kubernetes.io/name: gateway
    spec:
      containers:
      - image: nginx:1.27-alpine
        imagePullPolicy: IfNotPresent
        name: nginx
        ports:
        - containerPort: 80
          name: http
          protocol: TCP
        readinessProbe:
          httpGet:
            path: /healthz
            port: 80
          periodSeconds: 5
        volumeMounts:
        - mountPath: /etc/nginx/conf.d
          name: config
          readOnly: true
      volumes:
      - configMap:
          name: gateway
        name: config
---
apiVersion: kix.run/v1alpha1
kind: Activation
metadata:
  annotations:
    kix.run/built-via: /nix/store/nr8kfkik4s1scpm6ipjf5xx4msr6hr2c-kix-activation-06-service-dep.json
    kix.run/depends-on: 4sq8laq4iq1acp2kfbc1jidw8h96hb2a,ad5prhvm95mn8qwymfwzzn8c3cg4w1an,gsfac11mfypadvb0dvm6s5ns5ls2363k,mkgdf3yajj0a92l7fspcy7ciykw4dsl1
    kix.run/identity-hash: lfd9ky97bhsb4brq2nkdavain0f8mg3i
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
  labels:
    app.kubernetes.io/managed-by: kix
    kix.run/cluster: 06-service-dep
  name: 06-service-dep-lfd9ky97bhsb
spec:
  instances:
    kube-system:
      platform-dns: platform-dns
      platform-storage: platform-storage
    tutorial-06:
      backend: backend
      gateway: gateway
---
apiVersion: kix.run/v1alpha1
kind: PackageInstance
metadata:
  annotations:
    kix.run/depends-on: sj0fv5bs2hnh9zcqdh62ph34l2wm0b1m
    kix.run/identity-hash: mkgdf3yajj0a92l7fspcy7ciykw4dsl1
    kix.run/import-apiversion: v1
    kix.run/import-fqdn: kube-dns.kube-system.svc.cluster.local
    kix.run/import-kind: Service
    kix.run/import-name: kube-dns
    kix.run/mode: import
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
  labels:
    app.kubernetes.io/instance: platform-dns
    app.kubernetes.io/managed-by: kix
  name: platform-dns
  namespace: kube-system
spec:
  instanceName: platform-dns
  mode: import
  namespaceName: kube-system
---
apiVersion: kix.run/v1alpha1
kind: PackageInstance
metadata:
  annotations:
    kix.run/depends-on: sj0fv5bs2hnh9zcqdh62ph34l2wm0b1m
    kix.run/identity-hash: 4sq8laq4iq1acp2kfbc1jidw8h96hb2a
    kix.run/import-apiversion: storage.k8s.io/v1
    kix.run/import-kind: StorageClass
    kix.run/import-name: standard
    kix.run/mode: import
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
  labels:
    app.kubernetes.io/instance: platform-storage
    app.kubernetes.io/managed-by: kix
  name: platform-storage
  namespace: kube-system
spec:
  instanceName: platform-storage
  mode: import
  namespaceName: kube-system
---
apiVersion: kix.run/v1alpha1
kind: PackageInstance
metadata:
  annotations:
    kix.run/depends-on: 1wz2372bgznyyc56m28alsibkgfcq4dc,6qs443dzpy661bnba580kq63242nsdmx
    kix.run/identity-hash: ad5prhvm95mn8qwymfwzzn8c3cg4w1an
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
    kix.run/root: backend
  labels:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/managed-by: kix
  name: backend
  namespace: tutorial-06
spec:
  instanceName: backend
  namespaceName: tutorial-06
  package: echo-server
  version: "1.30.6"
---
apiVersion: kix.run/v1alpha1
kind: PackageInstance
metadata:
  annotations:
    kix.run/depends-on: 1wz2372bgznyyc56m28alsibkgfcq4dc,97cwl2h19skwpzblji6n4kfpfp61kai8
    kix.run/identity-hash: gsfac11mfypadvb0dvm6s5ns5ls2363k
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
    kix.run/root: gateway
  labels:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/managed-by: kix
  name: gateway
  namespace: tutorial-06
spec:
  instanceName: gateway
  namespaceName: tutorial-06
  version: "0.0.1"
---
apiVersion: v1
data:
  default.conf: |
    server {
        listen 8080;
        location / {
            root /etc/nginx/conf.d;
            default_type text/plain;
            try_files /message.txt =404;
            # nginx refuses a POST for a static file with 405. The
            # redirect turns the request into a GET, so every
            # method gets the message.
            error_page 405 =200 /message.txt;
        }
        location /healthz {
            default_type text/plain;
            return 200 'ok\n';
        }
    }
  message.txt: |
    Hello from the backend!
kind: ConfigMap
metadata:
  annotations:
    kix.run/depends-on: 1wz2372bgznyyc56m28alsibkgfcq4dc
    kix.run/identity-hash: 2pnlgcwav17xaaaqpmrcs4r2c4fqj6h7
    kix.run/package: backend
    kix.run/package-namespace: tutorial-06
  labels:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/managed-by: kix
  name: backend
  namespace: tutorial-06
---
apiVersion: v1
data:
  default.conf: |
    server {
        listen 80;
        location /healthz {
            default_type text/plain;
            return 200 'ok\n';
        }
        location / {
            proxy_pass http://backend.tutorial-06.svc.cluster.local:80/;
        }
    }
kind: ConfigMap
metadata:
  annotations:
    kix.run/depends-on: 1wz2372bgznyyc56m28alsibkgfcq4dc,6qs443dzpy661bnba580kq63242nsdmx
    kix.run/identity-hash: xr2f84lrr9mf397kk79fkdr0k5ccmnw3
    kix.run/package: gateway
    kix.run/package-namespace: tutorial-06
  labels:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/managed-by: kix
  name: gateway
  namespace: tutorial-06
---
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    kix.run/identity-hash: sj0fv5bs2hnh9zcqdh62ph34l2wm0b1m
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
  labels:
    app.kubernetes.io/managed-by: kix
    kubernetes.io/metadata.name: kube-system
  name: kube-system
---
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    kix.run/identity-hash: 1wz2372bgznyyc56m28alsibkgfcq4dc
    kix.run/package: _cluster
    kix.run/package-namespace: _cluster
  labels:
    app.kubernetes.io/managed-by: kix
    kubernetes.io/metadata.name: tutorial-06
  name: tutorial-06
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    kix.run/depends-on: 1wz2372bgznyyc56m28alsibkgfcq4dc,hw0cg9y57iini1fbjbsajk31fgi96h1q
    kix.run/identity-hash: 6qs443dzpy661bnba580kq63242nsdmx
    kix.run/package: backend
    kix.run/package-namespace: tutorial-06
  labels:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/managed-by: kix
  name: backend
  namespace: tutorial-06
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    app.kubernetes.io/instance: backend
    app.kubernetes.io/name: backend
  type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    kix.run/depends-on: 1wz2372bgznyyc56m28alsibkgfcq4dc,bfik31lsc8881b55n01wcwyjy2d4i53c
    kix.run/identity-hash: 97cwl2h19skwpzblji6n4kfpfp61kai8
    kix.run/package: gateway
    kix.run/package-namespace: tutorial-06
  labels:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/managed-by: kix
  name: gateway
  namespace: tutorial-06
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/name: gateway
  type: ClusterIP

In the gateway ConfigMap, the proxy_pass URL should contain the backend’s cluster DNS name. The package code did not hardcode that name; it came from backend.out.fqdn.

In tutorials/06-service-dep/cluster.nix, rename the backend instance to api:

tutorials/06-service-dep/cluster.nix
api = {
package = packages.echo-server;
config = {
message = "Hello from the backend!";
};
};

Then run:

kix-examples/ offline capture
❱ kix check 06-service-dep
Show outputHide output · 9 lines
 TOOL  RESULT  DETAILS   
 eval  fail    see below 

tutorial-06/gateway: dependency 'backend' has no matching instance in namespace 'tutorial-06'.
Fix: Declare an instance named 'backend' in namespace 'tutorial-06':
  instances.tutorial-06.backend.package = packages.<package>;
If another instance in 'tutorial-06' provides 'backend', wire it in instances.tutorial-06.gateway:
  deps.backend = ref.tutorial-06.<instance>;
(exit code: 1)

Kix should fail because the gateway package asks for backend, but there is no same-namespace instance with that name anymore.

Change api back to backend before continuing. Later tutorials assume this example is back in its working state.

You added the first real edge to the tutorial path:

  • a cluster can import a local package
  • an instance installs that local package just like a catalog package
  • a package can ask for another instance by argument name
  • Kix resolves that argument to a matching same-namespace instance
  • out lets one package use another package’s public values without hardcoded Service names

The next dependency tutorial puts the two services in different namespaces and uses ref to make the wiring explicit.