<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
	<id>https://fr-wiki.ikoula.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lhulotf79a8</id>
	<title>Ikoula Wiki - Contributions de l’utilisateur [fr]</title>
	<link rel="self" type="application/atom+xml" href="https://fr-wiki.ikoula.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lhulotf79a8"/>
	<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/fr/Sp%C3%A9cial:Contributions/Lhulotf79a8"/>
	<updated>2026-04-10T20:38:18Z</updated>
	<subtitle>Contributions de l’utilisateur</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_vos_instances_avec_Ansible&amp;diff=27342</id>
		<title>Deployer vos instances avec Ansible</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_vos_instances_avec_Ansible&amp;diff=27342"/>
		<updated>2019-11-28T10:14:15Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Déploiement d'une instance avec un playbook Ansible */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Description ==&lt;br /&gt;
&lt;br /&gt;
Nous allons voir comment déployer rapidement des instance(s) Cloud IKOULA One via l'outils Ansible&lt;br /&gt;
&lt;br /&gt;
Tout d'abord vous devrez installer Ansible (https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) puis le module &amp;quot;cs_instance&amp;quot; (peut être installé via &amp;quot;pip install cs&amp;quot; cf. https://docs.ansible.com/ansible/2.6/modules/cs_instance_module.html) permettant d'utiliser l'API de Cloud Ikoula One, si ce n'est pas déjà fait et disposer d'un compte Cloud IKOULA One.&lt;br /&gt;
&lt;br /&gt;
Ansible est disponible pour la plupart des distributions GNU/Linux, MacOS mais est aussi utilisable via Cygwin par exemple sous Microsoft Windows. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'une instance en une commande avec Ansible ==&lt;br /&gt;
&lt;br /&gt;
Vous devrez tout d'abord créer et renseigner/adapter le fichier de configuration &amp;quot;.cloudstack.ini&amp;quot; du module &amp;quot;cs_instance&amp;quot; de Ansible :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[CloudIkoulaOne]&lt;br /&gt;
endpoint = https://cloudstack.ikoula.com/client/api&lt;br /&gt;
key = &amp;lt;clé API de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
secret = &amp;lt;clé privée de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
timeout = 30&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ensuite il suffit de lancer cette commande en adaptant les valeurs des paramètres (nom de votre instance, nom du réseau, etc.) et les paramètres en eux-mêmes (si vous avez/voulez utliser ou non une paire de clé SSH par exemple) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ansible -i &amp;quot;localhost,&amp;quot; -c local all -m cs_instance -a &amp;quot;name=&amp;lt;Nom de la VM&amp;gt; display_name=&amp;lt;Nom de la VM&amp;gt;  state=present template=&amp;lt; Nom entre simples quotes ou ID du template voulu&amp;gt; api_region=CloudIkoulaOne zone=&amp;lt;Nom de la zone voulu&amp;gt; service_offering=&amp;lt; Nom de l’offre de calcul voulu &amp;gt; networks=&amp;lt;Nom du réseau existant voulu&amp;gt; ssh_key=&amp;lt;Nom de la paire de clés ssh CIO existante&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
où &amp;quot;&amp;lt;Nom de l’offre de calcul voulu &amp;gt;&amp;quot; correspond au choix à  :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;t1.pico&amp;quot; (1/2 Core CPU with 512MB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;t1.micro&amp;quot; (1 Core CPU with 1GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.small&amp;quot; (1 Core CPU with 1.7GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.medium&amp;quot; (2 Cores CPU with 3.8GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.large&amp;quot; (4 Cores CPU with 7.6GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.extralarge&amp;quot; (8 Cores CPU with 15.3GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voici un exemple ainsi que le retour de son exécution :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ansible -i &amp;quot;localhost,&amp;quot; -c local all -m cs_instance -a &amp;quot;name=Debian9advz1 display_name=Debian9adv1 state=present template='Debian 9 - Minimal - 64bits' api_region=CloudIkoulaOne zone=EU-FR-IKDC1-Z1-ADV service_offering=t1.micro networks=My-Network-Z1 ssh_key=MY_SSHKEY&amp;quot;&lt;br /&gt;
localhost | SUCCESS =&amp;gt; {&lt;br /&gt;
    &amp;quot;account&amp;quot;: &amp;quot;ikoula&amp;quot;,&lt;br /&gt;
    &amp;quot;affinity_groups&amp;quot;: [],&lt;br /&gt;
    &amp;quot;changed&amp;quot;: true,&lt;br /&gt;
    &amp;quot;created&amp;quot;: &amp;quot;2018-09-12T10:05:00+0200&amp;quot;,&lt;br /&gt;
    &amp;quot;default_ip&amp;quot;: &amp;quot;10.1.1.176&amp;quot;,&lt;br /&gt;
    &amp;quot;display_name&amp;quot;: &amp;quot;Debian9adv1&amp;quot;,&lt;br /&gt;
    &amp;quot;domain&amp;quot;: &amp;quot;ROOT&amp;quot;,&lt;br /&gt;
    &amp;quot;hypervisor&amp;quot;: &amp;quot;XenServer&amp;quot;,&lt;br /&gt;
    &amp;quot;id&amp;quot;: &amp;quot;3c60acc9-1480-48bc-ab78-934f0e607d6c&amp;quot;,&lt;br /&gt;
    &amp;quot;instance_name&amp;quot;: &amp;quot;i-1079-67026-VM&amp;quot;,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Debian9advz1&amp;quot;,&lt;br /&gt;
    &amp;quot;password&amp;quot;: &amp;quot;KYqrT3h28qOs&amp;quot;,&lt;br /&gt;
    &amp;quot;password_enabled&amp;quot;: true,&lt;br /&gt;
    &amp;quot;security_groups&amp;quot;: [],&lt;br /&gt;
    &amp;quot;service_offering&amp;quot;: &amp;quot;t1.micro&amp;quot;,&lt;br /&gt;
    &amp;quot;ssh_key&amp;quot;: &amp;quot;MY_SSHKEY&amp;quot;,&lt;br /&gt;
    &amp;quot;state&amp;quot;: &amp;quot;Running&amp;quot;,&lt;br /&gt;
    &amp;quot;tags&amp;quot;: [],&lt;br /&gt;
    &amp;quot;template&amp;quot;: &amp;quot;Debian 9 - Minimal - 64bits&amp;quot;,&lt;br /&gt;
    &amp;quot;user_data&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
    &amp;quot;zone&amp;quot;: &amp;quot;EU-FR-IKDC1-Z1-ADV&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Dans cet exemple, nous déployons une instance Debian 9 en zone avancée (EU-FR-IKDC1-Z1-ADV), utilisant l'offre de calcul &amp;quot;t1.micro&amp;quot; dans notre réseau nommé &amp;quot;My-Network-Z1&amp;quot; avec notre paire de clés SSH nommée &amp;quot;MY_SSHKEY&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Pour voir l'ensemble des paramètres utilisables et d'autres exemples, vous pouvez utiliser le ansible-doc du module &amp;quot;cs_instance&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ansible-doc cs_instance&lt;br /&gt;
&amp;gt; CS_INSTANCE    (/usr/lib/python2.7/site-packages/ansible/modules/cloud/cloudstack/cs_instance.py)&lt;br /&gt;
&lt;br /&gt;
  Deploy, start, update, scale, restart, restore, stop and destroy instances.&lt;br /&gt;
&lt;br /&gt;
Options (= is mandatory):&lt;br /&gt;
&lt;br /&gt;
- account&lt;br /&gt;
        Account the instance is related to.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- affinity_groups&lt;br /&gt;
        Affinity groups names to be applied to the new instance.&lt;br /&gt;
        [Default: []]&lt;br /&gt;
- api_http_method&lt;br /&gt;
        HTTP method used.&lt;br /&gt;
        (Choices: get, post)[Default: get]&lt;br /&gt;
- api_key&lt;br /&gt;
        API key of the CloudStack API.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- api_region&lt;br /&gt;
        Name of the ini section in the `cloustack.ini' file.&lt;br /&gt;
        [Default: cloudstack]&lt;br /&gt;
- api_secret&lt;br /&gt;
        Secret key of the CloudStack API.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- api_timeout&lt;br /&gt;
        HTTP timeout.&lt;br /&gt;
        [Default: 10]&lt;br /&gt;
- api_url&lt;br /&gt;
        URL of the CloudStack API e.g. https://cloud.example.com/client/api.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- cpu&lt;br /&gt;
        The number of CPUs to allocate to the instance, used with custom service offerings&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- cpu_speed&lt;br /&gt;
        The clock speed/shares allocated to the instance, used with custom service offerings&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- disk_offering&lt;br /&gt;
        Name of the disk offering to be used.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- disk_size&lt;br /&gt;
        Disk size in GByte required if deploying instance from ISO.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : la sortie de la commande est volontairement tronquée du fait de sa longueur.&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'une instance avec un playbook Ansible ==&lt;br /&gt;
&lt;br /&gt;
De la même façon que ci-dessus vous devez tout d'abord créer et renseigner/adapter le fichier de configuration &amp;quot;.cloudstack.ini&amp;quot; du module &amp;quot;cs_instance&amp;quot; de Ansible :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[CloudIkoulaOne]&lt;br /&gt;
endpoint = https://cloudstack.ikoula.com/client/api&lt;br /&gt;
key = &amp;lt;clé API de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
secret = &amp;lt;clé privée de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
timeout = 30&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ensuite il suffit de créer un fichier de playbook (extension yml / format YAML), comme ci-dessous, en adaptant les valeurs des paramètres (nom de votre instance, nom du réseau, etc.) et les paramètres en eux-mêmes (si vous avez/voulez utliser ou non une paire de clé SSH par exemple) :&lt;br /&gt;
&lt;br /&gt;
Exemple de playbook de déploiement d'une instance en zone avancée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat deploy_instance_adv.yml&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
- hosts: all&lt;br /&gt;
  connection: local&lt;br /&gt;
  user: root&lt;br /&gt;
&lt;br /&gt;
  tasks:&lt;br /&gt;
&lt;br /&gt;
  - name: 'Create Debian instance in Cloud IKOULA One with Ansible Playbook'&lt;br /&gt;
    cs_instance:&lt;br /&gt;
      name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
      state: present&lt;br /&gt;
      display_name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
      template: &amp;quot;&amp;lt;Nom entre simples quotes ou ID du template CIO voulu&amp;gt;&amp;quot;&lt;br /&gt;
      api_region: &amp;quot;CloudIkoulaOne&amp;quot;&lt;br /&gt;
      zone: &amp;quot;&amp;lt;Nom de la zone voulu&amp;gt;&amp;quot;&lt;br /&gt;
      service_offering: &amp;quot;&amp;lt;Nom de l’offre de calcul voulu &amp;gt;&amp;quot;&lt;br /&gt;
      networks: &amp;quot;&amp;lt;Nom du réseau existant voulu&amp;gt;&amp;quot;&lt;br /&gt;
      ssh_key: &amp;quot;&amp;lt;Nom de la paire de clés ssh CIO existante&amp;gt;&amp;quot;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exemple de playbook de déploiement d'une instance en zone basic (où on remplace simplement le paramètre réseau par celui des security groups et on ajoute le retour post-déploiement de l'adresse ip publique attribuée à la vm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat deploy_instance_basic.yml&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
- hosts: all&lt;br /&gt;
  connection: local&lt;br /&gt;
  user: root&lt;br /&gt;
&lt;br /&gt;
  tasks:&lt;br /&gt;
&lt;br /&gt;
  - name: 'Create Debian instance in Cloud IKOULA One with Ansible Playbook'&lt;br /&gt;
    cs_instance:&lt;br /&gt;
      name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
      state: present&lt;br /&gt;
      display_name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
      template: &amp;quot;&amp;lt;Nom entre simples quotes ou ID du template CIO voulu&amp;gt;&amp;quot;&lt;br /&gt;
      api_region: &amp;quot;CloudIkoulaOne&amp;quot;&lt;br /&gt;
      zone: &amp;quot;&amp;lt;Nom de la zone voulu&amp;gt;&amp;quot;&lt;br /&gt;
      service_offering: &amp;quot;&amp;lt;Nom de l’offre de calcul voulu &amp;gt;&amp;quot;&lt;br /&gt;
      security_groups: &amp;quot;&amp;lt;Nom du groupe de sécurité existant voulu&amp;gt;&amp;quot;&lt;br /&gt;
      ssh_key: &amp;quot;&amp;lt;Nom de la paire de clés ssh CIO existante&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  - name: &amp;quot;VM ip address:&amp;quot;&lt;br /&gt;
    debug:&lt;br /&gt;
      var: vminfo.default_ip&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Une fois les paramètres et leurs valeurs adapté(e)s, voici un exemple d'exécution du playbook (adaptez le nom de votre fichier playbook au besoin):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ansible-playbook -i &amp;quot;localhost,&amp;quot; -c local deploy_instance_adv.yml&lt;br /&gt;
&lt;br /&gt;
PLAY [all] ********************************************************************************************************************************************************************************************************************************************************************&lt;br /&gt;
&lt;br /&gt;
TASK [Gathering Facts] ********************************************************************************************************************************************************************************************************************************************************&lt;br /&gt;
ok: [localhost]&lt;br /&gt;
&lt;br /&gt;
TASK [Create Debian instance in Cloud IKOULA One with Ansible Playbook] ********************************************************************************************************************************************************************************************************************************&lt;br /&gt;
changed: [localhost]&lt;br /&gt;
&lt;br /&gt;
PLAY RECAP ********************************************************************************************************************************************************************************************************************************************************************&lt;br /&gt;
localhost                  : ok=2    changed=1    unreachable=0    failed=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Catégorie :Cloudstack]]&lt;br /&gt;
[[Catégorie :Cloud public]]&lt;br /&gt;
[[Catégorie:API]]&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_vos_instances_avec_Ansible&amp;diff=27341</id>
		<title>Deployer vos instances avec Ansible</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_vos_instances_avec_Ansible&amp;diff=27341"/>
		<updated>2019-11-28T10:08:52Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Déploiement d'une instance avec un playbook Ansible */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Description ==&lt;br /&gt;
&lt;br /&gt;
Nous allons voir comment déployer rapidement des instance(s) Cloud IKOULA One via l'outils Ansible&lt;br /&gt;
&lt;br /&gt;
Tout d'abord vous devrez installer Ansible (https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) puis le module &amp;quot;cs_instance&amp;quot; (peut être installé via &amp;quot;pip install cs&amp;quot; cf. https://docs.ansible.com/ansible/2.6/modules/cs_instance_module.html) permettant d'utiliser l'API de Cloud Ikoula One, si ce n'est pas déjà fait et disposer d'un compte Cloud IKOULA One.&lt;br /&gt;
&lt;br /&gt;
Ansible est disponible pour la plupart des distributions GNU/Linux, MacOS mais est aussi utilisable via Cygwin par exemple sous Microsoft Windows. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'une instance en une commande avec Ansible ==&lt;br /&gt;
&lt;br /&gt;
Vous devrez tout d'abord créer et renseigner/adapter le fichier de configuration &amp;quot;.cloudstack.ini&amp;quot; du module &amp;quot;cs_instance&amp;quot; de Ansible :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[CloudIkoulaOne]&lt;br /&gt;
endpoint = https://cloudstack.ikoula.com/client/api&lt;br /&gt;
key = &amp;lt;clé API de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
secret = &amp;lt;clé privée de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
timeout = 30&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ensuite il suffit de lancer cette commande en adaptant les valeurs des paramètres (nom de votre instance, nom du réseau, etc.) et les paramètres en eux-mêmes (si vous avez/voulez utliser ou non une paire de clé SSH par exemple) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ansible -i &amp;quot;localhost,&amp;quot; -c local all -m cs_instance -a &amp;quot;name=&amp;lt;Nom de la VM&amp;gt; display_name=&amp;lt;Nom de la VM&amp;gt;  state=present template=&amp;lt; Nom entre simples quotes ou ID du template voulu&amp;gt; api_region=CloudIkoulaOne zone=&amp;lt;Nom de la zone voulu&amp;gt; service_offering=&amp;lt; Nom de l’offre de calcul voulu &amp;gt; networks=&amp;lt;Nom du réseau existant voulu&amp;gt; ssh_key=&amp;lt;Nom de la paire de clés ssh CIO existante&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
où &amp;quot;&amp;lt;Nom de l’offre de calcul voulu &amp;gt;&amp;quot; correspond au choix à  :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;t1.pico&amp;quot; (1/2 Core CPU with 512MB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;t1.micro&amp;quot; (1 Core CPU with 1GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.small&amp;quot; (1 Core CPU with 1.7GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.medium&amp;quot; (2 Cores CPU with 3.8GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.large&amp;quot; (4 Cores CPU with 7.6GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.extralarge&amp;quot; (8 Cores CPU with 15.3GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voici un exemple ainsi que le retour de son exécution :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ansible -i &amp;quot;localhost,&amp;quot; -c local all -m cs_instance -a &amp;quot;name=Debian9advz1 display_name=Debian9adv1 state=present template='Debian 9 - Minimal - 64bits' api_region=CloudIkoulaOne zone=EU-FR-IKDC1-Z1-ADV service_offering=t1.micro networks=My-Network-Z1 ssh_key=MY_SSHKEY&amp;quot;&lt;br /&gt;
localhost | SUCCESS =&amp;gt; {&lt;br /&gt;
    &amp;quot;account&amp;quot;: &amp;quot;ikoula&amp;quot;,&lt;br /&gt;
    &amp;quot;affinity_groups&amp;quot;: [],&lt;br /&gt;
    &amp;quot;changed&amp;quot;: true,&lt;br /&gt;
    &amp;quot;created&amp;quot;: &amp;quot;2018-09-12T10:05:00+0200&amp;quot;,&lt;br /&gt;
    &amp;quot;default_ip&amp;quot;: &amp;quot;10.1.1.176&amp;quot;,&lt;br /&gt;
    &amp;quot;display_name&amp;quot;: &amp;quot;Debian9adv1&amp;quot;,&lt;br /&gt;
    &amp;quot;domain&amp;quot;: &amp;quot;ROOT&amp;quot;,&lt;br /&gt;
    &amp;quot;hypervisor&amp;quot;: &amp;quot;XenServer&amp;quot;,&lt;br /&gt;
    &amp;quot;id&amp;quot;: &amp;quot;3c60acc9-1480-48bc-ab78-934f0e607d6c&amp;quot;,&lt;br /&gt;
    &amp;quot;instance_name&amp;quot;: &amp;quot;i-1079-67026-VM&amp;quot;,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Debian9advz1&amp;quot;,&lt;br /&gt;
    &amp;quot;password&amp;quot;: &amp;quot;KYqrT3h28qOs&amp;quot;,&lt;br /&gt;
    &amp;quot;password_enabled&amp;quot;: true,&lt;br /&gt;
    &amp;quot;security_groups&amp;quot;: [],&lt;br /&gt;
    &amp;quot;service_offering&amp;quot;: &amp;quot;t1.micro&amp;quot;,&lt;br /&gt;
    &amp;quot;ssh_key&amp;quot;: &amp;quot;MY_SSHKEY&amp;quot;,&lt;br /&gt;
    &amp;quot;state&amp;quot;: &amp;quot;Running&amp;quot;,&lt;br /&gt;
    &amp;quot;tags&amp;quot;: [],&lt;br /&gt;
    &amp;quot;template&amp;quot;: &amp;quot;Debian 9 - Minimal - 64bits&amp;quot;,&lt;br /&gt;
    &amp;quot;user_data&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
    &amp;quot;zone&amp;quot;: &amp;quot;EU-FR-IKDC1-Z1-ADV&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Dans cet exemple, nous déployons une instance Debian 9 en zone avancée (EU-FR-IKDC1-Z1-ADV), utilisant l'offre de calcul &amp;quot;t1.micro&amp;quot; dans notre réseau nommé &amp;quot;My-Network-Z1&amp;quot; avec notre paire de clés SSH nommée &amp;quot;MY_SSHKEY&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Pour voir l'ensemble des paramètres utilisables et d'autres exemples, vous pouvez utiliser le ansible-doc du module &amp;quot;cs_instance&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ansible-doc cs_instance&lt;br /&gt;
&amp;gt; CS_INSTANCE    (/usr/lib/python2.7/site-packages/ansible/modules/cloud/cloudstack/cs_instance.py)&lt;br /&gt;
&lt;br /&gt;
  Deploy, start, update, scale, restart, restore, stop and destroy instances.&lt;br /&gt;
&lt;br /&gt;
Options (= is mandatory):&lt;br /&gt;
&lt;br /&gt;
- account&lt;br /&gt;
        Account the instance is related to.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- affinity_groups&lt;br /&gt;
        Affinity groups names to be applied to the new instance.&lt;br /&gt;
        [Default: []]&lt;br /&gt;
- api_http_method&lt;br /&gt;
        HTTP method used.&lt;br /&gt;
        (Choices: get, post)[Default: get]&lt;br /&gt;
- api_key&lt;br /&gt;
        API key of the CloudStack API.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- api_region&lt;br /&gt;
        Name of the ini section in the `cloustack.ini' file.&lt;br /&gt;
        [Default: cloudstack]&lt;br /&gt;
- api_secret&lt;br /&gt;
        Secret key of the CloudStack API.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- api_timeout&lt;br /&gt;
        HTTP timeout.&lt;br /&gt;
        [Default: 10]&lt;br /&gt;
- api_url&lt;br /&gt;
        URL of the CloudStack API e.g. https://cloud.example.com/client/api.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- cpu&lt;br /&gt;
        The number of CPUs to allocate to the instance, used with custom service offerings&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- cpu_speed&lt;br /&gt;
        The clock speed/shares allocated to the instance, used with custom service offerings&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- disk_offering&lt;br /&gt;
        Name of the disk offering to be used.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- disk_size&lt;br /&gt;
        Disk size in GByte required if deploying instance from ISO.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : la sortie de la commande est volontairement tronquée du fait de sa longueur.&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'une instance avec un playbook Ansible ==&lt;br /&gt;
&lt;br /&gt;
De la même façon que ci-dessus vous devez tout d'abord créer et renseigner/adapter le fichier de configuration &amp;quot;.cloudstack.ini&amp;quot; du module &amp;quot;cs_instance&amp;quot; de Ansible :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[CloudIkoulaOne]&lt;br /&gt;
endpoint = https://cloudstack.ikoula.com/client/api&lt;br /&gt;
key = &amp;lt;clé API de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
secret = &amp;lt;clé privée de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
timeout = 30&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ensuite il suffit de créer un fichier de playbook (extension yml / format YAML), comme ci-dessous, en adaptant les valeurs des paramètres (nom de votre instance, nom du réseau, etc.) et les paramètres en eux-mêmes (si vous avez/voulez utliser ou non une paire de clé SSH par exemple) :&lt;br /&gt;
&lt;br /&gt;
Exemple de playbook de déploiement d'une instance en zone avancée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat deploy_instance_adv.yml&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
- hosts: all&lt;br /&gt;
  connection: local&lt;br /&gt;
  user: root&lt;br /&gt;
&lt;br /&gt;
  tasks:&lt;br /&gt;
&lt;br /&gt;
 - name: 'Create Debian instance in Cloud IKOULA One with Ansible Playbook'&lt;br /&gt;
   cs_instance:&lt;br /&gt;
     name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
     state: present&lt;br /&gt;
     display_name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
     template: &amp;quot;&amp;lt;Nom entre simples quotes ou ID du template CIO voulu&amp;gt;&amp;quot;&lt;br /&gt;
     api_region: &amp;quot;CloudIkoulaOne&amp;quot;&lt;br /&gt;
     zone: &amp;quot;&amp;lt;Nom de la zone voulu&amp;gt;&amp;quot;&lt;br /&gt;
     service_offering: &amp;quot;&amp;lt;Nom de l’offre de calcul voulu &amp;gt;&amp;quot;&lt;br /&gt;
     networks: &amp;quot;&amp;lt;Nom du réseau existant voulu&amp;gt;&amp;quot;&lt;br /&gt;
     ssh_key: &amp;quot;&amp;lt;Nom de la paire de clés ssh CIO existante&amp;gt;&amp;quot;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exemple de playbook de déploiement d'une instance en zone basic (où on remplace simplement le paramètre réseau par celui des security groups et on ajoute le retour post-déploiement de l'adresse ip publique attribuée à la vm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat deploy_instance_basic.yml&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
- hosts: all&lt;br /&gt;
  connection: local&lt;br /&gt;
  user: root&lt;br /&gt;
&lt;br /&gt;
  tasks:&lt;br /&gt;
&lt;br /&gt;
 - name: 'Create Debian instance in Cloud IKOULA One with Ansible Playbook'&lt;br /&gt;
   cs_instance:&lt;br /&gt;
     name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
     state: present&lt;br /&gt;
     display_name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
     template: &amp;quot;&amp;lt;Nom entre simples quotes ou ID du template CIO voulu&amp;gt;&amp;quot;&lt;br /&gt;
     api_region: &amp;quot;CloudIkoulaOne&amp;quot;&lt;br /&gt;
     zone: &amp;quot;&amp;lt;Nom de la zone voulu&amp;gt;&amp;quot;&lt;br /&gt;
     service_offering: &amp;quot;&amp;lt;Nom de l’offre de calcul voulu &amp;gt;&amp;quot;&lt;br /&gt;
     security_groups: &amp;quot;&amp;lt;Nom du groupe de sécurité existant voulu&amp;gt;&amp;quot;&lt;br /&gt;
     ssh_key: &amp;quot;&amp;lt;Nom de la paire de clés ssh CIO existante&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 - name: &amp;quot;VM ip address:&amp;quot;&lt;br /&gt;
   debug:&lt;br /&gt;
     var: vminfo.default_ip&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Une fois les paramètres et leurs valeurs adapté(e)s, voici un exemple d'exécution du playbook (adaptez le nom de votre fichier playbook au besoin):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ansible-playbook -i &amp;quot;localhost,&amp;quot; -c local deploy_instance_adv.yml&lt;br /&gt;
&lt;br /&gt;
PLAY [all] ********************************************************************************************************************************************************************************************************************************************************************&lt;br /&gt;
&lt;br /&gt;
TASK [Gathering Facts] ********************************************************************************************************************************************************************************************************************************************************&lt;br /&gt;
ok: [localhost]&lt;br /&gt;
&lt;br /&gt;
TASK [Create Debian instance in Cloud IKOULA One with Ansible Playbook] ********************************************************************************************************************************************************************************************************************************&lt;br /&gt;
changed: [localhost]&lt;br /&gt;
&lt;br /&gt;
PLAY RECAP ********************************************************************************************************************************************************************************************************************************************************************&lt;br /&gt;
localhost                  : ok=2    changed=1    unreachable=0    failed=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Catégorie :Cloudstack]]&lt;br /&gt;
[[Catégorie :Cloud public]]&lt;br /&gt;
[[Catégorie:API]]&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_vos_instances_avec_Ansible&amp;diff=27340</id>
		<title>Deployer vos instances avec Ansible</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_vos_instances_avec_Ansible&amp;diff=27340"/>
		<updated>2019-11-28T10:08:07Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Déploiement d'une instance avec un playbook Ansible */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Description ==&lt;br /&gt;
&lt;br /&gt;
Nous allons voir comment déployer rapidement des instance(s) Cloud IKOULA One via l'outils Ansible&lt;br /&gt;
&lt;br /&gt;
Tout d'abord vous devrez installer Ansible (https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) puis le module &amp;quot;cs_instance&amp;quot; (peut être installé via &amp;quot;pip install cs&amp;quot; cf. https://docs.ansible.com/ansible/2.6/modules/cs_instance_module.html) permettant d'utiliser l'API de Cloud Ikoula One, si ce n'est pas déjà fait et disposer d'un compte Cloud IKOULA One.&lt;br /&gt;
&lt;br /&gt;
Ansible est disponible pour la plupart des distributions GNU/Linux, MacOS mais est aussi utilisable via Cygwin par exemple sous Microsoft Windows. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'une instance en une commande avec Ansible ==&lt;br /&gt;
&lt;br /&gt;
Vous devrez tout d'abord créer et renseigner/adapter le fichier de configuration &amp;quot;.cloudstack.ini&amp;quot; du module &amp;quot;cs_instance&amp;quot; de Ansible :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[CloudIkoulaOne]&lt;br /&gt;
endpoint = https://cloudstack.ikoula.com/client/api&lt;br /&gt;
key = &amp;lt;clé API de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
secret = &amp;lt;clé privée de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
timeout = 30&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ensuite il suffit de lancer cette commande en adaptant les valeurs des paramètres (nom de votre instance, nom du réseau, etc.) et les paramètres en eux-mêmes (si vous avez/voulez utliser ou non une paire de clé SSH par exemple) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ansible -i &amp;quot;localhost,&amp;quot; -c local all -m cs_instance -a &amp;quot;name=&amp;lt;Nom de la VM&amp;gt; display_name=&amp;lt;Nom de la VM&amp;gt;  state=present template=&amp;lt; Nom entre simples quotes ou ID du template voulu&amp;gt; api_region=CloudIkoulaOne zone=&amp;lt;Nom de la zone voulu&amp;gt; service_offering=&amp;lt; Nom de l’offre de calcul voulu &amp;gt; networks=&amp;lt;Nom du réseau existant voulu&amp;gt; ssh_key=&amp;lt;Nom de la paire de clés ssh CIO existante&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
où &amp;quot;&amp;lt;Nom de l’offre de calcul voulu &amp;gt;&amp;quot; correspond au choix à  :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;t1.pico&amp;quot; (1/2 Core CPU with 512MB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;t1.micro&amp;quot; (1 Core CPU with 1GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.small&amp;quot; (1 Core CPU with 1.7GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.medium&amp;quot; (2 Cores CPU with 3.8GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.large&amp;quot; (4 Cores CPU with 7.6GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.extralarge&amp;quot; (8 Cores CPU with 15.3GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voici un exemple ainsi que le retour de son exécution :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ansible -i &amp;quot;localhost,&amp;quot; -c local all -m cs_instance -a &amp;quot;name=Debian9advz1 display_name=Debian9adv1 state=present template='Debian 9 - Minimal - 64bits' api_region=CloudIkoulaOne zone=EU-FR-IKDC1-Z1-ADV service_offering=t1.micro networks=My-Network-Z1 ssh_key=MY_SSHKEY&amp;quot;&lt;br /&gt;
localhost | SUCCESS =&amp;gt; {&lt;br /&gt;
    &amp;quot;account&amp;quot;: &amp;quot;ikoula&amp;quot;,&lt;br /&gt;
    &amp;quot;affinity_groups&amp;quot;: [],&lt;br /&gt;
    &amp;quot;changed&amp;quot;: true,&lt;br /&gt;
    &amp;quot;created&amp;quot;: &amp;quot;2018-09-12T10:05:00+0200&amp;quot;,&lt;br /&gt;
    &amp;quot;default_ip&amp;quot;: &amp;quot;10.1.1.176&amp;quot;,&lt;br /&gt;
    &amp;quot;display_name&amp;quot;: &amp;quot;Debian9adv1&amp;quot;,&lt;br /&gt;
    &amp;quot;domain&amp;quot;: &amp;quot;ROOT&amp;quot;,&lt;br /&gt;
    &amp;quot;hypervisor&amp;quot;: &amp;quot;XenServer&amp;quot;,&lt;br /&gt;
    &amp;quot;id&amp;quot;: &amp;quot;3c60acc9-1480-48bc-ab78-934f0e607d6c&amp;quot;,&lt;br /&gt;
    &amp;quot;instance_name&amp;quot;: &amp;quot;i-1079-67026-VM&amp;quot;,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Debian9advz1&amp;quot;,&lt;br /&gt;
    &amp;quot;password&amp;quot;: &amp;quot;KYqrT3h28qOs&amp;quot;,&lt;br /&gt;
    &amp;quot;password_enabled&amp;quot;: true,&lt;br /&gt;
    &amp;quot;security_groups&amp;quot;: [],&lt;br /&gt;
    &amp;quot;service_offering&amp;quot;: &amp;quot;t1.micro&amp;quot;,&lt;br /&gt;
    &amp;quot;ssh_key&amp;quot;: &amp;quot;MY_SSHKEY&amp;quot;,&lt;br /&gt;
    &amp;quot;state&amp;quot;: &amp;quot;Running&amp;quot;,&lt;br /&gt;
    &amp;quot;tags&amp;quot;: [],&lt;br /&gt;
    &amp;quot;template&amp;quot;: &amp;quot;Debian 9 - Minimal - 64bits&amp;quot;,&lt;br /&gt;
    &amp;quot;user_data&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
    &amp;quot;zone&amp;quot;: &amp;quot;EU-FR-IKDC1-Z1-ADV&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Dans cet exemple, nous déployons une instance Debian 9 en zone avancée (EU-FR-IKDC1-Z1-ADV), utilisant l'offre de calcul &amp;quot;t1.micro&amp;quot; dans notre réseau nommé &amp;quot;My-Network-Z1&amp;quot; avec notre paire de clés SSH nommée &amp;quot;MY_SSHKEY&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Pour voir l'ensemble des paramètres utilisables et d'autres exemples, vous pouvez utiliser le ansible-doc du module &amp;quot;cs_instance&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ansible-doc cs_instance&lt;br /&gt;
&amp;gt; CS_INSTANCE    (/usr/lib/python2.7/site-packages/ansible/modules/cloud/cloudstack/cs_instance.py)&lt;br /&gt;
&lt;br /&gt;
  Deploy, start, update, scale, restart, restore, stop and destroy instances.&lt;br /&gt;
&lt;br /&gt;
Options (= is mandatory):&lt;br /&gt;
&lt;br /&gt;
- account&lt;br /&gt;
        Account the instance is related to.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- affinity_groups&lt;br /&gt;
        Affinity groups names to be applied to the new instance.&lt;br /&gt;
        [Default: []]&lt;br /&gt;
- api_http_method&lt;br /&gt;
        HTTP method used.&lt;br /&gt;
        (Choices: get, post)[Default: get]&lt;br /&gt;
- api_key&lt;br /&gt;
        API key of the CloudStack API.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- api_region&lt;br /&gt;
        Name of the ini section in the `cloustack.ini' file.&lt;br /&gt;
        [Default: cloudstack]&lt;br /&gt;
- api_secret&lt;br /&gt;
        Secret key of the CloudStack API.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- api_timeout&lt;br /&gt;
        HTTP timeout.&lt;br /&gt;
        [Default: 10]&lt;br /&gt;
- api_url&lt;br /&gt;
        URL of the CloudStack API e.g. https://cloud.example.com/client/api.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- cpu&lt;br /&gt;
        The number of CPUs to allocate to the instance, used with custom service offerings&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- cpu_speed&lt;br /&gt;
        The clock speed/shares allocated to the instance, used with custom service offerings&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- disk_offering&lt;br /&gt;
        Name of the disk offering to be used.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- disk_size&lt;br /&gt;
        Disk size in GByte required if deploying instance from ISO.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : la sortie de la commande est volontairement tronquée du fait de sa longueur.&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'une instance avec un playbook Ansible ==&lt;br /&gt;
&lt;br /&gt;
De la même façon que ci-dessus vous devez tout d'abord créer et renseigner/adapter le fichier de configuration &amp;quot;.cloudstack.ini&amp;quot; du module &amp;quot;cs_instance&amp;quot; de Ansible :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[CloudIkoulaOne]&lt;br /&gt;
endpoint = https://cloudstack.ikoula.com/client/api&lt;br /&gt;
key = &amp;lt;clé API de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
secret = &amp;lt;clé privée de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
timeout = 30&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ensuite il suffit de créer un fichier de playbook (extension yml / format YAML), comme ci-dessous, en adaptant les valeurs des paramètres (nom de votre instance, nom du réseau, etc.) et les paramètres en eux-mêmes (si vous avez/voulez utliser ou non une paire de clé SSH par exemple) :&lt;br /&gt;
&lt;br /&gt;
Exemple de playbook de déploiement d'une instance en zone avancée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat deploy_instance_adv.yml&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
- hosts: all&lt;br /&gt;
  connection: local&lt;br /&gt;
  user: root&lt;br /&gt;
&lt;br /&gt;
  tasks:&lt;br /&gt;
&lt;br /&gt;
 - name: 'Create Debian instance in Cloud IKOULA One with Ansible Playbook'&lt;br /&gt;
   cs_instance:&lt;br /&gt;
     name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
     state: present&lt;br /&gt;
     display_name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
     template: &amp;quot;&amp;lt;Nom entre simples quotes ou ID du template CIO voulu&amp;gt;&amp;quot;&lt;br /&gt;
     api_region: &amp;quot;CloudIkoulaOne&amp;quot;&lt;br /&gt;
     zone: &amp;quot;&amp;lt;Nom de la zone voulu&amp;gt;&amp;quot;&lt;br /&gt;
     service_offering: &amp;quot;&amp;lt;Nom de l’offre de calcul voulu &amp;gt;&amp;quot;&lt;br /&gt;
     networks: &amp;quot;&amp;lt;Nom du réseau existant voulu&amp;gt;&amp;quot;&lt;br /&gt;
     ssh_key: &amp;quot;&amp;lt;Nom de la paire de clés ssh CIO existante&amp;gt;&amp;quot;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exemple de playbook de déploiement d'une instance en zone basic (où on remplace simplement le paramètre réseau par celui des security groups et on ajoute le retour post-déploiement de l'adresse ip publique attribuée à la vm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat deploy_instance_basic.yml&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
- hosts: all&lt;br /&gt;
  connection: local&lt;br /&gt;
  user: root&lt;br /&gt;
&lt;br /&gt;
  tasks:&lt;br /&gt;
&lt;br /&gt;
 - name: 'Create Debian instance in Cloud IKOULA One with Ansible Playbook'&lt;br /&gt;
   cs_instance:&lt;br /&gt;
     name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
     state: present&lt;br /&gt;
     display_name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
     template: &amp;quot;&amp;lt;Nom entre simples quotes ou ID du template CIO voulu&amp;gt;&amp;quot;&lt;br /&gt;
     api_region: &amp;quot;CloudIkoulaOne&amp;quot;&lt;br /&gt;
     zone: &amp;quot;&amp;lt;Nom de la zone voulu&amp;gt;&amp;quot;&lt;br /&gt;
     service_offering: &amp;quot;&amp;lt;Nom de l’offre de calcul voulu &amp;gt;&amp;quot;&lt;br /&gt;
     security_groups: &amp;quot;&amp;lt;Nom du groupe de sécurité existant voulu&amp;gt;&amp;quot;&lt;br /&gt;
     ssh_key: &amp;quot;&amp;lt;Nom de la paire de clés ssh CIO existante&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  - name: &amp;quot;VM ip address:&amp;quot;&lt;br /&gt;
    debug:&lt;br /&gt;
      var: vminfo.default_ip&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Une fois les paramètres et leurs valeurs adapté(e)s, voici un exemple d'exécution du playbook (adaptez le nom de votre fichier playbook au besoin):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ansible-playbook -i &amp;quot;localhost,&amp;quot; -c local deploy_instance_adv.yml&lt;br /&gt;
&lt;br /&gt;
PLAY [all] ********************************************************************************************************************************************************************************************************************************************************************&lt;br /&gt;
&lt;br /&gt;
TASK [Gathering Facts] ********************************************************************************************************************************************************************************************************************************************************&lt;br /&gt;
ok: [localhost]&lt;br /&gt;
&lt;br /&gt;
TASK [Create Debian instance in Cloud IKOULA One with Ansible Playbook] ********************************************************************************************************************************************************************************************************************************&lt;br /&gt;
changed: [localhost]&lt;br /&gt;
&lt;br /&gt;
PLAY RECAP ********************************************************************************************************************************************************************************************************************************************************************&lt;br /&gt;
localhost                  : ok=2    changed=1    unreachable=0    failed=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Catégorie :Cloudstack]]&lt;br /&gt;
[[Catégorie :Cloud public]]&lt;br /&gt;
[[Catégorie:API]]&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_vos_instances_avec_Ansible&amp;diff=27339</id>
		<title>Deployer vos instances avec Ansible</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_vos_instances_avec_Ansible&amp;diff=27339"/>
		<updated>2019-11-28T10:03:28Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Déploiement d'une instance avec un playbook Ansible */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Description ==&lt;br /&gt;
&lt;br /&gt;
Nous allons voir comment déployer rapidement des instance(s) Cloud IKOULA One via l'outils Ansible&lt;br /&gt;
&lt;br /&gt;
Tout d'abord vous devrez installer Ansible (https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) puis le module &amp;quot;cs_instance&amp;quot; (peut être installé via &amp;quot;pip install cs&amp;quot; cf. https://docs.ansible.com/ansible/2.6/modules/cs_instance_module.html) permettant d'utiliser l'API de Cloud Ikoula One, si ce n'est pas déjà fait et disposer d'un compte Cloud IKOULA One.&lt;br /&gt;
&lt;br /&gt;
Ansible est disponible pour la plupart des distributions GNU/Linux, MacOS mais est aussi utilisable via Cygwin par exemple sous Microsoft Windows. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'une instance en une commande avec Ansible ==&lt;br /&gt;
&lt;br /&gt;
Vous devrez tout d'abord créer et renseigner/adapter le fichier de configuration &amp;quot;.cloudstack.ini&amp;quot; du module &amp;quot;cs_instance&amp;quot; de Ansible :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[CloudIkoulaOne]&lt;br /&gt;
endpoint = https://cloudstack.ikoula.com/client/api&lt;br /&gt;
key = &amp;lt;clé API de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
secret = &amp;lt;clé privée de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
timeout = 30&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ensuite il suffit de lancer cette commande en adaptant les valeurs des paramètres (nom de votre instance, nom du réseau, etc.) et les paramètres en eux-mêmes (si vous avez/voulez utliser ou non une paire de clé SSH par exemple) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ansible -i &amp;quot;localhost,&amp;quot; -c local all -m cs_instance -a &amp;quot;name=&amp;lt;Nom de la VM&amp;gt; display_name=&amp;lt;Nom de la VM&amp;gt;  state=present template=&amp;lt; Nom entre simples quotes ou ID du template voulu&amp;gt; api_region=CloudIkoulaOne zone=&amp;lt;Nom de la zone voulu&amp;gt; service_offering=&amp;lt; Nom de l’offre de calcul voulu &amp;gt; networks=&amp;lt;Nom du réseau existant voulu&amp;gt; ssh_key=&amp;lt;Nom de la paire de clés ssh CIO existante&amp;gt;&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
où &amp;quot;&amp;lt;Nom de l’offre de calcul voulu &amp;gt;&amp;quot; correspond au choix à  :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;t1.pico&amp;quot; (1/2 Core CPU with 512MB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;t1.micro&amp;quot; (1 Core CPU with 1GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.small&amp;quot; (1 Core CPU with 1.7GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.medium&amp;quot; (2 Cores CPU with 3.8GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.large&amp;quot; (4 Cores CPU with 7.6GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;quot;m1.extralarge&amp;quot; (8 Cores CPU with 15.3GB RAM and 100Mbps NIC)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Voici un exemple ainsi que le retour de son exécution :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ansible -i &amp;quot;localhost,&amp;quot; -c local all -m cs_instance -a &amp;quot;name=Debian9advz1 display_name=Debian9adv1 state=present template='Debian 9 - Minimal - 64bits' api_region=CloudIkoulaOne zone=EU-FR-IKDC1-Z1-ADV service_offering=t1.micro networks=My-Network-Z1 ssh_key=MY_SSHKEY&amp;quot;&lt;br /&gt;
localhost | SUCCESS =&amp;gt; {&lt;br /&gt;
    &amp;quot;account&amp;quot;: &amp;quot;ikoula&amp;quot;,&lt;br /&gt;
    &amp;quot;affinity_groups&amp;quot;: [],&lt;br /&gt;
    &amp;quot;changed&amp;quot;: true,&lt;br /&gt;
    &amp;quot;created&amp;quot;: &amp;quot;2018-09-12T10:05:00+0200&amp;quot;,&lt;br /&gt;
    &amp;quot;default_ip&amp;quot;: &amp;quot;10.1.1.176&amp;quot;,&lt;br /&gt;
    &amp;quot;display_name&amp;quot;: &amp;quot;Debian9adv1&amp;quot;,&lt;br /&gt;
    &amp;quot;domain&amp;quot;: &amp;quot;ROOT&amp;quot;,&lt;br /&gt;
    &amp;quot;hypervisor&amp;quot;: &amp;quot;XenServer&amp;quot;,&lt;br /&gt;
    &amp;quot;id&amp;quot;: &amp;quot;3c60acc9-1480-48bc-ab78-934f0e607d6c&amp;quot;,&lt;br /&gt;
    &amp;quot;instance_name&amp;quot;: &amp;quot;i-1079-67026-VM&amp;quot;,&lt;br /&gt;
    &amp;quot;name&amp;quot;: &amp;quot;Debian9advz1&amp;quot;,&lt;br /&gt;
    &amp;quot;password&amp;quot;: &amp;quot;KYqrT3h28qOs&amp;quot;,&lt;br /&gt;
    &amp;quot;password_enabled&amp;quot;: true,&lt;br /&gt;
    &amp;quot;security_groups&amp;quot;: [],&lt;br /&gt;
    &amp;quot;service_offering&amp;quot;: &amp;quot;t1.micro&amp;quot;,&lt;br /&gt;
    &amp;quot;ssh_key&amp;quot;: &amp;quot;MY_SSHKEY&amp;quot;,&lt;br /&gt;
    &amp;quot;state&amp;quot;: &amp;quot;Running&amp;quot;,&lt;br /&gt;
    &amp;quot;tags&amp;quot;: [],&lt;br /&gt;
    &amp;quot;template&amp;quot;: &amp;quot;Debian 9 - Minimal - 64bits&amp;quot;,&lt;br /&gt;
    &amp;quot;user_data&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
    &amp;quot;zone&amp;quot;: &amp;quot;EU-FR-IKDC1-Z1-ADV&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Dans cet exemple, nous déployons une instance Debian 9 en zone avancée (EU-FR-IKDC1-Z1-ADV), utilisant l'offre de calcul &amp;quot;t1.micro&amp;quot; dans notre réseau nommé &amp;quot;My-Network-Z1&amp;quot; avec notre paire de clés SSH nommée &amp;quot;MY_SSHKEY&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Pour voir l'ensemble des paramètres utilisables et d'autres exemples, vous pouvez utiliser le ansible-doc du module &amp;quot;cs_instance&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ansible-doc cs_instance&lt;br /&gt;
&amp;gt; CS_INSTANCE    (/usr/lib/python2.7/site-packages/ansible/modules/cloud/cloudstack/cs_instance.py)&lt;br /&gt;
&lt;br /&gt;
  Deploy, start, update, scale, restart, restore, stop and destroy instances.&lt;br /&gt;
&lt;br /&gt;
Options (= is mandatory):&lt;br /&gt;
&lt;br /&gt;
- account&lt;br /&gt;
        Account the instance is related to.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- affinity_groups&lt;br /&gt;
        Affinity groups names to be applied to the new instance.&lt;br /&gt;
        [Default: []]&lt;br /&gt;
- api_http_method&lt;br /&gt;
        HTTP method used.&lt;br /&gt;
        (Choices: get, post)[Default: get]&lt;br /&gt;
- api_key&lt;br /&gt;
        API key of the CloudStack API.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- api_region&lt;br /&gt;
        Name of the ini section in the `cloustack.ini' file.&lt;br /&gt;
        [Default: cloudstack]&lt;br /&gt;
- api_secret&lt;br /&gt;
        Secret key of the CloudStack API.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- api_timeout&lt;br /&gt;
        HTTP timeout.&lt;br /&gt;
        [Default: 10]&lt;br /&gt;
- api_url&lt;br /&gt;
        URL of the CloudStack API e.g. https://cloud.example.com/client/api.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- cpu&lt;br /&gt;
        The number of CPUs to allocate to the instance, used with custom service offerings&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- cpu_speed&lt;br /&gt;
        The clock speed/shares allocated to the instance, used with custom service offerings&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- disk_offering&lt;br /&gt;
        Name of the disk offering to be used.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
- disk_size&lt;br /&gt;
        Disk size in GByte required if deploying instance from ISO.&lt;br /&gt;
        [Default: None]&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : la sortie de la commande est volontairement tronquée du fait de sa longueur.&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'une instance avec un playbook Ansible ==&lt;br /&gt;
&lt;br /&gt;
De la même façon que ci-dessus vous devez tout d'abord créer et renseigner/adapter le fichier de configuration &amp;quot;.cloudstack.ini&amp;quot; du module &amp;quot;cs_instance&amp;quot; de Ansible :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[CloudIkoulaOne]&lt;br /&gt;
endpoint = https://cloudstack.ikoula.com/client/api&lt;br /&gt;
key = &amp;lt;clé API de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
secret = &amp;lt;clé privée de votre utilisateur/compte Cloud IKOULA One&amp;gt;&lt;br /&gt;
timeout = 30&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ensuite il suffit de créer un fichier de playbook (extension yml / format YAML), comme ci-dessous, en adaptant les valeurs des paramètres (nom de votre instance, nom du réseau, etc.) et les paramètres en eux-mêmes (si vous avez/voulez utliser ou non une paire de clé SSH par exemple) :&lt;br /&gt;
&lt;br /&gt;
Exemple de playbook de déploiement d'une instance en zone avancée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat deploy_instance_adv.yml&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
- hosts: all&lt;br /&gt;
  connection: local&lt;br /&gt;
  user: root&lt;br /&gt;
&lt;br /&gt;
  tasks:&lt;br /&gt;
&lt;br /&gt;
 - name: 'Create Debian instance in Cloud IKOULA One with Ansible Playbook'&lt;br /&gt;
    cs_instance:&lt;br /&gt;
      name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
      state: present&lt;br /&gt;
      display_name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
      template: &amp;quot;&amp;lt;Nom entre simples quotes ou ID du template CIO voulu&amp;gt;&amp;quot;&lt;br /&gt;
      api_region: &amp;quot;CloudIkoulaOne&amp;quot;&lt;br /&gt;
      zone: &amp;quot;&amp;lt;Nom de la zone voulu&amp;gt;&amp;quot;&lt;br /&gt;
      service_offering: &amp;quot;&amp;lt;Nom de l’offre de calcul voulu &amp;gt;&amp;quot;&lt;br /&gt;
      networks: &amp;quot;&amp;lt;Nom du réseau existant voulu&amp;gt;&amp;quot;&lt;br /&gt;
      ssh_key: &amp;quot;&amp;lt;Nom de la paire de clés ssh CIO existante&amp;gt;&amp;quot;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exemple de playbook de déploiement d'une instance en zone basic (où on remplace simplement le paramètre réseau par celui des security groups et on ajoute le retour post-déploiement de l'adresse ip publique attribuée à la vm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cat deploy_instance_basic.yml&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
- hosts: all&lt;br /&gt;
  connection: local&lt;br /&gt;
  user: root&lt;br /&gt;
&lt;br /&gt;
  tasks:&lt;br /&gt;
&lt;br /&gt;
 - name: 'Create Debian instance in Cloud IKOULA One with Ansible Playbook'&lt;br /&gt;
    cs_instance:&lt;br /&gt;
      name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
      state: present&lt;br /&gt;
      display_name: &amp;quot;&amp;lt;Nom de la VM&amp;gt;&amp;quot;&lt;br /&gt;
      template: &amp;quot;&amp;lt;Nom entre simples quotes ou ID du template CIO voulu&amp;gt;&amp;quot;&lt;br /&gt;
      api_region: &amp;quot;CloudIkoulaOne&amp;quot;&lt;br /&gt;
      zone: &amp;quot;&amp;lt;Nom de la zone voulu&amp;gt;&amp;quot;&lt;br /&gt;
      service_offering: &amp;quot;&amp;lt;Nom de l’offre de calcul voulu &amp;gt;&amp;quot;&lt;br /&gt;
      security_groups: &amp;quot;&amp;lt;Nom du groupe de sécurité existant voulu&amp;gt;&amp;quot;&lt;br /&gt;
      ssh_key: &amp;quot;&amp;lt;Nom de la paire de clés ssh CIO existante&amp;gt;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  - name: &amp;quot;VM ip address:&amp;quot;&lt;br /&gt;
    debug:&lt;br /&gt;
      var: vminfo.default_ip&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Une fois les paramètres et leurs valeurs adapté(e)s, voici un exemple d'exécution du playbook (adaptez le nom de votre fichier playbook au besoin):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ansible-playbook -i &amp;quot;localhost,&amp;quot; -c local deploy_instance_adv.yml&lt;br /&gt;
&lt;br /&gt;
PLAY [all] ********************************************************************************************************************************************************************************************************************************************************************&lt;br /&gt;
&lt;br /&gt;
TASK [Gathering Facts] ********************************************************************************************************************************************************************************************************************************************************&lt;br /&gt;
ok: [localhost]&lt;br /&gt;
&lt;br /&gt;
TASK [Create Debian instance in Cloud IKOULA One with Ansible Playbook] ********************************************************************************************************************************************************************************************************************************&lt;br /&gt;
changed: [localhost]&lt;br /&gt;
&lt;br /&gt;
PLAY RECAP ********************************************************************************************************************************************************************************************************************************************************************&lt;br /&gt;
localhost                  : ok=2    changed=1    unreachable=0    failed=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Catégorie :Cloudstack]]&lt;br /&gt;
[[Catégorie :Cloud public]]&lt;br /&gt;
[[Catégorie:API]]&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes_avec_CoreOS&amp;diff=25815</id>
		<title>Deployer un cluster Kubernetes avec CoreOS</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes_avec_CoreOS&amp;diff=25815"/>
		<updated>2019-04-12T14:27:31Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span data-link_translate_fr_title=&amp;quot;Deployer un cluster Kubernetes avec CoreOS (Dépréciée) &amp;quot;  data-link_translate_fr_url=&amp;quot;Deployer un cluster Kubernetes avec CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:fr:Deployer un cluster Kubernetes avec CoreOS]][[fr:Deployer un cluster Kubernetes avec CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_he_title=&amp;quot;לפרוס את אשכול Kubernetes עם CoreOS&amp;quot;  data-link_translate_he_url=&amp;quot;%D7%9C%D7%A4%D7%A8%D7%95%D7%A1+%D7%90%D7%AA+%D7%90%D7%A9%D7%9B%D7%95%D7%9C+Kubernetes+%D7%A2%D7%9D+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:he:לפרוס את אשכול Kubernetes עם CoreOS]][[he:לפרוס את אשכול Kubernetes עם CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_ro_title=&amp;quot;Implementaţi un cluster Kubernetes cu CoreOS&amp;quot;  data-link_translate_ro_url=&amp;quot;Implementa%C5%A3i+un+cluster+Kubernetes+cu+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ro:Implementaţi un cluster Kubernetes cu CoreOS]][[ro:Implementaţi un cluster Kubernetes cu CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_ru_title=&amp;quot;Развертывание кластера Kubernetes с CoreOS&amp;quot;  data-link_translate_ru_url=&amp;quot;%D0%A0%D0%B0%D0%B7%D0%B2%D0%B5%D1%80%D1%82%D1%8B%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5+%D0%BA%D0%BB%D0%B0%D1%81%D1%82%D0%B5%D1%80%D0%B0+Kubernetes+%D1%81+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ru:Развертывание кластера Kubernetes с CoreOS]][[ru:Развертывание кластера Kubernetes с CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_pl_title=&amp;quot;Wdróż klaster Kubernetes z CoreOS&amp;quot;  data-link_translate_pl_url=&amp;quot;Wdr%C3%B3%C5%BC+klaster+Kubernetes+z+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:pl:Wdróż klaster Kubernetes z CoreOS]][[pl:Wdróż klaster Kubernetes z CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_ja_title=&amp;quot;クラスター コア Os と Kubernetes を展開します。&amp;quot;  data-link_translate_ja_url=&amp;quot;%E3%82%AF%E3%83%A9%E3%82%B9%E3%82%BF%E3%83%BC+%E3%82%B3%E3%82%A2+Os+%E3%81%A8+Kubernetes+%E3%82%92%E5%B1%95%E9%96%8B%E3%81%97%E3%81%BE%E3%81%99%E3%80%82&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ja:クラスター コア Os と Kubernetes を展開します。]][[ja:クラスター コア Os と Kubernetes を展開します。]]&lt;br /&gt;
&amp;lt;span data-link_translate_ar_title=&amp;quot;نشر مجموعة كوبيرنيتيس مع CoreOS&amp;quot;  data-link_translate_ar_url=&amp;quot;%D9%86%D8%B4%D8%B1+%D9%85%D8%AC%D9%85%D9%88%D8%B9%D8%A9+%D9%83%D9%88%D8%A8%D9%8A%D8%B1%D9%86%D9%8A%D8%AA%D9%8A%D8%B3+%D9%85%D8%B9+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ar:نشر مجموعة كوبيرنيتيس مع CoreOS]][[ar:نشر مجموعة كوبيرنيتيس مع CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_zh_title=&amp;quot;部署群集与 CoreOS Kubernetes&amp;quot;  data-link_translate_zh_url=&amp;quot;%E9%83%A8%E7%BD%B2%E7%BE%A4%E9%9B%86%E4%B8%8E+CoreOS+Kubernetes&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:zh:部署群集与 CoreOS Kubernetes]][[zh:部署群集与 CoreOS Kubernetes]]&lt;br /&gt;
&amp;lt;span data-link_translate_de_title=&amp;quot;Bereitstellen eines Clusters Kubernetes mit CoreOS&amp;quot;  data-link_translate_de_url=&amp;quot;Bereitstellen+eines+Clusters+Kubernetes+mit+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:de:Bereitstellen eines Clusters Kubernetes mit CoreOS]][[de:Bereitstellen eines Clusters Kubernetes mit CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_nl_title=&amp;quot;Implementeer een cluster Kubernetes met CoreOS&amp;quot;  data-link_translate_nl_url=&amp;quot;Implementeer+een+cluster+Kubernetes+met+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:nl:Implementeer een cluster Kubernetes met CoreOS]][[nl:Implementeer een cluster Kubernetes met CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_it_title=&amp;quot;Distribuire un cluster Kubernetes con CoreOS&amp;quot;  data-link_translate_it_url=&amp;quot;Distribuire+un+cluster+Kubernetes+con+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:it:Distribuire un cluster Kubernetes con CoreOS]][[it:Distribuire un cluster Kubernetes con CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_pt_title=&amp;quot;Implantar um cluster Kubernetes com CoreOS&amp;quot;  data-link_translate_pt_url=&amp;quot;Implantar+um+cluster+Kubernetes+com+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:pt:Implantar um cluster Kubernetes com CoreOS]][[pt:Implantar um cluster Kubernetes com CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_es_title=&amp;quot;Implementar un clúster Kubernetes con CoreOS&amp;quot;  data-link_translate_es_url=&amp;quot;Implementar+un+cl%C3%BAster+Kubernetes+con+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:es:Implementar un clúster Kubernetes con CoreOS]][[es:Implementar un clúster Kubernetes con CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_en_title=&amp;quot;Deploy a cluster Kubernetes with CoreOS (Deprecated)&amp;quot;  data-link_translate_en_url=&amp;quot;Deploy+a+cluster+Kubernetes+with+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:en:Deploy a cluster Kubernetes with CoreOS]][[en:Deploy a cluster Kubernetes with CoreOS]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
'''Cette procédure est maintenant dépréciée du fait qu'elle s'appuie sur fleet qui n'est plus maintenu par CoreOS, veuillez suivre la procédure disponible ici https://fr-wiki.ikoula.com/fr/Deployer_un_cluster_Kubernetes'''&lt;br /&gt;
&lt;br /&gt;
Cette procédure décrit comment déployer rapidement et simplement un cluster [http://kubernetes.io/ Kubernetes] multi-nodes avec trois instances CoreOS. Kubernetes fonctionnent en mode client - {{Template:Serveur}}, le client Kubernetes est nommé &amp;quot;Kubernetes minion&amp;quot; et le {{Template:Serveur}} &amp;quot;Kubernetes master&amp;quot;. L'instance Kubernetes Master est l'instance qui va orchestrer de manière centralisée les instances Kubernetes Minions. Dans notre exemple, une instance CoreOS jouera la rôle de master Kubernetes et les deux autres instances joueront le rôle de node Kubernetes (minion).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
==Kubernetes==&lt;br /&gt;
Kubernetes est un système d'orchestration Open Source crée par Google permettant la gestion d'application conteneurisées avec Docker sur un cluster de plusieurs hôtes (trois VM CoreOS dans notre exemple). Il permet notamment le déploiement, la maintenance et la scalabilité d'applications. Pour en savoir plus, vous pouvez vous rendre sur [https://github.com/GoogleCloudPlatform/kubernetes/ le github Kubernetes].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
==Déroulé==&lt;br /&gt;
Nous partons du principe que vos trois instances CoreOS sont déjà déployées, qu''''elles peuvent communiquer entre elles''' et que vous y êtes connectés en SSH avec l'utilisateur core.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
Si cela n'est pas déjà fait, mettez à jour vos instances CoreOS afin qu'elles soient à minima en version CoreOS 653.0.0 et incluent Etcd2 (voir notre FAQ  [https://ikoula.wiki/help/Mettre_a_jour_CoreOS_manuellement Mettre à jour CoreOS manuellement]). Dans notre cas toutes nos instances sont en CoreOS stable 681.2.0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cat /etc/lsb-release&lt;br /&gt;
DISTRIB_ID=CoreOS&lt;br /&gt;
DISTRIB_RELEASE=681.2.0&lt;br /&gt;
DISTRIB_CODENAME=&amp;quot;Red Dog&amp;quot;&lt;br /&gt;
DISTRIB_DESCRIPTION=&amp;quot;CoreOS 681.2.0&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
Nous devons également faire en sorte que toutes nos instances CoreOS aient un ID de machine différent pour le bon fonctionnement en context cluster. Pour se faire il suffit de supprimer le fichier /etc/machine-id et de redémarrer chacune de vos instances CoreOS  soit : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo rm -f /etc/machine-id &amp;amp;&amp;amp; sudo reboot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Cela permet également la mise à jour de la version de CoreOS.&lt;br /&gt;
&lt;br /&gt;
=== Configuration de l'instance Kubernetes Master === &amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Ecraser le fichier {{Template:Cloud}}-config.yml par défaut par celui de notre configuration Kubernetes Master en effectuant les commandes suivantes ('''uniquement sur l'instance qui jouera le rôle master et dans le même ordre d'exécution que celui ci-dessous''') :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo wget -O /usr/share/oem/cloud-config.yml ftp://mirror02.ikoula.com/coreos/kubernetes-master.yaml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ export `cat /etc/environment`&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo sed -i 's#PRIVATE_IP#'$COREOS_PRIVATE_IPV4'#g' /usr/share/oem/cloud-config.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
On redémarre notre instance afin que sa configuration soit effective :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo reboot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
On vérifie que notre instance s'est bien initialisée :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo fleetctl list-machines&lt;br /&gt;
MACHINE         IP              METADATA&lt;br /&gt;
aee19a88...     10.1.1.138      role=master&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo etcdctl ls --recursive&lt;br /&gt;
/coreos.com&lt;br /&gt;
/coreos.com/updateengine&lt;br /&gt;
/coreos.com/updateengine/rebootlock&lt;br /&gt;
/coreos.com/updateengine/rebootlock/semaphore&lt;br /&gt;
/coreos.com/network&lt;br /&gt;
/coreos.com/network/config&lt;br /&gt;
/coreos.com/network/subnets&lt;br /&gt;
/coreos.com/network/subnets/10.244.69.0-24&lt;br /&gt;
/registry&lt;br /&gt;
/registry/ranges&lt;br /&gt;
/registry/ranges/serviceips&lt;br /&gt;
/registry/ranges/servicenodeports&lt;br /&gt;
/registry/namespaces&lt;br /&gt;
/registry/namespaces/default&lt;br /&gt;
/registry/services&lt;br /&gt;
/registry/services/endpoints&lt;br /&gt;
/registry/services/endpoints/default&lt;br /&gt;
/registry/services/endpoints/default/kubernetes&lt;br /&gt;
/registry/services/endpoints/default/kubernetes-ro&lt;br /&gt;
/registry/services/specs&lt;br /&gt;
/registry/services/specs/default&lt;br /&gt;
/registry/services/specs/default/kubernetes&lt;br /&gt;
/registry/services/specs/default/kubernetes-ro&lt;br /&gt;
/registry/serviceaccounts&lt;br /&gt;
/registry/serviceaccounts/default&lt;br /&gt;
/registry/serviceaccounts/default/default&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
On peut également voir les services / ports en écoute (on y retrouve les composants {{Template:Serveur}}/master Kubernetes):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo netstat -taupen | grep LISTEN&lt;br /&gt;
tcp        0      0 10.1.1.138:7001         0.0.0.0:*               LISTEN      232        16319      634/etcd2&lt;br /&gt;
tcp        0      0 10.1.1.138:7080         0.0.0.0:*               LISTEN      0          19392      1047/kube-apiserver&lt;br /&gt;
tcp        0      0 0.0.0.0:5000            0.0.0.0:*               LISTEN      0          19142      973/python&lt;br /&gt;
tcp        0      0 127.0.0.1:10251         0.0.0.0:*               LISTEN      0          20047      1075/kube-scheduler&lt;br /&gt;
tcp        0      0 10.1.1.138:6443         0.0.0.0:*               LISTEN      0          19406      1047/kube-apiserver&lt;br /&gt;
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      245        14794      502/systemd-resolve&lt;br /&gt;
tcp        0      0 127.0.0.1:10252         0.0.0.0:*               LISTEN      0          19653      1058/kube-controlle&lt;br /&gt;
tcp        0      0 10.1.1.138:2380         0.0.0.0:*               LISTEN      232        16313      634/etcd2&lt;br /&gt;
tcp6       0      0 :::8080                 :::*                    LISTEN      0          19390      1047/kube-apiserver&lt;br /&gt;
tcp6       0      0 :::22                   :::*                    LISTEN      0          13647      1/systemd&lt;br /&gt;
tcp6       0      0 :::4001                 :::*                    LISTEN      232        16321      634/etcd2&lt;br /&gt;
tcp6       0      0 :::2379                 :::*                    LISTEN      232        16320      634/etcd2&lt;br /&gt;
tcp6       0      0 :::5355                 :::*                    LISTEN      245        14796      502/systemd-resolve&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Configuration des instances Kubernetes Minions=== &amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
Écraser le fichier {{Template:Cloud}}-config.yml par défaut par celui de notre configuration Kubernetes Minion en effectuant les commandes suivantes sur l'ensemble de vos instance qui joueront le rôle de Kubernetes Minion ('''uniquement sur les instances qui joueront le rôle node/minion et dans le même ordre d'exécution que celui ci-dessous''') :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo wget -O /usr/share/oem/cloud-config.yml ftp://mirror02.ikoula.com/coreos/kubernetes-minion.yaml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:27--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ export `cat /etc/environment`&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:28--&amp;gt;&lt;br /&gt;
Attention il faut adapter l'adresse IP privée de votre instance kubernetes master dans la commande ci-dessous ('''remplacez 10.1.1.138 par l'ip privée de votre instance kubernetes master''') la commande ci-dessous :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:29--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo sed -i 's#MASTER_PRIVATE_IP#10.1.1.138#g' /usr/share/oem/cloud-config.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:30--&amp;gt;&lt;br /&gt;
Enfin une fois que vous avez effectuez ces commandes à l'identique sur chacune de vos instances/nodes kubernetes minion, redémarrez celles-ci afin que leur configuration soient effectives et quelles joignent le cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:31--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo reboot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:32--&amp;gt;&lt;br /&gt;
Nous vérifions que nos deux instances kubernetes minion ont bien rejoint notre cluster (la commande ci-dessous peut être exécutée sur n'importe laquelle de vos instances membre de votre cluster) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:33--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo fleetctl list-machines&lt;br /&gt;
MACHINE         IP              METADATA&lt;br /&gt;
5097f972...     10.1.1.215      role=node&lt;br /&gt;
aee19a88...     10.1.1.138      role=master&lt;br /&gt;
fe86214c...     10.1.1.83       role=node&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:34--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo etcdctl ls --recursive&lt;br /&gt;
/coreos.com&lt;br /&gt;
/coreos.com/updateengine&lt;br /&gt;
/coreos.com/updateengine/rebootlock&lt;br /&gt;
/coreos.com/updateengine/rebootlock/semaphore&lt;br /&gt;
/coreos.com/network&lt;br /&gt;
/coreos.com/network/config&lt;br /&gt;
/coreos.com/network/subnets&lt;br /&gt;
/coreos.com/network/subnets/10.244.69.0-24&lt;br /&gt;
/coreos.com/network/subnets/10.244.38.0-24&lt;br /&gt;
/coreos.com/network/subnets/10.244.23.0-24&lt;br /&gt;
/registry&lt;br /&gt;
/registry/ranges&lt;br /&gt;
/registry/ranges/serviceips&lt;br /&gt;
/registry/ranges/servicenodeports&lt;br /&gt;
/registry/namespaces&lt;br /&gt;
/registry/namespaces/default&lt;br /&gt;
/registry/services&lt;br /&gt;
/registry/services/specs&lt;br /&gt;
/registry/services/specs/default&lt;br /&gt;
/registry/services/specs/default/kubernetes&lt;br /&gt;
/registry/services/specs/default/kubernetes-ro&lt;br /&gt;
/registry/services/endpoints&lt;br /&gt;
/registry/services/endpoints/default&lt;br /&gt;
/registry/services/endpoints/default/kubernetes&lt;br /&gt;
/registry/services/endpoints/default/kubernetes-ro&lt;br /&gt;
/registry/serviceaccounts&lt;br /&gt;
/registry/serviceaccounts/default&lt;br /&gt;
/registry/serviceaccounts/default/default&lt;br /&gt;
/registry/events&lt;br /&gt;
/registry/events/default&lt;br /&gt;
/registry/events/default/10.1.1.215.13ea16c9c70924f4&lt;br /&gt;
/registry/events/default/10.1.1.83.13ea16f74bd4de1c&lt;br /&gt;
/registry/events/default/10.1.1.83.13ea16f77a4e7ab2&lt;br /&gt;
/registry/events/default/10.1.1.215.13ea16c991a4ee57&lt;br /&gt;
/registry/minions&lt;br /&gt;
/registry/minions/10.1.1.215&lt;br /&gt;
/registry/minions/10.1.1.83&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:35--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION2 ~ $ sudo etcdctl ls --recursive&lt;br /&gt;
/coreos.com&lt;br /&gt;
/coreos.com/updateengine&lt;br /&gt;
/coreos.com/updateengine/rebootlock&lt;br /&gt;
/coreos.com/updateengine/rebootlock/semaphore&lt;br /&gt;
/coreos.com/network&lt;br /&gt;
/coreos.com/network/config&lt;br /&gt;
/coreos.com/network/subnets&lt;br /&gt;
/coreos.com/network/subnets/10.244.69.0-24&lt;br /&gt;
/coreos.com/network/subnets/10.244.38.0-24&lt;br /&gt;
/coreos.com/network/subnets/10.244.23.0-24&lt;br /&gt;
/registry&lt;br /&gt;
/registry/ranges&lt;br /&gt;
/registry/ranges/serviceips&lt;br /&gt;
/registry/ranges/servicenodeports&lt;br /&gt;
/registry/namespaces&lt;br /&gt;
/registry/namespaces/default&lt;br /&gt;
/registry/services&lt;br /&gt;
/registry/services/specs&lt;br /&gt;
/registry/services/specs/default&lt;br /&gt;
/registry/services/specs/default/kubernetes&lt;br /&gt;
/registry/services/specs/default/kubernetes-ro&lt;br /&gt;
/registry/services/endpoints&lt;br /&gt;
/registry/services/endpoints/default&lt;br /&gt;
/registry/services/endpoints/default/kubernetes&lt;br /&gt;
/registry/services/endpoints/default/kubernetes-ro&lt;br /&gt;
/registry/serviceaccounts&lt;br /&gt;
/registry/serviceaccounts/default&lt;br /&gt;
/registry/serviceaccounts/default/default&lt;br /&gt;
/registry/events&lt;br /&gt;
/registry/events/default&lt;br /&gt;
/registry/events/default/10.1.1.83.13ea16f77a4e7ab2&lt;br /&gt;
/registry/events/default/10.1.1.215.13ea16c991a4ee57&lt;br /&gt;
/registry/events/default/10.1.1.215.13ea16c9c70924f4&lt;br /&gt;
/registry/events/default/10.1.1.83.13ea16f74bd4de1c&lt;br /&gt;
/registry/minions&lt;br /&gt;
/registry/minions/10.1.1.215&lt;br /&gt;
/registry/minions/10.1.1.83&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:36--&amp;gt;&lt;br /&gt;
Sur nos instances Kubernetes Minion voici les services/ports en écoute (dont le service Kubelet par lequel l'échange d'informations se fait avec le Kubernetes master) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:37--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo netstat -taupen | grep LISTEN&lt;br /&gt;
tcp        0      0 127.0.0.1:10249         0.0.0.0:*               LISTEN      0          18280      849/kube-proxy&lt;br /&gt;
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      245        14843      500/systemd-resolve&lt;br /&gt;
tcp6       0      0 :::49005                :::*                    LISTEN      0          18284      849/kube-proxy&lt;br /&gt;
tcp6       0      0 :::10255                :::*                    LISTEN      0          19213      1025/kubelet&lt;br /&gt;
tcp6       0      0 :::47666                :::*                    LISTEN      0          18309      849/kube-proxy&lt;br /&gt;
tcp6       0      0 :::22                   :::*                    LISTEN      0          13669      1/systemd&lt;br /&gt;
tcp6       0      0 :::4001                 :::*                    LISTEN      232        16106      617/etcd2&lt;br /&gt;
tcp6       0      0 :::4194                 :::*                    LISTEN      0          19096      1025/kubelet&lt;br /&gt;
tcp6       0      0 :::10248                :::*                    LISTEN      0          19210      1025/kubelet&lt;br /&gt;
tcp6       0      0 :::10250                :::*                    LISTEN      0          19305      1025/kubelet&lt;br /&gt;
tcp6       0      0 :::2379                 :::*                    LISTEN      232        16105      617/etcd2&lt;br /&gt;
tcp6       0      0 :::5355                 :::*                    LISTEN      245        14845      500/systemd-resolve&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Vérification de la communication avec l'API du Kubernetes Master== &amp;lt;!--T:38--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:39--&amp;gt;&lt;br /&gt;
'''La Kubernetes UI :'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:40--&amp;gt;&lt;br /&gt;
Pour accéder au dashboard Kubernetes, il vous faut autoriser les connexions au port 8080 (Kubernetes master API server) et effectuer une redirection de port si besoin (zone avancée) vers le port 8080 de votre instance Kubernetes master. Ensuite, il vous suffit d'accéder à l'URL http://''adresse_ip_publique_instance_kubernetes_master'':8080/static/app/#/dashboard/ dans votre navigateur :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:41--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:42--&amp;gt;&lt;br /&gt;
Depuis ce dashboard, il vous est entre autre possible d'afficher des informations sur vos nodes (Kubernetes Minion). Pour cela, vous pouvez cliquez sur &amp;quot;Views&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:43--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:44--&amp;gt;&lt;br /&gt;
Cliquez sur &amp;quot;Nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:45--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-3.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:46--&amp;gt;&lt;br /&gt;
La liste de vos nodes Kubernetes minion apparait :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:47--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-4.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:48--&amp;gt;&lt;br /&gt;
Cliquez sur l'un d'eux pour afficher les informations relatives à ce node (version de Docker, système, KubeProxy et Kubelet,etc.) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:49--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-5.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:50--&amp;gt;&lt;br /&gt;
'''Kubernetes CLI :'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:51--&amp;gt;&lt;br /&gt;
Vous pouvez également utiliser l'outil [https://cloud.google.com/container-engine/docs/kubectl/ Kubectl] depuis votre instance Kubernetes master. Pour se faire, vous devez installer cette utilitaire comme suit :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:52--&amp;gt;&lt;br /&gt;
Une fois connecté en ssh sur votre instance Kubernetes master saisissez les commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:53--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo wget -O /opt/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v0.17.0/bin/linux/amd64/kubectl&lt;br /&gt;
--2015-06-23 11:39:09--  https://storage.googleapis.com/kubernetes-release/release/v0.17.0/bin/linux/amd64/kubectl&lt;br /&gt;
Resolving storage.googleapis.com... 64.233.166.128, 2a00:1450:400c:c09::80&lt;br /&gt;
Connecting to storage.googleapis.com|64.233.166.128|:443... connected.&lt;br /&gt;
HTTP request sent, awaiting response... 200 OK&lt;br /&gt;
Length: 20077224 (19M) [application/octet-stream]&lt;br /&gt;
Saving to: '/opt/bin/kubectl'&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:54--&amp;gt;&lt;br /&gt;
/opt/bin/kubectl                              100%[===================================================================================================&amp;gt;]  19.15M  1.18MB/s   in 16s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:55--&amp;gt;&lt;br /&gt;
2015-06-23 11:39:26 (1.18 MB/s) - '/opt/bin/kubectl' saved [20077224/20077224]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:56--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo chmod 755 /opt/bin/kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:57--&amp;gt;&lt;br /&gt;
Test de la bonne communication avec votre API Kubernetes :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:58--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl get node&lt;br /&gt;
NAME         LABELS                              STATUS&lt;br /&gt;
10.1.1.215   kubernetes.io/hostname=10.1.1.215   Ready&lt;br /&gt;
10.1.1.83    kubernetes.io/hostname=10.1.1.83    Ready&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:59--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl cluster-info&lt;br /&gt;
Kubernetes master is running at http://localhost:8080&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:60--&amp;gt;&lt;br /&gt;
Nous pouvons ainsi déployer un premier container Nginx dans notre cluster :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:61--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl run-container nginx --image=nginx&lt;br /&gt;
CONTROLLER   CONTAINER(S)   IMAGE(S)   SELECTOR              REPLICAS&lt;br /&gt;
nginx        nginx          nginx      run-container=nginx   1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:62--&amp;gt;&lt;br /&gt;
On peut ensuite vérifier sur lequel de nos nodes minions ce container s'est déployé et exécuté ainsi que le nom du pod et l'ip qui lui a était affecté :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:63--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl get pods&lt;br /&gt;
POD           IP            CONTAINER(S)   IMAGE(S)   HOST                    LABELS                STATUS    CREATED     MESSAGE&lt;br /&gt;
nginx-zia71   10.244.38.2                             10.1.1.215/10.1.1.215   run-container=nginx   Running   3 minutes&lt;br /&gt;
                            nginx          nginx                                                    Running   1 minutes&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:64--&amp;gt;&lt;br /&gt;
Nous retrouvons ces mêmes informations via le dashboard de la Kubernete UI en allant dans &amp;quot;Views&amp;quot; puis &amp;quot;Pods&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:65--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-6.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:66--&amp;gt;&lt;br /&gt;
Nous pouvons voir l'IP de l'host sur lequel, ce container s'est déployé, avec le nom du Pod et son adresse IP : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:67--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-7.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:68--&amp;gt;&lt;br /&gt;
En cliquant dessus on obtient des informations plus détaillées sur notre Pod :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:69--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-8.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:70--&amp;gt;&lt;br /&gt;
Nous pouvons stopper notre container simplement :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:71--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl stop rc nginx&lt;br /&gt;
replicationcontrollers/nginx&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:72--&amp;gt;&lt;br /&gt;
Nous pouvons également déployer notre container avec deux replicas :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:73--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl run-container nginx --image=nginx --replicas=2&lt;br /&gt;
CONTROLLER   CONTAINER(S)   IMAGE(S)   SELECTOR              REPLICAS&lt;br /&gt;
nginx        nginx          nginx      run-container=nginx   2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:74--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl get pods&lt;br /&gt;
POD           IP            CONTAINER(S)   IMAGE(S)   HOST                    LABELS                STATUS    CREATED          MESSAGE&lt;br /&gt;
nginx-7gen5   10.244.38.3                             10.1.1.215/10.1.1.215   run-container=nginx   Running   About a minute&lt;br /&gt;
                            nginx          nginx                                                    Running   39 seconds&lt;br /&gt;
nginx-w4xue   10.244.23.3                             10.1.1.83/10.1.1.83     run-container=nginx   Running   About a minute&lt;br /&gt;
                            nginx          nginx                                                    Running   About a minute&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:75--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-9.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:76--&amp;gt;&lt;br /&gt;
Pour plus d'informations sur l'architecture, les différents composants et le fonctionnement d'un cluster Kubernetes, nous vous invitons à prendre connaissance de la documentation officielle [https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/design/architecture.md &amp;quot;Kubernetes architecture&amp;quot;] :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:77--&amp;gt;&lt;br /&gt;
[[category:cloudstack]]&lt;br /&gt;
[[category:cloud public]]&lt;br /&gt;
[[category:cloud privé]]&lt;br /&gt;
[[category:Docker]]&lt;br /&gt;
[[category:CoreOS]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;comments /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes_avec_CoreOS&amp;diff=25814</id>
		<title>Deployer un cluster Kubernetes avec CoreOS</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes_avec_CoreOS&amp;diff=25814"/>
		<updated>2019-04-12T14:27:13Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span data-link_translate_fr_title=&amp;quot;Deployer un cluster Kubernetes avec CoreOS (Dépréciée) &amp;quot;  data-link_translate_fr_url=&amp;quot;Deployer un cluster Kubernetes avec CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:fr:Deployer un cluster Kubernetes avec CoreOS]][[fr:Deployer un cluster Kubernetes avec CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_he_title=&amp;quot;לפרוס את אשכול Kubernetes עם CoreOS&amp;quot;  data-link_translate_he_url=&amp;quot;%D7%9C%D7%A4%D7%A8%D7%95%D7%A1+%D7%90%D7%AA+%D7%90%D7%A9%D7%9B%D7%95%D7%9C+Kubernetes+%D7%A2%D7%9D+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:he:לפרוס את אשכול Kubernetes עם CoreOS]][[he:לפרוס את אשכול Kubernetes עם CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_ro_title=&amp;quot;Implementaţi un cluster Kubernetes cu CoreOS&amp;quot;  data-link_translate_ro_url=&amp;quot;Implementa%C5%A3i+un+cluster+Kubernetes+cu+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ro:Implementaţi un cluster Kubernetes cu CoreOS]][[ro:Implementaţi un cluster Kubernetes cu CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_ru_title=&amp;quot;Развертывание кластера Kubernetes с CoreOS&amp;quot;  data-link_translate_ru_url=&amp;quot;%D0%A0%D0%B0%D0%B7%D0%B2%D0%B5%D1%80%D1%82%D1%8B%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5+%D0%BA%D0%BB%D0%B0%D1%81%D1%82%D0%B5%D1%80%D0%B0+Kubernetes+%D1%81+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ru:Развертывание кластера Kubernetes с CoreOS]][[ru:Развертывание кластера Kubernetes с CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_pl_title=&amp;quot;Wdróż klaster Kubernetes z CoreOS&amp;quot;  data-link_translate_pl_url=&amp;quot;Wdr%C3%B3%C5%BC+klaster+Kubernetes+z+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:pl:Wdróż klaster Kubernetes z CoreOS]][[pl:Wdróż klaster Kubernetes z CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_ja_title=&amp;quot;クラスター コア Os と Kubernetes を展開します。&amp;quot;  data-link_translate_ja_url=&amp;quot;%E3%82%AF%E3%83%A9%E3%82%B9%E3%82%BF%E3%83%BC+%E3%82%B3%E3%82%A2+Os+%E3%81%A8+Kubernetes+%E3%82%92%E5%B1%95%E9%96%8B%E3%81%97%E3%81%BE%E3%81%99%E3%80%82&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ja:クラスター コア Os と Kubernetes を展開します。]][[ja:クラスター コア Os と Kubernetes を展開します。]]&lt;br /&gt;
&amp;lt;span data-link_translate_ar_title=&amp;quot;نشر مجموعة كوبيرنيتيس مع CoreOS&amp;quot;  data-link_translate_ar_url=&amp;quot;%D9%86%D8%B4%D8%B1+%D9%85%D8%AC%D9%85%D9%88%D8%B9%D8%A9+%D9%83%D9%88%D8%A8%D9%8A%D8%B1%D9%86%D9%8A%D8%AA%D9%8A%D8%B3+%D9%85%D8%B9+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ar:نشر مجموعة كوبيرنيتيس مع CoreOS]][[ar:نشر مجموعة كوبيرنيتيس مع CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_zh_title=&amp;quot;部署群集与 CoreOS Kubernetes&amp;quot;  data-link_translate_zh_url=&amp;quot;%E9%83%A8%E7%BD%B2%E7%BE%A4%E9%9B%86%E4%B8%8E+CoreOS+Kubernetes&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:zh:部署群集与 CoreOS Kubernetes]][[zh:部署群集与 CoreOS Kubernetes]]&lt;br /&gt;
&amp;lt;span data-link_translate_de_title=&amp;quot;Bereitstellen eines Clusters Kubernetes mit CoreOS&amp;quot;  data-link_translate_de_url=&amp;quot;Bereitstellen+eines+Clusters+Kubernetes+mit+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:de:Bereitstellen eines Clusters Kubernetes mit CoreOS]][[de:Bereitstellen eines Clusters Kubernetes mit CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_nl_title=&amp;quot;Implementeer een cluster Kubernetes met CoreOS&amp;quot;  data-link_translate_nl_url=&amp;quot;Implementeer+een+cluster+Kubernetes+met+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:nl:Implementeer een cluster Kubernetes met CoreOS]][[nl:Implementeer een cluster Kubernetes met CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_it_title=&amp;quot;Distribuire un cluster Kubernetes con CoreOS&amp;quot;  data-link_translate_it_url=&amp;quot;Distribuire+un+cluster+Kubernetes+con+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:it:Distribuire un cluster Kubernetes con CoreOS]][[it:Distribuire un cluster Kubernetes con CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_pt_title=&amp;quot;Implantar um cluster Kubernetes com CoreOS&amp;quot;  data-link_translate_pt_url=&amp;quot;Implantar+um+cluster+Kubernetes+com+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:pt:Implantar um cluster Kubernetes com CoreOS]][[pt:Implantar um cluster Kubernetes com CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_es_title=&amp;quot;Implementar un clúster Kubernetes con CoreOS&amp;quot;  data-link_translate_es_url=&amp;quot;Implementar+un+cl%C3%BAster+Kubernetes+con+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:es:Implementar un clúster Kubernetes con CoreOS]][[es:Implementar un clúster Kubernetes con CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_en_title=&amp;quot;Deploy a cluster Kubernetes with CoreOS (Deprecated)&amp;quot;  data-link_translate_en_url=&amp;quot;Deploy+a+cluster+Kubernetes+with+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:en:Deploy a cluster Kubernetes with CoreOS]][[en:Deploy a cluster Kubernetes with CoreOS]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
'''Cette procédure est maintenant déprécié du fait qu'elle s'appuie sur fleet qui n'est plus maintenu par CoreOS, veuillez suivre la procédure disponible ici https://fr-wiki.ikoula.com/fr/Deployer_un_cluster_Kubernetes'''&lt;br /&gt;
&lt;br /&gt;
Cette procédure décrit comment déployer rapidement et simplement un cluster [http://kubernetes.io/ Kubernetes] multi-nodes avec trois instances CoreOS. Kubernetes fonctionnent en mode client - {{Template:Serveur}}, le client Kubernetes est nommé &amp;quot;Kubernetes minion&amp;quot; et le {{Template:Serveur}} &amp;quot;Kubernetes master&amp;quot;. L'instance Kubernetes Master est l'instance qui va orchestrer de manière centralisée les instances Kubernetes Minions. Dans notre exemple, une instance CoreOS jouera la rôle de master Kubernetes et les deux autres instances joueront le rôle de node Kubernetes (minion).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
==Kubernetes==&lt;br /&gt;
Kubernetes est un système d'orchestration Open Source crée par Google permettant la gestion d'application conteneurisées avec Docker sur un cluster de plusieurs hôtes (trois VM CoreOS dans notre exemple). Il permet notamment le déploiement, la maintenance et la scalabilité d'applications. Pour en savoir plus, vous pouvez vous rendre sur [https://github.com/GoogleCloudPlatform/kubernetes/ le github Kubernetes].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
==Déroulé==&lt;br /&gt;
Nous partons du principe que vos trois instances CoreOS sont déjà déployées, qu''''elles peuvent communiquer entre elles''' et que vous y êtes connectés en SSH avec l'utilisateur core.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
Si cela n'est pas déjà fait, mettez à jour vos instances CoreOS afin qu'elles soient à minima en version CoreOS 653.0.0 et incluent Etcd2 (voir notre FAQ  [https://ikoula.wiki/help/Mettre_a_jour_CoreOS_manuellement Mettre à jour CoreOS manuellement]). Dans notre cas toutes nos instances sont en CoreOS stable 681.2.0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cat /etc/lsb-release&lt;br /&gt;
DISTRIB_ID=CoreOS&lt;br /&gt;
DISTRIB_RELEASE=681.2.0&lt;br /&gt;
DISTRIB_CODENAME=&amp;quot;Red Dog&amp;quot;&lt;br /&gt;
DISTRIB_DESCRIPTION=&amp;quot;CoreOS 681.2.0&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
Nous devons également faire en sorte que toutes nos instances CoreOS aient un ID de machine différent pour le bon fonctionnement en context cluster. Pour se faire il suffit de supprimer le fichier /etc/machine-id et de redémarrer chacune de vos instances CoreOS  soit : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo rm -f /etc/machine-id &amp;amp;&amp;amp; sudo reboot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Cela permet également la mise à jour de la version de CoreOS.&lt;br /&gt;
&lt;br /&gt;
=== Configuration de l'instance Kubernetes Master === &amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Ecraser le fichier {{Template:Cloud}}-config.yml par défaut par celui de notre configuration Kubernetes Master en effectuant les commandes suivantes ('''uniquement sur l'instance qui jouera le rôle master et dans le même ordre d'exécution que celui ci-dessous''') :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo wget -O /usr/share/oem/cloud-config.yml ftp://mirror02.ikoula.com/coreos/kubernetes-master.yaml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ export `cat /etc/environment`&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo sed -i 's#PRIVATE_IP#'$COREOS_PRIVATE_IPV4'#g' /usr/share/oem/cloud-config.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
On redémarre notre instance afin que sa configuration soit effective :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo reboot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
On vérifie que notre instance s'est bien initialisée :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo fleetctl list-machines&lt;br /&gt;
MACHINE         IP              METADATA&lt;br /&gt;
aee19a88...     10.1.1.138      role=master&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo etcdctl ls --recursive&lt;br /&gt;
/coreos.com&lt;br /&gt;
/coreos.com/updateengine&lt;br /&gt;
/coreos.com/updateengine/rebootlock&lt;br /&gt;
/coreos.com/updateengine/rebootlock/semaphore&lt;br /&gt;
/coreos.com/network&lt;br /&gt;
/coreos.com/network/config&lt;br /&gt;
/coreos.com/network/subnets&lt;br /&gt;
/coreos.com/network/subnets/10.244.69.0-24&lt;br /&gt;
/registry&lt;br /&gt;
/registry/ranges&lt;br /&gt;
/registry/ranges/serviceips&lt;br /&gt;
/registry/ranges/servicenodeports&lt;br /&gt;
/registry/namespaces&lt;br /&gt;
/registry/namespaces/default&lt;br /&gt;
/registry/services&lt;br /&gt;
/registry/services/endpoints&lt;br /&gt;
/registry/services/endpoints/default&lt;br /&gt;
/registry/services/endpoints/default/kubernetes&lt;br /&gt;
/registry/services/endpoints/default/kubernetes-ro&lt;br /&gt;
/registry/services/specs&lt;br /&gt;
/registry/services/specs/default&lt;br /&gt;
/registry/services/specs/default/kubernetes&lt;br /&gt;
/registry/services/specs/default/kubernetes-ro&lt;br /&gt;
/registry/serviceaccounts&lt;br /&gt;
/registry/serviceaccounts/default&lt;br /&gt;
/registry/serviceaccounts/default/default&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
On peut également voir les services / ports en écoute (on y retrouve les composants {{Template:Serveur}}/master Kubernetes):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo netstat -taupen | grep LISTEN&lt;br /&gt;
tcp        0      0 10.1.1.138:7001         0.0.0.0:*               LISTEN      232        16319      634/etcd2&lt;br /&gt;
tcp        0      0 10.1.1.138:7080         0.0.0.0:*               LISTEN      0          19392      1047/kube-apiserver&lt;br /&gt;
tcp        0      0 0.0.0.0:5000            0.0.0.0:*               LISTEN      0          19142      973/python&lt;br /&gt;
tcp        0      0 127.0.0.1:10251         0.0.0.0:*               LISTEN      0          20047      1075/kube-scheduler&lt;br /&gt;
tcp        0      0 10.1.1.138:6443         0.0.0.0:*               LISTEN      0          19406      1047/kube-apiserver&lt;br /&gt;
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      245        14794      502/systemd-resolve&lt;br /&gt;
tcp        0      0 127.0.0.1:10252         0.0.0.0:*               LISTEN      0          19653      1058/kube-controlle&lt;br /&gt;
tcp        0      0 10.1.1.138:2380         0.0.0.0:*               LISTEN      232        16313      634/etcd2&lt;br /&gt;
tcp6       0      0 :::8080                 :::*                    LISTEN      0          19390      1047/kube-apiserver&lt;br /&gt;
tcp6       0      0 :::22                   :::*                    LISTEN      0          13647      1/systemd&lt;br /&gt;
tcp6       0      0 :::4001                 :::*                    LISTEN      232        16321      634/etcd2&lt;br /&gt;
tcp6       0      0 :::2379                 :::*                    LISTEN      232        16320      634/etcd2&lt;br /&gt;
tcp6       0      0 :::5355                 :::*                    LISTEN      245        14796      502/systemd-resolve&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Configuration des instances Kubernetes Minions=== &amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
Écraser le fichier {{Template:Cloud}}-config.yml par défaut par celui de notre configuration Kubernetes Minion en effectuant les commandes suivantes sur l'ensemble de vos instance qui joueront le rôle de Kubernetes Minion ('''uniquement sur les instances qui joueront le rôle node/minion et dans le même ordre d'exécution que celui ci-dessous''') :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo wget -O /usr/share/oem/cloud-config.yml ftp://mirror02.ikoula.com/coreos/kubernetes-minion.yaml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:27--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ export `cat /etc/environment`&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:28--&amp;gt;&lt;br /&gt;
Attention il faut adapter l'adresse IP privée de votre instance kubernetes master dans la commande ci-dessous ('''remplacez 10.1.1.138 par l'ip privée de votre instance kubernetes master''') la commande ci-dessous :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:29--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo sed -i 's#MASTER_PRIVATE_IP#10.1.1.138#g' /usr/share/oem/cloud-config.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:30--&amp;gt;&lt;br /&gt;
Enfin une fois que vous avez effectuez ces commandes à l'identique sur chacune de vos instances/nodes kubernetes minion, redémarrez celles-ci afin que leur configuration soient effectives et quelles joignent le cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:31--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo reboot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:32--&amp;gt;&lt;br /&gt;
Nous vérifions que nos deux instances kubernetes minion ont bien rejoint notre cluster (la commande ci-dessous peut être exécutée sur n'importe laquelle de vos instances membre de votre cluster) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:33--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo fleetctl list-machines&lt;br /&gt;
MACHINE         IP              METADATA&lt;br /&gt;
5097f972...     10.1.1.215      role=node&lt;br /&gt;
aee19a88...     10.1.1.138      role=master&lt;br /&gt;
fe86214c...     10.1.1.83       role=node&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:34--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo etcdctl ls --recursive&lt;br /&gt;
/coreos.com&lt;br /&gt;
/coreos.com/updateengine&lt;br /&gt;
/coreos.com/updateengine/rebootlock&lt;br /&gt;
/coreos.com/updateengine/rebootlock/semaphore&lt;br /&gt;
/coreos.com/network&lt;br /&gt;
/coreos.com/network/config&lt;br /&gt;
/coreos.com/network/subnets&lt;br /&gt;
/coreos.com/network/subnets/10.244.69.0-24&lt;br /&gt;
/coreos.com/network/subnets/10.244.38.0-24&lt;br /&gt;
/coreos.com/network/subnets/10.244.23.0-24&lt;br /&gt;
/registry&lt;br /&gt;
/registry/ranges&lt;br /&gt;
/registry/ranges/serviceips&lt;br /&gt;
/registry/ranges/servicenodeports&lt;br /&gt;
/registry/namespaces&lt;br /&gt;
/registry/namespaces/default&lt;br /&gt;
/registry/services&lt;br /&gt;
/registry/services/specs&lt;br /&gt;
/registry/services/specs/default&lt;br /&gt;
/registry/services/specs/default/kubernetes&lt;br /&gt;
/registry/services/specs/default/kubernetes-ro&lt;br /&gt;
/registry/services/endpoints&lt;br /&gt;
/registry/services/endpoints/default&lt;br /&gt;
/registry/services/endpoints/default/kubernetes&lt;br /&gt;
/registry/services/endpoints/default/kubernetes-ro&lt;br /&gt;
/registry/serviceaccounts&lt;br /&gt;
/registry/serviceaccounts/default&lt;br /&gt;
/registry/serviceaccounts/default/default&lt;br /&gt;
/registry/events&lt;br /&gt;
/registry/events/default&lt;br /&gt;
/registry/events/default/10.1.1.215.13ea16c9c70924f4&lt;br /&gt;
/registry/events/default/10.1.1.83.13ea16f74bd4de1c&lt;br /&gt;
/registry/events/default/10.1.1.83.13ea16f77a4e7ab2&lt;br /&gt;
/registry/events/default/10.1.1.215.13ea16c991a4ee57&lt;br /&gt;
/registry/minions&lt;br /&gt;
/registry/minions/10.1.1.215&lt;br /&gt;
/registry/minions/10.1.1.83&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:35--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION2 ~ $ sudo etcdctl ls --recursive&lt;br /&gt;
/coreos.com&lt;br /&gt;
/coreos.com/updateengine&lt;br /&gt;
/coreos.com/updateengine/rebootlock&lt;br /&gt;
/coreos.com/updateengine/rebootlock/semaphore&lt;br /&gt;
/coreos.com/network&lt;br /&gt;
/coreos.com/network/config&lt;br /&gt;
/coreos.com/network/subnets&lt;br /&gt;
/coreos.com/network/subnets/10.244.69.0-24&lt;br /&gt;
/coreos.com/network/subnets/10.244.38.0-24&lt;br /&gt;
/coreos.com/network/subnets/10.244.23.0-24&lt;br /&gt;
/registry&lt;br /&gt;
/registry/ranges&lt;br /&gt;
/registry/ranges/serviceips&lt;br /&gt;
/registry/ranges/servicenodeports&lt;br /&gt;
/registry/namespaces&lt;br /&gt;
/registry/namespaces/default&lt;br /&gt;
/registry/services&lt;br /&gt;
/registry/services/specs&lt;br /&gt;
/registry/services/specs/default&lt;br /&gt;
/registry/services/specs/default/kubernetes&lt;br /&gt;
/registry/services/specs/default/kubernetes-ro&lt;br /&gt;
/registry/services/endpoints&lt;br /&gt;
/registry/services/endpoints/default&lt;br /&gt;
/registry/services/endpoints/default/kubernetes&lt;br /&gt;
/registry/services/endpoints/default/kubernetes-ro&lt;br /&gt;
/registry/serviceaccounts&lt;br /&gt;
/registry/serviceaccounts/default&lt;br /&gt;
/registry/serviceaccounts/default/default&lt;br /&gt;
/registry/events&lt;br /&gt;
/registry/events/default&lt;br /&gt;
/registry/events/default/10.1.1.83.13ea16f77a4e7ab2&lt;br /&gt;
/registry/events/default/10.1.1.215.13ea16c991a4ee57&lt;br /&gt;
/registry/events/default/10.1.1.215.13ea16c9c70924f4&lt;br /&gt;
/registry/events/default/10.1.1.83.13ea16f74bd4de1c&lt;br /&gt;
/registry/minions&lt;br /&gt;
/registry/minions/10.1.1.215&lt;br /&gt;
/registry/minions/10.1.1.83&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:36--&amp;gt;&lt;br /&gt;
Sur nos instances Kubernetes Minion voici les services/ports en écoute (dont le service Kubelet par lequel l'échange d'informations se fait avec le Kubernetes master) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:37--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo netstat -taupen | grep LISTEN&lt;br /&gt;
tcp        0      0 127.0.0.1:10249         0.0.0.0:*               LISTEN      0          18280      849/kube-proxy&lt;br /&gt;
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      245        14843      500/systemd-resolve&lt;br /&gt;
tcp6       0      0 :::49005                :::*                    LISTEN      0          18284      849/kube-proxy&lt;br /&gt;
tcp6       0      0 :::10255                :::*                    LISTEN      0          19213      1025/kubelet&lt;br /&gt;
tcp6       0      0 :::47666                :::*                    LISTEN      0          18309      849/kube-proxy&lt;br /&gt;
tcp6       0      0 :::22                   :::*                    LISTEN      0          13669      1/systemd&lt;br /&gt;
tcp6       0      0 :::4001                 :::*                    LISTEN      232        16106      617/etcd2&lt;br /&gt;
tcp6       0      0 :::4194                 :::*                    LISTEN      0          19096      1025/kubelet&lt;br /&gt;
tcp6       0      0 :::10248                :::*                    LISTEN      0          19210      1025/kubelet&lt;br /&gt;
tcp6       0      0 :::10250                :::*                    LISTEN      0          19305      1025/kubelet&lt;br /&gt;
tcp6       0      0 :::2379                 :::*                    LISTEN      232        16105      617/etcd2&lt;br /&gt;
tcp6       0      0 :::5355                 :::*                    LISTEN      245        14845      500/systemd-resolve&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Vérification de la communication avec l'API du Kubernetes Master== &amp;lt;!--T:38--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:39--&amp;gt;&lt;br /&gt;
'''La Kubernetes UI :'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:40--&amp;gt;&lt;br /&gt;
Pour accéder au dashboard Kubernetes, il vous faut autoriser les connexions au port 8080 (Kubernetes master API server) et effectuer une redirection de port si besoin (zone avancée) vers le port 8080 de votre instance Kubernetes master. Ensuite, il vous suffit d'accéder à l'URL http://''adresse_ip_publique_instance_kubernetes_master'':8080/static/app/#/dashboard/ dans votre navigateur :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:41--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:42--&amp;gt;&lt;br /&gt;
Depuis ce dashboard, il vous est entre autre possible d'afficher des informations sur vos nodes (Kubernetes Minion). Pour cela, vous pouvez cliquez sur &amp;quot;Views&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:43--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:44--&amp;gt;&lt;br /&gt;
Cliquez sur &amp;quot;Nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:45--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-3.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:46--&amp;gt;&lt;br /&gt;
La liste de vos nodes Kubernetes minion apparait :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:47--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-4.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:48--&amp;gt;&lt;br /&gt;
Cliquez sur l'un d'eux pour afficher les informations relatives à ce node (version de Docker, système, KubeProxy et Kubelet,etc.) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:49--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-5.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:50--&amp;gt;&lt;br /&gt;
'''Kubernetes CLI :'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:51--&amp;gt;&lt;br /&gt;
Vous pouvez également utiliser l'outil [https://cloud.google.com/container-engine/docs/kubectl/ Kubectl] depuis votre instance Kubernetes master. Pour se faire, vous devez installer cette utilitaire comme suit :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:52--&amp;gt;&lt;br /&gt;
Une fois connecté en ssh sur votre instance Kubernetes master saisissez les commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:53--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo wget -O /opt/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v0.17.0/bin/linux/amd64/kubectl&lt;br /&gt;
--2015-06-23 11:39:09--  https://storage.googleapis.com/kubernetes-release/release/v0.17.0/bin/linux/amd64/kubectl&lt;br /&gt;
Resolving storage.googleapis.com... 64.233.166.128, 2a00:1450:400c:c09::80&lt;br /&gt;
Connecting to storage.googleapis.com|64.233.166.128|:443... connected.&lt;br /&gt;
HTTP request sent, awaiting response... 200 OK&lt;br /&gt;
Length: 20077224 (19M) [application/octet-stream]&lt;br /&gt;
Saving to: '/opt/bin/kubectl'&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:54--&amp;gt;&lt;br /&gt;
/opt/bin/kubectl                              100%[===================================================================================================&amp;gt;]  19.15M  1.18MB/s   in 16s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:55--&amp;gt;&lt;br /&gt;
2015-06-23 11:39:26 (1.18 MB/s) - '/opt/bin/kubectl' saved [20077224/20077224]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:56--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo chmod 755 /opt/bin/kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:57--&amp;gt;&lt;br /&gt;
Test de la bonne communication avec votre API Kubernetes :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:58--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl get node&lt;br /&gt;
NAME         LABELS                              STATUS&lt;br /&gt;
10.1.1.215   kubernetes.io/hostname=10.1.1.215   Ready&lt;br /&gt;
10.1.1.83    kubernetes.io/hostname=10.1.1.83    Ready&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:59--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl cluster-info&lt;br /&gt;
Kubernetes master is running at http://localhost:8080&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:60--&amp;gt;&lt;br /&gt;
Nous pouvons ainsi déployer un premier container Nginx dans notre cluster :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:61--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl run-container nginx --image=nginx&lt;br /&gt;
CONTROLLER   CONTAINER(S)   IMAGE(S)   SELECTOR              REPLICAS&lt;br /&gt;
nginx        nginx          nginx      run-container=nginx   1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:62--&amp;gt;&lt;br /&gt;
On peut ensuite vérifier sur lequel de nos nodes minions ce container s'est déployé et exécuté ainsi que le nom du pod et l'ip qui lui a était affecté :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:63--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl get pods&lt;br /&gt;
POD           IP            CONTAINER(S)   IMAGE(S)   HOST                    LABELS                STATUS    CREATED     MESSAGE&lt;br /&gt;
nginx-zia71   10.244.38.2                             10.1.1.215/10.1.1.215   run-container=nginx   Running   3 minutes&lt;br /&gt;
                            nginx          nginx                                                    Running   1 minutes&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:64--&amp;gt;&lt;br /&gt;
Nous retrouvons ces mêmes informations via le dashboard de la Kubernete UI en allant dans &amp;quot;Views&amp;quot; puis &amp;quot;Pods&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:65--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-6.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:66--&amp;gt;&lt;br /&gt;
Nous pouvons voir l'IP de l'host sur lequel, ce container s'est déployé, avec le nom du Pod et son adresse IP : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:67--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-7.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:68--&amp;gt;&lt;br /&gt;
En cliquant dessus on obtient des informations plus détaillées sur notre Pod :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:69--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-8.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:70--&amp;gt;&lt;br /&gt;
Nous pouvons stopper notre container simplement :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:71--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl stop rc nginx&lt;br /&gt;
replicationcontrollers/nginx&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:72--&amp;gt;&lt;br /&gt;
Nous pouvons également déployer notre container avec deux replicas :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:73--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl run-container nginx --image=nginx --replicas=2&lt;br /&gt;
CONTROLLER   CONTAINER(S)   IMAGE(S)   SELECTOR              REPLICAS&lt;br /&gt;
nginx        nginx          nginx      run-container=nginx   2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:74--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl get pods&lt;br /&gt;
POD           IP            CONTAINER(S)   IMAGE(S)   HOST                    LABELS                STATUS    CREATED          MESSAGE&lt;br /&gt;
nginx-7gen5   10.244.38.3                             10.1.1.215/10.1.1.215   run-container=nginx   Running   About a minute&lt;br /&gt;
                            nginx          nginx                                                    Running   39 seconds&lt;br /&gt;
nginx-w4xue   10.244.23.3                             10.1.1.83/10.1.1.83     run-container=nginx   Running   About a minute&lt;br /&gt;
                            nginx          nginx                                                    Running   About a minute&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:75--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-9.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:76--&amp;gt;&lt;br /&gt;
Pour plus d'informations sur l'architecture, les différents composants et le fonctionnement d'un cluster Kubernetes, nous vous invitons à prendre connaissance de la documentation officielle [https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/design/architecture.md &amp;quot;Kubernetes architecture&amp;quot;] :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:77--&amp;gt;&lt;br /&gt;
[[category:cloudstack]]&lt;br /&gt;
[[category:cloud public]]&lt;br /&gt;
[[category:cloud privé]]&lt;br /&gt;
[[category:Docker]]&lt;br /&gt;
[[category:CoreOS]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;comments /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes_avec_CoreOS&amp;diff=25813</id>
		<title>Deployer un cluster Kubernetes avec CoreOS</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes_avec_CoreOS&amp;diff=25813"/>
		<updated>2019-04-12T14:26:17Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span data-link_translate_fr_title=&amp;quot;Deployer un cluster Kubernetes avec CoreOS (Dépréciée) &amp;quot;  data-link_translate_fr_url=&amp;quot;Deployer un cluster Kubernetes avec CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:fr:Deployer un cluster Kubernetes avec CoreOS]][[fr:Deployer un cluster Kubernetes avec CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_he_title=&amp;quot;לפרוס את אשכול Kubernetes עם CoreOS&amp;quot;  data-link_translate_he_url=&amp;quot;%D7%9C%D7%A4%D7%A8%D7%95%D7%A1+%D7%90%D7%AA+%D7%90%D7%A9%D7%9B%D7%95%D7%9C+Kubernetes+%D7%A2%D7%9D+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:he:לפרוס את אשכול Kubernetes עם CoreOS]][[he:לפרוס את אשכול Kubernetes עם CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_ro_title=&amp;quot;Implementaţi un cluster Kubernetes cu CoreOS&amp;quot;  data-link_translate_ro_url=&amp;quot;Implementa%C5%A3i+un+cluster+Kubernetes+cu+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ro:Implementaţi un cluster Kubernetes cu CoreOS]][[ro:Implementaţi un cluster Kubernetes cu CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_ru_title=&amp;quot;Развертывание кластера Kubernetes с CoreOS&amp;quot;  data-link_translate_ru_url=&amp;quot;%D0%A0%D0%B0%D0%B7%D0%B2%D0%B5%D1%80%D1%82%D1%8B%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5+%D0%BA%D0%BB%D0%B0%D1%81%D1%82%D0%B5%D1%80%D0%B0+Kubernetes+%D1%81+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ru:Развертывание кластера Kubernetes с CoreOS]][[ru:Развертывание кластера Kubernetes с CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_pl_title=&amp;quot;Wdróż klaster Kubernetes z CoreOS&amp;quot;  data-link_translate_pl_url=&amp;quot;Wdr%C3%B3%C5%BC+klaster+Kubernetes+z+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:pl:Wdróż klaster Kubernetes z CoreOS]][[pl:Wdróż klaster Kubernetes z CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_ja_title=&amp;quot;クラスター コア Os と Kubernetes を展開します。&amp;quot;  data-link_translate_ja_url=&amp;quot;%E3%82%AF%E3%83%A9%E3%82%B9%E3%82%BF%E3%83%BC+%E3%82%B3%E3%82%A2+Os+%E3%81%A8+Kubernetes+%E3%82%92%E5%B1%95%E9%96%8B%E3%81%97%E3%81%BE%E3%81%99%E3%80%82&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ja:クラスター コア Os と Kubernetes を展開します。]][[ja:クラスター コア Os と Kubernetes を展開します。]]&lt;br /&gt;
&amp;lt;span data-link_translate_ar_title=&amp;quot;نشر مجموعة كوبيرنيتيس مع CoreOS&amp;quot;  data-link_translate_ar_url=&amp;quot;%D9%86%D8%B4%D8%B1+%D9%85%D8%AC%D9%85%D9%88%D8%B9%D8%A9+%D9%83%D9%88%D8%A8%D9%8A%D8%B1%D9%86%D9%8A%D8%AA%D9%8A%D8%B3+%D9%85%D8%B9+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ar:نشر مجموعة كوبيرنيتيس مع CoreOS]][[ar:نشر مجموعة كوبيرنيتيس مع CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_zh_title=&amp;quot;部署群集与 CoreOS Kubernetes&amp;quot;  data-link_translate_zh_url=&amp;quot;%E9%83%A8%E7%BD%B2%E7%BE%A4%E9%9B%86%E4%B8%8E+CoreOS+Kubernetes&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:zh:部署群集与 CoreOS Kubernetes]][[zh:部署群集与 CoreOS Kubernetes]]&lt;br /&gt;
&amp;lt;span data-link_translate_de_title=&amp;quot;Bereitstellen eines Clusters Kubernetes mit CoreOS&amp;quot;  data-link_translate_de_url=&amp;quot;Bereitstellen+eines+Clusters+Kubernetes+mit+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:de:Bereitstellen eines Clusters Kubernetes mit CoreOS]][[de:Bereitstellen eines Clusters Kubernetes mit CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_nl_title=&amp;quot;Implementeer een cluster Kubernetes met CoreOS&amp;quot;  data-link_translate_nl_url=&amp;quot;Implementeer+een+cluster+Kubernetes+met+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:nl:Implementeer een cluster Kubernetes met CoreOS]][[nl:Implementeer een cluster Kubernetes met CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_it_title=&amp;quot;Distribuire un cluster Kubernetes con CoreOS&amp;quot;  data-link_translate_it_url=&amp;quot;Distribuire+un+cluster+Kubernetes+con+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:it:Distribuire un cluster Kubernetes con CoreOS]][[it:Distribuire un cluster Kubernetes con CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_pt_title=&amp;quot;Implantar um cluster Kubernetes com CoreOS&amp;quot;  data-link_translate_pt_url=&amp;quot;Implantar+um+cluster+Kubernetes+com+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:pt:Implantar um cluster Kubernetes com CoreOS]][[pt:Implantar um cluster Kubernetes com CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_es_title=&amp;quot;Implementar un clúster Kubernetes con CoreOS&amp;quot;  data-link_translate_es_url=&amp;quot;Implementar+un+cl%C3%BAster+Kubernetes+con+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:es:Implementar un clúster Kubernetes con CoreOS]][[es:Implementar un clúster Kubernetes con CoreOS]]&lt;br /&gt;
&amp;lt;span data-link_translate_en_title=&amp;quot;Deploy a cluster Kubernetes with CoreOS (Deprecated)&amp;quot;  data-link_translate_en_url=&amp;quot;Deploy+a+cluster+Kubernetes+with+CoreOS&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:en:Deploy a cluster Kubernetes with CoreOS]][[en:Deploy a cluster Kubernetes with CoreOS]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Cette procédure est maintenant déprécié du fait qu'elle s'appuie sur fleet qui n'est plus maintenu par CoreOS, veuillez suivre la procédure disponible ici https://fr-wiki.ikoula.com/fr/Deployer_un_cluster_Kubernetes&lt;br /&gt;
&lt;br /&gt;
Cette procédure décrit comment déployer rapidement et simplement un cluster [http://kubernetes.io/ Kubernetes] multi-nodes avec trois instances CoreOS. Kubernetes fonctionnent en mode client - {{Template:Serveur}}, le client Kubernetes est nommé &amp;quot;Kubernetes minion&amp;quot; et le {{Template:Serveur}} &amp;quot;Kubernetes master&amp;quot;. L'instance Kubernetes Master est l'instance qui va orchestrer de manière centralisée les instances Kubernetes Minions. Dans notre exemple, une instance CoreOS jouera la rôle de master Kubernetes et les deux autres instances joueront le rôle de node Kubernetes (minion).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
==Kubernetes==&lt;br /&gt;
Kubernetes est un système d'orchestration Open Source crée par Google permettant la gestion d'application conteneurisées avec Docker sur un cluster de plusieurs hôtes (trois VM CoreOS dans notre exemple). Il permet notamment le déploiement, la maintenance et la scalabilité d'applications. Pour en savoir plus, vous pouvez vous rendre sur [https://github.com/GoogleCloudPlatform/kubernetes/ le github Kubernetes].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
==Déroulé==&lt;br /&gt;
Nous partons du principe que vos trois instances CoreOS sont déjà déployées, qu''''elles peuvent communiquer entre elles''' et que vous y êtes connectés en SSH avec l'utilisateur core.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
Si cela n'est pas déjà fait, mettez à jour vos instances CoreOS afin qu'elles soient à minima en version CoreOS 653.0.0 et incluent Etcd2 (voir notre FAQ  [https://ikoula.wiki/help/Mettre_a_jour_CoreOS_manuellement Mettre à jour CoreOS manuellement]). Dans notre cas toutes nos instances sont en CoreOS stable 681.2.0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cat /etc/lsb-release&lt;br /&gt;
DISTRIB_ID=CoreOS&lt;br /&gt;
DISTRIB_RELEASE=681.2.0&lt;br /&gt;
DISTRIB_CODENAME=&amp;quot;Red Dog&amp;quot;&lt;br /&gt;
DISTRIB_DESCRIPTION=&amp;quot;CoreOS 681.2.0&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
Nous devons également faire en sorte que toutes nos instances CoreOS aient un ID de machine différent pour le bon fonctionnement en context cluster. Pour se faire il suffit de supprimer le fichier /etc/machine-id et de redémarrer chacune de vos instances CoreOS  soit : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo rm -f /etc/machine-id &amp;amp;&amp;amp; sudo reboot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Cela permet également la mise à jour de la version de CoreOS.&lt;br /&gt;
&lt;br /&gt;
=== Configuration de l'instance Kubernetes Master === &amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Ecraser le fichier {{Template:Cloud}}-config.yml par défaut par celui de notre configuration Kubernetes Master en effectuant les commandes suivantes ('''uniquement sur l'instance qui jouera le rôle master et dans le même ordre d'exécution que celui ci-dessous''') :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo wget -O /usr/share/oem/cloud-config.yml ftp://mirror02.ikoula.com/coreos/kubernetes-master.yaml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ export `cat /etc/environment`&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo sed -i 's#PRIVATE_IP#'$COREOS_PRIVATE_IPV4'#g' /usr/share/oem/cloud-config.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
On redémarre notre instance afin que sa configuration soit effective :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo reboot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
On vérifie que notre instance s'est bien initialisée :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo fleetctl list-machines&lt;br /&gt;
MACHINE         IP              METADATA&lt;br /&gt;
aee19a88...     10.1.1.138      role=master&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo etcdctl ls --recursive&lt;br /&gt;
/coreos.com&lt;br /&gt;
/coreos.com/updateengine&lt;br /&gt;
/coreos.com/updateengine/rebootlock&lt;br /&gt;
/coreos.com/updateengine/rebootlock/semaphore&lt;br /&gt;
/coreos.com/network&lt;br /&gt;
/coreos.com/network/config&lt;br /&gt;
/coreos.com/network/subnets&lt;br /&gt;
/coreos.com/network/subnets/10.244.69.0-24&lt;br /&gt;
/registry&lt;br /&gt;
/registry/ranges&lt;br /&gt;
/registry/ranges/serviceips&lt;br /&gt;
/registry/ranges/servicenodeports&lt;br /&gt;
/registry/namespaces&lt;br /&gt;
/registry/namespaces/default&lt;br /&gt;
/registry/services&lt;br /&gt;
/registry/services/endpoints&lt;br /&gt;
/registry/services/endpoints/default&lt;br /&gt;
/registry/services/endpoints/default/kubernetes&lt;br /&gt;
/registry/services/endpoints/default/kubernetes-ro&lt;br /&gt;
/registry/services/specs&lt;br /&gt;
/registry/services/specs/default&lt;br /&gt;
/registry/services/specs/default/kubernetes&lt;br /&gt;
/registry/services/specs/default/kubernetes-ro&lt;br /&gt;
/registry/serviceaccounts&lt;br /&gt;
/registry/serviceaccounts/default&lt;br /&gt;
/registry/serviceaccounts/default/default&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
On peut également voir les services / ports en écoute (on y retrouve les composants {{Template:Serveur}}/master Kubernetes):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo netstat -taupen | grep LISTEN&lt;br /&gt;
tcp        0      0 10.1.1.138:7001         0.0.0.0:*               LISTEN      232        16319      634/etcd2&lt;br /&gt;
tcp        0      0 10.1.1.138:7080         0.0.0.0:*               LISTEN      0          19392      1047/kube-apiserver&lt;br /&gt;
tcp        0      0 0.0.0.0:5000            0.0.0.0:*               LISTEN      0          19142      973/python&lt;br /&gt;
tcp        0      0 127.0.0.1:10251         0.0.0.0:*               LISTEN      0          20047      1075/kube-scheduler&lt;br /&gt;
tcp        0      0 10.1.1.138:6443         0.0.0.0:*               LISTEN      0          19406      1047/kube-apiserver&lt;br /&gt;
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      245        14794      502/systemd-resolve&lt;br /&gt;
tcp        0      0 127.0.0.1:10252         0.0.0.0:*               LISTEN      0          19653      1058/kube-controlle&lt;br /&gt;
tcp        0      0 10.1.1.138:2380         0.0.0.0:*               LISTEN      232        16313      634/etcd2&lt;br /&gt;
tcp6       0      0 :::8080                 :::*                    LISTEN      0          19390      1047/kube-apiserver&lt;br /&gt;
tcp6       0      0 :::22                   :::*                    LISTEN      0          13647      1/systemd&lt;br /&gt;
tcp6       0      0 :::4001                 :::*                    LISTEN      232        16321      634/etcd2&lt;br /&gt;
tcp6       0      0 :::2379                 :::*                    LISTEN      232        16320      634/etcd2&lt;br /&gt;
tcp6       0      0 :::5355                 :::*                    LISTEN      245        14796      502/systemd-resolve&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Configuration des instances Kubernetes Minions=== &amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
Écraser le fichier {{Template:Cloud}}-config.yml par défaut par celui de notre configuration Kubernetes Minion en effectuant les commandes suivantes sur l'ensemble de vos instance qui joueront le rôle de Kubernetes Minion ('''uniquement sur les instances qui joueront le rôle node/minion et dans le même ordre d'exécution que celui ci-dessous''') :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo wget -O /usr/share/oem/cloud-config.yml ftp://mirror02.ikoula.com/coreos/kubernetes-minion.yaml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:27--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ export `cat /etc/environment`&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:28--&amp;gt;&lt;br /&gt;
Attention il faut adapter l'adresse IP privée de votre instance kubernetes master dans la commande ci-dessous ('''remplacez 10.1.1.138 par l'ip privée de votre instance kubernetes master''') la commande ci-dessous :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:29--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo sed -i 's#MASTER_PRIVATE_IP#10.1.1.138#g' /usr/share/oem/cloud-config.yml&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:30--&amp;gt;&lt;br /&gt;
Enfin une fois que vous avez effectuez ces commandes à l'identique sur chacune de vos instances/nodes kubernetes minion, redémarrez celles-ci afin que leur configuration soient effectives et quelles joignent le cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:31--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo reboot&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:32--&amp;gt;&lt;br /&gt;
Nous vérifions que nos deux instances kubernetes minion ont bien rejoint notre cluster (la commande ci-dessous peut être exécutée sur n'importe laquelle de vos instances membre de votre cluster) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:33--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo fleetctl list-machines&lt;br /&gt;
MACHINE         IP              METADATA&lt;br /&gt;
5097f972...     10.1.1.215      role=node&lt;br /&gt;
aee19a88...     10.1.1.138      role=master&lt;br /&gt;
fe86214c...     10.1.1.83       role=node&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:34--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo etcdctl ls --recursive&lt;br /&gt;
/coreos.com&lt;br /&gt;
/coreos.com/updateengine&lt;br /&gt;
/coreos.com/updateengine/rebootlock&lt;br /&gt;
/coreos.com/updateengine/rebootlock/semaphore&lt;br /&gt;
/coreos.com/network&lt;br /&gt;
/coreos.com/network/config&lt;br /&gt;
/coreos.com/network/subnets&lt;br /&gt;
/coreos.com/network/subnets/10.244.69.0-24&lt;br /&gt;
/coreos.com/network/subnets/10.244.38.0-24&lt;br /&gt;
/coreos.com/network/subnets/10.244.23.0-24&lt;br /&gt;
/registry&lt;br /&gt;
/registry/ranges&lt;br /&gt;
/registry/ranges/serviceips&lt;br /&gt;
/registry/ranges/servicenodeports&lt;br /&gt;
/registry/namespaces&lt;br /&gt;
/registry/namespaces/default&lt;br /&gt;
/registry/services&lt;br /&gt;
/registry/services/specs&lt;br /&gt;
/registry/services/specs/default&lt;br /&gt;
/registry/services/specs/default/kubernetes&lt;br /&gt;
/registry/services/specs/default/kubernetes-ro&lt;br /&gt;
/registry/services/endpoints&lt;br /&gt;
/registry/services/endpoints/default&lt;br /&gt;
/registry/services/endpoints/default/kubernetes&lt;br /&gt;
/registry/services/endpoints/default/kubernetes-ro&lt;br /&gt;
/registry/serviceaccounts&lt;br /&gt;
/registry/serviceaccounts/default&lt;br /&gt;
/registry/serviceaccounts/default/default&lt;br /&gt;
/registry/events&lt;br /&gt;
/registry/events/default&lt;br /&gt;
/registry/events/default/10.1.1.215.13ea16c9c70924f4&lt;br /&gt;
/registry/events/default/10.1.1.83.13ea16f74bd4de1c&lt;br /&gt;
/registry/events/default/10.1.1.83.13ea16f77a4e7ab2&lt;br /&gt;
/registry/events/default/10.1.1.215.13ea16c991a4ee57&lt;br /&gt;
/registry/minions&lt;br /&gt;
/registry/minions/10.1.1.215&lt;br /&gt;
/registry/minions/10.1.1.83&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:35--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION2 ~ $ sudo etcdctl ls --recursive&lt;br /&gt;
/coreos.com&lt;br /&gt;
/coreos.com/updateengine&lt;br /&gt;
/coreos.com/updateengine/rebootlock&lt;br /&gt;
/coreos.com/updateengine/rebootlock/semaphore&lt;br /&gt;
/coreos.com/network&lt;br /&gt;
/coreos.com/network/config&lt;br /&gt;
/coreos.com/network/subnets&lt;br /&gt;
/coreos.com/network/subnets/10.244.69.0-24&lt;br /&gt;
/coreos.com/network/subnets/10.244.38.0-24&lt;br /&gt;
/coreos.com/network/subnets/10.244.23.0-24&lt;br /&gt;
/registry&lt;br /&gt;
/registry/ranges&lt;br /&gt;
/registry/ranges/serviceips&lt;br /&gt;
/registry/ranges/servicenodeports&lt;br /&gt;
/registry/namespaces&lt;br /&gt;
/registry/namespaces/default&lt;br /&gt;
/registry/services&lt;br /&gt;
/registry/services/specs&lt;br /&gt;
/registry/services/specs/default&lt;br /&gt;
/registry/services/specs/default/kubernetes&lt;br /&gt;
/registry/services/specs/default/kubernetes-ro&lt;br /&gt;
/registry/services/endpoints&lt;br /&gt;
/registry/services/endpoints/default&lt;br /&gt;
/registry/services/endpoints/default/kubernetes&lt;br /&gt;
/registry/services/endpoints/default/kubernetes-ro&lt;br /&gt;
/registry/serviceaccounts&lt;br /&gt;
/registry/serviceaccounts/default&lt;br /&gt;
/registry/serviceaccounts/default/default&lt;br /&gt;
/registry/events&lt;br /&gt;
/registry/events/default&lt;br /&gt;
/registry/events/default/10.1.1.83.13ea16f77a4e7ab2&lt;br /&gt;
/registry/events/default/10.1.1.215.13ea16c991a4ee57&lt;br /&gt;
/registry/events/default/10.1.1.215.13ea16c9c70924f4&lt;br /&gt;
/registry/events/default/10.1.1.83.13ea16f74bd4de1c&lt;br /&gt;
/registry/minions&lt;br /&gt;
/registry/minions/10.1.1.215&lt;br /&gt;
/registry/minions/10.1.1.83&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:36--&amp;gt;&lt;br /&gt;
Sur nos instances Kubernetes Minion voici les services/ports en écoute (dont le service Kubelet par lequel l'échange d'informations se fait avec le Kubernetes master) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:37--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MINION1 ~ $ sudo netstat -taupen | grep LISTEN&lt;br /&gt;
tcp        0      0 127.0.0.1:10249         0.0.0.0:*               LISTEN      0          18280      849/kube-proxy&lt;br /&gt;
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      245        14843      500/systemd-resolve&lt;br /&gt;
tcp6       0      0 :::49005                :::*                    LISTEN      0          18284      849/kube-proxy&lt;br /&gt;
tcp6       0      0 :::10255                :::*                    LISTEN      0          19213      1025/kubelet&lt;br /&gt;
tcp6       0      0 :::47666                :::*                    LISTEN      0          18309      849/kube-proxy&lt;br /&gt;
tcp6       0      0 :::22                   :::*                    LISTEN      0          13669      1/systemd&lt;br /&gt;
tcp6       0      0 :::4001                 :::*                    LISTEN      232        16106      617/etcd2&lt;br /&gt;
tcp6       0      0 :::4194                 :::*                    LISTEN      0          19096      1025/kubelet&lt;br /&gt;
tcp6       0      0 :::10248                :::*                    LISTEN      0          19210      1025/kubelet&lt;br /&gt;
tcp6       0      0 :::10250                :::*                    LISTEN      0          19305      1025/kubelet&lt;br /&gt;
tcp6       0      0 :::2379                 :::*                    LISTEN      232        16105      617/etcd2&lt;br /&gt;
tcp6       0      0 :::5355                 :::*                    LISTEN      245        14845      500/systemd-resolve&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Vérification de la communication avec l'API du Kubernetes Master== &amp;lt;!--T:38--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:39--&amp;gt;&lt;br /&gt;
'''La Kubernetes UI :'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:40--&amp;gt;&lt;br /&gt;
Pour accéder au dashboard Kubernetes, il vous faut autoriser les connexions au port 8080 (Kubernetes master API server) et effectuer une redirection de port si besoin (zone avancée) vers le port 8080 de votre instance Kubernetes master. Ensuite, il vous suffit d'accéder à l'URL http://''adresse_ip_publique_instance_kubernetes_master'':8080/static/app/#/dashboard/ dans votre navigateur :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:41--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:42--&amp;gt;&lt;br /&gt;
Depuis ce dashboard, il vous est entre autre possible d'afficher des informations sur vos nodes (Kubernetes Minion). Pour cela, vous pouvez cliquez sur &amp;quot;Views&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:43--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:44--&amp;gt;&lt;br /&gt;
Cliquez sur &amp;quot;Nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:45--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-3.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:46--&amp;gt;&lt;br /&gt;
La liste de vos nodes Kubernetes minion apparait :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:47--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-4.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:48--&amp;gt;&lt;br /&gt;
Cliquez sur l'un d'eux pour afficher les informations relatives à ce node (version de Docker, système, KubeProxy et Kubelet,etc.) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:49--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-5.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:50--&amp;gt;&lt;br /&gt;
'''Kubernetes CLI :'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:51--&amp;gt;&lt;br /&gt;
Vous pouvez également utiliser l'outil [https://cloud.google.com/container-engine/docs/kubectl/ Kubectl] depuis votre instance Kubernetes master. Pour se faire, vous devez installer cette utilitaire comme suit :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:52--&amp;gt;&lt;br /&gt;
Une fois connecté en ssh sur votre instance Kubernetes master saisissez les commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:53--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo wget -O /opt/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v0.17.0/bin/linux/amd64/kubectl&lt;br /&gt;
--2015-06-23 11:39:09--  https://storage.googleapis.com/kubernetes-release/release/v0.17.0/bin/linux/amd64/kubectl&lt;br /&gt;
Resolving storage.googleapis.com... 64.233.166.128, 2a00:1450:400c:c09::80&lt;br /&gt;
Connecting to storage.googleapis.com|64.233.166.128|:443... connected.&lt;br /&gt;
HTTP request sent, awaiting response... 200 OK&lt;br /&gt;
Length: 20077224 (19M) [application/octet-stream]&lt;br /&gt;
Saving to: '/opt/bin/kubectl'&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:54--&amp;gt;&lt;br /&gt;
/opt/bin/kubectl                              100%[===================================================================================================&amp;gt;]  19.15M  1.18MB/s   in 16s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:55--&amp;gt;&lt;br /&gt;
2015-06-23 11:39:26 (1.18 MB/s) - '/opt/bin/kubectl' saved [20077224/20077224]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:56--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ sudo chmod 755 /opt/bin/kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:57--&amp;gt;&lt;br /&gt;
Test de la bonne communication avec votre API Kubernetes :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:58--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl get node&lt;br /&gt;
NAME         LABELS                              STATUS&lt;br /&gt;
10.1.1.215   kubernetes.io/hostname=10.1.1.215   Ready&lt;br /&gt;
10.1.1.83    kubernetes.io/hostname=10.1.1.83    Ready&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:59--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl cluster-info&lt;br /&gt;
Kubernetes master is running at http://localhost:8080&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:60--&amp;gt;&lt;br /&gt;
Nous pouvons ainsi déployer un premier container Nginx dans notre cluster :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:61--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl run-container nginx --image=nginx&lt;br /&gt;
CONTROLLER   CONTAINER(S)   IMAGE(S)   SELECTOR              REPLICAS&lt;br /&gt;
nginx        nginx          nginx      run-container=nginx   1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:62--&amp;gt;&lt;br /&gt;
On peut ensuite vérifier sur lequel de nos nodes minions ce container s'est déployé et exécuté ainsi que le nom du pod et l'ip qui lui a était affecté :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:63--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl get pods&lt;br /&gt;
POD           IP            CONTAINER(S)   IMAGE(S)   HOST                    LABELS                STATUS    CREATED     MESSAGE&lt;br /&gt;
nginx-zia71   10.244.38.2                             10.1.1.215/10.1.1.215   run-container=nginx   Running   3 minutes&lt;br /&gt;
                            nginx          nginx                                                    Running   1 minutes&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:64--&amp;gt;&lt;br /&gt;
Nous retrouvons ces mêmes informations via le dashboard de la Kubernete UI en allant dans &amp;quot;Views&amp;quot; puis &amp;quot;Pods&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:65--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-6.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:66--&amp;gt;&lt;br /&gt;
Nous pouvons voir l'IP de l'host sur lequel, ce container s'est déployé, avec le nom du Pod et son adresse IP : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:67--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-7.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:68--&amp;gt;&lt;br /&gt;
En cliquant dessus on obtient des informations plus détaillées sur notre Pod :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:69--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-8.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:70--&amp;gt;&lt;br /&gt;
Nous pouvons stopper notre container simplement :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:71--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl stop rc nginx&lt;br /&gt;
replicationcontrollers/nginx&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:72--&amp;gt;&lt;br /&gt;
Nous pouvons également déployer notre container avec deux replicas :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:73--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl run-container nginx --image=nginx --replicas=2&lt;br /&gt;
CONTROLLER   CONTAINER(S)   IMAGE(S)   SELECTOR              REPLICAS&lt;br /&gt;
nginx        nginx          nginx      run-container=nginx   2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:74--&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
core@Kube-MASTER ~ $ kubectl get pods&lt;br /&gt;
POD           IP            CONTAINER(S)   IMAGE(S)   HOST                    LABELS                STATUS    CREATED          MESSAGE&lt;br /&gt;
nginx-7gen5   10.244.38.3                             10.1.1.215/10.1.1.215   run-container=nginx   Running   About a minute&lt;br /&gt;
                            nginx          nginx                                                    Running   39 seconds&lt;br /&gt;
nginx-w4xue   10.244.23.3                             10.1.1.83/10.1.1.83     run-container=nginx   Running   About a minute&lt;br /&gt;
                            nginx          nginx                                                    Running   About a minute&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:75--&amp;gt;&lt;br /&gt;
[[File:Kubernetes-UI-9.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:76--&amp;gt;&lt;br /&gt;
Pour plus d'informations sur l'architecture, les différents composants et le fonctionnement d'un cluster Kubernetes, nous vous invitons à prendre connaissance de la documentation officielle [https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/design/architecture.md &amp;quot;Kubernetes architecture&amp;quot;] :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:77--&amp;gt;&lt;br /&gt;
[[category:cloudstack]]&lt;br /&gt;
[[category:cloud public]]&lt;br /&gt;
[[category:cloud privé]]&lt;br /&gt;
[[category:Docker]]&lt;br /&gt;
[[category:CoreOS]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;comments /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Comment_redimensionner_le_volume_rootdisk_de_son_instance_Linux&amp;diff=25794</id>
		<title>Comment redimensionner le volume rootdisk de son instance Linux</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Comment_redimensionner_le_volume_rootdisk_de_son_instance_Linux&amp;diff=25794"/>
		<updated>2019-04-01T07:41:58Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : Révocation des modifications de Abrascamp7fad0 (discussion) vers la dernière version de Ikbot&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;span data-link_translate_fr_title=&amp;quot;Comment redimensionner le volume rootdisk de son instance Linux&amp;quot;  data-link_translate_fr_url=&amp;quot;Comment redimensionner le volume rootdisk de son instance Linux&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:fr:Comment redimensionner le volume rootdisk de son instance Linux]][[fr:Comment redimensionner le volume rootdisk de son instance Linux]]&lt;br /&gt;
&amp;lt;span data-link_translate_he_title=&amp;quot;כיצד ניתן לשנות את גודל אמצעי האחסון שלה rootdisk מופע של לינוקס&amp;quot;  data-link_translate_he_url=&amp;quot;%D7%9B%D7%99%D7%A6%D7%93+%D7%A0%D7%99%D7%AA%D7%9F+%D7%9C%D7%A9%D7%A0%D7%95%D7%AA+%D7%90%D7%AA+%D7%92%D7%95%D7%93%D7%9C+%D7%90%D7%9E%D7%A6%D7%A2%D7%99+%D7%94%D7%90%D7%97%D7%A1%D7%95%D7%9F+%D7%A9%D7%9C%D7%94+rootdisk+%D7%9E%D7%95%D7%A4%D7%A2+%D7%A9%D7%9C+%D7%9C%D7%99%D7%A0%D7%95%D7%A7%D7%A1&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:he:כיצד ניתן לשנות את גודל אמצעי האחסון שלה rootdisk מופע של לינוקס]][[he:כיצד ניתן לשנות את גודל אמצעי האחסון שלה rootdisk מופע של לינוקס]]&lt;br /&gt;
&amp;lt;span data-link_translate_ro_title=&amp;quot;Cum pentru a redimensiona volumul său rootdisk de exemplu Linux&amp;quot;  data-link_translate_ro_url=&amp;quot;Cum+pentru+a+redimensiona+volumul+s%C4%83u+rootdisk+de+exemplu+Linux&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ro:Cum pentru a redimensiona volumul său rootdisk de exemplu Linux]][[ro:Cum pentru a redimensiona volumul său rootdisk de exemplu Linux]]&lt;br /&gt;
&amp;lt;span data-link_translate_ru_title=&amp;quot;Как изменить размер тома его rootdisk экземпляр Linux&amp;quot;  data-link_translate_ru_url=&amp;quot;%D0%9A%D0%B0%D0%BA+%D0%B8%D0%B7%D0%BC%D0%B5%D0%BD%D0%B8%D1%82%D1%8C+%D1%80%D0%B0%D0%B7%D0%BC%D0%B5%D1%80+%D1%82%D0%BE%D0%BC%D0%B0+%D0%B5%D0%B3%D0%BE+rootdisk+%D1%8D%D0%BA%D0%B7%D0%B5%D0%BC%D0%BF%D0%BB%D1%8F%D1%80+Linux&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ru:Как изменить размер тома его rootdisk экземпляр Linux]][[ru:Как изменить размер тома его rootdisk экземпляр Linux]]&lt;br /&gt;
&amp;lt;span data-link_translate_pl_title=&amp;quot;Jak zmienić rozmiar woluminu jego partycja wystąpienie Linux&amp;quot;  data-link_translate_pl_url=&amp;quot;Jak+zmieni%C4%87+rozmiar+woluminu+jego+partycja+wyst%C4%85pienie+Linux&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:pl:Jak zmienić rozmiar woluminu jego partycja wystąpienie Linux]][[pl:Jak zmienić rozmiar woluminu jego partycja wystąpienie Linux]]&lt;br /&gt;
&amp;lt;span data-link_translate_ja_title=&amp;quot;その Linux インスタンスのルート ボリュームのサイズを変更する方法&amp;quot;  data-link_translate_ja_url=&amp;quot;%E3%81%9D%E3%81%AE+Linux+%E3%82%A4%E3%83%B3%E3%82%B9%E3%82%BF%E3%83%B3%E3%82%B9%E3%81%AE%E3%83%AB%E3%83%BC%E3%83%88+%E3%83%9C%E3%83%AA%E3%83%A5%E3%83%BC%E3%83%A0%E3%81%AE%E3%82%B5%E3%82%A4%E3%82%BA%E3%82%92%E5%A4%89%E6%9B%B4%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ja:その Linux インスタンスのルート ボリュームのサイズを変更する方法]][[ja:その Linux インスタンスのルート ボリュームのサイズを変更する方法]]&lt;br /&gt;
&amp;lt;span data-link_translate_ar_title=&amp;quot;كيفية تغيير حجم وحدة التخزين في روتديسك مثيل لينكس&amp;quot;  data-link_translate_ar_url=&amp;quot;%D9%83%D9%8A%D9%81%D9%8A%D8%A9+%D8%AA%D8%BA%D9%8A%D9%8A%D8%B1+%D8%AD%D8%AC%D9%85+%D9%88%D8%AD%D8%AF%D8%A9+%D8%A7%D9%84%D8%AA%D8%AE%D8%B2%D9%8A%D9%86+%D9%81%D9%8A+%D8%B1%D9%88%D8%AA%D8%AF%D9%8A%D8%B3%D9%83+%D9%85%D8%AB%D9%8A%D9%84+%D9%84%D9%8A%D9%86%D9%83%D8%B3&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:ar:كيفية تغيير حجم وحدة التخزين في روتديسك مثيل لينكس]][[ar:كيفية تغيير حجم وحدة التخزين في روتديسك مثيل لينكس]]&lt;br /&gt;
&amp;lt;span data-link_translate_zh_title=&amp;quot;如何调整音量大小其 Linux 实例 rootdisk&amp;quot;  data-link_translate_zh_url=&amp;quot;%E5%A6%82%E4%BD%95%E8%B0%83%E6%95%B4%E9%9F%B3%E9%87%8F%E5%A4%A7%E5%B0%8F%E5%85%B6+Linux+%E5%AE%9E%E4%BE%8B+rootdisk&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:zh:如何调整音量大小其 Linux 实例 rootdisk]][[zh:如何调整音量大小其 Linux 实例 rootdisk]]&lt;br /&gt;
&amp;lt;span data-link_translate_de_title=&amp;quot;Wie man dem Volumen ihrer Linux-Instanz Rootdiskette Größe&amp;quot;  data-link_translate_de_url=&amp;quot;Wie+man+dem+Volumen+ihrer+Linux-Instanz+Rootdiskette+Gr%C3%B6%C3%9Fe&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:de:Wie man dem Volumen ihrer Linux-Instanz Rootdiskette Größe]][[de:Wie man dem Volumen ihrer Linux-Instanz Rootdiskette Größe]]&lt;br /&gt;
&amp;lt;span data-link_translate_nl_title=&amp;quot;Hoe te resize het volume zijn Linux aanleg rootdisk&amp;quot;  data-link_translate_nl_url=&amp;quot;Hoe+te+resize+het+volume+zijn+Linux+aanleg+rootdisk&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:nl:Hoe te resize het volume zijn Linux aanleg rootdisk]][[nl:Hoe te resize het volume zijn Linux aanleg rootdisk]]&lt;br /&gt;
&amp;lt;span data-link_translate_it_title=&amp;quot;Come ridimensionare il volume relativo rootdisk istanza di Linux&amp;quot;  data-link_translate_it_url=&amp;quot;Come+ridimensionare+il+volume+relativo+rootdisk+istanza+di+Linux&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:it:Come ridimensionare il volume relativo rootdisk istanza di Linux]][[it:Come ridimensionare il volume relativo rootdisk istanza di Linux]]&lt;br /&gt;
&amp;lt;span data-link_translate_pt_title=&amp;quot;Como redimensionar o volume de seu Linux instância rootdisk&amp;quot;  data-link_translate_pt_url=&amp;quot;Como+redimensionar+o+volume+de+seu+Linux+inst%C3%A2ncia+rootdisk&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:pt:Como redimensionar o volume de seu Linux instância rootdisk]][[pt:Como redimensionar o volume de seu Linux instância rootdisk]]&lt;br /&gt;
&amp;lt;span data-link_translate_es_title=&amp;quot;Cómo cambiar el tamaño el volumen de su Linux instancia rootdisk&amp;quot;  data-link_translate_es_url=&amp;quot;C%C3%B3mo+cambiar+el+tama%C3%B1o+el+volumen+de+su+Linux+instancia+rootdisk&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:es:Cómo cambiar el tamaño el volumen de su Linux instancia rootdisk]][[es:Cómo cambiar el tamaño el volumen de su Linux instancia rootdisk]]&lt;br /&gt;
&amp;lt;span data-link_translate_en_title=&amp;quot;How to resize the volume its Linux instance rootdisk&amp;quot;  data-link_translate_en_url=&amp;quot;How+to+resize+the+volume+its+Linux+instance+rootdisk&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;[[:en:How to resize the volume its Linux instance rootdisk]][[en:How to resize the volume its Linux instance rootdisk]]&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Vous avez déployé une instance GNU/Linux avec un modèle « Sponsorisé » (préparé par nos équipes) avec donc un volume rootdisk de 50GB et souhaitez agrandir ce dernier, cette KB vous explique comment procéder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dans notre exemple, il s’agit d’une instance déployée avec le modèle sponsorisé « Debian 8 – Minimal – 64 bits »  :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Celle-ci dispose d’un volume rootdisk de 50GB et on souhaite augmenter sa taille de 10GB dans notre exemple.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Déroulé==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-	Dans un premier temps votre instance doit être stoppée, stoppez votre instance si ce n’est pas déjà le cas&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-	Cliquez sur « Voir Volumes » (dans l’onglet « Détails » de votre instance) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_2.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-	Cliquez sur le nom du volume roodisk de votre instance :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_3.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-	Cliquez sur l’icône « Redimensionner Volume » :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_4.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-	Saisissez la nouvelle taille que vous souhaitez pour votre volume rootdisk (dans notre cas on veut agrandir de 10GB donc 50 + 10 soit une nouvelle taille de 60GB) puis cliquez sur OK pour valider :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_5.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-	Vérifiez la nouvelle taille de votre volume rootdisk au niveau de l’interface :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_6.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-	Démarrez votre instance &lt;br /&gt;
-	Vérifiez la nouvelle taille de votre volume rootdisk au niveau de votre système (correspond à /dev/xvda) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_7.png]]&lt;br /&gt;
&lt;br /&gt;
Ici on voit que notre disque virtuel /dev/xvda (volume rootdisk) fait bien 60G soit la nouvelle taille.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-	Créez une nouvelle partition avec le nouvel espace disque :&lt;br /&gt;
&lt;br /&gt;
On vérifie dans un premier temps où se termine la dernière partition actuelle (/dev/xvda5) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_8.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On crée la nouvelle partition à partir de la fin de la dernière partition actuelle +1MB et en prenant tout l’espace libre soit :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_9.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On vérifie, on a bien une nouvelle partition primaire /dev/xvda3 qui fait 10G dans notre cas :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_10.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On paramètre le type de notre nouvelle partition (3ème partition d’où le « set 3 ») en LVM (pas une obligation sauf si on souhaite créer un nouveau PV LVM qui permettra d’étendre les volumes LVM actuelles) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_11.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-	On crée un nouveau PV (physical volume) LVM avec notre nouvelle partition :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_12.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-	On étend le  groupe de volume (VG) LVM existant avec notre nouveau PV :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_13.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-	On peut maintenant créer un nouveau volume (LV) LVM ou redimensionner un/des LV existant. Nous choisissons d’étendre le LV &amp;quot;root&amp;quot; existant qui correspond à la racine de notre système :&lt;br /&gt;
&lt;br /&gt;
Avant extension :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_14.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On étend notre LV root avec 100% de l’espace libre disponible de notre groupe de volume (VG) soit de 10G dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_15.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On vérifie :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_16.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre volume (LV) LVM &amp;quot;root&amp;quot; est bien passé, dans notre cas, d’une taille de 48.13g à 58.13g soit 10g de plus.&lt;br /&gt;
&lt;br /&gt;
-	Redimensionnez le système de fichier de votre LV /dev/vg01/root pour qu’il utilise tout l’espace disque :&lt;br /&gt;
&lt;br /&gt;
Avant redimensionnement :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_17.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On redimensionne pour prendre en compte le nouvel espace disque de notre LV LVM :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_18.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On vérifie :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Fichier:Resize_rootdisk_cloudikoula_19.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre système de fichier de notre LV LVM &amp;quot;root&amp;quot; fait maintenant bien 58G soit 10G de plus.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[category:cloudstack]]&lt;br /&gt;
[[category:cloud public]]&lt;br /&gt;
[[category:cloud privé]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;comments /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25619</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25619"/>
		<updated>2019-01-11T13:28:16Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster Kubernetes (k8s) de trois nodes à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer simplement, le node master est le node depuis lequel on gère le cluster Kubernetes (orchestrateur de conteneurs) depuis son API et les nodes workers sont les nodes sur lesquels s'exécuteront les pod soit les conteneurs (Docker dans notre cas). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh pour y exécuter les commandes qui suivront.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple et qui servira d'exemple tout au long de cette procédure :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancée où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - \$basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/\$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présents dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présents dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ajout des nodes workers au cluster ==&lt;br /&gt;
&lt;br /&gt;
Actions à n'effectuer que sur les instances/nodes workers&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajoutés à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajoutés à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier [https://kubernetes.io/docs/concepts/workloads/pods/pod/ pod] dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propres au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifier nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre public votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créez votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Testez l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'aller plus loin en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voire en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/docker-cli-to-kubectl/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[category:cloudstack]]&lt;br /&gt;
[[category:cloud public]]&lt;br /&gt;
[[category:cloud privé]]&lt;br /&gt;
[[category:Docker]]&lt;br /&gt;
[[category:CoreOS]]&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Creer_et_utiliser_un_volume_Docker_NFS&amp;diff=25595</id>
		<title>Creer et utiliser un volume Docker NFS</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Creer_et_utiliser_un_volume_Docker_NFS&amp;diff=25595"/>
		<updated>2018-11-26T16:25:01Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cet article décrit comment créer un volume Docker de type NFS, c'est à dire créer un volume qui va présenter les données d'un export NFS (par exemple un partage nfs depuis un NAS type Synology) puis utiliser celui-ci depuis des containers Docker.&lt;br /&gt;
