{"id":1016,"date":"2021-06-03T20:55:37","date_gmt":"2021-06-03T18:55:37","guid":{"rendered":"https:\/\/loeilduse.fr\/?p=1016"},"modified":"2021-06-11T09:02:20","modified_gmt":"2021-06-11T07:02:20","slug":"etapes-pour-la-creation-de-vm-via-kubectl","status":"publish","type":"post","link":"https:\/\/loeilduse.fr\/?p=1016&lang=fr","title":{"rendered":"Etapes pour la cr\u00e9ation de VM via kubectl"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1018 aligncenter\" src=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/VM-POD-Network.png\" alt=\"\" width=\"624\" height=\"105\" srcset=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/VM-POD-Network.png 624w, https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/VM-POD-Network-300x50.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Pour cr\u00e9er une machine virtuelle avec vSphere with Tanzu via la commande kubectl, il y a des \u00e9tapes \u00e0 respecter pour l\u2019administrateur et pour le d\u00e9veloppeur, elles sont tr\u00e8s simples mais ce ne m\u2019a pas emp\u00each\u00e9 de perdre un peu de temps cot\u00e9 personnalisation sur la partie OS.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">je vous recommande cet article pour comprendre l&#8217;int\u00e9ret de d\u00e9ployer des VM via Kubernetes : <a href=\"https:\/\/loeilduse.fr\/?p=1055&amp;lang=fr\">D\u00e9ployer des VMs dans et via Kubernetes.<\/a> Le blog de mon coll\u00e8gue : <a href=\"https:\/\/core.vmware.com\/blog\/introducing-virtual-machine-provisioning-kubernetes-vm-service\">Introducing Virtual Machine Provisioning, via Kubernetes with VM Service | VMware<\/a> est aussi tr\u00e8s bien d\u00e9taill\u00e9. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Dans la derni\u00e8re partie cet article, je vais apporter quelques pr\u00e9cisions sur la partie Content Library et sur la partie YAML. Mais d&#8217;abord, revoyons avant les <\/span><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">partie \u00e0 faire cot\u00e9 administrateur et cot\u00e9 d\u00e9veloppeur<\/span><\/p>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1019 aligncenter\" src=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Dev-admin-vwt.png\" alt=\"\" width=\"624\" height=\"241\" srcset=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Dev-admin-vwt.png 624w, https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Dev-admin-vwt-300x116.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif; font-size: 14pt;\"><strong>Concernant l\u2019administrateur<br \/>\n<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">La premi\u00e8re \u00e9tape consiste \u00e0 t\u00e9l\u00e9charger les images VMs qui sont diff\u00e9rentes de celles utilis\u00e9es pour TKC (Tanzu Kubernetes Cluster aussi appel\u00e9 Guest Cluster). Les images sont disponibles dans la marketplace VMware, au moment de la r\u00e9daction de cet article, il y en a 2 (Ubuntu et Centos), la version Ubuntu actuelle ne permet pas l\u2019utilisation de volume persistent (PVC) car elle est bas\u00e9e sur une version virtual hardware 10 et il faut au minimum une version 12, ce probl\u00e8me va bient\u00f4t \u00eatre corrig\u00e9.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Il faut aller sur la marketplace et faire une recherche avec le mot cl\u00e9 \u00ab\u00a0vm service\u00a0\u00bb, \u00e7a permet de filtrer (un peu) les images compatibles\u00a0=&gt; <a href=\"https:\/\/marketplace.cloud.vmware.com\/services?search=vm%20service\">VMware Marketplace<\/a>.<\/span><\/p>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1020 aligncenter\" src=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Marketplace-search-image.png\" alt=\"\" width=\"624\" height=\"310\" srcset=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Marketplace-search-image.png 624w, https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Marketplace-search-image-300x149.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Ensuite cliquer sur l\u2019image souhait\u00e9e, se connecter avec son compte MyVMware.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1021 aligncenter\" src=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Marketplace-sigin.png\" alt=\"\" width=\"624\" height=\"79\" srcset=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Marketplace-sigin.png 624w, https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Marketplace-sigin-300x38.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Vous avez deux possibilit\u00e9s, la t\u00e9l\u00e9charger puis la charger dans une content library locale <\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1022 aligncenter\" src=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Marketplace-download.png\" alt=\"\" width=\"624\" height=\"105\" srcset=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Marketplace-download.png 624w, https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Marketplace-download-300x50.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">ou r\u00e9cup\u00e9rer l\u2019url de souscription pour cr\u00e9er une content library qui se synchronisera \u00e0 celle h\u00e9berg\u00e9e par VMware.<\/span><\/p>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1023 aligncenter\" src=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Marketplace-subscribe.png\" alt=\"\" width=\"624\" height=\"90\" srcset=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Marketplace-subscribe.png 624w, https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/Marketplace-subscribe-300x43.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Une fois l\u2019image charg\u00e9e ou le lien renseign\u00e9, vous devriez avoir une content library de ce type\u00a0:<\/span><\/p>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1024 aligncenter\" src=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/content-library-list.png\" alt=\"\" width=\"624\" height=\"304\" srcset=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/content-library-list.png 624w, https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/content-library-list-300x146.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Toujours depuis l\u2019interface vSphere, il faut maintenant cr\u00e9er, un namespace, octroyer les droits aux utilisateurs pour qu\u2019ils puissent s\u2019y connecter, affecter la classe de VM, la content library et la classe de stockage, ce qui devrait donner ceci\u00a0:<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1026 aligncenter\" src=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/namespace-cl-vmclass-perm-storage.png\" alt=\"\" width=\"624\" height=\"240\" srcset=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/namespace-cl-vmclass-perm-storage.png 624w, https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/namespace-cl-vmclass-perm-storage-300x115.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">L\u2019exemple ci-dessus montre une fois le namespace cr\u00e9\u00e9, comment affecter une classe de VM, une content library, autoriser les d\u00e9veloppeurs qui pourront consommer ce namespace, quelle classe de stockage \u00e0 utiliser et enfin si besoin caper les ressource, CPU, m\u00e9moire et stockage.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">C\u2019est tout ce qu\u2019il y a \u00e0 faire cot\u00e9 administrateur d\u2019infrastructure.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\"><strong><span style=\"font-size: 14pt;\">Concernant le d\u00e9veloppeur<\/span> <\/strong><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Il faut un descriptif YAML pour : <\/span><\/p>\n<ul style=\"list-style-type: circle;\">\n<li style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">La configmap qui contient la personnalisation de la VM<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">La cr\u00e9ation de la VM<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Le service r\u00e9seau si vous souhaitez vous y connecter \u00e0 partir d&#8217;un r\u00e9seau ext\u00e9rieur (optionnel)<br \/>\n<\/span><\/li>\n<li style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Le PVC si vous souhaitez utiliser des volumes persistants (optionnel)<br \/>\n<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Via la commande Kubernetes, le d\u00e9veloppeur se connecte avec son compte au Namespace fourni, il pourra ainsi lister les classes de services qu\u2019il peut utiliser ainsi que les images qu\u2019il pourra d\u00e9ployer.<\/span><\/p>\n<p><span style=\"font-family: courier new, courier, monospace;\"><strong>kubectl get virtualmachineclass<\/strong><\/span><\/p>\n<p><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">NAME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 CPU\u00a0\u00a0 MEMORY\u00a0\u00a0 AGE<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">best-effort-2xlarge\u00a0\u00a0 8\u00a0\u00a0\u00a0\u00a0 64Gi\u00a0\u00a0\u00a0\u00a0 22d<\/span><br \/>\n<span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">best-effort-4xlarge\u00a0\u00a0 16\u00a0\u00a0\u00a0 128Gi\u00a0\u00a0\u00a0 22d<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">best-effort-8xlarge\u00a0\u00a0 32\u00a0 \u00a0\u00a0128Gi\u00a0\u00a0\u00a0 22d<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">best-effort-large\u00a0\u00a0\u00a0\u00a0 4\u00a0\u00a0\u00a0\u00a0 16Gi\u00a0\u00a0\u00a0\u00a0 22d<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">best-effort-medium\u00a0\u00a0\u00a0 2\u00a0\u00a0\u00a0\u00a0 8Gi\u00a0\u00a0\u00a0\u00a0\u00a0 31d<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">best-effort-small\u00a0\u00a0\u00a0\u00a0 2\u00a0\u00a0\u00a0\u00a0 4Gi\u00a0\u00a0\u00a0\u00a0\u00a0 31d<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">best-effort-xlarge\u00a0\u00a0\u00a0 4\u00a0\u00a0\u00a0\u00a0 32Gi\u00a0\u00a0\u00a0\u00a0 22d<br \/>\nbest-effort-xsmall\u00a0\u00a0\u00a0 2\u00a0\u00a0\u00a0\u00a0 2Gi\u00a0\u00a0\u00a0\u00a0\u00a0 22d<br \/>\n<\/span>..<br \/>\n<span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">guaranteed-xsmall\u00a0\u00a0\u00a0\u00a0 2\u00a0\u00a0\u00a0\u00a0 2Gi\u00a0\u00a0\u00a0\u00a0\u00a0 22d<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\"><strong>kubectl get virtualmachineimage<br \/>\n<\/strong><\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">NAME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 VERSION\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OSTYPE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 FORMAT\u00a0\u00a0 AGE<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">centos-stream-8-vmservice-v1alpha1-1619529007339\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 centos8_64Guest\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ovf\u00a0\u00a0\u00a0\u00a0\u00a0 4h8m<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">ob-15957779-photon-3-k8s-v1.16.8&#8212;vmware.1-tkg.3.60d2ffd\u00a0\u00a0\u00a0 v1.16.8+vmware.1-tkg.3.60d2ffd\u00a0\u00a0\u00a0 vmwarePhoton64Guest\u00a0\u00a0 ovf\u00a0\u00a0\u00a0\u00a0\u00a0 2d19h<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">ob-16466772-photon-3-k8s-v1.17.7&#8212;vmware.1-tkg.1.154236c\u00a0\u00a0\u00a0 v1.17.7+vmware.1-tkg.1.154236c\u00a0\u00a0\u00a0 vmwarePhoton64Guest\u00a0\u00a0 ovf\u00a0\u00a0\u00a0\u00a0\u00a0 2d19h<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">ob-16545581-photon-3-k8s-v1.16.12&#8212;vmware.1-tkg.1.da7afe7\u00a0\u00a0 v1.16.12+vmware.1-tkg.1.da7afe7\u00a0\u00a0 vmwarePhoton64Guest\u00a0\u00a0 ovf\u00a0\u00a0\u00a0\u00a0\u00a0 2d19h<br \/>\n&#8230;&#8230;<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">ubuntu-20-1621373774638\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ubuntu64Guest\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ovf\u00a0\u00a0\u00a0\u00a0\u00a0 4h8m<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Il peut ainsi cr\u00e9er ses fichiers descriptifs YAML afin de d\u00e9finir ses besoins en ressources pour sa ou ses machines virtuelles et s\u2019ils le souhaitent, il peut la ou les personnaliser afin d\u2019y installer ses outils.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Le fichier descriptif configmap, comprend la personnalisation de la VM. Les 3 champs importants \u00e0 renseigner pour la personnalisation sont :<\/span><\/p>\n<ol style=\"text-align: justify;\">\n<li><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Le <strong><span style=\"font-family: courier new, courier, monospace;\">hostname<\/span> <\/strong>qui contient le hostname de l\u2019OS<\/span><\/li>\n<li><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">La <span style=\"font-family: courier new, courier, monospace;\"><strong>public-keys<\/strong><\/span>, qui contient la cl\u00e9 publique d\u2019un poste \u00e0 partir duquel on se connectera \u00e0 l\u2019os en ssh.<\/span><\/li>\n<li><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">La partie <span style=\"font-family: courier new, courier, monospace;\"><strong>user-data <\/strong><\/span>est, si vous le souhaitez, l\u2019endroit o\u00f9 on met le contenu du fichier de configuration Cloud Init, il faudra le chiffrer avec la commande base64.<\/span><\/li>\n<\/ol>\n<p style=\"text-align: left;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\"><strong>\u00a0<\/strong><\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-size: 8pt;\"><span style=\"font-family: courier new, courier, monospace;\"><strong>cat loeil-du-se-vm-configmap.yaml<\/strong><br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">apiVersion: v1<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">kind: ConfigMap<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">metadata:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0\u00a0\u00a0 name: loeil-du-se-vm-configmap # Le nom de la ConfigMap, doit \u00eatre le m\u00eame que celui r\u00e9f\u00e9renc\u00e9 dans le YAML de la VirtualMachine<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0\u00a0\u00a0 namespace: loeil-du-se<br \/>\ndata:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0 # Champs OVF utilis\u00e9s lors du d\u00e9ploiment de la VM<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0 hostname: loeil-du-se<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0 public-keys: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDC4Cclh3rN\/l70lBNlwQyK6ZtugxqT\/7HeerHZKPSO0hcl5ZWLvz2+7QG5FqvYbkPP6EomvyDhE2MPnQ0kWaIrumVxYXAbVdpBBKKdTI3xJpewWB2syxgVOXP2ZOrw4cRLFv18rnESGHfsohedyaSB1qvubPWAqBFa+PSS4xh3zKalUknwc7Bs14fci8tEwEg8cpvNsqvrPZliJ6qTYFGqKuG6Ct+y449JNW6k6itTepgSYvUdJfjBTxk5tDzBdWz28km5N7lxgUB0rIWgSDl1XLCBrmm+H6bkHtD59MxAuxwLjih4tS4PzspcVjwWiJhd0HH7u2wbsPLCrrAX7am4EP40zphu9IR+fVxk+2jp7eD2uXPS6p9sDPEWHl6wGclI7pnfuoyvcn+CIwCtMweLuUw5MPj2eIIXcBhqUffeVAXVHrx8+e7+yHvqfyhqm2J9Ay3yt3zvAcXW0VqDxfvnfmv8sc9VNUW+8fUeyoo4b4uZRLLSf2DHM8= root@fbenrejdal-z01 # Cl\u00e9 publique SSH du poste permettant de se connecter sans mot de passe \u00e0 l&#8217;OS de la VM<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0 user-data: | # optionel, le contenu chiffr\u00e9 en base64 du fichier Cloud Init. La cl\u00e9 peut \u00eatre sur une seule ligne ou sur plusieurs, elle doit d\u00e9marrer au niveau du &#8220;r&#8221; sous user-data<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0\u00a0\u00a0\u00a0 I2Nsb3VkLWNvbmZpZwojIFdBVENIT1VUIHRoZSBmaXJzdCBsaW5lIG11c3Qgc3RhcnQgd2l0aCAj<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0\u00a0\u00a0\u00a0 Y2xvdWQtY29uZmlnCmdyb3VwczoKICAtIGRldm9wcwp1c2VyczoKICAtIGRlZmF1bHQgIyBDcmVh<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0\u00a0\u00a0\u00a0 dGUgdGhlIGRlZmF1bHQgdXNlciBmb3IgdGhlIE9TCiAgLSBuYW1lOiBmYmUKICAgIHNzaC1hdXRo<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0\u00a0\u00a0\u00a0 b3JpemVkLWtleXM6ICMgdGhlIHB1YmxpYyBrZXkgb2YgbXkgbGFwdG9wLCBpdCBjb3VsZCBhbHNv<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0\u00a0\u00a0\u00a0 IGJlIGZpbGxlZCBpbiB0aGUgT1ZGIHByb3BlcnR5CiAgICAgIC0gc3NoLXJzYSBBQUFBQjNOemFD<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0\u00a0\u00a0\u00a0 MXljMkVBQUFBREFRQUJBQUFCZ1FEQzRDY2xoM3JOL2w3MGxCTmx3UXlLNlp0dWd4cVRHLzdIZWVy<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0\u00a0\u00a0\u00a0 SFpLUFNPMGhjbDVaV0x2ejIrN1FHNUZxdllia1BQNkVvbXZ5RGhFMk1QblEwa1dhSXJ1bVZ4WVhB<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0\u00a0\u00a0\u00a0 YlZkcEJCS0tkVEkzeEpwZXdXL0Iyc3l4Z1ZPWFAyWk9ydzRjUkxGdjE4cm5FU0dIZisvc29oZWR5<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0\u00a0\u00a0\u00a0 YVNCMXF2dWJQV0FxQkZhK1BTUzR4aDZELzN6S2FsVWtud2M3QnMxNGZjaTh0RXdFZzhjcHZOc3F2<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0\u00a0\u00a0\u00a0 clBabGlKNnFUWUZHcUt1RzZDdCt5NDQ5Sk5XNms2aXRUZXBnU1l2VWRKZmpCVHhrNXREekJkV3oy<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0\u00a0\u00a0\u00a0 OGttNU43bHhnVUIwcklXZ1NEbDFYTENCcm1tK0g2YmtIdEQ1OU14QXV4d0xqaWg0dFM0UHpzcGNW<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace;\">\u00a0\u00a0\u00a0\u00a0 dGFydCBtb25nb2QK<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif; font-size: 12pt;\">La base64 est obtenu de la mani\u00e8re suivante\u00a0:<\/span><br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">base64\u00a0 loeil-du-se-vm-cloud-init.yaml<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif; font-size: 12pt;\">Son contenu\u00a0en clair :<\/span><br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\"><strong>cat\u00a0 loeil-du-se-vm-cloud-init.yaml<br \/>\n<\/strong><\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">#cloud-config<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\"># ATTENTION la premi\u00e8re ligne doit commencer par #cloud-config<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">groups:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; devops<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">users:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; default # Cr\u00e9\u00e9 l&#8217;utisateur par d\u00e9faut<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; name: fbe<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 ssh-authorized-keys: # Cl\u00e9 SSH de mon laptop me permettant de me connecter via SSH sans mot de passe. Cl\u00e9 d\u00e9j\u00e0 renseign\u00e9e dans la configmap<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0\u00a0\u00a0 &#8211; ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDC4Cclh3rN\/l70lBNlwQyK6ZtugxqTG7HeerHZKPSO0hcl5ZWLvz2+7QG5FqvYbkPP6EomvyDhE2MPnQ0kWaIrumVxYXAbVdpBBKKdTI3xJpewWB2syxgVOXP2ZOrw4cRLFv18rnESGHf+sohedyaSB1qvubPWAqBFa+PSS4xh6D3zKalUknwc7Bs14fci8tEwEg8cpvNsqvrPZliJ6qTYFGqKuG6Ct+y449JNW6k6itTepgSYvUdJfjBTxk5tDzBdWz28km5N7lxgUB0rIWgSDl1XLCBrmm+H6bkHtD59MxAuxwLjih4tS4PzspcVjwWiJhd0HH7u2wbsPLCrrAX7am4EP40zphu9IR+fVxk+2jp7eD2uXPS6p9sDPEWHl6wGclI7pnfuoyvcn+CIwCtMweLuUw5MPj2eIIXcBhqUffeVAXVHrx8+e7+yHvqfyhqm2J9Ay3yt3zvAcXW0VqDxfvnfmv8sc9VNUW+8fUeyoo4b4uZRLLSf2DHM8= root@fbenrejdal-z01<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0 groups: sudo, devops<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0\u00a0\u00a0 shell: \/bin\/bash<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0\u00a0\u00a0 passwd: VMware1!<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0\u00a0\u00a0 sudo: [&#8216;ALL=(ALL) NOPASSWD:ALL&#8217;] # l&#8217;utilisateur fbe n&#8217;aura pas \u00e0 rentrer de mot de passe avec la commande sudo<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 ssh_pwauth: true<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 chpasswd:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 list: |<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0\u00a0\u00a0 fbe:VMware1! # changer le mot de passe de l&#8217;utilisateur fbe<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0\u00a0\u00a0 expire: false\u00a0 # Pour que le mot de passe n&#8217;expire pas<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">runcmd: # Exemple de runcmd pour installer MongoDB. Cloud Init est aussi capable d&#8217;utiliser directement APT pour faire des installations<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; echo &#8220;deb [ arch=amd64,arm64 ] https:\/\/repo.mongodb.org\/apt\/ubuntu focal\/mongodb-org\/4.4 multiverse&#8221; | tee \/etc\/apt\/sources.list.d\/mongodb-org-4.4.list<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; wget -qO &#8211; https:\/\/www.mongodb.org\/static\/pgp\/server-4.4.asc | apt-key add &#8211;<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; echo &#8220;deb [ arch=amd64,arm64 ] https:\/\/repo.mongodb.org\/apt\/ubuntu focal\/mongodb-org\/4.4 multiverse&#8221; | tee \/etc\/apt\/sources.list.d\/mongodb-org-4.4.list<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; apt-get update<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; apt-get install -y mongodb-org<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; echo &#8220;mongodb-org hold&#8221; | dpkg &#8211;set-selections<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; echo &#8220;mongodb-org-server hold&#8221; | dpkg &#8211;set-selections<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; echo &#8220;mongodb-org-shell hold&#8221; | dpkg &#8211;set-selections<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; echo &#8220;mongodb-org-mongos hold&#8221; | dpkg &#8211;set-selections<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; echo &#8220;mongodb-org-tools hold&#8221; | dpkg &#8211;set-selections<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; sed -i &#8216;s\/127.0.0.1\/0.0.0.0\/&#8217; \/etc\/mongod.conf<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; ufw allow from any to any port 27017 proto tcp<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; sleep 2<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; systemctl start mongod<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Tr\u00e8s tr\u00e8s important, le fichier doit absolument commencer par <span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">#cloud-config <\/span>et pas autre chose. \u00c7a reste un fichier Cloud Init classique.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Si vous ne maitrisez pas trop Cloud Init, j\u2019y ai mis des commentaires pour que ce soit un peu plus lisible.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Le fichier descriptif de la VM<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\"><strong>cat loeil-du-se-vm-deployment.yaml<br \/>\n<\/strong><\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">apiVersion: vmoperator.vmware.com\/v1alpha1<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">kind: VirtualMachine<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">metadata:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 name: loeil-du-se-vm<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 namespace: loeil-du-se<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">labels:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 vm: loeil-du-se-vm<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">spec:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 imageName: ubuntu-20-1621373774638 #L&#8217;image doit \u00eatre pr\u00e9sente dans la content library et visible via la commande kubectl get virtualmachineimage<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 className: best-effort-xsmall<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 powerState: poweredOn<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 storageClass: silver-storage-policy<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 networkInterfaces:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 &#8211; networkType: nsx-t # soit nsx-t ou vsphere-distributed en fonction de votre installation<br \/>\n# networkName: <\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">si -networkType est vsphere-distributed il faut mettre le nom du port group des workload<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 vmMetadata:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0\u00a0\u00a0 configMapName: loeil-du-se-vm-configmap # Nom de la configmap o\u00f9 la personnalisation de la VM est stock\u00e9e<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0\u00a0\u00a0 transport: OvfEnv<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">#<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">#\u00a0 Au moment de l&#8217;\u00e9criture de cet article l&#8217;image ubuntu (ubuntu-20-1621373774638) ne peut pas utiliser les volumes car elle est bas\u00e9e sur la version 10 du virtual hardware est il faut au minimum qu&#8217;elle soit en 12<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">#\u00a0 L&#8217;image centos image (centos-stream-8-vmservice-v1alpha1-1619529007339) peut utiliser des volumes<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">#\u00a0 volumes: # au moment de l&#8217;\u00e9criture de cet article, le param\u00e8tre mount n&#8217;est pas utilisable, le volume est vu mais doit \u00eatre mont\u00e9 \u00e0 la main ou via Cloud Init<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">#\u00a0\u00a0\u00a0 &#8211; name: loeil-du-se-volume<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">#\u00a0\u00a0\u00a0\u00a0\u00a0 persistentVolumeClaim:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">#\u00a0\u00a0\u00a0\u00a0\u00a0 claimName: loeil-du-se-pvc<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">#\u00a0\u00a0\u00a0\u00a0\u00a0 readOnly: false<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">\u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Optionnel, le fichier descriptif du service r\u00e9seau<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Dans mon exemple, je cr\u00e9\u00e9 un service de type LoadBalancer pour me connecter en ssh \u00e0 partir d\u2019un r\u00e9seau externe \u00e0 celui des PODs.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Attention, le kind n\u2019est pas Service comme habituellement mais VirtualMachineService<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\"><strong>cat loeil-du-se-vm-service.yaml<br \/>\n<\/strong><\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">apiVersion: vmoperator.vmware.com\/v1alpha1<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">kind: VirtualMachineService<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">metadata:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 name: loeil-du-se-vm<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">spec:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 selector:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0\u00a0\u00a0 vm: loeil-du-se-vm<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 type: LoadBalancer<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0 ports:<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0\u00a0\u00a0 &#8211; name: ssh<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0 port: 22<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0 protocol: TCP<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0 targetPort: 22<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Une fois les fichiers YAML cr\u00e9\u00e9s, il ne reste plus qu\u2019\u00e0 les faire prendre en compte par Kubernetes.<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">Kubectl create -f loeil-du-se-vm-configmap.yaml<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">Kubectl create -f loeil-du-se-vm-deployment.yaml<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">Kubectl create -f loeil-du-se-vm-service.yaml<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Pour verifier la creation de la VM\u00a0:<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">Kubectl get vm<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Pour en savoir un peu plus\u00a0:<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">Kubectl describe vm loeil-du-se-vm<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Ca reste une VM classique, donc elle va b\u00e9n\u00e9ficier de HA et vMotion (via DRS ou mode maintenance du host). Par contre, elle est \u00ab\u00a0Developer Managed\u00a0\u00bb, c\u2019est-\u00e0-dire qu\u2019elle n\u2019est pas administrable via le vCenter, vous ne verrez pas par exemple le contenu de la console.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1047 aligncenter\" src=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/vm-developper-managed.png\" alt=\"\" width=\"537\" height=\"41\" srcset=\"https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/vm-developper-managed.png 537w, https:\/\/loeilduse.fr\/wp-content\/uploads\/2021\/06\/vm-developper-managed-300x23.png 300w\" sizes=\"(max-width: 537px) 100vw, 537px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Une astuce tout de m\u00eame, v\u00e9rifiez sur quel ESXi la VM s\u2019ex\u00e9cute, ensuite connectez-vous directement sur l\u2019ESXi via un navigateur et l\u00e0 vous aurez acc\u00e8s \u00e0 la console.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Pour se connecter en ssh, si vous avez comme moi un acc\u00e8s via un loadbalancer vous pouvez vous y connecter directement, sinon vous devrez passer par un POD de rebond (genre busybox, alpine ou autre) et faire un ssh avec l\u2019adresse IP sur le r\u00e9seau de POD. Vous pouvez la retrouver ainsi\u00a0:<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">kubectl get vm loeil-du-se-vm -o jsonpath='{.status.vmIp}&#8217;; echo<br \/>\n10.244.0.130<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Le ssh doit se faire via le user renseign\u00e9 dans le Cloud Init, j\u2019avais mis fbe, ca donne \u00e7a\u00a0:<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">kubectl get svc loeil-du-se-vm<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">NAME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TYPE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 CLUSTER-IP\u00a0\u00a0\u00a0 EXTERNAL-IP\u00a0\u00a0\u00a0 PORT(S)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 AGE<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">loeil-du-se-vm\u00a0\u00a0 LoadBalancer\u00a0\u00a0 10.96.1.108\u00a0\u00a0 172.20.18.71\u00a0\u00a0 22:32148\/TCP\u00a0\u00a0 2d22h<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">ssh <a href=\"mailto:fbe@172.20.18.71\">fbe@172.20.18.71<\/a><br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\u2026<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">To run a command as administrator (user &#8220;root&#8221;), use &#8220;sudo &lt;command&gt;&#8221;.<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">See &#8220;man sudo_root&#8221; for details.<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">fbe@loeil-du-se:~$<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Si le ssh ne fonctionne pas, c\u2019est que le user n\u2019a pas \u00e9tait pris en compte par Cloud Init, essayez avec root pour obtenir le user par d\u00e9faut, en g\u00e9n\u00e9rale ubuntu pour Ubuntu et cloud-user pour CentOS\u00a0:<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">ssh roo@172.20.18.71<br \/>\n<\/span><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">Please login as the user &#8220;ubuntu&#8221; rather than the user &#8220;root&#8221;.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Si vous avez l\u2019erreur ci-dessous, c\u2019est que le poste \u00e0 partir duquel vous vous connectez n\u2019a pas la cl\u00e9 ssh publique renseign\u00e9e ou il y a une erreur dans celle-ci, il faut donc v\u00e9rifier la cl\u00e9 figurant dans le fichier de configmap\u00a0:<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">fbe@172.20.18.71: Permission denied (publickey,password).<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Pour debugger Cloud Init, il faut se connecter \u00e0 l\u2019os de la vm via ssh ou via la console est regardez la log <span style=\"font-family: courier new, courier, monospace; font-size: 8pt;\">\/var\/log\/cloud-init-output.log<\/span><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: trebuchet ms, geneva, sans-serif;\">Voil\u00e0, n\u2019h\u00e9sitez pas \u00e0 me pinger si vous avez besoin d\u2019informations compl\u00e9mentaires.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pour cr\u00e9er une machine virtuelle avec vSphere with Tanzu via la commande kubectl, il y a des \u00e9tapes \u00e0 respecter pour l\u2019administrateur et pour le d\u00e9veloppeur, elles sont tr\u00e8s simples mais ce ne m\u2019a pas emp\u00each\u00e9 de perdre un peu de temps cot\u00e9 personnalisation sur la partie OS. je vous recommande cet article pour comprendre<\/p><\/div>\n<div class=\"blog-btn\"><a href=\"https:\/\/loeilduse.fr\/?p=1016&#038;lang=fr\" class=\"home-blog-btn\">Lire la suite<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[147],"tags":[474,468,470,466,464,149,472,462,498,500,416],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/loeilduse.fr\/index.php?rest_route=\/wp\/v2\/posts\/1016"}],"collection":[{"href":"https:\/\/loeilduse.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/loeilduse.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/loeilduse.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/loeilduse.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1016"}],"version-history":[{"count":15,"href":"https:\/\/loeilduse.fr\/index.php?rest_route=\/wp\/v2\/posts\/1016\/revisions"}],"predecessor-version":[{"id":1102,"href":"https:\/\/loeilduse.fr\/index.php?rest_route=\/wp\/v2\/posts\/1016\/revisions\/1102"}],"wp:attachment":[{"href":"https:\/\/loeilduse.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/loeilduse.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/loeilduse.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}