Naming various components in K8S and WebApplication

Narendra Sisodiya
2 min readMay 5, 2023

We are following this scheme for naming various components and I found this highly simple and intuitive.

Basic Hierarchy

a company has many products

a product has many components/modules etc

a component has many git branches

Examples

Imagine our product (web app) name is — expensely,

now, here are various names of components.

In our case, we have 2 environments.

environment === k8s namespace === branch

production environment

Our production environment is called prod, it is built from a branch called prod, and the k8s namespace is expensely-prod.

staging environment

Our staging environment is called staging, it is built from a branch called staging, and the k8s namespace is expensely-staging.

namespace = <product-name> <branch name>

Components

We have 3 components, frontend, backend and website.

Example of components related to front-end.

const frontend = `${product}-frontend`;
const frontendDeployment = `${frontend}-deployment`;
const frontendService = `${frontend}-service`;
const frontendContainer = `${frontend}-container`;
const frontendImageUrl = `${containerRegistry}/${company}-${product}-frontend:${deployBranch}`;

Which will result in

{
"frontend": "expensely-frontend",
"frontendDeployment": "expensely-frontend-deployment",
"frontendService": "expensely-frontend-service",
"frontendContainer": "expensely-frontend-container"
}

We can generate similar variables for other components like backend, website etc.

Docker image for front-end.

The image for prod has :prod as tag. so a unique name for the Docker image will be

yugam-expensely-frontend:prod

yugam-expensely-frontend:staging

Similarly, other names for other components will be derived.

Ingress

<product name> — <branch> — ingress

Example — expensely-prod-ingress, expensely-staging-ingress

Code directory and Folder names

we can have mono-repo or folders inside mono repo.

/src/apps/expensely-frontend
/src/apps/expensely-backend
/src/apps/expensely-website
/src/packages/expensely-shared
/src/packages/lib123
/src/packages/lib456

Or these folder names can become separate git repo.

Overall, this approach is useful for multiple products too. we can have multiple products and they can follow similar naming conventions.

Like this article?

visit expensely.in to track your expenses. This tool I created long back. Its a Free tool.

--

--