&lt;br /&gt;
Nous avons effectué cette procédure depuis une instance Cloud Ikoula One  et utiliser l'export NFS d'un NAS Synology mais cette procédure est tout à fait opérationnelle sur un serveur dédié et avec un export NFS standard.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vous avez déjà accès à un système avec Docker installé et d'un export NFS existant.&lt;br /&gt;
&lt;br /&gt;
== Création du volume Docker de type NFS : ==&lt;br /&gt;
&lt;br /&gt;
Voici la commande permettant de créer un volume Docker de type NFS en accès lecture/écriture depuis un export NFS existant :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@ikoula ~]# docker volume create --driver local --opt type=nfs --opt o=addr=&amp;lt;adresse ip serveur nfs&amp;gt;,rw --opt device=:&amp;lt;chemin export nfs&amp;gt; &amp;lt;nom du volume NFS Docker&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: vous pouvez évidemment nommer votre volume Docker comme vous le souhaitez.&lt;br /&gt;
&lt;br /&gt;
ce qui donne dans notre cas (notre volume est créé à partir d'un export NFS &amp;quot;/volume1/datas&amp;quot; d'un NAS synology)   :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume create --driver local --opt type=nfs --opt o=addr=213.246.x.x,rw --opt device=:/volume1/datas synodatas &lt;br /&gt;
synodatas&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre volume NFS est maintenant présent dans la liste des volumes Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume ls&lt;br /&gt;
DRIVER              VOLUME NAME&lt;br /&gt;
local               synodatas&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également inspecter notre volume :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume inspect synodatas&lt;br /&gt;
[&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;CreatedAt&amp;quot;: &amp;quot;2018-11-26T11:00:27+01:00&amp;quot;,&lt;br /&gt;
        &amp;quot;Driver&amp;quot;: &amp;quot;local&amp;quot;,&lt;br /&gt;
        &amp;quot;Labels&amp;quot;: {},&lt;br /&gt;
        &amp;quot;Mountpoint&amp;quot;: &amp;quot;/var/lib/docker/volumes/synodatas/_data&amp;quot;,&lt;br /&gt;
        &amp;quot;Name&amp;quot;: &amp;quot;synodatas&amp;quot;,&lt;br /&gt;
        &amp;quot;Options&amp;quot;: {&lt;br /&gt;
            &amp;quot;device&amp;quot;: &amp;quot;:/volume1/datas&amp;quot;,&lt;br /&gt;
            &amp;quot;o&amp;quot;: &amp;quot;addr=213.246.x.x,rw&amp;quot;,&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;nfs&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;Scope&amp;quot;: &amp;quot;local&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Utilisation du volume Docker de type NFS sur des containers Docker : ==&lt;br /&gt;
&lt;br /&gt;
'''Il faut préalablement avoir installé le client NFS sur l'hôte.''' &lt;br /&gt;
&lt;br /&gt;
Dans notre cas, l'hôte (une instance CIO) est en &amp;quot;Centos7&amp;quot;, il suffit d'installer le paquet &amp;quot;nfs-utils&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# yum install nfs-utils&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons maintenant utiliser notre volume Docker de type NFS créé précédemment sur un ou plusieurs container via la commande suivante : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker run -d  -it --name &amp;lt;Nom container&amp;gt; --mount source=&amp;lt;Nom du volume NFS&amp;gt;,target=&amp;lt;point de montage du contenu du volume NFS dans le container&amp;gt; &amp;lt;Nom image docker&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ce qui donne dans notre cas (on crée un container nommé &amp;quot;deb9&amp;quot; à partir de l'image debian dans lequel on monte le contenu de notre volume NFS &amp;quot;synodatas&amp;quot; sur le point de montage /mnt) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker run -d  -it --name deb9 --mount source=synodatas,target=/mnt debian&lt;br /&gt;
ce6328ab1a44c8c7a07e2fd9c4022d33d394828376d3cb10171bbdeec745371a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
La section &amp;quot;mount&amp;quot; de notre container (&amp;quot;docker inspect deb9) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;quot;Mounts&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;Type&amp;quot;: &amp;quot;volume&amp;quot;,&lt;br /&gt;
                &amp;quot;Name&amp;quot;: &amp;quot;synodatas&amp;quot;,&lt;br /&gt;
                &amp;quot;Source&amp;quot;: &amp;quot;/var/lib/docker/volumes/synodatas/_data&amp;quot;,&lt;br /&gt;
                &amp;quot;Destination&amp;quot;: &amp;quot;/mnt&amp;quot;,&lt;br /&gt;
                &amp;quot;Driver&amp;quot;: &amp;quot;local&amp;quot;,&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;z&amp;quot;,&lt;br /&gt;
                &amp;quot;RW&amp;quot;: true,&lt;br /&gt;
                &amp;quot;Propagation&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        ],&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on se connecte à notre container deb9, on peut lister les fichiers de notre export/volume docker NFS depuis le point de montage :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker exec -it deb9 /bin/bash&lt;br /&gt;
root@ce6328ab1a44:/# ls -1 /mnt/&lt;br /&gt;
file_test1&lt;br /&gt;
file_test2&lt;br /&gt;
file_test3&lt;br /&gt;
file_test4&lt;br /&gt;
file_test5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comme nous avons crée notre volume Docker en lecture/écriture, nous pouvons également créer ou modifier des fichiers sur ce dernier depuis notre container :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@ce6328ab1a44:/# touch /mnt/testfromdocker&lt;br /&gt;
root@ce6328ab1a44:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Vous l'aurez compris cette procédure vous permet d'utiliser du stockage persistant au sein d'un ou plusieurs containers Docker (simultanément ou non) via un volume Docker de type NFS en utilisant par exemple un export NFS de votre NAS.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour aller plus loin :&lt;br /&gt;
&lt;br /&gt;
https://docs.docker.com/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
[[category:cloudstack]]&lt;br /&gt;
[[category:cloud public]]&lt;br /&gt;
[[category:cloud privé]]&lt;br /&gt;
[[category:Docker]]&lt;br /&gt;
[[category:Synology]]&lt;br /&gt;
[[Catégorie:FLEX]]&lt;br /&gt;
[[category:Serveur_dédié]]&lt;br /&gt;
[[Catégorie:Linux]]&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Creer_et_utiliser_un_volume_Docker_NFS&amp;diff=25594</id>
		<title>Creer et utiliser un volume Docker NFS</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Creer_et_utiliser_un_volume_Docker_NFS&amp;diff=25594"/>
		<updated>2018-11-26T16:24:38Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cet article décrit comment créer un volume Docker de type NFS, c'est à dire créer un volume qui va présenter les données d'un export NFS (par exemple un partage nfs depuis un NAS type Synology) puis utiliser celui-ci depuis des containers Docker.&lt;br /&gt;
&lt;br /&gt;
Nous avons effectué cette procédure depuis une instance Cloud Ikoula One  et utiliser l'export NFS d'un NAS Synology mais cette procédure est tout à fait opérationnelle sur un serveur dédié et avec un export NFS standard.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vous avez déjà accès à un système avec Docker installé et d'un export NFS existant.&lt;br /&gt;
&lt;br /&gt;
== Création du volume Docker de type NFS : ==&lt;br /&gt;
&lt;br /&gt;
Voici la commande permettant de créer un volume Docker de type NFS en accès lecture/écriture depuis un export NFS existant :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@ikoula ~]# docker volume create --driver local --opt type=nfs --opt o=addr=&amp;lt;adresse ip serveur nfs&amp;gt;,rw --opt device=:&amp;lt;chemin export nfs&amp;gt; &amp;lt;nom du volume NFS Docker&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: vous pouvez évidemment nommer votre volume Docker comme vous le souhaitez.&lt;br /&gt;
&lt;br /&gt;
ce qui donne dans notre cas (notre volume est créé à partir d'un export NFS &amp;quot;/volume1/datas&amp;quot; d'un NAS synology)   :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume create --driver local --opt type=nfs --opt o=addr=213.246.x.x,rw --opt device=:/volume1/datas synodatas &lt;br /&gt;
synodatas&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre volume NFS est maintenant présent dans la liste des volumes Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume ls&lt;br /&gt;
DRIVER              VOLUME NAME&lt;br /&gt;
local               synodatas&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également inspecter notre volume :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume inspect synodatas&lt;br /&gt;
[&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;CreatedAt&amp;quot;: &amp;quot;2018-11-26T11:00:27+01:00&amp;quot;,&lt;br /&gt;
        &amp;quot;Driver&amp;quot;: &amp;quot;local&amp;quot;,&lt;br /&gt;
        &amp;quot;Labels&amp;quot;: {},&lt;br /&gt;
        &amp;quot;Mountpoint&amp;quot;: &amp;quot;/var/lib/docker/volumes/synodatas/_data&amp;quot;,&lt;br /&gt;
        &amp;quot;Name&amp;quot;: &amp;quot;synodatas&amp;quot;,&lt;br /&gt;
        &amp;quot;Options&amp;quot;: {&lt;br /&gt;
            &amp;quot;device&amp;quot;: &amp;quot;:/volume1/datas&amp;quot;,&lt;br /&gt;
            &amp;quot;o&amp;quot;: &amp;quot;addr=213.246.x.x,rw&amp;quot;,&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;nfs&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;Scope&amp;quot;: &amp;quot;local&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Utilisation du volume Docker de type NFS sur des containers Docker : ==&lt;br /&gt;
&lt;br /&gt;
'''Il faut préalablement avoir installé le client NFS sur l'hôte.''' &lt;br /&gt;
&lt;br /&gt;
Dans notre cas, l'hôte (une instance CIO) est en &amp;quot;Centos7&amp;quot;, il suffit d'installer le paquet &amp;quot;nfs-utils&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# yum install nfs-utils&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons maintenant utiliser notre volume Docker de type NFS créé précédemment sur un ou plusieurs container via la commande suivante : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker run -d  -it --name &amp;lt;Nom container&amp;gt; --mount source=&amp;lt;Nom du volume NFS&amp;gt;,target=&amp;lt;point de montage du contenu du volume NFS dans le container&amp;gt; &amp;lt;Nom image docker&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ce qui donne dans notre cas (on crée un container nommé &amp;quot;deb9&amp;quot; à partir de l'image debian dans lequel on monte le contenu de notre volume NFS &amp;quot;synodatas&amp;quot; sur le point de montage /mnt) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker run -d  -it --name deb9 --mount source=synodatas,target=/mnt debian&lt;br /&gt;
ce6328ab1a44c8c7a07e2fd9c4022d33d394828376d3cb10171bbdeec745371a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
La section &amp;quot;mount&amp;quot; de notre container (&amp;quot;docker inspect deb9) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;quot;Mounts&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;Type&amp;quot;: &amp;quot;volume&amp;quot;,&lt;br /&gt;
                &amp;quot;Name&amp;quot;: &amp;quot;synodatas&amp;quot;,&lt;br /&gt;
                &amp;quot;Source&amp;quot;: &amp;quot;/var/lib/docker/volumes/synodatas/_data&amp;quot;,&lt;br /&gt;
                &amp;quot;Destination&amp;quot;: &amp;quot;/mnt&amp;quot;,&lt;br /&gt;
                &amp;quot;Driver&amp;quot;: &amp;quot;local&amp;quot;,&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;z&amp;quot;,&lt;br /&gt;
                &amp;quot;RW&amp;quot;: true,&lt;br /&gt;
                &amp;quot;Propagation&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        ],&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on se connecte à notre container deb9, on peut lister les fichiers de notre export/volume docker NFS depuis le point de montage :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker exec -it deb9 /bin/bash&lt;br /&gt;
root@ce6328ab1a44:/# ls -1 /mnt/&lt;br /&gt;
file_test1&lt;br /&gt;
file_test2&lt;br /&gt;
file_test3&lt;br /&gt;
file_test4&lt;br /&gt;
file_test5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comme nous avons crée notre volume Docker en lecture/écriture, nous pouvons également créer ou modifier des fichiers sur ce dernier depuis notre container :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@ce6328ab1a44:/# touch /mnt/testfromdocker&lt;br /&gt;
root@ce6328ab1a44:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Vous l'aurez compris cette procédure vous permet d'utiliser du stockage persistant au sein d'un ou plusieurs containers Docker (simultanément ou non) via un volume Docker de type NFS en utilisant par exemple un export NFS de votre NAS.&lt;br /&gt;
&lt;br /&gt;
Pour aller plus loin :&lt;br /&gt;
&lt;br /&gt;
https://docs.docker.com/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
[[category:cloudstack]]&lt;br /&gt;
[[category:cloud public]]&lt;br /&gt;
[[category:cloud privé]]&lt;br /&gt;
[[category:Docker]]&lt;br /&gt;
[[category:Synology]]&lt;br /&gt;
[[Catégorie:FLEX]]&lt;br /&gt;
[[category:Serveur_dédié]]&lt;br /&gt;
[[Catégorie:Linux]]&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Creer_et_utiliser_un_volume_Docker_NFS&amp;diff=25593</id>
		<title>Creer et utiliser un volume Docker NFS</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Creer_et_utiliser_un_volume_Docker_NFS&amp;diff=25593"/>
		<updated>2018-11-26T15:52:39Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cet article décrit comment créer un volume Docker de type NFS, c'est à dire créer un volume qui va présenter les données d'un export NFS (par exemple un partage nfs depuis un NAS type Synology) puis utiliser celui-ci depuis des containers Docker.&lt;br /&gt;
&lt;br /&gt;
Nous avons effectué cette procédure depuis une instance Cloud Ikoula One  et utiliser l'export NFS d'un NAS Synology mais cette procédure est tout à fait opérationnelle sur un serveur dédié et avec un export NFS standard.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vous avez déjà accès à un système avec Docker installé et d'un export NFS existant.&lt;br /&gt;
&lt;br /&gt;
== Création du volume Docker de type NFS : ==&lt;br /&gt;
&lt;br /&gt;
Voici la commande permettant de créer un volume Docker de type NFS en accès lecture/écriture depuis un export NFS existant :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@ikoula ~]# docker volume create --driver local --opt type=nfs --opt o=addr=&amp;lt;adresse ip serveur nfs&amp;gt;,rw --opt device=:&amp;lt;chemin export nfs&amp;gt; &amp;lt;nom du volume NFS Docker&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: vous pouvez évidemment nommer votre volume Docker comme vous le souhaitez.&lt;br /&gt;
&lt;br /&gt;
ce qui donne dans notre cas (notre volume est créé à partir d'un export NFS &amp;quot;/volume1/datas&amp;quot; d'un NAS synology)   :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume create --driver local --opt type=nfs --opt o=addr=213.246.x.x,rw --opt device=:/volume1/datas synodatas &lt;br /&gt;
synodatas&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre volume NFS est maintenant présent dans la liste des volumes Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume ls&lt;br /&gt;
DRIVER              VOLUME NAME&lt;br /&gt;
local               synodatas&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également inspecter notre volume :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume inspect synodatas&lt;br /&gt;
[&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;CreatedAt&amp;quot;: &amp;quot;2018-11-26T11:00:27+01:00&amp;quot;,&lt;br /&gt;
        &amp;quot;Driver&amp;quot;: &amp;quot;local&amp;quot;,&lt;br /&gt;
        &amp;quot;Labels&amp;quot;: {},&lt;br /&gt;
        &amp;quot;Mountpoint&amp;quot;: &amp;quot;/var/lib/docker/volumes/synodatas/_data&amp;quot;,&lt;br /&gt;
        &amp;quot;Name&amp;quot;: &amp;quot;synodatas&amp;quot;,&lt;br /&gt;
        &amp;quot;Options&amp;quot;: {&lt;br /&gt;
            &amp;quot;device&amp;quot;: &amp;quot;:/volume1/datas&amp;quot;,&lt;br /&gt;
            &amp;quot;o&amp;quot;: &amp;quot;addr=213.246.x.x,rw&amp;quot;,&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;nfs&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;Scope&amp;quot;: &amp;quot;local&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Utilisation du volume Docker de type NFS sur des containers Docker : ==&lt;br /&gt;
&lt;br /&gt;
'''Il faut préalablement avoir installé le client NFS sur l'hôte.''' &lt;br /&gt;
&lt;br /&gt;
Dans notre cas, l'hôte (une instance CIO) est en &amp;quot;Centos7&amp;quot;, il suffit d'installer le paquet &amp;quot;nfs-utils&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# yum install nfs-utils&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons maintenant utiliser notre volume Docker de type NFS créé précédemment sur un ou plusieurs container via la commande suivante : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker run -d  -it --name &amp;lt;Nom container&amp;gt; --mount source=&amp;lt;Nom du volume NFS&amp;gt;,target=&amp;lt;point de montage du contenu du volume NFS dans le container&amp;gt; &amp;lt;Nom image docker&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ce qui donne dans notre cas (on crée un container nommé &amp;quot;deb9&amp;quot; à partir de l'image debian dans lequel on monte le contenu de notre volume NFS &amp;quot;synodatas&amp;quot; sur le point de montage /mnt) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker run -d  -it --name deb9 --mount source=synodatas,target=/mnt debian&lt;br /&gt;
ce6328ab1a44c8c7a07e2fd9c4022d33d394828376d3cb10171bbdeec745371a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
La section &amp;quot;mount&amp;quot; de notre container (&amp;quot;docker inspect deb9) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;quot;Mounts&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;Type&amp;quot;: &amp;quot;volume&amp;quot;,&lt;br /&gt;
                &amp;quot;Name&amp;quot;: &amp;quot;synodatas&amp;quot;,&lt;br /&gt;
                &amp;quot;Source&amp;quot;: &amp;quot;/var/lib/docker/volumes/synodatas/_data&amp;quot;,&lt;br /&gt;
                &amp;quot;Destination&amp;quot;: &amp;quot;/mnt&amp;quot;,&lt;br /&gt;
                &amp;quot;Driver&amp;quot;: &amp;quot;local&amp;quot;,&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;z&amp;quot;,&lt;br /&gt;
                &amp;quot;RW&amp;quot;: true,&lt;br /&gt;
                &amp;quot;Propagation&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        ],&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on se connecte à notre container deb9, on peut lister les fichiers de notre export/volume docker NFS depuis le point de montage :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker exec -it deb9 /bin/bash&lt;br /&gt;
root@ce6328ab1a44:/# ls -1 /mnt/&lt;br /&gt;
file_test1&lt;br /&gt;
file_test2&lt;br /&gt;
file_test3&lt;br /&gt;
file_test4&lt;br /&gt;
file_test5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comme nous avons crée notre volume Docker en lecture/écriture, nous pouvons également créer ou modifier des fichiers sur ce dernier depuis notre container :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@ce6328ab1a44:/# touch /mnt/testfromdocker&lt;br /&gt;
root@ce6328ab1a44:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Vous l'aurez compris cette procédure vous permet d'utiliser du stockage persistant au sein d'un ou plusieurs containers Docker (simultanément ou non) via un volume Docker de type NFS en utilisant par exemple un export NFS de votre NAS.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[category:cloudstack]]&lt;br /&gt;
[[category:cloud public]]&lt;br /&gt;
[[category:cloud privé]]&lt;br /&gt;
[[category:Docker]]&lt;br /&gt;
[[category:Synology]]&lt;br /&gt;
[[Catégorie:FLEX]]&lt;br /&gt;
[[category:Serveur_dédié]]&lt;br /&gt;
[[Catégorie:Linux]]&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Creer_et_utiliser_un_volume_Docker_NFS&amp;diff=25592</id>
		<title>Creer et utiliser un volume Docker NFS</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Creer_et_utiliser_un_volume_Docker_NFS&amp;diff=25592"/>
		<updated>2018-11-26T11:40:30Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cet article décrit comment créer un volume Docker de type NFS, c'est à dire créer un volume qui va présenter les données d'un export NFS (par exemple un partage nfs depuis un NAS type Synology) puis utiliser celui-ci depuis des containers Docker.&lt;br /&gt;
&lt;br /&gt;
Nous avons effectué cette procédure depuis une instance Cloud Ikoula One  et utiliser l'export NFS d'un NAS Synology mais cette procédure est tout à fait opérationnelle sur un serveur dédié et avec un export NFS standard.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vous avez déjà accès à un système avec Docker installé et d'un export NFS existant.&lt;br /&gt;
&lt;br /&gt;
== Création du volume Docker de type NFS : ==&lt;br /&gt;
&lt;br /&gt;
Voici la commande permettant de créer un volume Docker de type NFS en accès lecture/écriture depuis un export NFS existant :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@ikoula ~]# docker volume create --driver local --opt type=nfs --opt o=addr=&amp;lt;adresse ip serveur nfs&amp;gt;,rw --opt device=:&amp;lt;chemin export nfs&amp;gt; &amp;lt;nom du volume NFS Docker&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: vous pouvez évidemment nommer votre volume Docker comme vous le souhaitez.&lt;br /&gt;
&lt;br /&gt;
ce qui donne dans notre cas (notre volume est créé à partir d'un export NFS &amp;quot;/volume1/datas&amp;quot; d'un NAS synology)   :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume create --driver local --opt type=nfs --opt o=addr=213.246.x.x,rw --opt device=:/volume1/datas synodatas &lt;br /&gt;
synodatas&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre volume NFS est maintenant présent dans la liste des volumes Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume ls&lt;br /&gt;
DRIVER              VOLUME NAME&lt;br /&gt;
local               synodatas&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également inspecter notre volume :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume inspect synodatas&lt;br /&gt;
[&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;CreatedAt&amp;quot;: &amp;quot;2018-11-26T11:00:27+01:00&amp;quot;,&lt;br /&gt;
        &amp;quot;Driver&amp;quot;: &amp;quot;local&amp;quot;,&lt;br /&gt;
        &amp;quot;Labels&amp;quot;: {},&lt;br /&gt;
        &amp;quot;Mountpoint&amp;quot;: &amp;quot;/var/lib/docker/volumes/synodatas/_data&amp;quot;,&lt;br /&gt;
        &amp;quot;Name&amp;quot;: &amp;quot;synodatas&amp;quot;,&lt;br /&gt;
        &amp;quot;Options&amp;quot;: {&lt;br /&gt;
            &amp;quot;device&amp;quot;: &amp;quot;:/volume1/datas&amp;quot;,&lt;br /&gt;
            &amp;quot;o&amp;quot;: &amp;quot;addr=213.246.x.x,rw&amp;quot;,&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;nfs&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;Scope&amp;quot;: &amp;quot;local&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Utilisation du volume Docker de type NFS sur des containers Docker : ==&lt;br /&gt;
&lt;br /&gt;
'''Il faut préalablement avoir installé le client NFS sur l'hôte.''' &lt;br /&gt;
&lt;br /&gt;
Dans notre cas, l'hôte (une instance CIO) est en &amp;quot;Centos7&amp;quot;, il suffit d'installer le paquet &amp;quot;nfs-utils&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# yum install nfs-utils&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons maintenant utiliser notre volume Docker de type NFS créé précédemment sur un ou plusieurs container via la commande suivante : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker run -d  -it --name &amp;lt;Nom container&amp;gt; --mount source=&amp;lt;Nom du volume NFS&amp;gt;,target=&amp;lt;point de montage du contenu du volume NFS dans le container&amp;gt; &amp;lt;Nom image docker&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ce qui donne dans notre cas (on crée un container nommé &amp;quot;deb9&amp;quot; à partir de l'image debian dans lequel on monte le contenu de notre volume NFS &amp;quot;synodatas&amp;quot; sur le point de montage /mnt) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker run --privileged=true -d  -it --name deb9 --mount source=synodatas,target=/mnt debian&lt;br /&gt;
ce6328ab1a44c8c7a07e2fd9c4022d33d394828376d3cb10171bbdeec745371a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
La section &amp;quot;mount&amp;quot; de notre container (&amp;quot;docker inspect deb9) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;quot;Mounts&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;Type&amp;quot;: &amp;quot;volume&amp;quot;,&lt;br /&gt;
                &amp;quot;Name&amp;quot;: &amp;quot;synodatas&amp;quot;,&lt;br /&gt;
                &amp;quot;Source&amp;quot;: &amp;quot;/var/lib/docker/volumes/synodatas/_data&amp;quot;,&lt;br /&gt;
                &amp;quot;Destination&amp;quot;: &amp;quot;/mnt&amp;quot;,&lt;br /&gt;
                &amp;quot;Driver&amp;quot;: &amp;quot;local&amp;quot;,&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;z&amp;quot;,&lt;br /&gt;
                &amp;quot;RW&amp;quot;: true,&lt;br /&gt;
                &amp;quot;Propagation&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        ],&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on se connecte à notre container deb9, on peut lister les fichiers de notre export/volume docker NFS depuis le point de montage :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker exec -it deb9 /bin/bash&lt;br /&gt;
root@ce6328ab1a44:/# ls -1 /mnt/&lt;br /&gt;
file_test1&lt;br /&gt;
file_test2&lt;br /&gt;
file_test3&lt;br /&gt;
file_test4&lt;br /&gt;
file_test5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comme nous avons crée notre volume Docker en lecture/écriture, nous pouvons également créer ou modifier des fichiers sur ce dernier depuis notre container :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@ce6328ab1a44:/# touch /mnt/testfromdocker&lt;br /&gt;
root@ce6328ab1a44:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Vous l'aurez compris cette procédure vous permet d'utiliser du stockage persistent au sein d'un ou plusieurs containers Docker (simultanément ou non) via un volume Docker de type NFS en utilisant par exemple un export NFS de votre NAS.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Creer_et_utiliser_un_volume_Docker_NFS&amp;diff=25591</id>
		<title>Creer et utiliser un volume Docker NFS</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Creer_et_utiliser_un_volume_Docker_NFS&amp;diff=25591"/>
		<updated>2018-11-26T11:24:41Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : Page créée avec « Cet article décrit comment créer un volume Docker de type NFS, c'est à dire créer un volume qui va présenter les données d'un export NFS (par exemple d'un partage nf... »&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cet article décrit comment créer un volume Docker de type NFS, c'est à dire créer un volume qui va présenter les données d'un export NFS (par exemple d'un partage nfs depuis un NAS type Synology) puis utiliser celui-ci depuis des containers Docker.&lt;br /&gt;
&lt;br /&gt;
Nous avons effectué cette procédure depuis une instance Cloud Ikoula One  et utiliser l'export NFS d'un NAS Synology mais cette procédure est tout à fait opérationnelle sur un serveur dédié.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vous avez déjà accès à un système avec Docker et d'un export NFS accessible.&lt;br /&gt;
&lt;br /&gt;
== Création du volume Docker de type NFS : ==&lt;br /&gt;
&lt;br /&gt;
Voici la commande permettant de créer un volume Docker de type NFS en accès lecture/écriture depuis un export NFS existant :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@ikoula ~]# docker volume create --driver local --opt type=nfs --opt o=addr=&amp;lt;adresse ip serveur nfs&amp;gt;,rw --opt device=:&amp;lt;chemin export nfs&amp;gt; &amp;lt;nom du volume NFS Docker&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ce qui donne dans notre cas (notre volume est créé à partir d'un export NFS &amp;quot;/volume1/datas&amp;quot; d'un NAS synology)   :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume create --driver local --opt type=nfs --opt o=addr=213.246.x.x,rw --opt device=:/volume1/datas synodatas &lt;br /&gt;
synodatas&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre volume NFS est maintenant présent dans la liste des volumes Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume ls&lt;br /&gt;
DRIVER              VOLUME NAME&lt;br /&gt;
local               synodatas&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également inspecter notre volume :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker volume inspect synodatas&lt;br /&gt;
[&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;CreatedAt&amp;quot;: &amp;quot;2018-11-26T11:00:27+01:00&amp;quot;,&lt;br /&gt;
        &amp;quot;Driver&amp;quot;: &amp;quot;local&amp;quot;,&lt;br /&gt;
        &amp;quot;Labels&amp;quot;: {},&lt;br /&gt;
        &amp;quot;Mountpoint&amp;quot;: &amp;quot;/var/lib/docker/volumes/synodatas/_data&amp;quot;,&lt;br /&gt;
        &amp;quot;Name&amp;quot;: &amp;quot;synodatas&amp;quot;,&lt;br /&gt;
        &amp;quot;Options&amp;quot;: {&lt;br /&gt;
            &amp;quot;device&amp;quot;: &amp;quot;:/volume1/datas&amp;quot;,&lt;br /&gt;
            &amp;quot;o&amp;quot;: &amp;quot;addr=213.246.x.x,rw&amp;quot;,&lt;br /&gt;
            &amp;quot;type&amp;quot;: &amp;quot;nfs&amp;quot;&lt;br /&gt;
        },&lt;br /&gt;
        &amp;quot;Scope&amp;quot;: &amp;quot;local&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Utilisation du volume Docker de type NFS sur des containers Docker : ==&lt;br /&gt;
&lt;br /&gt;
Il faut avant tout installer le client NFS sur l'hôte. &lt;br /&gt;
&lt;br /&gt;
Dans notre cas, l'hôte est en &amp;quot;Centos7&amp;quot;, il suffit d'installer le paquet &amp;quot;nfs-utils&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# yum install nfs-utils&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons maintenant utiliser notre volume Docker de type NFS sur un ou plusieurs container via la commande suivante : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker run -d  -it --name &amp;lt;Nom container&amp;gt; --mount source=&amp;lt;Nom du volume NFS&amp;gt;,target=&amp;lt;point de montage du contenu du volume NFS dans le container&amp;gt; &amp;lt;Nom image docker&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ce qui donne dans notre cas (on crée un container nommé &amp;quot;deb9&amp;quot; à partir de l'image debian dans lequel on monte le contenu de notre volume NFS &amp;quot;synodatas&amp;quot; sur le point de montage /mnt) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker run --privileged=true -d  -it --name deb9 --mount source=synodatas,target=/mnt debian&lt;br /&gt;
ce6328ab1a44c8c7a07e2fd9c4022d33d394828376d3cb10171bbdeec745371a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
La section &amp;quot;mount&amp;quot; de notre container (&amp;quot;docker inspect deb9) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;quot;Mounts&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;Type&amp;quot;: &amp;quot;volume&amp;quot;,&lt;br /&gt;
                &amp;quot;Name&amp;quot;: &amp;quot;synodatas&amp;quot;,&lt;br /&gt;
                &amp;quot;Source&amp;quot;: &amp;quot;/var/lib/docker/volumes/synodatas/_data&amp;quot;,&lt;br /&gt;
                &amp;quot;Destination&amp;quot;: &amp;quot;/mnt&amp;quot;,&lt;br /&gt;
                &amp;quot;Driver&amp;quot;: &amp;quot;local&amp;quot;,&lt;br /&gt;
                &amp;quot;Mode&amp;quot;: &amp;quot;z&amp;quot;,&lt;br /&gt;
                &amp;quot;RW&amp;quot;: true,&lt;br /&gt;
                &amp;quot;Propagation&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        ],&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on se connecte à notre container deb9, on peut lister les fichiers de notre export/volume docker NFS depuis le point de montage :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@CentOS7 ~]# docker exec -it deb9 /bin/bash&lt;br /&gt;
