Cloud Native 4 min read

Deploying Microservices on Kubernetes: A Step‑by‑Step Guide

Learn how to package each microservice into containers and host them on a Kubernetes cluster, covering architecture diagrams, Ingress traffic routing, service discovery, ConfigMap and Secret management, persistent storage, deployment manifests, autoscaling, and CI/CD automation, while avoiding promotional fluff.

Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Deploying Microservices on Kubernetes: A Step‑by‑Step Guide

Introduction

Microservices have become the core of large‑scale architectures, and Kubernetes (K8s) is the dominant platform for building and delivering scalable, reliable applications. This article explains how to deploy a complete set of microservices onto a Kubernetes cluster.

Architecture Overview

In a billion‑scale system the typical K8s topology includes an external CDN, an Ingress layer for traffic entry, multiple Services for internal discovery, Deployments for stateless workloads, StatefulSets with PersistentVolumeClaims for stateful services, and a middleware cluster (Redis, MQ, Elasticsearch, MySQL, Kafka) behind the services.

Microservice Kubernetes architecture diagram
Microservice Kubernetes architecture diagram

Ingress (Traffic Entry Layer)

Microservices are not exposed directly via Pod IPs. An Ingress controller (e.g., Nginx Ingress) provides domain‑based routing, SSL termination, and can implement gray‑release strategies.

Service Discovery and Load Balancing

Each microservice creates a Service object, enabling other services to locate it internally. CoreDNS resolves service names to ClusterIP addresses, decoupling callers from pod locations.

Configuration and Secret Management

Environment variables and configuration files (such as Redis connection strings) are stored in ConfigMap objects, allowing the same container image to run in multiple environments. Sensitive data is kept in Secret objects.

Data Persistence (PV/PVC)

Stateful services like databases use PersistentVolumes (PV) and PersistentVolumeClaims (PVC) to mount cloud disks, ensuring data survives container restarts.

Deployment Process

Build container images and push them to a private registry.

Write Deployment, Service, ConfigMap, and Secret manifests for each microservice; use StatefulSet and PVC for stateful services.

Configure a Horizontal Pod Autoscaler (HPA) based on request QPS and CPU usage.

Expose the API gateway via an Ingress or LoadBalancer, configuring TLS and domain names.

Implement CI/CD pipelines to automate deployment, rollback, and version promotion.

┌────────CDN────────┐
││
││
┌──▼───┐┌──▼───┐
│Ingress││Ingress│
└──┬───┘└──┬───┘
┌──────▼─────────┐
│Service A ││Service B │
│   (Deployment)   ││   (Deployment)   │
└──────┬─────────┘
││
││
┌───▼────┐┌───▼────┐
│Pod││Pod│
││││
│(副本n)││(副本n)│
└────────┘└────────┘
┌────────────中间件集群────────────┐
│Redis/ MQ / ES / MySQL / Kafka│
└──────────────────────────────────┘

CI/CD Automation

Continuous Integration/Continuous Deployment pipelines automate image building, manifest application, and rollback procedures, ensuring consistent and repeatable releases.

cloud-nativeCI/CDdeploymentKubernetesIngressConfigMap
Mike Chen's Internet Architecture
Written by

Mike Chen's Internet Architecture

Over ten years of BAT architecture experience, shared generously!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.