diff --git a/3.Kubernetes_Dashboard_deploiement.md b/3.Kubernetes_Dashboard_deploiement.md index 9d1faa3a512bc588eb5a96868868965f634f897a..8e162652bb9925c4ae2e1c465836f5be683593a9 100644 --- a/3.Kubernetes_Dashboard_deploiement.md +++ b/3.Kubernetes_Dashboard_deploiement.md @@ -65,5 +65,5 @@ nohup kubectl port-forward -n kubernetes-dashboard service/kubernetes-dashboard ``` **Cette methode est bien entendu temporaire** - - + + diff --git a/6.Creation_openldap.md b/6.Creation_openldap.md new file mode 100644 index 0000000000000000000000000000000000000000..3de4d9c86d514e5f0b44bff68a722e6aa0a78f36 --- /dev/null +++ b/6.Creation_openldap.md @@ -0,0 +1,210 @@ +# Déploiement d'un Serveur LDAP sur Kubernetes + +## Introduction + +Ce guide détaille le processus de déploiement d'un serveur OpenLDAP sur un cluster Kubernetes, accompagné de **phpLDAPadmin** pour une gestion simplifiée via une interface web. L'objectif est de mettre en place un système de gestion des utilisateurs et des permissions au sein de Kubernetes. + +## Étapes du Déploiement + +### 1. Création d'un Namespace dédié + +Pour isoler les ressources liées à OpenLDAP, il est recommandé de créer un namespace spécifique : + +```bash +kubectl create namespace openldap +``` + +### 2. Préparation du fichier de déploiement + +Un fichier YAML est nécessaire pour définir les ressources Kubernetes requises : Secret, PersistentVolumeClaim, Deployments et Services. + +#### Création des Secrets + +Les informations sensibles, telles que le nom de domaine, l'organisation et le mot de passe administrateur, doivent être encodées en base64 et stockées dans un Secret Kubernetes. + +```yaml +apiVersion: v1 +kind: Secret +metadata: + name: openldap-secrets + namespace: openldap +type: Opaque +data: + organization: "bXlvcmdhbml6YXRpb24=" # myorganization encodé en base64 + domain: "bXlkb21haW4=" # mydomain encodé en base64 + password: "bXlwYXNzd29yZA==" # mypassword encodé en base64 +``` + +#### Définition du PersistentVolumeClaim + +Pour assurer la persistance des données LDAP, un PersistentVolumeClaim est défini : + +```yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: openldap-data-disk + namespace: openldap +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi +``` + +#### Déploiement d'OpenLDAP + +Le déploiement spécifie l'image Docker d'OpenLDAP, les ports à exposer, les variables d'environnement (récupérées depuis le Secret) et les volumes pour la persistance des données : + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: openldap-deployment + namespace: openldap + labels: + app: openldap +spec: + replicas: 1 + selector: + matchLabels: + app: openldap + template: + metadata: + labels: + app: openldap + spec: + containers: + - name: openldap + image: osixia/openldap:1.3.0 + ports: + - containerPort: 389 + - containerPort: 636 + env: + - name: LDAP_ORGANISATION + valueFrom: + secretKeyRef: + name: openldap-secrets + key: organization + - name: LDAP_DOMAIN + valueFrom: + secretKeyRef: + name: openldap-secrets + key: domain + - name: LDAP_ADMIN_PASSWORD + valueFrom: + secretKeyRef: + name: openldap-secrets + key: password + volumeMounts: + - name: openldap-volume + mountPath: "/var/lib/ldap" + subPath: database + - name: openldap-volume + mountPath: "/etc/ldap/slapd.d" + subPath: config + volumes: + - name: openldap-volume + persistentVolumeClaim: + claimName: openldap-data-disk +``` + +#### Service pour OpenLDAP + +Un Service de type ClusterIP est créé pour exposer OpenLDAP au sein du cluster : + +```yaml +apiVersion: v1 +kind: Service +metadata: + name: openldap-service + namespace: openldap +spec: + selector: + app: openldap + ports: + - name: ldap + protocol: TCP + port: 389 + targetPort: 389 + - name: ldaps + protocol: TCP + port: 636 + targetPort: 636 +``` + +#### Déploiement de phpLDAPadmin + +Pour faciliter la gestion de LDAP, phpLDAPadmin est déployé : + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: phpldapadmin-deployment + namespace: openldap + labels: + app: phpldapadmin +spec: + replicas: 1 + selector: + matchLabels: + app: phpldapadmin + template: + metadata: + labels: + app: phpldapadmin + spec: + containers: + - name: phpldapadmin + image: osixia/phpldapadmin:0.9.0 + ports: + - containerPort: 443 + env: + - name: PHPLDAPADMIN_LDAP_HOSTS + value: openldap-service +``` + +#### Service pour phpLDAPadmin + +Un Service de type LoadBalancer est défini pour permettre l'accès externe à phpLDAPadmin : + +```yaml +apiVersion: v1 +kind: Service +metadata: + name: phpldapadmin-service + namespace: openldap +spec: + type: LoadBalancer + selector: + app: phpldapadmin + ports: + - protocol: TCP + port: 9943 + targetPort: 443 +``` + +### 3. Application du fichier YAML + +Après avoir défini toutes les ressources, appliquer le fichier YAML pour déployer OpenLDAP et phpLDAPadmin : + +```bash +kubectl apply -f openldap.yaml +``` + +### 4. Accès à phpLDAPadmin + +Une fois le déploiement terminé, accéder à phpLDAPadmin via l'adresse IP attribuée au Service LoadBalancer, en utilisant le port 9943 : + +``` +https://192.168.10.101:9943 +``` + +Identifiants de connexion : + +- **Utilisateur** : `cn=admin,dc=mydomain` +- **Mot de passe** : celui défini dans le secret Kubernetes. + +Ce déploiement permet de gérer un annuaire LDAP efficacement dans un cluster Kubernetes, tout en garantissant une interface web simplifiée pour l'administration. diff --git a/100000 - dashboard enable 2.png b/images/100000 - dashboard enable 2.png similarity index 100% rename from 100000 - dashboard enable 2.png rename to images/100000 - dashboard enable 2.png diff --git a/100000 - dashboard enable 3.png b/images/100000 - dashboard enable 3.png similarity index 100% rename from 100000 - dashboard enable 3.png rename to images/100000 - dashboard enable 3.png