root@ce6328ab1a44:/# ls -1 /mnt/&lt;br /&gt;
file_test1&lt;br /&gt;
file_test2&lt;br /&gt;
file_test3&lt;br /&gt;
file_test4&lt;br /&gt;
file_test5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Comme nous avons crée notre volume Docker en lecture/écriture, nous pouvons également créer ou modifier des fichiers sur ce dernier depuis notre container :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
root@ce6328ab1a44:/# touch /mnt/testfromdocker&lt;br /&gt;
root@ce6328ab1a44:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Vous l'aurez compris cette procédure vous permet d'utiliser du stockage persistent au sein d'un ou plusieurs containers Docker via un volume Docker de type NFS en utilisant par exemple un export NFS de votre NAS.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25563</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25563"/>
		<updated>2018-11-08T09:31:37Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster Kubernetes (k8s) de trois nodes à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer simplement, le node master est le node depuis lequel on gère le cluster Kubernetes (orchestrateur de conteneurs) depuis son API et les nodes workers sont les nodes sur lesquels s'exécuteront les pod soit les conteneurs (Docker dans notre cas). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh pour y exécuter les commandes qui suivront.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple et qui servira d'exemple tout au long de cette procédure :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancée où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - \$basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/\$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présents dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présents dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ajout des nodes workers au cluster ==&lt;br /&gt;
