Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

clelgo/k8s-microproject

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Steps

Part 1

Step 1 - Initial project setup

  1. Clone this repository
git clone git@github.com:nas-tabchiche/k8s-microproject.git
  1. Create your own repository on Github

  2. Change the repote to your repository

git remote set-url origin git@github.com:<github-username>/<repo-name>.git

Step 2 - Install and run the application

Requirements:

  • Node 22+
  • npm
  • cURL
  1. Install dependencies
npm install
  1. Run the application
node app.js
  1. Send a GET request to the exposed endpoint
curl http://localhost:3000/

The output should be 'Hello, Kubernetes!'

Step 3 - Dockerize and publish the image

  1. Write a Dockerfile

  2. Build your image with the k8s-microproject tag

docker build . -t <username>/k8s-microproject
  1. Publish the image on dockerhub
docker push <username>/k8s-microproject

Step 4 - Create and expose your first deployment

  1. Write a deployment.yaml file describing your deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: k8s-microproject-deployment
spec:
  ...
  1. Write a service.yamlfile describing your service
apiVersion: v1
kind: Service
metadata:
  name: k8s-microproject-service
spec:
  1. Apply your deployment and service
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
  1. Check that your pods are running
kubectl get pods

Note

Their status should be 'Running'. It might take a few seconds to get there.

  1. Expose your application
# If you use minikube
minikube service k8s-microproject-service --url
  1. Send a GET request to the exposed endpoint
curl <URL of the exposed service>

The output should be 'Hello, Kubernetes!'

Step 5 - Create an ingress

  1. Write a ingress.yaml file describing your ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: k8s-microproject-ingress
spec:
  ...
  1. Apply your ingress
kubectl apply -f ingress.yaml
  1. Check that your ingress is operational
kubectl get ingress
  1. Send a GET request to the ingress
curl --resolve "<ingress-host>:80:<ingress-address>" -i http://<ingress-host>/

Part 2

Liveness probe

Docs: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-liveness-http-request

  • Your pods have a liveness probe set up

HTTPS support

  • Your ingress is accessible through https

Persistence

  • The log files generated by the application are persisted in a PersistentVolume

ConfigMaps

  • The environment variables required to operate the application are defined in a ConfigMap object and are properly passed to your deployments

StatefulSets

  • Your application is deployed using a StatefulSet
  • A ConfigMap is used to pass any environment variables needed by your application

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 84.0%
  • Dockerfile 16.0%