Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
elearning:workbooks:kubernetes:k8s07 [2022/09/17 08:14] adminelearning:workbooks:kubernetes:k8s07 [2024/12/15 06:55] (Version actuelle) admin
Ligne 1: Ligne 1:
 ~~PDF:LANDSCAPE~~ ~~PDF:LANDSCAPE~~
  
-Version - **2022.02**+Version - **2024.01**
  
 Dernière mise-à-jour : ~~LASTMOD~~ Dernière mise-à-jour : ~~LASTMOD~~
  
-======DOF308 - Introduction à la Sécurisation de Kubernetes======+ 
 +======DOF308 - Introduction à la Sécurisation de K8s======
  
 =====Contenu du Module===== =====Contenu du Module=====
  
-  * **DOF308 - Introduction à la Sécurisation de Kubernetes**+  * **DOF308 - Introduction à la Sécurisation de K8s**
     * Contenu du Module     * Contenu du Module
     * LAB #1 - Role Based Acces Control et Certificats TLS     * LAB #1 - Role Based Acces Control et Certificats TLS
Ligne 24: Ligne 25:
       * 2.3 - Kubernetes Network Policies       * 2.3 - Kubernetes Network Policies
       * 2.4 - Kubernetes Resource Allocation Management       * 2.4 - Kubernetes Resource Allocation Management
 +
 +=====Ressources=====
 +
 +====Lab #1====
 +
 +  * https://www.dropbox.com/scl/fi/ttklc9ejfhpuyq3eh7wbo/flask.yaml?rlkey=gt1fxvfd8a1vxh75e8y8bz6yw&dl=0
 +  * https://www.dropbox.com/scl/fi/ujyzyh5ixqibqtychuyzr/deployment.yaml?rlkey=u4tnbrh2f0b6ewk1mt15y6y63&dl=0
 +
 +====Lab #2====
 +
 +  * https://www.dropbox.com/scl/fi/sbzoft6ioo6gmo5n56035/readonly.yaml?rlkey=xsqnve5dvkg3l3nbuep06j0tj&dl=0
 +  * https://www.dropbox.com/scl/fi/enbctxxwp95s10ssw3l13/drop.yaml?rlkey=pfo8r09cv9zk2xrxohyies9ki&dl=0
 +  * https://www.dropbox.com/scl/fi/qptbh81o3gtl8bnii91er/guestbook-all-in-one.yaml?rlkey=5g3cr8a5llggdrme0le254pip&dl=0
 +  * https://www.dropbox.com/scl/fi/664obj0d9d0y95kj3czsd/guestbook-network-policy.yaml?rlkey=u3o8yrgpgratq30jgk12rtj90&dl=0
 +  * https://www.dropbox.com/scl/fi/f4f3mb8epcy7xr9cgmj1m/flask-resources.yaml?rlkey=l9gptrnet3mh4x5p2v09xvu06&dl=0
  
 =====LAB #1 - Role Based Acces Control et Certificats TLS===== =====LAB #1 - Role Based Acces Control et Certificats TLS=====
Ligne 800: Ligne 816:
 ====2.3 - Kubernetes Network Policies==== ====2.3 - Kubernetes Network Policies====
  
-Installez l'application exemple **Guestbook** de Kubernetes :+Créez le fichier **guestbook-all-in-one.yaml** :
  
 <code> <code>