&lt;br /&gt;
Actions à n'effectuer que sur les instances/nodes workers&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajoutés à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajoutés à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier [https://kubernetes.io/docs/concepts/workloads/pods/pod/ pod] dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propres au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifier nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre public votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créez votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Testez l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'aller plus loin en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voire en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[category:cloudstack]]&lt;br /&gt;
[[category:cloud public]]&lt;br /&gt;
[[category:cloud privé]]&lt;br /&gt;
[[category:Docker]]&lt;br /&gt;
[[category:CoreOS]]&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25562</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25562"/>
		<updated>2018-11-08T09:29:27Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster Kubernetes (k8s) de trois nodes à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer simplement, le node master est le node depuis lequel on gère le cluster Kubernetes (orchestrateur de conteneurs) depuis son API et les nodes workers sont les nodes sur lesquels s'exécuteront les pod soit les conteneurs (Docker dans notre cas). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh pour y exécuter les commandes qui suivront.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple et qui servira d'exemple tout au long de cette procédure :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancée où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présents dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présents dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ajout des nodes workers au cluster ==&lt;br /&gt;
&lt;br /&gt;
Actions à n'effectuer que sur les instances/nodes workers&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajoutés à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajoutés à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier [https://kubernetes.io/docs/concepts/workloads/pods/pod/ pod] dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propres au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifier nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre public votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créez votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Testez l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'aller plus loin en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voire en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[category:cloudstack]]&lt;br /&gt;
[[category:cloud public]]&lt;br /&gt;
[[category:cloud privé]]&lt;br /&gt;
[[category:Docker]]&lt;br /&gt;
[[category:CoreOS]]&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25559</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25559"/>
		<updated>2018-11-07T09:38:20Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Initialisation du cluster Kubernetes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster Kubernetes (k8s) de trois nodes à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer simplement, le node master est le node depuis lequel on gère le cluster Kubernetes (orchestrateur de conteneurs) depuis son API et les nodes workers sont les nodes sur lesquels s'exécuteront les pod soit les conteneurs (Docker dans notre cas). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh pour y exécuter les commandes qui suivront.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple et qui servira d'exemple tout au long de cette procédure :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancée où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présents dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présents dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ajout des nodes workers au cluster ==&lt;br /&gt;
