ÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõÄÈÝÆ÷ÖÎÀíƽ̨£¨ÈçKubernetes£©
ÔõÑùÔÚlinuxÉÏÉèÖø߿ÉÓõÄÈÝÆ÷ÖÎÀíƽ̨£¨Èçkubernetes£©
СÐò£º
Ëæ×ÅÈÝÆ÷ÊÖÒÕµÄÉú³¤£¬Ô½À´Ô½¶àµÄÆóÒµ×îÏȽÓÄÉÈÝÆ÷ÖÎÀíƽ̨À´¾ÙÐÐÓ¦Óõİ²ÅźÍÖÎÀí¡£¶øÆäÖÐ×îÊܽӴýµÄÈÝÆ÷ÖÎÀíƽ̨֮һ¾ÍÊÇKubernetes¡£±¾ÎĽ«ÏêϸÏÈÈÝÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõÄKubernetes¼¯Èº£¬ÒÔʵÏÖÈÝÆ÷µÄ¸ß¿ÉÓÃÐÔ¡£
×°ÖÃDocker
Ê×ÏÈ£¬ÔÚÿ̨ Linux Ö÷»úÉÏ×°Öà Docker£¬×÷Ϊ Kubernetes µÄµ×²ãÈÝÆ÷ÔËÐÐÇéÐΡ£ÒÔÏÂʾÀýÑÝʾÁËÔÚ Ubuntu ϵͳÉÏ×°Öà Docker µÄ°ì·¨¡£
$ sudo apt update $ sudo apt install docker.io
µÇ¼ºó¸´ÖÆ
×°ÖÃkubelet¡¢kubeadmºÍkubectl
½ÓÏÂÀ´£¬×°Öà Kubernetes µÄ×é¼þ kubelet¡¢kubeadm ºÍ kubectl¡£Kubelet ÊÇ Kubernetes µÄ½ÚµãÊðÀí£¬ÔÚÿ¸ö½ÚµãÉÏÔËÐÐÒÔÖÎÀíÈÝÆ÷¡£Kubeadm ÊÇÓÃÓÚ³õʼ»¯ Kubernetes ¼¯ÈºµÄ¹¤¾ß£¬¶ø kubectl ÊÇ Kubernetes µÄÏÂÁîÐй¤¾ß£¬ÓÃÓÚÓ뼯Ⱥ¾ÙÐн»»¥¡£
$ sudo apt update $ sudo apt install kubelet kubeadm kubectl
µÇ¼ºó¸´ÖÆ
³õʼ»¯Master½Úµã
Ñ¡Ôñһ̨Ö÷»ú×÷Ϊ Kubernetes ¼¯ÈºµÄ Master ½Úµã£¬²¢Ê¹Óà kubeadm ¹¤¾ß¾ÙÐгõʼ»¯¡£
$ sudo kubeadm init
µÇ¼ºó¸´ÖÆ
³õʼ»¯Àú³ÌÐèҪһЩʱ¼ä£¬Íê³Éºó»áÊä³öһЩÐÅÏ¢£¬ÆäÖаüÀ¨Ò»¸öÀàËÆÓÚÏÂÃæµÄÏÂÁÓÃÓÚ½«½Úµã¼ÓÈëµ½¼¯ÈºÖС£
$ sudo kubeadm join <master-ip>:<master-port> --token <token> --discovery-token-ca-cert-hash <hash>
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
½«Õâ¸öÏÂÁîÉúÑĵ½Ò»¸öÎļþÖУ¬ÒÔ±¸ºóÓá£
¼ÓÈëWorker½Úµã
ÔÚÆäËüËùÓеĽڵãÉÏ£¬Ê¹ÓÃÉÏÒ»²½ÉúÑÄµÄ join ÏÂÁîÀ´½«ËüÃǼÓÈëµ½ Kubernetes ¼¯ÈºÖС£
$ sudo kubeadm join <master-ip>:<master-port> --token <token> --discovery-token-ca-cert-hash <hash>
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ÉÔµÈƬÉΣ¬µ±½ÚµãÀֳɼÓÈëºó£¬Ê¹ÓÃÒÔÏÂÏÂÁîÈ·ÈϽڵãµÄ״̬¡£
$ kubectl get nodes
µÇ¼ºó¸´ÖÆ
×°ÖÃÍøÂç²å¼þ
ΪÁËʵÏÖ Kubernetes ¼¯ÈºÖи÷¸öÈÝÆ÷µÄÍøÂçͨѶ£¬ÎÒÃÇÐèҪװÖÃÒ»¸öÍøÂç²å¼þ¡£ÕâÀïÒÔCalicoÍøÂç²å¼þΪÀý¾ÙÐÐÑÝʾ¡£
$ kubectl apply -f https://docs.projectcalico.org/v3.11/manifests/calico.yaml
µÇ¼ºó¸´ÖÆ
ÉÔµÈƬÉΣ¬Ê¹ÓÃÒÔÏÂÏÂÁîÈ·ÈÏÍøÂç²å¼þµÄ״̬¡£
$ kubectl get pods --all-namespaces
µÇ¼ºó¸´ÖÆ
ÉèÖø߿ÉÓÃÐÔ
ΪÁËʵÏÖ Kubernetes ЧÀ͵ĸ߿ÉÓÃÐÔ£¬ÎÒÃÇ¿ÉÒÔʹÓà Kubernetes µÄ¸ß¿ÉÓÃ×é¼þkube-high-availability£¨kubeadm-ha£©£¬¼ò»¯ÉèÖõÄÀú³Ì¡£ÒÔÏÂʾÀýÑÝʾÁËÔõÑùʹÓà kube-ha ¹¤¾ß¾ÙÐÐÉèÖá£
$ sudo wget https://github.com/lucj/kube-ha/archive/master.zip $ sudo unzip master.zip $ cd kube-ha-master $ sudo systemctl start kubelet $ sudo ./install.sh
µÇ¼ºó¸´ÖÆ
´ó¹¦¸æ³É£¡ÏÖÔÚÄãÒѾÀÖ³ÉÉèÖÃÁËÒ»¸ö¸ß¿ÉÓÃµÄ Kubernetes ¼¯Èº¡£
½áÂÛ£º
ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÏêϸÏÈÈÝÁËÔõÑùÔÚ Linux ÉÏÉèÖø߿ÉÓÃµÄ Kubernetes ¼¯Èº¡£´Ó×°Öà Docker ºÍ Kubernetes ×é¼þ£¬µ½³õʼ»¯ Master ½ÚµãºÍ¼ÓÈë Worker ½Úµã£¬×îºó×°ÖÃÍøÂç²å¼þºÍÉèÖø߿ÉÓÃÐÔ£¬Ò»²½Ò»²½µÄÖ¸µ¼È·±£ÁËÎÒÃÇÀֳɵØÉèÖÃÁËÒ»¸ö¸ß¿ÉÓõÄÈÝÆ÷ÖÎÀíƽ̨¡£Õ⽫ΪÆóÒµÌṩһ¸öÎȹ̿ɿ¿µÄ»ù´¡ÉèÊ©£¬Ê¹µÃÈÝÆ÷Ó¦Óõİ²ÅźÍÖÎÀí±äµÃÔ½·¢¼òÆÓ¸ßЧ¡£
ÒÔÉϾÍÊÇÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõÄÈÝÆ÷ÖÎÀíƽ̨£¨ÈçKubernetes£©µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