0% found this document useful (0 votes)
20 views11 pages

Jenkins K8s-Installer

Uploaded by

Zbedi Chaima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views11 pages

Jenkins K8s-Installer

Uploaded by

Zbedi Chaima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

ATELIER : DEVOPS

Mohamed HAMMOUDA

DevOps

A Successful Path To
Continuous Integration
And Continuous Delivery

Année Universitaire 2020-2021 1


▪ PLAN DE L’ATELIER

1 INTRODUCTION AU DEVOPS

2 LE CONTRÔLE DES VERSIONS : GIT & GITLAB

3 LE CONTRÔLE DE QUALITÉ DES LOGICIELS

4 LES CONTENEURS APPLICATIVES : DOCKER


INTÉGRATION CONTINUE ET DÉPLOIEMENT
5
CONTINU

2
▪ PLAN DE L’ATELIER

1 INTRODUCTION AU DEVOPS

2 LE CONTRÔLE DES VERSIONS : GIT & GITLAB

3 LE CONTRÔLE DE QUALITÉ DES LOGICIELS

4 LES CONTENEURS APPLICATIVES : DOCKER


INTÉGRATION CONTINUE ET DÉPLOIEMENT
5
CONTINU

3
▪ KUBERNETES
▪ K8s Installer tools
MiniKube
is usuallythe first Kubernetes technology Minimum requirements for the host machine:
found when someone wants to begin •CPU: 2
(Kubernetes official documentation offers a •Memory: 2 GB
tutorial to deploy your first cluster using •Disk space: 20 GB
miniKube).

PROS CONS
•Easy to install •Too minimal
•Light

The inconvenience of this solution is this is not possible to add other nodes, and
by consequence, to discover how the architecture really works and the full power
of Kubernetes.
▪ KUBERNETES
▪ K8s Installer tools
Kind
Kind is another tool to deploy a Kubernetes This solution allows you to deploy all type of clusters:
cluster locally. Its specificity is that the •Single node
cluster will be deployed inside a Docker •1 master and several workers
container. •Several masters and several workers

PROS CONS
•Very easy to install •Network external
•Cluster very easy to access to the cluster
deploy more complicated

The main inconvenience for a beginner is that as the cluster is deployed inside a
docker container, so the network management to get access to the cluster is
more difficult.
▪ KUBERNETES
▪ K8s Installer tools
Kubeadm
Kubeadm is the “hard way” to begin with solution is quite heavy to run on a laptop. Each node
Kubernetes. With this solution, you will be should be deployed in a VM and the minimal
able to bootstrap a minimum viable requirements are:
Kubernetes cluster that conforms to best •Memory: 2 GB
practices. The cluster minimal size is •CPU: 2 (only for the master)
composed of two nodes:

PROS CONS
•Full architecture •Installation more
production level challenging
•Use docker containers •Very heavy to run on a
single laptop
•Only one node master
authorized

The main inconvenience for a beginner is that as the cluster is deployed inside a
docker container, so the network management to get access to the cluster is
more difficult.
▪ KUBERNETES
▪ Minikube
MINIKUBE START
minikube is local Kubernetes, focusing on making it easy to learn and develop for Kubernetes.

• Download Binary Minikube 😄 minikube v1.27.1 on Ubuntu 20.04


👎 Unable to pick a default driver. Here is what was considered, in preference order:
$ curl -Lo minikube ▪ docker: Not healthy: "docker version --format {{.Server.Os}}-{{.Server.Version}}" exit status 1:
https://storage.googleapis.com/miniku Got permission denied while trying to connect to the Docker daemon socket at
unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/version": dial unix
be/releases/latest/minikube-linux- /var/run/docker.sock: connect: permission denied
amd64 ▪ docker: Suggestion: Add your user to the 'docker' group: 'sudo usermod -aG docker $USER &&
newgrp docker' <https://docs.docker.com/engine/install/linux-postinstall/>
$ chmod +x minikube 💡 Alternatively you could install one of these drivers:
$ sudo mv minikube /usr/local/bin ▪ kvm2: Not installed: exec: "virsh": executable file not found in $PATH
$ minikube start ▪ vmware: Not installed: exec: "docker-machine-driver-vmware": executable file not found in
$PATH
▪ podman: Not installed: exec: "podman": executable file not found in $PATH
• Add docker to the user group ▪ virtualbox: Not installed: unable to find VBoxManage in $PATH
▪ qemu2: Not installed: exec: "qemu-system-x86_64": executable file not found in $PATH
$ sudo usermod -aG docker $USER && ❌ Exiting due to DRV_NOT_HEALTHY: Found driver(s) but none were healthy. See above for
newgrp docker suggestions how to fix installed drivers.
$ minikube start --driver=docker