&lt;br /&gt;
Actions à n'effectuer que sur les instances/nodes workers&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajoutés à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajoutés à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier [https://kubernetes.io/docs/concepts/workloads/pods/pod/ pod] dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propres au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifier nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre public votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créez votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Testez l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'aller plus loin en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voire en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25558</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25558"/>
		<updated>2018-11-07T09:34:57Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster Kubernetes (k8s) de trois nodes à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer simplement, le node master est le node depuis lequel on gère le cluster Kubernetes (orchestrateur de conteneurs) depuis son API et les nodes workers sont les nodes sur lesquels s'exécuteront les pod soit les conteneurs (Docker dans notre cas). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh pour y exécuter les commandes qui suivront.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple et qui servira d'exemple tout au long de cette procédure :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancée où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présents dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ajout des nodes workers au cluster ==&lt;br /&gt;
&lt;br /&gt;
Actions à n'effectuer que sur les instances/nodes workers&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajoutés à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajoutés à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier [https://kubernetes.io/docs/concepts/workloads/pods/pod/ pod] dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propres au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifier nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre public votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créez votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Testez l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'aller plus loin en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voire en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25557</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25557"/>
		<updated>2018-11-07T09:33:54Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster Kubernetes (k8s) de trois nodes à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer simplement, le node master est le node depuis lequel on gère le cluster Kubernetes (orchestrateur de conteneurs) depuis son API et les nodes workers sont les nodes sur lesquels s'exécuteront les pod soit les conteneurs Docker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh pour y exécuter les commandes qui suivront.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple et qui servira d'exemple tout au long de cette procédure :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancée où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présents dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ajout des nodes workers au cluster ==&lt;br /&gt;
