×ðÁú¿­Ê±¹ÙÍøµÇ¼

ÔõÑùÔÚLinuxÉÏÉèÖÃÈÝÆ÷ÖÎÀíƽ̨£¨ÈçKubernetes£©

ÔõÑùÔÚlinuxÉÏÉèÖÃÈÝÆ÷ÖÎÀíƽ̨£¨Èçkubernetes£©

СÐò£º

ÔÚµ±½ñµÄÔÆÅÌËãʱ´ú £¬ÈÝÆ÷»¯ÊÖÒÕ³ÉΪÁËÒ»ÖÖÊ¢Ðеİ²ÅźÍÖÎÀíÓ¦ÓóÌÐòµÄ·½·¨¡£KubernetesÊÇÒ»¸ö¿ªÔ´µÄÈÝÆ÷±àÅźÍÖÎÀíƽ̨ £¬Ëü¿ÉÒÔ¼ò»¯Ó¦ÓóÌÐòµÄ°²ÅÅ¡¢À©Õ¹ºÍÖÎÀí¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚLinuxÉÏÉèÖÃKubernetes £¬°üÀ¨×°ÖúÍÉèÖõÄÏêϸ°ì·¨ £¬ÒÔ¼°Ò»Ð©³£ÓõÄÏÂÁîºÍʾÀý¡£

Ò»¡¢×°ÖÃDocker

ÔÚÉèÖÃKubernetes֮ǰ £¬ÎÒÃÇÐèÒªÏÈ×°ÖÃDocker £¬ÓÉÓÚKubernetesʹÓÃDockerÀ´ÔËÐÐÈÝÆ÷¡£ÒÔÏÂÊÇÔÚUbuntuϵͳÉÏ×°ÖÃDockerµÄʾÀýÏÂÁ

sudo apt update
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker

µÇ¼ºó¸´ÖÆ

¶þ¡¢×°ÖÃKubernetes

×°ÖÃkubelet¡¢kubeadmºÍkubectlÈý¸ö×é¼þ £¬ÕâЩ×é¼þ»®·ÖÓÃÓÚÔÚ¼¯ÈºÖеĽڵãÉÏÔËÐС¢³õʼ»¯ºÍÖÎÀíKubernetes¡£

sudo apt update
sudo apt install -y kubelet kubeadm kubectl
sudo systemctl enable kubelet

µÇ¼ºó¸´ÖÆ

ÉèÖÃÍøÂç²å¼þ £¬KubernetesÐèÒªÍøÂç²å¼þÀ´ÎªÈÝÆ÷ÌṩÍøÂ绥ͨµÄ¹¦Ð§¡£ÕâÀïÎÒÃÇÑ¡ÔñʹÓÃCalico×÷ΪÍøÂç²å¼þ¡£

sudo kubectl apply -f https://docs.projectcalico.org/v3.8/manifests/calico.yaml

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

³õʼ»¯Kubernetes Master½Úµã £¬Ê¹ÓÃkubeadm initÏÂÁîÀ´³õʼ»¯Kubernetes Master½Úµã £¬²¢½«ÌìÉúµÄjoinÏÂÁîÉúÑÄÏÂÀ´ÓÃÓÚºóÐø½ÚµãµÄ¼ÓÈë¡£

sudo kubeadm init --pod-network-cidr=192.168.0.0/16

µÇ¼ºó¸´ÖÆ

ÉèÖÃKubernetes Master½Úµã £¬Æ¾Ö¤initÏÂÁîµÄÊä³öÐÅÏ¢ £¬Ö´ÐÐÒÔÏÂÏÂÁîÀ´ÉèÖÃKubernetes Master½Úµã¡£

sudo mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

µÇ¼ºó¸´ÖÆ

°²ÅÅÍøÂç²å¼þ £¬Ê¹ÓÃÒÔÏÂÏÂÁîÀ´°²ÅÅÍøÂç²å¼þ¡£

sudo kubectl apply -f https://docs.projectcalico.org/v3.8/manifests/calico.yaml

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

¼ÓÈëKubernetes½Úµã £¬Æ¾Ö¤Ö®ËÞÊÀ´æµÄjoinÏÂÁî £¬Ö´ÐÐÒÔÏÂÏÂÁîÀ´½«ÆäËû½Úµã¼ÓÈëµ½Kubernetes¼¯ÈºÖС£

sudo kubeadm join <master-ip>:<master-port> --token <token> --discovery-token-ca-cert-hash <hash>

µÇ¼ºó¸´ÖÆ

Èý¡¢³£ÓÃÏÂÁîºÍʾÀý

Éó²é¼¯ÈºÐÅÏ¢ £¬Ê¹ÓÃÒÔÏÂÏÂÁîÀ´Éó²éKubernetes¼¯ÈºµÄÐÅÏ¢¡£

kubectl cluster-info

µÇ¼ºó¸´ÖÆ

Éó²é½ÚµãÐÅÏ¢ £¬Ê¹ÓÃÒÔÏÂÏÂÁîÀ´Éó²éKubernetes¼¯ÈºÖеĽڵãÐÅÏ¢¡£

kubectl get nodes

µÇ¼ºó¸´ÖÆ

°²ÅÅÓ¦ÓóÌÐò £¬Ê¹ÓÃÒÔÏÂÏÂÁîÀ´°²ÅÅÒ»¸öÓ¦ÓóÌÐò¡£

kubectl run <app-name> --image=<image-name> --port=<port>

µÇ¼ºó¸´ÖÆ

Éó²éÓ¦ÓóÌÐòµÄ״̬ £¬Ê¹ÓÃÒÔÏÂÏÂÁîÀ´Éó²éÓ¦ÓóÌÐòµÄ״̬¡£

kubectl get pods

µÇ¼ºó¸´ÖÆ

À©Õ¹Ó¦ÓóÌÐò £¬Ê¹ÓÃÒÔÏÂÏÂÁîÀ´À©Õ¹Ò»¸öÓ¦ÓóÌÐòµÄ¸±±¾Êý¡£

kubectl scale deployment <deploy-name> --replicas=<replica-count>

µÇ¼ºó¸´ÖÆ

½áÂÛ£º

ͨ¹ýÒÔÉÏ°ì·¨ £¬ÎÒÃÇÀֳɵØÔÚLinuxÉÏÉèÖÃÁËKubernetesÈÝÆ÷ÖÎÀíƽ̨¡£Í¨¹ýKubernetes £¬ÎÒÃÇ¿ÉÒÔ¸üÀû±ãµØ°²ÅÅ¡¢À©Õ¹ºÍÖÎÀíÓ¦ÓóÌÐò¡£¿ÉÊÇҪעÖØ £¬ÔÚÉèÖÃKubernetesʱ £¬ÐèÒª×ÐϸÔĶÁ¹Ù·½Îĵµ²¢×ñÕÕ×°ÖÃÖ¸ÄÏ £¬ÒÔÈ·±£×°ÖúÍÉèÖõÄ׼ȷÐÔ¡£

²Î¿¼Á´½Ó£º

Kubernetes¹Ù·½Îĵµ£ºhttps://kubernetes.io/

Calico¹Ù·½Îĵµ£ºhttps://docs.projectcalico.org/v3.8/getting-started/kubernetes/

ÒÔÉϾÍÊÇÔõÑùÔÚLinuxÉÏÉèÖÃÈÝÆ÷ÖÎÀíƽ̨£¨ÈçKubernetes£©µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