Formation DevOps | Formation kubernetes : 6 - Premiers pas sur Kubernetes avec une application NodeJs
Premiers pas sur Kubernetes avec une application NodeJs
Créer une image docker à partir du l’mage node:6.14.2 et du fichier : server.js
var http = require('http');
var handleRequest = function(request, response) {
console.log('Received request for URL: ' + request.url);
response.writeHead(200);
response.end('Welcom to ItGalaxy.io trainings , check our web site https://www.itgalaxy.io/');
};
var www = http.createServer(handleRequest);
www.listen(8080);
Récupération du répos git : git@gitlab.com:Itgalaxy1/k8s-formations/application-simple-nodejs.git
git clone git@gitlab.com:Itgalaxy1/k8s-formations/application-simple-nodejs.git
cd application-simple-nodejs
Pousser cette image sur le registry
AWS ECR ( on a déja crée une registry public vous pouvez pusher dedans : 670270766287.dkr.ecr.eu-west-1.amazonaws.com/formationsk8s:latest )
aws configure (avec les credentials)
aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com
docker build -t formationsk8s .
docker tag formationsk8s:latest 670270766287.dkr.ecr.eu-west-1.amazonaws.com/formationsk8s:latest
docker push 670270766287.dkr.ecr.eu-west-1.amazonaws.com/formationsk8s:latest
Dockerhub : formationsk8s avec un tag perso
docker login -u contact@ItGalaxy.io.com -p ItGalaxy.io.com
docker tag formationsk8s:latest ItGalaxy.io/formationk8s:dockerhub
docker push ItGalaxy.io/formationk8s:dockerhub
Utilisant la ligne de command Kubectl :
• Création d’un namespace
kubectl create namespace formationsk8s
• créer un pod à partir de cette image écoute le port 8080 dans un namespace ‘formationsk8s’
kubectl run formationk8s --image=670270766287.dkr.ecr.eu-west-1.amazonaws.com/formationsk8s --port=8080
• Exposer les pods via un service .
kubectl expose pod formationk8s --type NodePort --target-port=8080
kubectl get svc
• Ensuite vérifier que fonctionne bien .
Utilisant les fichiers YAML :
kubectl apply -f app.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: webserver
labels:
app: webserver
spec:
selector:
matchLabels:
app: webserver
service: webserver
template:
metadata:
labels:
app: webserver
service: webserver
spec:
containers:
- name: webserver
image: 670270766287.dkr.ecr.eu-west-1.amazonaws.com/formationsk8s
imagePullPolicy: Always
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: webserver-service
labels:
app: webserver
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 8080
selector:
app: webserver
service: webserver
kubectl get all
Maintenant notre application est exposé avec un Loadbalancer créer par AWS , curl -vvv af6b797790ff043508b3214b8322064d-960531654.eu-west-1.elb.amazonaws.com
1. Nous contactez
- Description: Besoin de Formation et des Solutions cloud complètes pour vos applications
- Links:
2. Infra as a Service
- Description: Infrastructure cloud évolutive et sécurisée
- Links:
3. Projets Développeurs
- Description: Découvrez des opportunités passionnantes pour les développeurs
- Links:
4. Développeurs
- Description: Rejoignez notre communauté de développeurs
- Links:
5. Formations Complètes
- Description: Accédez à des formations professionnelles de haute qualité
- Links:
6. Marketplace
- Description: Découvrez notre place de marché de services
- Links:
7. Blogs
- Description: Découvrez nos blogs
- Links:
- comment creer une application mobile ?
- Comment monitorer un site web ?
- Command Checkout in git ?
- Comment git checkout to commit ?
- supprimer une branche git
- dockercoin
- kubernetes c est quoi
- architecture kubernetes
- Installer Gitlab Runner ?
- .gitlab-ci.yml exemples
- CI/CD
- svelte 5 vs solid
- svelte vs lit
- solidjs vs qwik
- alpine vs vue
- Plateform Freelance 2025
- Creation d’un site Web gratuitement
This website is powered by ItGalaxy.io