&lt;br /&gt;
Actions à n'effectuer que sur les instances/nodes workers&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajoutés à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajoutés à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier [https://kubernetes.io/docs/concepts/workloads/pods/pod/ pod] dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propres au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifier nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre public votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créez votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Testez l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'aller plus loin en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voire en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25556</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25556"/>
		<updated>2018-11-07T09:24:23Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Actions à n'effectuer que sur les instances/nodes worker */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster Kubernetes (k8s) de trois nodes à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer simplement, le node master est le node depuis lequel on gère le cluster Kubernetes depuis son API et les nodes workers sont les nodes sur lesquels s'exécuteront les pod soit les conteneurs Docker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh pour y exécuter les commandes qui suivront.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple et qui servira d'exemple tout au long de cette procédure :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancée où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présents dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ajout des nodes workers au cluster ==&lt;br /&gt;
&lt;br /&gt;
Actions à n'effectuer que sur les instances/nodes workers&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajoutés à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajoutés à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier [https://kubernetes.io/docs/concepts/workloads/pods/pod/ pod] dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propres au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifier nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre public votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créez votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Testez l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'aller plus loin en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voire en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25555</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25555"/>
		<updated>2018-11-07T07:49:11Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster Kubernetes (k8s) de trois nodes à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer simplement, le node master est le node depuis lequel on gère le cluster Kubernetes depuis son API et les nodes workers sont les nodes sur lesquels s'exécuteront les pod soit les conteneurs Docker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh pour y exécuter les commandes qui suivront.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple et qui servira d'exemple tout au long de cette procédure :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancée où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présents dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajoutés à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajoutés à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier [https://kubernetes.io/docs/concepts/workloads/pods/pod/ pod] dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propres au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifier nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre public votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créez votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Testez l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'aller plus loin en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voire en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25553</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25553"/>
		<updated>2018-11-06T10:07:17Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Déploiement d'un premier pod */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster Kubernetes (k8s) de trois nodes à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer simplement, le node master est le node depuis lequel on gère le cluster Kubernetes depuis son API et les nodes workers sont les nodes sur lesquelles s'exécuteront les pod soit les conteneurs Docker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh pour y exécuter les commandes qui suivront.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple et qui servira d'exemple tout au long de cette procédure :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier [https://kubernetes.io/docs/concepts/workloads/pods/pod/ pod] dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre publique votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'allez plus loin en en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voir en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25552</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25552"/>
		<updated>2018-11-06T10:05:48Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Initialisation du cluster Kubernetes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster Kubernetes (k8s) de trois nodes à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer simplement, le node master est le node depuis lequel on gère le cluster Kubernetes depuis son API et les nodes workers sont les nodes sur lesquelles s'exécuteront les pod soit les conteneurs Docker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh pour y exécuter les commandes qui suivront.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple et qui servira d'exemple tout au long de cette procédure :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier [https://kubernetes.io/docs/concepts/workloads/pods/pod/ pod] dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre publique votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'allez plus loin en en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voir en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25551</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25551"/>
		<updated>2018-11-06T10:03:45Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Préparation du système et installation de Kubernetes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster Kubernetes (k8s) de trois nodes à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer simplement, le node master est le node depuis lequel on gère le cluster Kubernetes depuis son API et les nodes workers sont les nodes sur lesquelles s'exécuteront les pod soit les conteneurs Docker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh pour y exécuter les commandes qui suivront.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple et qui servira d'exemple tout au long de cette procédure :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier [https://kubernetes.io/docs/concepts/workloads/pods/pod/ pod] dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre publique votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'allez plus loin en en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voir en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25550</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25550"/>
		<updated>2018-11-06T10:03:06Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster Kubernetes (k8s) de trois nodes à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer simplement, le node master est le node depuis lequel on gère le cluster Kubernetes depuis son API et les nodes workers sont les nodes sur lesquelles s'exécuteront les pod soit les conteneurs Docker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh pour y exécuter les commandes qui suivront.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple et qui servira d'exemple tout au long de cette procédure :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier [https://kubernetes.io/docs/concepts/workloads/pods/pod/ pod] dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre publique votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'allez plus loin en en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voir en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25549</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25549"/>
		<updated>2018-11-06T10:02:02Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster Kubernetes (k8s) de trois nodes à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer simplement le node master est le node depuis lequel on gère le cluster Kubernetes depuis son API et les nodes workers sont les nodes sur lesquelles s'exécuteront les pod soit les conteneurs Docker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh pour y exécuter les commandes qui suivront.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple et qui servira d'exemple tout au long de cette procédure :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier [https://kubernetes.io/docs/concepts/workloads/pods/pod/ pod] dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre publique votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'allez plus loin en en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voir en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25548</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25548"/>
		<updated>2018-11-06T09:57:04Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier [https://kubernetes.io/docs/concepts/workloads/pods/pod/ pod] dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre publique votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'allez plus loin en en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voir en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25547</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25547"/>
		<updated>2018-11-06T09:54:18Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Déploiement d'un premier pod */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre publique votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur (via l'ip publique de votre réseau sur laquelle vous avez crée la règle LB) :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'allez plus loin en en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voir en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25546</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25546"/>
		<updated>2018-11-06T09:52:47Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Déploiement d'un premier pod */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre publique votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker.&lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'allez plus loin en en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voir en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25545</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25545"/>
		<updated>2018-11-06T09:51:28Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Allez plus loin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre publique votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker. &lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'allez plus loin en en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voir en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25544</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25544"/>
		<updated>2018-11-06T09:51:10Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre publique votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker. &lt;br /&gt;
&lt;br /&gt;
== Allez plus loin ==&lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'allez plus loin en en déployant le dashboard Kubernetes ou en créant par exemple des volumes persistants pour vos pods, en augmentant le nombre de vos nodes worker, voir en redondant le rôle master pour faire de la haute disponibilité ou encore de dédier des nodes à certains composants tel que Etcd par exemple. . &lt;br /&gt;
&lt;br /&gt;
Voici quelques liens utiles :&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/reference/kubectl/cheatsheet/ &lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/concepts/storage/volumes/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;br /&gt;
&lt;br /&gt;
https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25543</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25543"/>
		<updated>2018-11-06T09:33:14Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
veuillez penser à également commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s’initialise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker (ne pas faire sur votre instance master), lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Vérification de l'état du cluster  ==&lt;br /&gt;
&lt;br /&gt;
Actions à effectuer depuis l'instance/node master&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque: On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Déploiement d'un premier pod ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod dans notre cluster Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de la commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de la liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre au fonctionnement de Kubernetes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant cette même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service (de type NodePort) via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous pouvez également simplement exécuter une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Il ne vous reste donc plus qu'à créer votre règle de load balancing sur votre réseau Cloud Ikoula One pour accéder à /rendre publique votre serveur web (pod nginx)  :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est rendu possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci/ceux-ci (en cas de réplicats).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vous venez donc de déployer un cluster Kubernetes de base de 3 nodes avec un master et deux worker. &lt;br /&gt;
&lt;br /&gt;
Il vous est possible d'allez plus loin en créant par exemple des volumes persistants pour vos pods ou en augmentant le nombre de vos nodes worker, voir de redondé votre master pour faire de la haute disponibilité ou encore de dédié des nodes à certains composants tel que Etcd. Voici quelques liens&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25542</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25542"/>
		<updated>2018-11-06T09:15:36Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Préparation du système et installation de Kubernetes : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes : ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25541</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25541"/>
		<updated>2018-11-06T09:14:27Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Action à n'effectuer que sur l'instance node master : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes : ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initialisation du cluster Kubernetes : ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes ne sont à effectuer que sur l'instance node master &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lancez l’initialisation de votre cluster Kubernetes via la commande ci-dessous en prenant soin de modifier la valeur du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par l'adresse ip de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez ne pas modifier l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; car celui-ci permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi doit ressembler le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
On crée un répertoire et fichier de configuration dans le répertoire de notre utilisateur (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On déploie notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie par le retour  de la commande d'initialisation de côté (&amp;quot;kubeadm join...&amp;quot;) afin d'exécuter celle-ci sur nos instances workers par la suite pour les joindre à notre cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut maintenant faire les premières vérifications de notre cluster depuis notre instance master  :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes au cluster.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remarque : Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25540</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25540"/>
		<updated>2018-11-06T09:04:17Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Préparation du système et installation de Kubernetes : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes : ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root (ou avec les droits sudo nécessaires).&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts sur chacune de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectif (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS). &lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Puis installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour y ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap, vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadmsi vous ne désactivez pas celle-ci) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25539</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25539"/>
		<updated>2018-11-06T08:57:23Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Préparation du système et installation de Kubernetes : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes : ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait résolveur DNS interne). &lt;br /&gt;
&lt;br /&gt;
Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25538</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25538"/>
		<updated>2018-11-06T08:56:06Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Préparation du système et installation de Kubernetes : ==&lt;br /&gt;
&lt;br /&gt;
Les actions suivantes sont à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait notamment office de résolveur DNS interne). Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25537</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25537"/>
		<updated>2018-11-06T08:53:38Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées au sein d'un même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait notamment office de résolveur DNS interne). Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25536</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25536"/>
		<updated>2018-11-06T08:51:34Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées dans le même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait notamment office de résolveur DNS interne). Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25535</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25535"/>
		<updated>2018-11-06T08:50:27Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées dans le même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : ==&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait notamment office de résolveur DNS interne). Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25534</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25534"/>
		<updated>2018-11-06T08:48:10Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées dans le même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&amp;lt;br&amp;gt;&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&amp;lt;br&amp;gt;&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : ==&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait notamment office de résolveur DNS interne). Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25533</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25533"/>
		<updated>2018-11-06T08:03:23Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées dans le même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&lt;br /&gt;
