This repository contains a demonstration of deploying and managing applications using Kubernetes (k8s). It is designed to help users understand the basics of Kubernetes, including deployments, services, scaling, and other core concepts. Whether you're new to Kubernetes or looking for a practical example to experiment with, this project provides a hands-on approach to working with k8s.
- Overview
- Prerequisites
- Getting Started
- Project Structure
- Deploying the Application
- Scaling and Managing the Application
- Cleaning Up
- Contributing
- License
This project demonstrates how to:
- Deploy a sample application to a Kubernetes cluster.
- Expose the application using Kubernetes Services.
- Scale the application using ReplicaSets.
- Manage configurations using ConfigMaps and Secrets.
- Clean up resources after deployment.
The demo application is a simple web server that serves a static webpage or API endpoint.
Before you begin, ensure you have the following installed:
- Kubernetes Cluster: You can use a local cluster like Minikube, Kind, or a cloud-based cluster (e.g., GKE, EKS, AKS).
- kubectl: The Kubernetes command-line tool. Installation guide.
- Docker: To build and manage container images. Installation guide.
-
Clone this repository:
git clone https://github.com/JawherKl/k8s-demo.git cd k8s-demo
-
Ensure your Kubernetes cluster is running:
kubectl cluster-info
-
Build the Docker image (if applicable):
docker build -t your-username/k8s-demo-app:latest .
-
Deploy the application to your cluster (see Deploying the Application).
k8s-demo/
├── manifests/ # Kubernetes YAML files
│ ├── deployment.yaml # Deployment configuration
│ ├── service.yaml # Service configuration
│ ├── configmap.yaml # ConfigMap for environment variables
│ └── ... # Other Kubernetes resources
├── src/ # Application source code (if applicable)
├── Dockerfile # Dockerfile for building the application image
└── README.md # This file
-
Apply the Kubernetes manifests:
kubectl apply -f manifests/
-
Verify the deployment:
kubectl get pods kubectl get services
-
Access the application:
- If using a local cluster (e.g., Minikube), run:
minikube service <service-name>
- For cloud clusters, use the external IP or LoadBalancer endpoint provided by the service.
- If using a local cluster (e.g., Minikube), run:
-
Scale the application:
kubectl scale deployment <deployment-name> --replicas=3
-
Update the application:
- Modify the
deployment.yaml
file or other manifests. - Reapply the changes:
kubectl apply -f manifests/
- Modify the
-
View logs:
kubectl logs <pod-name>
To delete the deployed resources:
kubectl delete -f manifests/
Contributions are welcome! If you'd like to improve this project, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature
). - Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/your-feature
). - Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.