LAB 3 ‐ OCI Compartment Hierarchy - DevWithNehaCloud/Oracle-Cloud-Infrastructure-wiki GitHub Wiki

A compartment in Oracle Cloud Infrastructure (OCI) is a logical separation of services and cloud resources (such as compute, storage, and networking) within a tenancy.

OCI Compartment Hierarchy:

In OCI, we use a hierarchical structure to organize resources, manage security, and track costs. Using a large-scale application like Flipkart as an example, here is how the levels are structured:

Level 1: Root Level (The Tenancy)

The Root Compartment represents the entire organization (e.g., Flipkart Corp).

Scope: It is the top-level container for all cloud resources.

Function: Global admins manage high-level policies and governance here.

Level 2: Application Level or Child Compartment (The Environment/Project)

Below the Root, we create compartments for specific applications or environments.

Example: Flipkart-Production or Flipkart-Development.

Function: This isolates the "Live" app from the "Testing" phase. If a developer makes a mistake in the Development compartment, it will not crash the actual Production app used by customers.

Level 3. Service Level (The Resource Layer)

Inside the Application compartment, we create sub-compartments based on specific Services or Tiers.

Example Sub-compartments:

Network_Service: Contains VCNs, Subnets, and Load Balancers.

Compute_Service: Contains the Virtual Machines (Web Servers) that run the app.

Database_Service: Contains the SQL/OCI databases storing customer and order data.

Function: This allows for Role-Based Access Control (RBAC). For instance, you can write a policy that allows the "Database Team" to manage only the Database_Service compartment without touching the Network_Service.

Steps to Create a Compartment

Log in to your Oracle Cloud Console.

Open the Navigation Menu (the "hamburger" icon in the top-left corner) and Go to Identity & Security.

Under the Identity section, click on Compartments.

Click the Create Compartment button.

Fill in the following details:

Name: Give it a clear name. Note: No spaces allowed.

Description: Enter a brief note about what this compartment is for.

Parent Compartment: By default, this will be your Root Compartment (your tenancy). You can leave it as is or pick a different parent if you are creating a nested structure.

Click Create Compartment.

Now we will create 2 services(child) compartments in our application(swiggy)compartment to segregate the services

When creating a service compartment, first navigate into the application compartment and click on Create Compartment. On the create compartment page, provide the name and description for the service(child)compartment by selecting the application compartment as root(parent) compartment.

now create the first service(child)compartment for network related services

create the second service(child)compartment for compute and storage related services