&lt;br /&gt;
== Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : ==&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait notamment office de résolveur DNS interne). Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25532</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25532"/>
		<updated>2018-11-06T08:03:09Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées dans le même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&lt;br /&gt;
&lt;br /&gt;
== Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : ==&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait notamment office de résolveur DNS interne). Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;poem&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/poem&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25531</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25531"/>
		<updated>2018-11-06T08:02:15Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées dans le même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&lt;br /&gt;
&lt;br /&gt;
== Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : ==&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait notamment office de résolveur DNS interne). Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25530</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25530"/>
		<updated>2018-11-06T08:01:31Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées dans le même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&lt;br /&gt;
&lt;br /&gt;
== Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : ==&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait notamment office de résolveur DNS interne). Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&amp;lt;br&amp;gt;&lt;br /&gt;
127.0.0.1   localhost&amp;lt;br&amp;gt;&lt;br /&gt;
::1         localhost&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
10.1.1.16 k8s-master&amp;lt;br&amp;gt;&lt;br /&gt;
10.1.1.169 k8s-worker01&amp;lt;br&amp;gt;&lt;br /&gt;
10.1.1.87 k8s-worker02&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25529</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25529"/>
		<updated>2018-11-06T07:59:56Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées dans le même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&lt;br /&gt;
&lt;br /&gt;
== Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : ==&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait notamment office de résolveur DNS interne). Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25528</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25528"/>
		<updated>2018-11-06T07:55:05Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Déploiement de notre premier pod / conteneur : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées dans le même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&lt;br /&gt;