• Connect to Minikube add list informations about k8s components


$ Minikube ssh
$ docker ps --filter "name=kube-apiserver" --filter "name=etcd" --filter " name=kube-scheduler" --filter "
name=kube-controller-manager" | grep -v " pause
▪ KUBERNETES
▪ Minkube

DEPLOYING YOUR APPLICATION


The imperative way to deploy an application is to use the kubectl create deployment
command.
By using the imperative command, you avoid the need to know the structure of
Deployment objects as when you write YAML or JSON manifests.

CREATING A DEPLOYMENT
• deploy Nginx server to your Kubernetes cluster.
$ kubectl create deployment Nginx --image=nginx
deployment.apps/kubia created

In this command we have specified three things here:


▪ You want to create a deployment object.
▪ You want the object to be called nginx.
▪ You want the deployment to use the container image nginx

The Deployment object is now stored in the Kubernetes API. The existence of this object tells
Kubernetes that the nginx container must run in your cluster.
You’ve stated your desired state. Kubernetes must now ensure that the actual state reflects
your wishes.
▪ KUBERNETES
▪ Minikube
LISTING DEPLOYMENTS
The interaction with Kubernetes consists mainly of
the creation and manipulation of objects via its API.

Kubernetes stores these objects and then performs


operations to bring them to life. For example, when
you create a Deployment object, Kubernetes runs an
application.

Kubernetes then keeps you informed about the


current state of the application by writing the status
to the same Deployment object.

• List all Deployment objects


$ kubectl get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
kubia 0/1 1 0 6s
▪ KUBERNETES
▪ Minikube
EXPOSING YOUR APPLICATION TO THE WORLD
The next question to answer is how to access it. I mentioned that each pod gets its own IP address, but this
address is internal to the cluster and not accessible from the outside. To make the pod accessible externally,
you’ll expose it by creating a Service object.

Several types of Service objects exist.


• Some expose pods only within the cluster :NodePort
• while others expose them externally : LoadBalancer

A service with the type LoadBalancer provisions an external load balancer, which makes the service accessible
via a public IP. This is the type of service you’ll create now.

The easiest way to create the service is to use the following imperative command:
• Create a loadBalancer Service
$ kubectl expose deployment nginx --type=LoadBalancer --port 8080
service/kubia exposed
$ minikube ip
192.168.49.2
$kubectl -n default edit svc nginx
externalIPs:
- 172.42.42.100
$kubectl -n default get service nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx LoadBalancer 10.96.63.171 192.168.49.2 80:30497/TCP 7d
▪ KUBERNETES
▪ Minikube
LISTING SERVICES
Services are API objects, just like Pods,
Deployments, Nodes and virtually everything else
in Kubernetes, so you can list them by executing
kubectl get services, as in the next listing. The list shows two services with their types, IPs and the
ports they expose. The kubia service doesn’t yet have an
external IP address. Whether it gets one depends on how
Tester le scenario suivant :
you’ve deployed the cluster.
• Supprimer un pod
$ kubectl delete pod « name »

• Faites de get successifs, quest ce que vous


remarquer
$ kubectl get pod mohamed@ubuntu:~$ kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-minikube1-c4bdfc98f-s7p2s 1/1 Running 1 (7d2h ago) 7d8h
• Supprimer un deployment hello-minikube2-78f7c45f5b-ns52t 1/1 Running 0 7d1h
$ kubectl delete -n default DEPLOYMENT « name » nginx-76d6c9b8c-p47cl 0/1 ContainerCreating 0 71s
mohamed@ubuntu:~$ kubectl get pods
NAME READY STATUS RESTARTS AGE
• Faites de get successifs, quest ce que vous hello-minikube1-c4bdfc98f-s7p2s 1/1 Running 1 (7d2h ago) 7d9h
remarquer hello-minikube2-78f7c45f5b-ns52t 1/1 Running 0 7d1h
nginx-76d6c9b8c-p47cl 1/1 Running 0 117s
$ kubectl get pod

You might also like