-root@kubemaster:~# kubectl create -f https://raw.githubusercontent.com/fabric8io/kansible/master/vendor/k8s.io/kubernetes/examples/guestbook/all-in-one/guestbook-all-in-one.yaml +root@kubemaster:~# vi guestbook-all-in-one.yaml  
-service/redis-master created +root@kubemaster:~# cat  guestbook-all-in-one.yaml  
-replicationcontroller/redis-master created +apiVersion: v1 
-service/redis-slave created +kind: Service 
-replicationcontroller/redis-slave created +metadata: 
-service/frontend created +  name: redis-master 
-replicationcontroller/frontend created+  labels: 
 +    app: redis 
 +    tier: backend 
 +    role: master 
 +spec: 
 +  ports: 
 +    # the port that this service should serve on 
 +  - port: 6379 
 +    targetPort: 6379 
 +  selector: 
 +    app: redis 
 +    tier: backend 
 +    role: master 
 +--- 
 +apiVersion: v1 
 +kind: ReplicationController 
 +metadata: 
 +  name: redis-master 
 +  # these labels can be applied automatically  
 +  # from the labels in the pod template if not set 
 +  labels: 
 +    app: redis 
 +    role: master 
 +    tier: backend 
 +spec: 
 +  # this replicas value is default 
 +  # modify it according to your case 
 +  replicas: 1 
 +  # selector can be applied automatically  
 +  # from the labels in the pod template if not set 
 +  # selector: 
 +  #   app: guestbook 
 +  #   role: master 
 +  #   tier: backend 
 +  template: 
 +    metadata: 
 +      labels: 
 +        app: redis 
 +        role: master 
 +        tier: backend 
 +    spec: 
 +      containers: 
 +      name: master 
 +        image: gcr.io/google_containers/redis:e2e  # or just image: redis 
 +        resources: 
 +          requests: 
 +            cpu: 100m 
 +            memory: 100Mi 
 +        ports: 
 +        containerPort: 6379 
 +--- 
 +apiVersion: v1 
 +kind: Service 
 +metadata: 
 +  name: redis-slave 
 +  labels: 
 +    app: redis 
 +    tier: backend 
 +    role: slave 
 +spec: 
 +  ports: 
 +    # the port that this service should serve on 
 +  - port: 6379 
 +  selector: 
 +    app: redis 
 +    tier: backend 
 +    role: slave 
 +--- 
 +apiVersion: v1 
 +kind: ReplicationController 
 +metadata: 
 +  name: redis-slave 
 +  # these labels can be applied automatically 
 +  # from the labels in the pod template if not set 
 +  labels: 
 +    app: redis 
 +    role: slave 
 +    tier: backend 
 +spec: 
 +  # this replicas value is default 
 +  # modify it according to your case 
 +  replicas: 2 
 +  # selector can be applied automatically 
 +  # from the labels in the pod template if not set 
 +  # selector: 
 +  #   app: guestbook 
 +  #   role: slave 
 +  #   tier: backend 
 +  template: 
 +    metadata: 
 +      labels: 
 +        app: redis 
 +        role: slave 
 +        tier: backend 
 +    spec: 
 +      containers: 
 +      - name: slave 
 +        image: gcr.io/google_samples/gb-redisslave:v1 
 +        resources: 
 +          requests: 
 +            cpu: 100m 
 +            memory: 100Mi 
 +        env: 
 +        - name: GET_HOSTS_FROM 
 +          value: dns 
 +          # If your cluster config does not include a dns service, then to 
 +          # instead access an environment variable to find the master 
 +          # service's host, comment out the 'value: dns' line above, and 
 +          # uncomment the line below. 
 +          # value: env 
 +        ports: 
 +        - containerPort: 6379 
 +--- 
 +apiVersion: v1 
 +kind: Service 
 +metadata: 
 +  name: frontend 
 +  labels: 
 +    app: guestbook 
 +    tier: frontend 
 +spec: 
 +  # if your cluster supports it, uncomment the following to automatically create 
 +  # an external load-balanced IP for the frontend service. 
 +  # type: LoadBalancer 
 +  ports: 
 +    # the port that this service should serve on 
 +  - port: 80 
 +  selector: 
 +    app: guestbook 
 +    tier: frontend 
 +--- 
 +apiVersion: v1 
 +kind: ReplicationController 
 +metadata: 
 +  name: frontend 
 +  # these labels can be applied automatically 
 +  # from the labels in the pod template if not set 
 +  labels: 
 +    app: guestbook 
 +    tier: frontend 
 +spec: 
 +  # this replicas value is default 
 +  # modify it according to your case 
 +  replicas: 3 
 +  # selector can be applied automatically 
 +  # from the labels in the pod template if not set 
 +  # selector: 
 +  #   app: guestbook 
 +  #   tier: frontend 
 +  template: 
 +    metadata: 
 +      labels: 
 +        app: guestbook 
 +        tier: frontend 
 +    spec: 
 +      containers: 
 +      - name: php-redis 
 +        image: corelab/gb-frontend:v5 
 +        resources: 
 +          requests: 
 +            cpu: 100m 
 +            memory: 100Mi 
 +        env: 
 +        - name: GET_HOSTS_FROM 
 +          value: dns 
 +          # If your cluster config does not include a dns service, then to 
 +          # instead access environment variables to find service host 
 +          # info, comment out the 'value: dns' line above, and uncomment the 
 +          # line below. 
 +          # value: env 
 +        ports: 
 +        - containerPort: 80 
 +</code> 
 + 
 +Installez l'application **Guestbook** : 
 + 
 +<code> 
 +root@kubemaster:~# kubectl create -f guestbook-all-in-one.yaml
 </code> </code>
  
Ligne 909: Ligne 1102:
 root@kubemaster:~# kubectl exec -it frontend-dhd4w -- bash root@kubemaster:~# kubectl exec -it frontend-dhd4w -- bash
 root@frontend-dhd4w:/var/www/html#   root@frontend-dhd4w:/var/www/html#  
 +</code>
 +
 +Installez le paquet **iputils-ping** :
 +
 +<code>
 +root@frontend-dhd4w:/var/www/html# apt update
 +root@frontend-dhd4w:/var/www/html# apt install iputils-ping -y
 </code> </code>
  
Ligne 1011: Ligne 1211:
  
 <code> <code>
 +root@flask-resources:/# echo "deb http://archive.debian.org/debian/ jessie main contrib non-free" > /etc/apt/sources.list
 +root@flask-resources:/# echo "deb http://archive.debian.org/debian-security jessie/updates main contrib non-free" >> /etc/apt/sources.list
 +root@flask-resources:/# cat /etc/apt/sources.list
 +deb http://archive.debian.org/debian/ jessie main contrib non-free
 +deb http://archive.debian.org/debian-security jessie/updates main contrib non-free
 +root@flask-resources:/# apt update
 root@flask-resources:/# apt install stress -y root@flask-resources:/# apt install stress -y
 </code> </code>
Ligne 1033: Ligne 1239:
  
 ---- ----
-Copyright © 2022 Hugh Norris+Copyright © 2024 Hugh Norris
Menu