Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| elearning:workbooks:kubernetes:k8s07 [2022/09/04 11:44] – created admin | elearning:workbooks:kubernetes:k8s07 [2024/12/15 06:55] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ~~PDF: | ~~PDF: | ||
| - | Version - **2022.02** | + | Version - **2024.01** |
| Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
| - | ======DOF305 | + | |
| + | ======DOF308 | ||
| =====Contenu du Module===== | =====Contenu du Module===== | ||
| - | * **DOF305 | + | * **DOF308 |
| * 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:// | ||
| + | * https:// | ||
| + | |||
| + | ====Lab #2==== | ||
| + | |||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| =====LAB #1 - Role Based Acces Control et Certificats TLS===== | =====LAB #1 - Role Based Acces Control et Certificats TLS===== | ||
| Ligne 57: | Ligne 73: | ||
| * définir des permissions pour des ressources du cluster. | * définir des permissions pour des ressources du cluster. | ||
| - | * Un exemple d'un Role pour accorder les permissions dans le Namespace default est : | + | Un exemple d'un Role pour accorder les permissions dans le Namespace default est : |
| < | < | ||
| Ligne 66: | Ligne 82: | ||
| name: pod-reader | name: pod-reader | ||
| rules: | rules: | ||
| - | - apiGroups: ["" | + | - apiGroups: ["" |
| resources: [" | resources: [" | ||
| verbs: [" | verbs: [" | ||
| </ | </ | ||
| - | | + | <WRAP center round important> |
| + | **Important** : apiGroups: ["" | ||
| + | </ | ||
| + | |||
| + | Un example d'un ClusterRole pour accorder des permissions de lecture des secrets dans un Namespace spécifique ou dans tous les Namespaces est : | ||
| < | < | ||
| Ligne 279: | Ligne 299: | ||
| * un Role appelé **flask-backend-role** qui accorde les permissions **get**, **watch** et **list** sur les pods dans le Namespace **flask**, | * un Role appelé **flask-backend-role** qui accorde les permissions **get**, **watch** et **list** sur les pods dans le Namespace **flask**, | ||
| * un RoleBinding appelé **flask-backend-role-binding** qui accorde les permissions définies dans le Role **flask-backend-role** au Subject de type serviceAccount appelé **flask-backend**. | * un RoleBinding appelé **flask-backend-role-binding** qui accorde les permissions définies dans le Role **flask-backend-role** au Subject de type serviceAccount appelé **flask-backend**. | ||
| - | |||
| - | <WRAP center round important> | ||
| - | **Important** : apiGroups: ["" | ||
| - | </ | ||
| Appliquez le fichier : | Appliquez le fichier : | ||
| Ligne 800: | Ligne 816: | ||
| ====2.3 - Kubernetes Network Policies==== | ====2.3 - Kubernetes Network Policies==== | ||
| - | Installez l' | + | Créez le fichier |
| < | < | ||
| - | root@kubemaster: | + | root@kubemaster: |
| - | service/redis-master | + | root@kubemaster: |
| - | replicationcontroller/ | + | apiVersion: v1 |
| - | service/redis-slave created | + | kind: Service |
| - | replicationcontroller/ | + | metadata: |
| - | service/ | + | name: redis-master |
| - | replicationcontroller/ | + | labels: |
| + | app: redis | ||
| + | tier: backend | ||
| + | role: master | ||
| + | spec: | ||
| + | ports: | ||
| + | # the port that this service | ||
| + | - 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: | ||
| + | | ||
| + | | ||
| + | resources: | ||
| + | requests: | ||
| + | cpu: 100m | ||
| + | memory: 100Mi | ||
| + | ports: | ||
| + | | ||
| + | --- | ||
| + | apiVersion: v1 | ||
| + | kind: Service | ||
| + | metadata: | ||
| + | name: redis-slave | ||
| + | | ||
| + | app: redis | ||
| + | tier: backend | ||
| + | role: slave | ||
| + | spec: | ||
| + | ports: | ||
| + | # the port that this service | ||
| + | - 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/ | ||
| + | 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' | ||
| + | # uncomment the line below. | ||
| + | # value: env | ||
| + | ports: | ||
| + | - containerPort: | ||
| + | --- | ||
| + | apiVersion: v1 | ||
| + | kind: Service | ||
| + | metadata: | ||
| + | name: frontend | ||
| + | | ||
| + | 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 ' | ||
| + | # line below. | ||
| + | # value: env | ||
| + | ports: | ||
| + | - containerPort: | ||
| + | </ | ||
| + | |||
| + | Installez l' | ||
| + | |||
| + | < | ||
| + | root@kubemaster: | ||
| </ | </ | ||
| Ligne 909: | Ligne 1102: | ||
| root@kubemaster: | root@kubemaster: | ||
| root@frontend-dhd4w:/ | root@frontend-dhd4w:/ | ||
| + | </ | ||
| + | |||
| + | Installez le paquet **iputils-ping** : | ||
| + | |||
| + | < | ||
| + | root@frontend-dhd4w:/ | ||
| + | root@frontend-dhd4w:/ | ||
| </ | </ | ||
| Ligne 1011: | Ligne 1211: | ||
| < | < | ||
| + | root@flask-resources:/# | ||
| + | root@flask-resources:/# | ||
| + | root@flask-resources:/# | ||
| + | deb http:// | ||
| + | deb http:// | ||
| + | root@flask-resources:/# | ||
| root@flask-resources:/# | root@flask-resources:/# | ||
| </ | </ | ||
| Ligne 1033: | Ligne 1239: | ||
| ---- | ---- | ||
| - | Copyright © 2022 Hugh Norris | + | Copyright © 2024 Hugh Norris |