Skip to content

Ft_services est sujet d’Administration Système, utilisant Kubernetes afin de faire virtualiser un réseau et d'implémenter un environnement de production

Notifications You must be signed in to change notification settings

Jean-xavierr/42Ft_services

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Ft_services - @42Born2code

Ft_services is an individual project at 42 about System Administration, using Kubernetes to virtualize a network and implement a production environment

Introduction

Ft_services is a project where we have to deploy several services (Nginx, Wordpress, PhpMyAdmin, Mysql (Mariadb), Grafana, Influxdb, Telegraf, FTPS, SSH), via kubernetes, each service will have to run in a different pod, all services should be build with Alpine Linux for performance reasons, they will all have to have a Dockerfile. 🐳

Project duration : about 3 weeks

Tips and good methodology to do the project at the bottom of the readme

What is Minikube in Kubernetes

For this project we use Minikube. Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a Virtual Machine (VM) on your laptop for users looking to try out Kubernetes or develop with it day-to-day

What is Docker 🐳

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.

Application Details 📱

Name Description
FTPS Secure file server by SSL protocol for the encryption of transfers.
Nginx Web server allowing to host a website.
Wordpress Wordpress website allowing to easily create a web page or blog.
MariaDB Database used by Wordpress to store its data
PhpMyAdmin Database administration website
Grafana Monitoring website for all the services deployed
InfluxDB Temporal database used to store the measurements of the services, this is where Grafana takes the data
Telegraf Information gathering software to acquire service data to store them in InfluxDB

Installation 🖥

Use the setup.sh script to build the docker images and deploye kubernetes.

# Use the setup.sh script with an argument, according to your environment
sh setup.sh 42Mac
# or
sh setup.sh 42Linux

Tips command

Docker basics command 🐳

# build a docker image from a Dockerfile
docker build -t <name image> <path Dockerfile>
exemple : docker build -t alpine_nginx /srcs/

# Run instance of docker image
docker run -it <name image>

# Run instance of docker image and expose port
docker run -it -p <port:port> <name image>
exemple : docker run -it -p 80:80 alpine_nginx

# See all images
docker images

# See running containers
docker ps

# Inspect a container
docker inspect <ID container>

# Kill a container
docker kill <ID container>

# Add environnement variable in Docker
docker run -it -e <name_of_env_var=value> <name image>
exemple : docker run -it -e USER=jereligi alpine_nginx

# donner une ip a un container
exemple : docker run --network=“bridge” -t alpine_wordpress .

# Stop a container
docker stop

# Delete a image
docker image rm <ID iamge>

Docker documentation

Kubernetes basics command

Kubernetes

# Create a pod from YAML file
kubectl apply -f <file.yaml>
kubectl create -f <file.yaml>

# Get shell in a pod
kubectl exec -t -i <pod_name> -- /bin/bash

# Get the pod
kubectl get pods

# Get the deployment
kubectl get deployment

# Get the service
kubectl get service

# Describe the pod
kubectl describe <pod_name> 

# Delete a YAML file
kubectl delete -f <file.yaml>

# Delete deployment
kubectl delete deployment <name_deployment>

# Launch minikube dashboard
minikube dashboard

# Connects to the service IP
minikube service <nom du service> --url

# ⚠️ Kill a process directly inside the pod | very important to check if the services restart correctly after a crash
kubectl exec deploy/<name_deployment> -- pkill <APP>

# Launch minikube by choosing are driver
minikube start --vm-driver=virtualbox
minikube start --vm-driver=docker
minikube start --vm-driver=none

# Reset Minikube VM
minikube delete

Kubernetes documentation

Tips project

⚠️ Warning: Don't copy/paste code you don't understand: it's bad for you, and for the school. I have put my login in a lot of files to encourage you doing your own version. Have fun !

Methodological advice to carry out the project

  1. Creation of a first version of all Docker images to test their proper functioning one by one locally.
  2. Development of the first version of the script to check the dependencies and install them if needed, notably under 42Mac. For the 42VM, no dependencies are necessary, but some configuration at the ip level, as well as changing the minikube driver [virtualbox -> docker].
  3. Writing .yaml files to deploy and test Docker images in kubernetes.
  4. Installation of the Loadbalancer (Metallb) to be able to access the service as a customer.
  5. Automation of Docker image builds in the bash script.
  6. Automation of deployments in minikube in the bash script.
  7. Test your program regularly this is important !
  8. Checking the health status of services with livenessprobe
  9. Last script settings
  10. Be proud of your project and of yourself

Project documentation 📚

Contributing, Question or suggestions ?

42Slack : jereligi

42Intra : jereligi

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

Thanks for reading this read me, advice or corrections are welcome

About

Ft_services est sujet d’Administration Système, utilisant Kubernetes afin de faire virtualiser un réseau et d'implémenter un environnement de production

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published