&lt;br /&gt;
== Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : ==&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait notamment office de résolveur DNS interne). Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web (pod nginx) :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25527</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25527"/>
		<updated>2018-11-06T07:53:39Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Déploiement de notre premier pod / conteneur : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées dans le même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&lt;br /&gt;
&lt;br /&gt;
== Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : ==&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait notamment office de résolveur DNS interne). Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface Cloud Ikoula One [https://cloudstack.ikoula.com/client Cloud Ikoula One]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25526</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25526"/>
		<updated>2018-11-06T07:52:26Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Déploiement de notre premier pod / conteneur : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées dans le même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&lt;br /&gt;
&lt;br /&gt;
== Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : ==&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait notamment office de résolveur DNS interne). Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface Cloud Ikoula One [https://cloudstack.ikoula.com/client]&lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
	<entry>
		<id>https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25525</id>
		<title>Deployer un cluster Kubernetes</title>
		<link rel="alternate" type="text/html" href="https://fr-wiki.ikoula.com/index.php?title=Deployer_un_cluster_Kubernetes&amp;diff=25525"/>
		<updated>2018-11-06T07:48:19Z</updated>

		<summary type="html">&lt;p&gt;Lhulotf79a8 : /* Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Cette procédure va vous permettre de déployer rapidement et facilement un cluster de trois nodes Kubernetes (nommé également via le raccourci &amp;quot;k8s&amp;quot;) à partir de trois instances CentOS 7 déployées dans le même réseau en zone avancée.&lt;br /&gt;
&lt;br /&gt;
L'une de ces trois instances sera notre node master et les deux autres seront nos nodes workers. Pour résumer le node master est le node depuis lequel on gère le cluster Kubernetes depuis l'API et les nodes workers sont les nodes sur lesquelles s'exécuteront les conteneurs Docker. Ce n'est pas l'objet de cette procédure mais sachez qu'il est possible d'avoir une configuration Haute Disponibilité avec par exemple deux nodes master.&lt;br /&gt;
&lt;br /&gt;
Nous partirons du principe que vos 3 instances CentOS 7 sont déjà déployées et que vous y avez accès en ssh.&lt;br /&gt;
&lt;br /&gt;
Voici la configuration que nous avons dans notre exemple :&lt;br /&gt;
&lt;br /&gt;
Node master : &amp;quot;k8s-master&amp;quot; / 10.1.1.16&lt;br /&gt;
Premier node worker : &amp;quot;k8s-worker01&amp;quot; / 10.1.1.169&lt;br /&gt;
Second node worker : &amp;quot;k8s-worker02&amp;quot; / 10.1.1.87&lt;br /&gt;
&lt;br /&gt;
== Actions à effectuer sur toutes les instances (master et workers) en tant que root ou avec les droits sudo nécessaires : ==&lt;br /&gt;
&lt;br /&gt;
Commencez par peupler le fichier /etc/hosts de vos instances afin qu'elles puissent résoudre leur nom d'hôte respectivement (normalement déjà le cas dans un réseau en zone avancé où le routeur virtuel fait notamment office de résolveur DNS interne). Dans notre exemple cela donne le fichier /etc/hosts suivant sur nos trois instances (adaptez celui-ci avec le nom et l'ip de vos instances) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat /etc/hosts&lt;br /&gt;
127.0.0.1   localhost&lt;br /&gt;
::1         localhost&lt;br /&gt;
&lt;br /&gt;
10.1.1.16 k8s-master&lt;br /&gt;
10.1.1.169 k8s-worker01&lt;br /&gt;
10.1.1.87 k8s-worker02&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Activez le module bridge et les règles iptables pour ce dernier via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
modprobe bridge&lt;br /&gt;
echo &amp;quot;net.bridge.bridge-nf-call-iptables = 1&amp;quot; &amp;gt;&amp;gt; /etc/sysctl.conf&lt;br /&gt;
sysctl -p /etc/sysctl.conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ajoutez le dépôt YUM Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/docker.repo&lt;br /&gt;
[docker-ce-stable]&lt;br /&gt;
name=Docker CE Stable - $basearch&lt;br /&gt;
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
gpgkey=https://download.docker.com/linux/centos/gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez Docker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y docker-ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ajouter le dépôt YUM Kubernetes : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/yum.repos.d/kubernetes.repo&lt;br /&gt;
[kubernetes]&lt;br /&gt;
name=Kubernetes&lt;br /&gt;
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64&lt;br /&gt;
enabled=1&lt;br /&gt;
gpgcheck=1&lt;br /&gt;
repo_gpgcheck=1&lt;br /&gt;
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg&lt;br /&gt;
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg&lt;br /&gt;
EOF&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Installez les paquets Kubernetes nécessaires :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
yum install -y kubeadm kubelet kubectl&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Editez le fichier de configuration de l'unité systemd kubelet (/etc/systemd/system/kubelet.service.d/10-kubeadm.conf)  pour ajouter la ligne suivante dans la partie  &amp;quot;[Service]&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf&lt;br /&gt;
# Note: This dropin only works with kubeadm and kubelet v1.11+&lt;br /&gt;
[Service]&lt;br /&gt;
Environment=&amp;quot;KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
Environment=&amp;quot;KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
*Environment=&amp;quot;KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs&amp;quot;*&lt;br /&gt;
# This is a file that &amp;quot;kubeadm init&amp;quot; and &amp;quot;kubeadm join&amp;quot; generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically&lt;br /&gt;
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env&lt;br /&gt;
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use&lt;br /&gt;
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.&lt;br /&gt;
EnvironmentFile=-/etc/sysconfig/kubelet&lt;br /&gt;
ExecStart=&lt;br /&gt;
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rechargez la configuration, activez puis démarrez les services docker et kubelet via les trois commandes suivantes :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl daemon-reload&lt;br /&gt;
systemctl enable docker kubelet&lt;br /&gt;
systemctl start docker kubelet&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Désactivez la swap du système (kubelet ne supportant pas la mémoire swap vous obtiendrez une erreur lors des &amp;quot;pre-flight checks à l'initialisation de votre cluster via kubeadm) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
swapoff -a&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pensez également à commenter/retirer la ligne concernant la swap dans le fichier /etc/fstab de chacune de vos instances tel que :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#/dev/mapper/vg01-swap  swap            swap    defaults                0       0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Action à n'effectuer que sur l'instance node master : ==&lt;br /&gt;
&lt;br /&gt;
Lancez l'initilalisation de votre cluster Kubernetes via la commande suivante en prenant soin de modifier l'ip du paramètre &amp;quot;--apiserver-advertise-address=&amp;quot; par celle de votre instance master.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubeadm init --apiserver-advertise-address=&amp;lt;ip de votre instance master&amp;gt; --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : Veuillez garder tel quel l'ip du réseau &amp;quot;10.244.0.0/16&amp;quot; indiquée dans le paramètre &amp;quot;--pod-network-cidr=&amp;quot; qui permet d'indiquer que nous allons utiliser le plugin CNI Flannel pour gérer la partie réseau de nos pods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Voici à quoi ressemble le retour de cette commande quand le cluster s'initalise avec succès :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=10.1.1.16 --pod-network-cidr=10.244.0.0/16&lt;br /&gt;
[init] using Kubernetes version: v1.12.2&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
[preflight/images] Pulling images required for setting up a Kubernetes cluster&lt;br /&gt;
[preflight/images] This might take a minute or two, depending on the speed of your internet connection&lt;br /&gt;
[preflight/images] You can also perform this action in beforehand using 'kubeadm config images pull'&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[certificates] Generated ca certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-kubelet-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver certificate and key.&lt;br /&gt;
[certificates] apiserver serving cert is signed for DNS names [k8s-master.cs437cloud.internal kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.1.1.16]&lt;br /&gt;
[certificates] Generated front-proxy-ca certificate and key.&lt;br /&gt;
[certificates] Generated front-proxy-client certificate and key.&lt;br /&gt;
[certificates] Generated etcd/ca certificate and key.&lt;br /&gt;
[certificates] Generated etcd/server certificate and key.&lt;br /&gt;
[certificates] etcd/server serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/peer certificate and key.&lt;br /&gt;
[certificates] etcd/peer serving cert is signed for DNS names [k8s-master.cs437cloud.internal localhost] and IPs [10.1.1.16 127.0.0.1 ::1]&lt;br /&gt;
[certificates] Generated etcd/healthcheck-client certificate and key.&lt;br /&gt;
[certificates] Generated apiserver-etcd-client certificate and key.&lt;br /&gt;
[certificates] valid certificates and keys now exist in &amp;quot;/etc/kubernetes/pki&amp;quot;&lt;br /&gt;
[certificates] Generated sa key and public key.&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/admin.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/kubelet.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/controller-manager.conf&amp;quot;&lt;br /&gt;
[kubeconfig] Wrote KubeConfig file to disk: &amp;quot;/etc/kubernetes/scheduler.conf&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-apiserver to &amp;quot;/etc/kubernetes/manifests/kube-apiserver.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-controller-manager to &amp;quot;/etc/kubernetes/manifests/kube-controller-manager.yaml&amp;quot;&lt;br /&gt;
[controlplane] wrote Static Pod manifest for component kube-scheduler to &amp;quot;/etc/kubernetes/manifests/kube-scheduler.yaml&amp;quot;&lt;br /&gt;
[etcd] Wrote Static Pod manifest for a local etcd instance to &amp;quot;/etc/kubernetes/manifests/etcd.yaml&amp;quot;&lt;br /&gt;
[init] waiting for the kubelet to boot up the control plane as Static Pods from directory &amp;quot;/etc/kubernetes/manifests&amp;quot;&lt;br /&gt;
[init] this might take a minute or longer if the control plane images have to be pulled&lt;br /&gt;
[apiclient] All control plane components are healthy after 32.502898 seconds&lt;br /&gt;
[uploadconfig] storing the configuration used in ConfigMap &amp;quot;kubeadm-config&amp;quot; in the &amp;quot;kube-system&amp;quot; Namespace&lt;br /&gt;
[kubelet] Creating a ConfigMap &amp;quot;kubelet-config-1.12&amp;quot; in namespace kube-system with the configuration for the kubelets in the cluster&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the label &amp;quot;node-role.kubernetes.io/master=''&amp;quot;&lt;br /&gt;
[markmaster] Marking the node k8s-master.cs437cloud.internal as master by adding the taints [node-role.kubernetes.io/master:NoSchedule]&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-master.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
[bootstraptoken] using token: e83pes.u3igpccj2metetu8&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token&lt;br /&gt;
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster&lt;br /&gt;
[bootstraptoken] creating the &amp;quot;cluster-info&amp;quot; ConfigMap in the &amp;quot;kube-public&amp;quot; namespace&lt;br /&gt;
[addons] Applied essential addon: CoreDNS&lt;br /&gt;
[addons] Applied essential addon: kube-proxy&lt;br /&gt;
&lt;br /&gt;
Your Kubernetes master has initialized successfully!&lt;br /&gt;
&lt;br /&gt;
To start using your cluster, you need to run the following as a regular user:&lt;br /&gt;
&lt;br /&gt;
  mkdir -p $HOME/.kube&lt;br /&gt;
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config&lt;br /&gt;
  sudo chown $(id -u):$(id -g) $HOME/.kube/config&lt;br /&gt;
&lt;br /&gt;
You should now deploy a pod network to the cluster.&lt;br /&gt;
Run &amp;quot;kubectl apply -f [podnetwork].yaml&amp;quot; with one of the options listed at:&lt;br /&gt;
  https://kubernetes.io/docs/concepts/cluster-administration/addons/&lt;br /&gt;
&lt;br /&gt;
You can now join any number of machines by running the following on each node&lt;br /&gt;
as root:&lt;br /&gt;
&lt;br /&gt;
  kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous effectuons les opérations demandées afin de finaliser l'initialisation de notre cluster :&lt;br /&gt;
&lt;br /&gt;
soit la création d'un répertoire et fichie de config pour notre utilisateur courante (root dans notre cas) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p $HOME/.kube&lt;br /&gt;
cp /etc/kubernetes/admin.conf ~/.kube/config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
le déploiement de notre réseau pod Flannel pour notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml&lt;br /&gt;
clusterrole.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
clusterrolebinding.rbac.authorization.k8s.io/flannel created&lt;br /&gt;
serviceaccount/flannel created&lt;br /&gt;
configmap/kube-flannel-cfg created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-amd64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm64 created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-arm created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-ppc64le created&lt;br /&gt;
daemonset.extensions/kube-flannel-ds-s390x created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
remarque : nous allons garder la dernière commande fournie de côté afin de l'exécuter ensuite sur nos instances workers pour les faire joindre notre cluster.&lt;br /&gt;
&lt;br /&gt;
On peut maintenant effectuer les premières vérifications de notre cluster :&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get nodes&amp;quot; pour vérifier les nodes actuellement présent dans votre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                             STATUS   ROLES    AGE   VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal   Ready    master   41m   v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note : il n'y a actuellement que votre node master ce qui est normal car nous n'avons pas encore ajouté les autres nodes&lt;br /&gt;
&lt;br /&gt;
Tapez la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; pour vérifier les pods/conteneurs actuellement présent dans votre cluster : &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          41m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          84s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          41m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          40m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il n'y a que les pods correspondant aux composants Kubernetes nécessaires pour notre node master (kube-apiserver, etcd, kube-scheduler, etc.).&lt;br /&gt;
&lt;br /&gt;
On peut vérifier l'état de ces composants avec la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get cs&lt;br /&gt;
NAME                 STATUS    MESSAGE              ERROR&lt;br /&gt;
scheduler            Healthy   ok&lt;br /&gt;
controller-manager   Healthy   ok&lt;br /&gt;
etcd-0               Healthy   {&amp;quot;health&amp;quot;: &amp;quot;true&amp;quot;}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Actions à n'effectuer que sur les instances/nodes worker : ==&lt;br /&gt;
&lt;br /&gt;
Sur chacune de vos instances worker, lancez la commande &amp;quot;kubeadm join ...&amp;quot; fournie à la fin de l'initialisation de votre cluster un peu plus haut :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker01 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker01.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-worker02 ~]# kubeadm join 10.1.1.16:6443 --token e83pes.u3igpccj2metetu8 --discovery-token-ca-cert-hash sha256:7ea9169bc5ac77b3a2ec37e5129006d9a895ce040e306f3093ce77e7422f7f1c&lt;br /&gt;
[preflight] running pre-flight checks&lt;br /&gt;
        [WARNING RequiredIPVSKernelModulesAvailable]: the IPVS proxier will not be used, because the following required kernel modules are not loaded: [ip_vs_wrr ip_vs_sh ip_vs ip_vs_rr] or no builtin kernel ipvs support: map[ip_vs:{} ip_vs_rr:{} ip_vs_wrr:{} ip_vs_sh:{} nf_conntrack_ipv4:{}]&lt;br /&gt;
you can solve this problem with following methods:&lt;br /&gt;
 1. Run 'modprobe -- ' to load missing kernel modules;&lt;br /&gt;
2. Provide the missing builtin kernel ipvs support&lt;br /&gt;
&lt;br /&gt;
[discovery] Trying to connect to API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Created cluster-info discovery client, requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Requesting info from &amp;quot;https://10.1.1.16:6443&amp;quot; again to validate TLS against the pinned public key&lt;br /&gt;
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[discovery] Successfully established connection with API Server &amp;quot;10.1.1.16:6443&amp;quot;&lt;br /&gt;
[kubelet] Downloading configuration for the kubelet from the &amp;quot;kubelet-config-1.12&amp;quot; ConfigMap in the kube-system namespace&lt;br /&gt;
[kubelet] Writing kubelet configuration to file &amp;quot;/var/lib/kubelet/config.yaml&amp;quot;&lt;br /&gt;
[kubelet] Writing kubelet environment file with flags to file &amp;quot;/var/lib/kubelet/kubeadm-flags.env&amp;quot;&lt;br /&gt;
[preflight] Activating the kubelet service&lt;br /&gt;
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...&lt;br /&gt;
[patchnode] Uploading the CRI Socket information &amp;quot;/var/run/dockershim.sock&amp;quot; to the Node API object &amp;quot;k8s-worker02.cs437cloud.internal&amp;quot; as an annotation&lt;br /&gt;
&lt;br /&gt;
This node has joined the cluster:&lt;br /&gt;
* Certificate signing request was sent to apiserver and a response was received.&lt;br /&gt;
* The Kubelet was informed of the new secure connection details.&lt;br /&gt;
&lt;br /&gt;
Run 'kubectl get nodes' on the master to see this node join the cluster.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Vérification à faire depuis l'instance/node master : ==&lt;br /&gt;
&lt;br /&gt;
Vérifiez que vos nodes worker ont bien été ajouté à votre cluster en ré-exécutant la commande &amp;quot;kubectl get nodes&amp;quot; depuis &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get nodes&lt;br /&gt;
NAME                               STATUS   ROLES    AGE    VERSION&lt;br /&gt;
k8s-master.cs437cloud.internal     Ready    master   46m    v1.12.2&lt;br /&gt;
k8s-worker01.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   103s   v1.12.2&lt;br /&gt;
k8s-worker02.cs437cloud.internal   Ready    &amp;lt;none&amp;gt;   48s    v1.12.2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On voit bien nos deux nodes worker (k8s-worker01 et k8s-worker02), ils ont donc bien été ajouté à notre cluster.&lt;br /&gt;
&lt;br /&gt;
Relançons maintenant la commande &amp;quot;kubectl get pods --all-namespaces&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          46m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          6m31s&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          70s&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          2m6s&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          46m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          70s&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          46m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On peut constater qu'il y a autant de pods/conteneurs &amp;quot;kube-flannel&amp;quot; et &amp;quot;kube-proxy&amp;quot; que nous avons de nodes dans notre cluster.&lt;br /&gt;
&lt;br /&gt;
== Déploiement de notre premier pod / conteneur : ==&lt;br /&gt;
&lt;br /&gt;
Nous allons déployer notre premier pod/conteneur dans notre cluster Kubernetes fraichement créé.&lt;br /&gt;
&lt;br /&gt;
Par simplicité, nous choisissons de déployer un pod (sans réplicat) nommé &amp;quot;nginx&amp;quot; et utilisant l'image &amp;quot;nginx&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx&lt;br /&gt;
deployment.apps/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Si on vérifie, celui-ci apparait bien au retour de notre commande listant les pods de notre cluster :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --all-namespaces&lt;br /&gt;
NAMESPACE     NAME                                                     READY   STATUS    RESTARTS   AGE&lt;br /&gt;
default       nginx-55bd7c9fd-5bghl                                    1/1     Running   0          104s&lt;br /&gt;
kube-system   coredns-576cbf47c7-fwxj9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   coredns-576cbf47c7-t86s9                                 1/1     Running   0          57m&lt;br /&gt;
kube-system   etcd-k8s-master.cs437cloud.internal                      1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-apiserver-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-controller-manager-k8s-master.cs437cloud.internal   1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-724nl                              1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-wcm7v                              1/1     Running   0          17m&lt;br /&gt;
kube-system   kube-flannel-ds-amd64-z7mwg                              1/1     Running   3          12m&lt;br /&gt;
kube-system   kube-proxy-8r7wg                                         1/1     Running   0          13m&lt;br /&gt;
kube-system   kube-proxy-h94bs                                         1/1     Running   0          57m&lt;br /&gt;
kube-system   kube-proxy-m2f5r                                         1/1     Running   0          12m&lt;br /&gt;
kube-system   kube-scheduler-k8s-master.cs437cloud.internal            1/1     Running   0          57m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il figure en haut de notre liste dans un namespace différent de &amp;quot;kube-system&amp;quot; puisqu'il ne s'agit pas d'un composant propre à Kubernetes.&lt;br /&gt;
&lt;br /&gt;
Il est d'ailleurs possible de ne pas afficher les pods propre au namespace kube-system en effectuant la même commande sans le paramètre &amp;quot;--all-namespace&amp;quot; :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq     1/1     Running   0          3d2h&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pour afficher les labels :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --show-labels&lt;br /&gt;
NAME                      READY   STATUS    RESTARTS   AGE    LABELS&lt;br /&gt;
nginx-55bd7c9fd-ckltn     1/1     Running   0          8m2s   app=nginx,pod-template-hash=55bd7c9fd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également vérifié nos déploiements via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get deployments&lt;br /&gt;
NAME    DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE&lt;br /&gt;
nginx   1         1         1            1           93m&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nous avons donc un pod nginx de déployé et démarré mais qui n'est pour l'instant pas accessible de l'extérieur. Pour le rendre accessible depuis l'extérieur, nous devons exposer le port de notre pod en créant le service via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl create service nodeport nginx --tcp=80:80&lt;br /&gt;
service/nginx created&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notre service est ainsi crée :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get svc&lt;br /&gt;
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE&lt;br /&gt;
kubernetes   ClusterIP   10.96.0.1        &amp;lt;none&amp;gt;        443/TCP        147m&lt;br /&gt;
nginx        NodePort    10.108.251.178   &amp;lt;none&amp;gt;        80:30566/TCP   20s&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il écoute sur le port 80/tcp et sera disponible/exposé depuis l'extérieur sur le port 30566/tcp&lt;br /&gt;
&lt;br /&gt;
Nous pouvons obtenir l'ip flannel de notre pod ainsi que le nom du node sur lequel il tourne actuellement via la commande suivante :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl get pods --selector=&amp;quot;app=nginx&amp;quot; --output=wide&lt;br /&gt;
NAME                    READY   STATUS    RESTARTS   AGE    IP           NODE                               NOMINATED NODE&lt;br /&gt;
nginx-55bd7c9fd-vs4fq   1/1     Running   0          174m   10.244.2.2   k8s-worker02.cs437cloud.internal   &amp;lt;none&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ici notre pod nginx a donc l'ip 10.244.2.2 et tourne sur notre node k8s-worker02.&lt;br /&gt;
&lt;br /&gt;
Nous pouvons également simplement exécuté une commande ou ouvrir un shell sur notre pod nginx via la commande suivante (très similaire à la commande docker) :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
[root@k8s-master ~]# kubectl exec -it nginx-55bd7c9fd-vs4fq -- /bin/bash&lt;br /&gt;
root@nginx-55bd7c9fd-vs4fq:/#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Il ne nous reste plus qu'à créer notre règle de load balancing sur Cloud Ikoula One pour accéder à /rendre publique notre serveur web :&lt;br /&gt;
&lt;br /&gt;
- Connectez-vous à l'interface Cloud Ikoula One (https://cloudstack.ikoula.com/client) &lt;br /&gt;
- allez dans &amp;quot;Network&amp;quot; dans le menu vertical gauche&lt;br /&gt;
- cliquez sur votre réseau dans lequel vous avez déployé vos instances Kubernetes puis sur &amp;quot;View IP Addresses&amp;quot; et sur votre ip Source NAT et allez dans l'onglet &amp;quot;Configuration&amp;quot;&lt;br /&gt;
- cliquez sur &amp;quot;Load Balancing&amp;quot; et créé votre règle en spécifiant un nom, le port public &amp;quot;80&amp;quot; dans notre cas, le port privé &amp;quot;30566&amp;quot; dans notre cas (cf. plus haut), en choisissant un algorithme LB (ex: round-robin) tel que :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-01.png]]&lt;br /&gt;
&lt;br /&gt;
- cochez l'ensemble de vos instances worker :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-02.png]]&lt;br /&gt;
&lt;br /&gt;
ce qui donne :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_regle_lb-03.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tester l'accès à votre server web / pod nginx depuis votre navigateur :&lt;br /&gt;
&lt;br /&gt;
[[File:faq_k8s_browser_nginx.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le fait que votre pod nginx soit accessible depuis n'importe lequel de vos nodes est possible grâce au composant &amp;quot;kube-proxy&amp;quot; qui se charge de faire pointer les connexions sur le/les node(s) sur lequel tourne celui-ci.&lt;/div&gt;</summary>
		<author><name>Lhulotf79a8</name></author>
	</entry>
</feed>