Deploy containers to OCI using OKE (Kubernetes) or Container Instances. Use when deploying applications to Oracle Cloud, pushing images to OCIR, or configuring OKE clusters. Trigger with "oraclecloud deploy", "oci kubernetes", "oke deploy", "oci container instances", "oracle cloud deploy integration".
Deploy containerized applications to OCI using either OKE (Oracle Kubernetes Engine) or Container Instances. OKE provides full Kubernetes but requires 4x more config than EKS — you need a VCN, subnet, node pool, OCIR registry, and IAM policies before a single pod runs. Container Instances offer a simpler serverless alternative for workloads that don't need Kubernetes orchestration.
Purpose: Get containers running on OCI through both the full Kubernetes path (OKE) and the simpler Container Instances path, with working manifests and registry auth.
~/.oci/configpip install oci for SDK-based provisioningOracle Cloud Infrastructure Registry (OCIR) is OCI's Docker-compatible registry. Auth uses an OCI auth token, not your API key:
# Generate an auth token: Console > Profile > Auth Tokens > Generate Token
# Save the token — it's only shown once
# Login to OCIR (format: {region-key}.ocir.io/{namespace})
docker login us-ashburn-1.ocir.io
# Username: {tenancy-namespace}/oracleidentitycloudservice/{email}
# Password: your auth token
# Tag and push
docker tag myapp:latest us-ashburn-1.ocir.io/{namespace}/myapp:latest
docker push us-ashburn-1.ocir.io/{namespace}/myapp:latest
Use the OCI Python SDK to provision an OKE cluster programmatically:
import oci
config = oci.config.from_file("~/.oci/config")
container_engine = oci.container_engine.ContainerEngineClient(config)
# Create cluster
create_cluster_response = container_engine.create_cluster(
oci.container_engine.models.CreateClusterDetails(
name="my-oke-cluster",
compartment_id="ocid1.compartment.oc1..example",
vcn_id="ocid1.vcn.oc1..example",
kubernetes_version="v1.28.2",
options=oci.container_engine.models.ClusterCreateOptions(
service_lb_subnet_ids=["ocid1.subnet.oc1..example-public"],
kubernetes_network_config=oci.container_engine.models.KubernetesNetworkConfig(
pods_cidr="10.244.0.0/16",
services_cidr="10.96.0.0/16"
)
)
)
)
cluster_id = create_cluster_response.headers["opc-work-request-id"]
print(f"Cluster creation initiated: {cluster_id}")
OKE clusters need at least one node pool to schedule workloads:
container_engine.create_node_pool(
oci.container_engine.models.CreateNodePoolDetails(
compartment_id="ocid1.compartment.oc1..example",
cluster_id="ocid1.cluster.oc1..example",
name="pool-1",
kubernetes_version="v1.28.2",
node_shape="VM.Standard.E4.Flex",
node_shape_config=oci.container_engine.models.CreateNodeShapeConfigDetails(
ocpus=2.0,
memory_in_gbs=16.0
),
node_config_details=oci.container_engine.models.CreateNodePoolNodeConfigDetails(
size=3,
placement_configs=[
oci.container_engine.models.NodePoolPlacementConfigDetails(
availability_domain="Uocm:US-ASHBURN-AD-1",
subnet_id="ocid1.subnet.oc1..example-private"
)
]
)
)
)
# Install the OCI CLI and set up kubeconfig
oci ce cluster create-kubeconfig \
--cluster-id ocid1.cluster.oc1..example \
--file ~/.kube/config \
--region us-ashburn-1 \
--token-version 2.0.0
# Verify connectivity
kubectl get nodes
Create a Kubernetes deployment manifest with OCIR image pull secret:
# Create OCIR pull secret
kubectl create secret docker-registry ocir-secret \
--docker-server=us-ashburn-1.ocir.io \
--docker-username='{namespace}/oracleidentitycloudservice/{email}' \
--docker-password='{auth-token}' \
--docker-email='{email}'
# deployment.yaml
apiVersion: apps/v1