Skip to content

ValentineOO/k8s-express-hello

Repository files navigation

k8s-express-hello

A demonstration project showcasing Kubernetes deployment of a Node.js Express application with configuration management and security best practices.

Project Overview

This project serves as a practical example of deploying a Node.js application on Kubernetes, incorporating various Kubernetes resources and best practices.

Features

  • Express.js REST API
  • Docker containerization
  • Kubernetes deployments with:
    • Pod scaling (3 replicas)
    • Resource management
    • Environment configuration via ConfigMap
    • Secret management
    • Load balancer service
    • Security considerations

Prerequisites

  • Node.js 20.x
  • Docker
  • Kubernetes cluster (local or cloud-based)
  • kubectl CLI tool

Project Structure

├── app/
│   └── app.js              # Express application
├── Dockerfile              # Container image definition
├── hello-config.yaml       # ConfigMap definition
├── hello-deployment.yaml   # Deployment configuration
├── hello-pod.yaml         # Pod configuration
├── hello-secret.yaml      # Secrets definition
├── hello-service.yaml     # Service configuration
└── package.json           # Node.js dependencies

Getting Started

  1. Build the Docker image:

    docker build -t hello-k8s:v1 .
  2. Apply Kubernetes configurations:

    kubectl apply -f hello-config.yaml
    kubectl apply -f hello-secret.yaml
    kubectl apply -f hello-deployment.yaml
    kubectl apply -f hello-service.yaml
  3. Access the application:

    kubectl get service hello-service

    Use the external IP address provided by the LoadBalancer to access the application.

Configuration

  • The application message can be modified via the ConfigMap (hello-config.yaml)
  • API key can be updated in the Secret configuration (hello-secret.yaml)
  • Resource limits and scaling can be adjusted in the Deployment configuration

License

ISC

About

A practical demonstration of Kubernetes deployment patterns using a Node.js Express application, showcasing configuration management, scaling, and security best practices.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors