- Clone this repository
git clone git@github.com:nas-tabchiche/k8s-microproject.git-
Create your own repository on Github
-
Change the repote to your repository
git remote set-url origin git@github.com:<github-username>/<repo-name>.gitRequirements:
- Node 22+
- npm
- cURL
- Install dependencies
npm install- Run the application
node app.js
- Send a GET request to the exposed endpoint
curl http://localhost:3000/The output should be 'Hello, Kubernetes!'
-
Write a Dockerfile
-
Build your image with the
k8s-microprojecttag
docker build . -t <username>/k8s-microproject- Publish the image on dockerhub
docker push <username>/k8s-microproject- Write a
deployment.yamlfile describing your deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: k8s-microproject-deployment
spec:
...- Write a
service.yamlfile describing your service
apiVersion: v1
kind: Service
metadata:
name: k8s-microproject-service
spec:- Apply your deployment and service
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml- Check that your pods are running
kubectl get podsNote
Their status should be 'Running'. It might take a few seconds to get there.
- Expose your application
# If you use minikube
minikube service k8s-microproject-service --url- Send a GET request to the exposed endpoint
curl <URL of the exposed service>The output should be 'Hello, Kubernetes!'
- Write a
ingress.yamlfile describing your ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: k8s-microproject-ingress
spec:
...- Apply your ingress
kubectl apply -f ingress.yaml- Check that your ingress is operational
kubectl get ingress- Send a GET request to the ingress
curl --resolve "<ingress-host>:80:<ingress-address>" -i http://<ingress-host>/- Your pods have a liveness probe set up
- Your ingress is accessible through https
- The log files generated by the application are persisted in a PersistentVolume
- The environment variables required to operate the application are defined in a ConfigMap object and are properly passed to your deployments
- Your application is deployed using a StatefulSet
- A ConfigMap is used to pass any environment variables needed by your application