ÔõÑùÔÚLinuxÉϴÇå¾²¿É¿¿µÄÈÝÆ÷±àÅÅƽ̨£¿
ÔõÑùÔÚlinuxÉϴÇå¾²¿É¿¿µÄÈÝÆ÷±àÅÅƽ̨£¿
СÐò£º
ÈÝÆ÷ÊÖÒÕ½üÄêÀ´»ñµÃÆÕ±éµÄÓ¦ÓÃÓëÉú³¤£¬ËüµÄ·ºÆðʹµÃÓ¦Óð²ÅźÍÉý¼¶±äµÃ¸üΪÎÞаºÍ¸ßЧ¡£¶øÈÝÆ÷±àÅÅƽ̨Ôò¿ÉÒÔ½øÒ»²½Ìá¸ßÈÝÆ÷ÖÎÀíµÄ×Ô¶¯»¯ºÍ¿É¿¿ÐÔ¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚLinuxÉϴһ¸öÇå¾²¿É¿¿µÄÈÝÆ÷±àÅÅƽ̨£¬²¢ÌṩÏà¹Ø´úÂëʾÀý¡£
×°ÖÃDocker
DockerÊÇÒ»¸ö¿ªÔ´µÄÈÝÆ÷ÒýÇ棬Ëü¿ÉÒÔʵÏÖ½«Ó¦ÓóÌÐò×Ô¶¯´ò°üÔÚÈÝÆ÷ÖУ¬Àû±ã°²ÅźÍÔËÐС£ÔڴÈÝÆ÷±àÅÅƽ̨֮ǰ£¬ÐèÒªÏÈÔÚLinuxÉÏ×°ÖÃDocker¡£
ÔÚUbuntuÉÏ×°ÖÃDockerµÄÏÂÁîÈçÏ£º
sudo apt update sudo apt install docker.io
µÇ¼ºó¸´ÖÆ
×°ÖÃKubernetes
KubernetesÊÇÒ»¸ö¿ªÔ´µÄÈÝÆ÷±àÅÅƽ̨£¬Ëü¿ÉÒÔÓÃÀ´ÖÎÀíºÍµ÷ÀíÈÝÆ÷£¬Ìṩ¸ß¿ÉÓᢵ¯ÐÔÉìËõºÍ×Ô¶¯»¯µÄÈÝÆ÷°²ÅÅ·½·¨¡£ÔڴÈÝÆ÷±àÅÅƽ̨֮ǰ£¬ÐèҪװÖÃKubernetes¡£
ÔÚUbuntuÉÏ×°ÖÃKubernetesµÄÏÂÁîÈçÏ£º
sudo apt update sudo apt install kubeadm kubelet kubectl
µÇ¼ºó¸´ÖÆ
³õʼ»¯Kubernetes¼¯Èº
ÔڴÈÝÆ÷±àÅÅƽ̨֮ǰ£¬ÐèÒª³õʼ»¯Kubernetes¼¯Èº¡£Ê×ÏÈ£¬ÔÚÖ÷½ÚµãÉÏÔËÐÐÒÔÏÂÏÂÁî¾ÙÐгõʼ»¯£º
sudo kubeadm init
µÇ¼ºó¸´ÖÆ
È»ºó£¬Æ¾Ö¤Öն˵ÄÊä³ö£¬½«ÌìÉúµÄtokenÉúÑÄÏÂÀ´¡£½ÓÏÂÀ´£¬ÔÚÊÂÇé½ÚµãÉÏÔËÐÐÒÔÏÂÏÂÁî¾ÙÐмÓÈ뼯Ⱥ£º
sudo kubeadm join <master-ip>:<master-port> --token <token> --discovery-token-ca-cert-hash sha256:<hash>
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬ ÊÇÖ÷½ÚµãµÄIPµØµã£¬ ÊÇÖ÷½ÚµãµÄ¶Ë¿ÚºÅ£¬ ºÍ Êdzõʼ»¯Ö÷½ÚµãʱÌìÉúµÄtokenºÍhash¡£
×°ÖÃÈÝÆ÷ÍøÂç²å¼þ
½ÓÏÂÀ´£¬ÎÒÃÇÐèҪװÖÃÒ»¸öÈÝÆ÷ÍøÂç²å¼þ£¬ÒÔʵÏÖÈÝÆ÷Ö®¼äµÄͨѶ¡£ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÑ¡Ôñ×°ÖÃCalicoÍøÂç²å¼þ¡£
ÔÚÖ÷½ÚµãÉÏÔËÐÐÒÔÏÂÏÂÁî¾ÙÐÐ×°Öãº
kubectl create -f https://docs.projectcalico.org/v3.14/manifests/calico.yaml
µÇ¼ºó¸´ÖÆ
°²ÅÅÈÝÆ÷Ó¦ÓÃ
ÏÖÔÚ£¬ÎÒÃÇÒѾ´î½¨ºÃÁËÇå¾²¿É¿¿µÄÈÝÆ÷±àÅÅƽ̨£¬¿ÉÒÔ°²ÅÅÈÝÆ÷Ó¦ÓÃÁË¡£Ê×ÏÈ£¬ÐèÒª±àдһ¸ö°üÀ¨ÈÝÆ÷Ó¦ÓÃÉèÖõÄYAMLÎļþ¡£
ʾÀýµÄYAMLÎļþÈçÏ£º
apiVersion: apps/v1 kind: Deployment metadata: name: my-app spec: replicas: 3 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: - name: my-app-container image: my-app-image:latest ports: - containerPort: 80
µÇ¼ºó¸´ÖÆ
È»ºó£¬ÔËÐÐÒÔÏÂÏÂÁî¾ÙÐа²ÅÅ£º
kubectl apply -f my-app.yaml
µÇ¼ºó¸´ÖÆ
¼à¿ØºÍÈÕÖ¾ÖÎÀí
ÔÚÈÝÆ÷±àÅÅƽ̨ÖУ¬¼à¿ØºÍÈÕÖ¾ÖÎÀíÊǺÜÊÇÖ÷ÒªµÄÒ»²¿·Ö¡£¿ÉÒÔʹÓÃPrometheusºÍGrafanaÀ´¾ÙÐмà¿Ø£¬Ê¹ÓÃEFK£¨Elasticsearch+Fluentd+Kibana£©À´¾ÙÐÐÈÕÖ¾ÖÎÀí¡£ÕâÀï¸ø³öÒ»¸ö¼òÆÓµÄʾÀý¹©²Î¿¼£º
°²ÅÅPrometheusºÍGrafana£º
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.28.0/deploy/mandatory.yaml kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.28.0/deploy/provider/cloud-generic.yaml
µÇ¼ºó¸´ÖÆ
°²ÅÅEFK£º
kubectl apply -f https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/fluentd-elasticsearch/es-statefulset.yaml kubectl apply -f https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/fluentd-elasticsearch/es-service.yaml kubectl apply -f https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/fluentd-elasticsearch/fluentd-es-configmap.yaml kubectl apply -f https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/fluentd-elasticsearch/fluentd-es-ds.yaml kubectl apply -f https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/fluentd-elasticsearch/kibana-service.yaml
µÇ¼ºó¸´ÖÆ
½áÂÛ£º
±¾ÎÄÏÈÈÝÁËÔõÑùÔÚLinuxÉϴһ¸öÇå¾²¿É¿¿µÄÈÝÆ÷±àÅÅƽ̨¡£Í¨¹ý×°ÖÃDockerºÍKubernetes£¬²¢Ê¹ÓÃCalicoÍøÂç²å¼þ£¬¿ÉÒÔʵÏÖÈÝÆ÷µÄ¸ß¿ÉÓú͵¯ÐÔÉìËõ¡£±ðµÄ£¬Í¨¹ý°²ÅÅPrometheusºÍGrafana¾ÙÐмà¿Ø£¬ÒÔ¼°°²ÅÅEFK¾ÙÐÐÈÕÖ¾ÖÎÀí£¬¿ÉÒÔÌá¸ßÈÝÆ÷ÖÎÀíµÄ¿É¿¿ÐÔºÍÇå¾²ÐÔ¡£Ï£Íû±¾ÎĶԸ÷ÈËÔڴÈÝÆ÷±àÅÅƽ̨·½ÃæÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇÔõÑùÔÚLinuxÉϴÇå¾²¿É¿¿µÄÈÝÆ÷±àÅÅƽ̨£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