Choose OKE Cluster and Node Contracts from Current Support
A cluster is two contracts, not one resource. The cluster contract fixes the service capabilities and the API endpoint. The node contract fixes capacity, placement and the pod network. A plan that treats them as one block hides which change needs a new control plane and which is a pool rollout.
Enhanced is a capability gate, not a size. A basic cluster runs workloads, but workload identity, managed add-ons, virtual nodes, node cycling and the uptime SLA belong to enhanced clusters. If any of those is on the roadmap, the type is a create-time decision rather than a later upgrade.
Enhanced clusters must be VCN-native. OKE requires the API endpoint to be integrated into your VCN, so the endpoint subnet and its NSGs come from the network root. A basic cluster can still be built the older way; an enhanced one cannot.
An upgrade is not a type flip. A basic cluster can move to enhanced only when it is already VCN-native; one built with the older public endpoint has no upgrade path. Enhanced clusters cannot be downgraded, so treat the type as permanent from the first apply.
The CNI is the second create-time choice. Flannel overlay keeps pods on an internal CIDR, while VCN-native gives each pod an address from pod subnets you own. The choice changes the address budget and the NSG model, and it is not a toggle on a running cluster.
The pod address plan is an input, not a result. Maximum pods per node is capped by the VNICs the shape supports, and each pod consumes a VCN address. Compute the CIDR from pods per node, node count and surge, then pass the number into the pool.
The node contract starts with placement. A pool takes one placement configuration per availability domain, each pointing at a node subnet. A regional subnet still needs one entry per AD, and the pool size is distributed across those entries.
Availability domains constrain the shape before the price does. Not every shape is offered in every AD, and capacity reservations are AD-scoped. Choose the ADs from the shapes you can actually launch, then set one placement entry per AD.
Shape and image are separate pins. A flexible shape takes OCPU and memory values; the boot image comes from the node pool options for the cluster's Kubernetes version. A hard-coded image OCID becomes a pool that cannot be created after Oracle retires it.
Pods get a network contract of their own. In a VCN-native pool, the pod network options set pod subnets, maximum pods per node and pod NSGs. Size those subnets from pods per node times node count plus surge, or the pool scales into an address wall.
Node identity has no role field in OCI. OKE nodes are compute instances whose permissions come from instance principals and dynamic-group rules, not from a role attached to the pool. That is why pool tags matter: they are the stable handle for scoping a node group.
Cycling is the upgrade contract. With node cycling enabled, OKE cordons, drains and replaces nodes when the image or Kubernetes version changes. Set maximum surge and unavailable deliberately, and remember that the eviction grace period bounds how long a drain can block the rollout.
Cluster and node upgrades are separate clocks. The control plane version and the node version can differ within a supported skew, and an auto-upgrade policy can move one without the other. Record the skew you are willing to run, because a control-plane-only upgrade leaves a gap that a later pool change has to close.
Labels are scheduling data; keep them boring. Initial node labels distinguish pools for scheduling and for policy selection. Changing a label key can move pods, so treat the keys as an API rather than as free text.
Add-ons are a third version surface. CoreDNS and kube-proxy ship with the cluster, and optional add-ons are separate resources with their own versions. Pin them where the cluster type allows, and remember that a workload manifest using an add-on CRD needs that CRD installed first.
Service load balancers need their own subnet contract. The service load balancer subnets decide where OCI creates load balancers for services of type LoadBalancer. Put them in the cluster contract rather than in a per-service annotation, or every team will invent its own exposure model.
The compartment layout follows the same boundary. A cluster and its node pools can live in different compartments, which changes who can delete instances and where quotas apply. Put node pools in a compute compartment you can audit separately, and pass the cluster OCID in explicitly rather than assuming co-location.
Table 1 separates the two cluster tiers on the capabilities that change a plan.
| Capability | Basic cluster | Enhanced cluster | Plan consequence |
|---|---|---|---|
| Workload identity | no | yes | choose enhanced at create |
| Managed add-ons | limited | full | add-on versions become a contract |
| Virtual nodes | no | yes | serverless capacity stays optional |
| Node cycling | no | yes | in-place image updates need enhanced |
| VCN-native API | optional | required | endpoint subnet must exist first |
| Uptime SLA | no | yes | production baseline |
Table 2 records the releases this part was written against. A provider upgrade changes the hand-off more often than it changes a single resource argument.
| Piece | Pinned release | What the pin protects |
|---|---|---|
| Terraform | 1.17.1 | provider configuration and plan behaviour |
| oracle/oci | 9.12.1 | cluster, pool and repository schemas |
| hashicorp/kubernetes | 3.5.0 | workload objects and provider configuration |
Service limits are part of the contract. Cluster count, node pools per cluster and nodes per pool all have regional limits, and a large VCN-native pool also consumes addresses and VNICs. Check the limits before the first scale test, not during an incident.
Two choices deserve a decision record. Cluster type and CNI cannot be corrected cheaply after the first apply, so write them down with the reason. A pool can be replaced; the control plane should not be.
Figure 1 walks the choice from the network inputs to a bounded node pool.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
NET["VCN, regional subnets, NSGs
from the network root"] --> Q{"Workload identity or
managed add-ons needed?"}
Q -->|"yes"| ENH["Enhanced cluster
VCN-native required"]
Q -->|"no"| BASIC["Basic cluster
fewer features, lower cost"]
ENH --> CNI{"Pods need VCN
addresses?"}
BASIC --> CNI
CNI -->|"yes"| NAT["OCI_VCN_IP_NATIVE
pod subnets and max pods"]
CNI -->|"no"| FL["FLANNEL_OVERLAY
pod CIDR only"]
NAT --> EP["Endpoint contract
subnet, public IP, NSG"]
FL --> EP
EP --> POOL["Node pool per AD
shape, image, size"]
POOL --> OK["Cluster and node contracts recorded"]
Q -.->|"basic chosen, identity needed later"| X1["Upgrade only if VCN-native
otherwise replace"]
CNI -.->|"pod subnet too small"| X2["Pods Pending
no VCN address"]
POOL -.->|"image OCID hard-coded"| X3["Pool create fails
after image retires"]
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class NET,POOL primary;
class Q,CNI warn;
class ENH,BASIC,NAT,FL,EP secondary;
class OK ok;
class X1,X2,X3 danger;
Figure 2 draws the same decision as ownership boundaries.
A node pool is not a cluster setting. Keep the pool in the infrastructure root only while both are infrastructure, and move workloads out as soon as the Kubernetes provider appears. That split is what makes the API boundary in the next section possible.
Make the Kubernetes API Reachable to the Planned Runner
Provider configuration runs before the graph. The Kubernetes provider needs a host and credentials while the plan is built, so a root that creates the cluster and its objects in one state has nothing to connect to on the first run. Split the roots at the API, not at the resource type.
The endpoint is a subnet and NSG decision. The cluster endpoint config places the API in a regional subnet and decides whether it receives a public IP. The NSG on the endpoint is the first firewall; the route table is the second, and both must admit the runner.
Public and private endpoints are different runner designs. A public endpoint is reachable from anywhere the route and NSG allow. A private endpoint is reachable only from inside the VCN or a connected network, so a laptop plan fails before it can show a diff, which is the design working.
Network and identity failures look different. A timeout or TLS error points at the route, DNS name or certificate. A 401 or 403 points at IAM or RBAC. Read the error class before editing the kubeconfig.
Use the hostname, not the bare IP. A private endpoint exposes an address and a VCN hostname, and the certificate matches the hostname. A kubeconfig pointed at the address fails TLS verification, which looks like a credential problem and is not.
Kubeconfig version 2.0.0 is the short-lived form. The generated file invokes an OCI CLI exec plugin to mint a token instead of embedding one. The file is still user-specific: a kubeconfig another person generated does not authenticate you.
Plan the token lifetime against the run. Version 2.0.0 tokens are short-lived, and a long apply can outlive one. The Kubernetes provider runs the exec plugin again between plan and apply, which is where an expired session usually appears.
Two authorizations produce two different errors. OCI IAM decides whether the principal may read the cluster and fetch a credential. Kubernetes RBAC decides what the resulting user may create, so a pipeline can pass IAM and fail RBAC with a namespace error.
Do not give the pipeline cluster-admin. The deploy identity needs create and update on the objects it owns, in the namespaces it owns. A cluster-admin kubeconfig turns a compromised CI job into a cluster takeover.
The kubeconfig data source is the hand-off. It returns content for a chosen endpoint and token version, and the cluster root publishes the host and CA or the content itself. The workload root consumes that output instead of rebuilding a connection string.
A static kubeconfig in a pipeline is a secret in a pipeline. A rendered file carries the identity that generated it and outlives the job. Prefer an exec-based provider, or a pipeline step that writes a short-lived file with restrictive permissions.
The content is sensitive even when the token is short-lived. The file names the cluster, the user and the exec command, and it reveals how the runner authenticates. Treat it as a credential artifact in CI logs, caches and build outputs.
Endpoint subnet capacity is a scale limit. The API endpoint consumes addresses in its subnet, and larger clusters can require additional endpoint addresses. Leave headroom rather than filling that subnet with unrelated resources.
Nodes need egress as well as the runner. Worker nodes must reach the API endpoint, and they need a path to the registry and to OCI services. A private endpoint with no service gateway or NAT leaves nodes unable to pull images or reach OCI services, even though the control plane is healthy.
Probe with the deploy identity, not an administrator. Read the credential, call the API, and confirm the identity that answers is the one Terraform will use. An administrator probe proves the network and hides the RBAC gap.
A bastion is a runner with its own network position. The OCI Bastion service gives a private endpoint a path without exposing it publicly, but the session still needs IAM permission and RBAC once it connects. Treat the bastion as another deploy identity to test, not as a way around the identity model.
Cloud Shell is a runner outside your VCN. It can reach a public endpoint without any route you own, which makes it useful for a first probe and misleading as a readiness test. If the pipeline runs inside the VCN, prove the path from there instead.
Table 3 compares the endpoint choices by what the runner must supply.
| Exposure | What the cluster publishes | Runner needs | Typical failure |
|---|---|---|---|
| Public IP | public endpoint address | route to the public subnet, NSG allow | public IP disabled after the fact |
| Private IP | private endpoint address | VPN, FastConnect, bastion or peering | no path from the runner |
| VCN hostname | FQDN for the private endpoint | private DNS and a private path | IP used instead of the name |
Figure 3 shows the gate order and the failure at each step.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
RUN["Runner
CI job or operator"] --> KC["Kubeconfig
token version 2.0.0"]
KC --> IAM{"OCI IAM admits
the principal?"}
IAM -->|"no"| F1["401 or 404
cannot read the cluster"]
IAM -->|"yes"| EP{"Which endpoint
was published?"}
EP -->|"public"| PUB["Public IP on the
endpoint subnet"]
EP -->|"private"| PRIV["Private IP or VCN
hostname endpoint"]
PUB --> RBAC{"Kubernetes RBAC
grants the verb?"}
PRIV --> PATH{"Runner has a
private path?"}
PATH -->|"no"| F2["Plan fails before a diff
timeout or TLS error"]
PATH -->|"yes"| RBAC
RBAC -->|"no"| F3["Forbidden
on namespaces"]
RBAC -->|"yes"| OK["API answers with
the deploy identity"]
KC -.->|"generated by another user"| F4["Wrong identity
or rejected kubeconfig"]
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class RUN,OK primary;
class IAM,EP,PATH,RBAC warn;
class PUB,PRIV,KC secondary;
class F1,F2,F3,F4 danger;
A cluster status of Active is not API readiness. The cluster resource reaches an active state when the control plane is up, not when your runner can authenticate. Treat the probe as a separate gate between the cluster apply and the workload plan.
Hand the order to the pipeline. Apply infrastructure, publish the endpoint, probe it with the deploy identity, then plan the workload root. Terraform orders resources inside one state; across a hand-off only the pipeline can hold the order.
Distinguish Node Principals and Pod Workload Identity
Four principal types appear in OKE policy, and only one is a pod. The cluster, the node pool, the node instance and the workload each authenticate differently. Writing one grant for all of them is how application permissions end up on every node.
The cluster principal is OCI's handle on OKE's own controllers. A policy matches the cluster principal type and the cluster OCID, and it covers work the cluster does on your behalf. Delegating a Vault key for block volumes is the common example, and it is not a pod identity.
The node pool principal is separate again. Boot-volume key delegation is scoped to the pool rather than the cluster, so a missing policy fails node launch instead of application startup. The two principals are easy to conflate because both appear during cluster provisioning.
The node principal is an instance principal. OKE nodes are compute instances, and a dynamic group matches them by compartment, instance ID or defined tag. The grant is node-wide: every pod that reaches the instance metadata service inherits it.
Pool tags are the only stable scoping handle. Tags applied to a pool propagate to its instances, so a dynamic group can match one pool rather than a whole compartment. That is the right tool when a daemonset genuinely needs node-level access.
Workload identity is the pod-level option, and it is enhanced-only. The identity is the triple of cluster, namespace and service account. OCI IAM policies match the workload principal type plus those three values, which is the finest scope OCI offers on OKE.
The policy is evaluated on every request. Workload tokens are exchanged repeatedly, so a revoked policy takes effect at the next exchange rather than at pod restart. That is the operational advantage over a node grant baked into a running instance.
Workload identities are not dynamic-group members. The documented policy uses an any-user statement with request conditions, and the documentation states that workload identities cannot currently be used with dynamic groups. Model them as their own principal, not as a dynamic group with a different rule.
The SDK performs the exchange. The pod mounts a projected service-account token, and an OCI SDK workload-identity provider exchanges it for a short-lived OCI token. No auth token, API key or registry secret is written into the pod.
The pod spec has two required fields. The service account name binds the pod to the identity, and automounting the service-account token makes the exchange possible. A deployment that omits either fails authorization with a message that rarely names the missing field.
The three conditions must match exactly. A typo in the namespace, service account or cluster OCID fails with a not-authorized message that does not name the condition. Publish the triple from the workload root so the policy and the manifest cannot drift.
Cross-compartment access needs a workload mapping. A namespace can be mapped to another compartment, and the policy still lives with the target resources. The mapping is namespace-wide, so service-account conditions do the finer scoping inside it.
Workload identity is not Kubernetes RBAC. It authorizes OCI API calls, not kubectl verbs. API server user authentication is a separate contract; the cluster's OIDC authentication settings configure people, not pods.
The service account joins two permission systems. Kubernetes RBAC can grant it access to API objects, while its workload identity grants access to OCI resources. The grants are independent, and neither implies the other.
Policy placement follows the resource, not the cluster. A workload policy is written in the compartment whose resources it names, and the cluster OCID in the condition is what ties it back. Putting every policy in the cluster compartment makes the resource compartment's administrators depend on a team they do not control.
Audit sees the workload principal, not the node. Calls made through workload identity appear against the workload triple, which is what makes per-team chargeback and incident review possible. Calls made through the node principal appear against the instance, not the pod.
Table 4 keeps the four principals apart, because they are revoked in four different places.
| Principal | Created by | Policy condition | Scope | Typical grant |
|---|---|---|---|---|
| Cluster | OKE | cluster principal plus cluster OCID | cluster-wide | key delegation for volumes |
| Node pool | OKE | nodepool principal | one pool | boot volume keys |
| Node | Compute | dynamic group rule | every pod on the node | node agents and daemonsets |
| Workload | service account | workload principal plus triple | one workload | named OCI API actions |
Start from deny for the node. A node principal should not hold application API permissions, because there is no way to revoke them from a single pod. Give the workload the narrow verb and resource, and keep the node grant for the agents that need it.
Do not fall back to the node principal. When workload identity fails, the tempting fix is to grant the node. That turns a pod-scoped defect into a node-wide permission and hides the condition that was wrong.
Virtual nodes have no instance to match. A virtual node runs pods outside your compute footprint, so there is no worker instance for a dynamic group rule to match. Workload identity is the pod-level path that still applies.
Figure 4 shows the three runtime principals as separate lanes.
Keep Registry Artifacts and Workload Roots Separately Versioned
The registry is an artifact store, not part of the cluster lifecycle. Images are built and pushed on a different cadence than clusters are rebuilt. Give repositories their own root so a cluster replacement never becomes a registry migration.
Terraform owns the repository, not the layers. The build system produces the image; Terraform declares the repository, its compartment and its policy. An apply should never be the thing that uploads a layer or decides which source revision is current.
A tag is a pointer and a digest is the artifact. A tag can be moved, so a rollback that names a tag can deploy different bytes. The build records the digest, and the workload root takes that digest as an input.
The repository path is part of the deployment contract. A full image reference combines the regional registry endpoint, the tenancy namespace and the repository name. A region move or namespace change produces a new reference, so build it once and pass it down.
Version the roots separately. The registry root changes when retention or policy changes; the workload root changes when the digest changes. Sharing a state file couples a policy edit to a pod restart.
Repository creation can escape your root. If first-push auto-creation is on, a push to a new path creates a repository in the root compartment, outside the compartment you planned. Turn it off and create repositories explicitly.
An existing registry is imported, not recreated. If a team already pushes to a repository, importing it into the registry root preserves the artifacts. Recreating a repository with the same name is not a no-op, and it can collide with the existing path.
Immutability is not yet enforced by the provider. The repository resource accepts an immutable flag, but the provider notes that the setting is not supported and defaults to false. Digest pinning is your control, not the API's.
Pull authentication is a different grant from push. CI needs write on the repository; the cluster needs read. A pull secret built from a user's auth token is tied to that user until the token is revoked, and it lands in Terraform state if Terraform writes the secret.
A pull secret has a Terraform lifecycle. If Terraform creates the secret, rotating the token is an apply, and the previous value remains in state and its backups. Prefer a secret manager or an out-of-band rotation path when the token must rotate often.
Passwordless pull is possible, but it moves the identity to the node. A kubelet credential provider installed through node user data can use the node's instance principal to mint registry credentials, which needs a dynamic group and a read policy. It removes the secret and makes every pod on the node able to pull what the node can pull.
A public repository removes the pull decision entirely. A public repository accepts unauthenticated reads, which is convenient for a demo and wrong for anything private. Keep repositories private and make the read policy the only way in, so revoking a puller is an IAM change.
Workload identity does not authenticate image pulls. It authorizes OCI API calls from a pod, not registry reads by the kubelet. Keep the pull identity and the workload identity separate, or a registry incident will look like an application permission incident.
The registry network path is a second contract. Same-region pulls can route through a service gateway; without one, the nodes need a NAT or internet path. A valid token with no route still fails, and the error usually mentions the registry rather than the network.
The tenancy namespace is shared and is not a Terraform resource. The registry path begins with the tenancy namespace, which is fixed for the tenancy. A repository name is therefore a path component: renaming it creates a new repository rather than renaming the old one.
Image verification is a cluster-side policy. The cluster can require images signed by approved KMS keys, and that check belongs to the cluster contract rather than the repository. Roll it out before the first unsigned image, not after.
Signing and scanning are different controls. A signature proves who built the image; a scan reports what is inside it. The cluster's image policy enforces the first, and the registry's scan informs the second, but neither replaces digest pinning.
Keep the build identity out of the cluster. The push credential should not exist in the cluster, and the pull credential should not exist in CI. That separation limits what a compromised runner can do in either direction.
Table 5 assigns each concern to the root that should own it.
| Concern | Owner root | Declared with | Changes when |
|---|---|---|---|
| Repository | registry | container repository resource | retention or policy changes |
| Build | CI | no Terraform resource | source changes |
| Pull authentication | cluster | secret or node credential provider | credential rotates |
| Deployment | workload | Kubernetes deployment | digest changes |
Table 6 compares the pull authentication designs on what they leave behind.
| Option | Subject | Secret in state | Rotation | Fails when |
|---|---|---|---|---|
| User auth token | named user | yes, if Terraform writes it | manual | token revoked or user leaves |
| Node instance principal | node | no | automatic | node lacks the read policy |
| Workload identity | pod | no | automatic | not a registry mechanism |
Retention is a registry-root concern. How many tags and digests you keep is a policy decision with cost and rollback consequences. Decide it in the registry root, not in a deployment manifest.
A tag convention is not versioning. Reusing a moving tag makes the manifest readable and the deployment ambiguous. Use a unique tag per build for humans and the digest for the cluster; the tag is a label, not the version.
Figure 5 shows the build, registry and workload lanes with the digest as the only hand-off.
Verify One Workload and Respect Cloud Teardown Dependencies
One workload is enough to prove the path. A namespace, a deployment, a ClusterIP service and one service account cover scheduling, image pull, DNS and identity. Ingress, autoscaling and a mesh add variables before the straight line is known to work.
Verification is a sequence, not a smoke test. Scheduling proves the node contract, the pull proves the registry contract, and a denied API call proves the identity boundary. Run them in that order so a failure points at one contract.
Verify the digest, not the tag. Read the running container's image ID and compare it with the approved digest. A manifest that names the right tag proves nothing about the bytes that are running.
Break one path at a time. Remove pull permission and watch the image fail, restore it, then remove the workload policy and watch one API call fail. A single failure does not identify which boundary broke.
Read events before editing a policy. Pull failures, RBAC denials and identity errors surface in pod events, API responses and SDK logs respectively. Collect all three before changing anything, or the fix will be a guess.
Controllers create resources Terraform does not own. A LoadBalancer service creates an OCI load balancer, a persistent volume claim creates a block volume, and VCN-native pods consume VNICs and private IPs. Those objects exist outside the Terraform graph.
Cluster deletion is narrower than people expect. Deleting a cluster removes the control plane, worker nodes and node pools. It does not delete VCNs, gateways, route tables, security lists, load balancers or block volumes.
Teardown is reverse dependency followed by an audit. Delete workload objects first, wait for controllers to release load balancers and volumes, then remove node pools, then the cluster. Remove registry content only when the artifacts are meant to go, then the network inputs.
Do not parallelise a cross-root destroy. Two pipelines destroying the workload root and the node pools at the same time can remove the node that is still serving the pods. Order the stages, and make each stage wait for the previous one to report success.
A zero exit code is not an audit. List load balancers, block volumes, VNICs and private IPs after each stage. A successful destroy with a stranded volume is the common outcome of a hurried teardown.
Audit one resource type at a time. Load balancers, block volumes, VNICs, private IPs and repositories have different list views. A single compartment view can hide a resource in another compartment, so check each type where the roots actually wrote.
Registry retention is a decision, not a default. Destroying the registry root deletes the artifacts and the rollback target with them. Protect the repository or keep its root out of the teardown path.
A namespace is not an identity. Two workloads in one namespace still have two service accounts and two workload identities. Do not collapse them into one account to simplify the manifest.
Keep one compartment per root in the lab. Cross-compartment resources are the usual reason a teardown audit misses something. If the design needs a workload mapping, record both compartments on the teardown sheet.
Table 7 is the teardown order, with the resource type each stage is responsible for.
| Stage | Destroy | Wait for | Left behind if skipped |
|---|---|---|---|
| Workload | service, deployment, claim | load balancer and volume release | billed load balancer, orphan volume |
| Node pools | each pool | nodes terminated | compute instances |
| Cluster | cluster | control plane gone | control plane and node billing |
| Registry | repository, only if intended | none | digests you may want to keep |
| Network | subnets and VCN | none | VCN and subnets |
Record the boundary that proved the path. Table 8 is the evidence sheet; every row should name the artifact a reviewer can check before the first apply.
| Boundary | Owner root | Evidence to retain |
|---|---|---|
| Network inputs | network | endpoint hostname and the NSG rule that admits the runner |
| Cluster | cluster | API response that names the deploy identity |
| Image pull | cluster | running container image ID matching the approved digest |
| Workload identity | workload | one allowed and one denied OCI API result |
| Teardown | all | post-destroy inventory of load balancers and volumes |
Verify One Workload and Respect Cloud Teardown Dependencies
Execution status: design-only. This is a lab plan for Terraform 1.17.1, oracle/oci 9.12.1 and hashicorp/kubernetes 3.5.0 against a disposable compartment in a test tenancy. No command output, cluster OCID or registry path is recorded here, and none of these steps was run.
Prerequisites. A VCN with an endpoint subnet, a node subnet and a pod subnet from the network root, permission to create an enhanced cluster, one repository you can push to, and a runner with a path to the endpoint you choose. Use an image you built; nothing here depends on a public image.
| Boundary | Owner root | Pass condition |
|---|---|---|
| Network | network | endpoint NSG admits the runner |
| Cluster | cluster | active control plane and a TLS-valid hostname |
| Registry | registry | repository exists and pull policy is separate |
| Workload | workload | digest matches and one API call is denied |
| Teardown | all | no load balancer or volume survives |
- Apply the network root and record the endpoint, node and pod subnet IDs. Confirm the endpoint NSG admits the runner before creating the cluster.
- Apply the cluster root with enhanced type, VCN-native CNI, a private endpoint and one node pool per availability domain. Expect a long create and an active control plane.
- Read the kubeconfig for the private endpoint with token version 2.0.0, and confirm the hostname in the file matches the certificate.
- Apply the workload root with the deploy identity. Confirm a plan against a namespace the identity does not own is refused.
- Push one image with the build identity, record the digest, and deploy that digest rather than the tag.
- Confirm the pod is running and read the image ID from the running container. It must match the digest you recorded.
- Call one OCI API action the workload policy allows, then one it does not. Record both results.
- Create a LoadBalancer service in a branch, watch the load balancer appear, then delete the service and wait for the cloud object to leave.
- Create a persistent volume claim, confirm the block volume, delete the claim and wait for the volume to leave.
- Destroy in order: workload root, node pools, cluster, registry content only if intended, then network. After each stage, list only the resource type that stage should have removed to catch a skip.
Expected observation. The pod runs from the recorded digest without a manual pull secret, one API call succeeds and one is denied, and a stage-by-stage destroy leaves no billed object behind.
Failure checks. The lab fails if the pod can call an API its policy does not grant, if the image runs from a tag that no longer resolves to the recorded digest, if a load balancer or block volume survives the workload destroy, if the cluster destroy removes a repository you meant to keep, or if the registry root loses a digest a rollback still needs.
Cleanup. Delete the service and claim before the namespace, confirm the load balancer and volume are gone, remove the node pools, then the cluster. Keep the registry root and its digest until the rollback window closes.
Evidence to keep. The endpoint hostname, the kubeconfig token version, the approved digest, one allowed and one denied API result, the pull failure without permission, and the post-destroy inventory of load balancers and volumes.
What survives the lab is the split, not the cluster. The network IDs, the cluster type and CNI, the node pool contract, the principal model and the digest hand-off are all reusable. The cluster is the part you can replace.
Next in the Series
In OCI Serverless: Functions, API Gateway and Event Delivery, we'll explore Coordinate application images and infrastructure with resource-principal and invocation boundaries.