# The dependency graph

In plain Kubernetes YAML, files know nothing about each other. When a web Deployment mounts a ConfigMap and connects to a database Service, nothing in those files tells your deploy tool what order to apply them in or which ports to open between them. In Kix, reading an output value from another resource records that relationship in a cluster-wide dependency graph, which drives both rollout order and generated network policies.

<Video
  title="The dependency graph"
  duration="3:31"
  src="https://media.kix.run/videos/explanation-dependency-graph/v3/explanation-dependency-graph.mp4"
  poster="https://media.kix.run/videos/explanation-dependency-graph/v3/poster.webp"
  captions="https://media.kix.run/videos/explanation-dependency-graph/v3/captions.en.vtt"
/>

## Turning references into relationships

You rarely need to maintain separate dependency lists in Kix. Kix discovers dependencies directly from the values that pass between resources during compilation.

Each built Kubernetes resource exposes output strings such as its name, internal DNS hostname, or URL. Kix attaches a hidden reference to that resource onto each output string while rendering ordinary text into your final YAML. When a gateway ConfigMap or Deployment reads a backend Service's hostname output, the manifest gets the normal DNS string and Kix records that the gateway depends on the backend Service. Because the value and the dependency travel together, you cannot read another resource's output and forget to wire the dependency. If someone writes a hardcoded cluster hostname string instead, Kix's scorecard rules flag the untracked literal before deployment.

That metadata also distinguishes naming a resource from connecting to it over the network. Reading a ConfigMap or ServiceAccount name orders the pod after that object without opening any ports. Reading a Service's hostname or URL carries endpoint metadata, even through an intermediate ConfigMap or Secret, so Kix knows which pod labels and ports need a firewall rule when network policies are enabled. Kix also orders RBAC role bindings and network policies automatically: it applies them before the pods they govern and deletes them only after those pods finish shutting down.

## Dependency resolution and explicit deps

Each package declares the other services it requires or can optionally use, such as a PostgreSQL database or a Redis cache. Before building manifests, Kix matches those inputs against the cluster's instances in a fixed priority order.

First, an explicit link in your cluster file always wins. Second, Kix looks in the application's own namespace for a matching service. Keeping automatic matching inside the namespace prevents teams in separate namespaces from binding to each other's databases by accident, and if two services in the same namespace match, Kix stops and asks you to choose one.

Third, if nothing matches in the same namespace, Kix checks the rest of the cluster for services marked as cluster-wide, such as an ingress controller, certificate manager, or imported cloud service. Fourth, if a required input is still missing and the cluster offers a package catalog for on-demand creation, Kix adds a stable instance automatically; otherwise, optional inputs stay empty and missing required inputs fail the build with a suggested fix. At every step, Kix-managed instances take precedence over fallback platform imports, so you can replace a built-in default later without editing consuming applications.

## DAG-driven deployment scheduler

Once compilation finishes, Kix links every resource and dependency into a directed acyclic graph.

During deployment, Kix streams updates across that graph in parallel. It applies a resource as soon as all of its upstream dependencies are ready, so a stateless web service never waits behind an unrelated database rollout in another namespace.

Applying an object to the API server is separate from marking it ready. Before starting downstream workloads, Kix waits for pod rollouts to complete, waits for custom resource definitions to report established, checks that external Secrets and imported Services exist on the cluster, and waits for operator health conditions and post-deploy migration jobs to succeed.

Next, read [Dependency contracts](/docs/concepts/dependency-contracts/) to see how shared service interfaces decouple applications from specific operators and cloud services. For wiring fields and graph inspection commands, see [Instances and composition](/docs/reference/instances-and-composition/) and [Visualize the dependency graph](/docs/how-to/debug-dependency-wiring/visualize-the-dependency-graph-with-kix-graph/).