{"id":957,"date":"2019-03-24T09:43:16","date_gmt":"2019-03-24T01:43:16","guid":{"rendered":"http:\/\/www.rao-bing.cn\/?p=957"},"modified":"2020-01-06T16:12:14","modified_gmt":"2020-01-06T08:12:14","slug":"install-k8s","status":"publish","type":"post","link":"http:\/\/www.rao-bing.cn\/index.php\/2019\/03\/24\/957\/","title":{"rendered":"install k8s"},"content":{"rendered":"<h3><\/h3>\n<h1>master\u8282\u70b9\u6b65\u9aa4<\/h1>\n<p>\u521d\u59cb\u73af\u5883\uff1aredhat 7.5 \u6700\u5c0f\u5b89\u88c5<\/p>\n<h2>1.\u51c6\u5907\u5de5\u4f5c\uff1a<\/h2>\n<h3>1.1 local yum repo<\/h3>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:814fdb19-c5f2-47c1-8558-084f25295e22\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; pad-line-numbers: true; title: ; notranslate\" title=\"\">\ncat &lt;&lt;EOF &gt;\/etc\/yum.repos.d\/rhel.repo\n&#x5B;RHEL75]\nname=RHEL 7.5\nbaseurl=file:\/\/\/mnt\ngpgcheck=0 \nenabled=1\nEOF\n\n<\/pre>\n<\/div>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:26c5c832-5771-44e3-8b54-89029d5a8104\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nmount \/dev\/sr0 \/mnt\n\nyum repolist\n<\/pre>\n<\/div>\n<h6><\/h6>\n<h3>1.2 \u5b89\u88c5\u5fc5\u8981\u5de5\u5177<\/h3>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:cc8e4d51-d03e-4a3d-b8ec-806362efc6ca\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# yum install perl wget\n<\/pre>\n<\/div>\n<h3>1.3 \u5173\u95edselinux\uff0c\u5173\u95ed\u9632\u706b\u5899<\/h3>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:6c7b5895-e4ea-4506-8039-60b7c7ecff05\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# systemctl disable firewalld\n\n# systemctl stop firewalld\n\n# perl -p -i -e \"s\/SELINUX=enforcing\/SELINUX=disabled\/g\" \/etc\/selinux\/config\n<\/pre>\n<\/div>\n<h3>1.4 \u786e\u4fdd\u6bcf\u4e2a\u8282\u70b9\u4e0a MAC \u5730\u5740\u548c product_uuid \u7684\u552f\u4e00\u6027\u3002<\/h3>\n<p><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528\u4e0b\u5217\u547d\u4ee4\u83b7\u53d6\u7f51\u7edc\u63a5\u53e3\u7684 MAC \u5730\u5740\uff1a<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:5137f4ca-7e4f-462e-8d44-321ef7b4e98a\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# ifconfig -a\n<\/pre>\n<\/div>\n<p>\u4e0b\u5217\u547d\u4ee4\u53ef\u4ee5\u7528\u6765\u83b7\u53d6 product_uuid <\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:2764bcb8-1eef-48c5-98d9-b010e88aa958\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# sudo cat \/sys\/class\/dmi\/id\/product_uuid\n<\/pre>\n<\/div>\n<p>\u4e00\u822c\u6765\u8bb2\uff0c\u786c\u4ef6\u8bbe\u5907\u4f1a\u62e5\u6709\u72ec\u4e00\u65e0\u4e8c\u7684\u5730\u5740\uff0c\u4f46\u662f\u6709\u4e9b\u865a\u62df\u673a\u53ef\u80fd\u4f1a\u96f7\u540c\u3002Kubernetes \u4f7f\u7528\u8fd9\u4e9b\u503c\u6765\u552f\u4e00\u786e\u5b9a\u96c6\u7fa4\u4e2d\u7684\u8282\u70b9\u3002\u5982\u679c\u8fd9\u4e9b\u503c\u5728\u96c6\u7fa4\u4e2d\u4e0d\u552f\u4e00\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5b89\u88c5\u5931\u8d25\u3002<\/p>\n<h3>1.5 \u5173\u6389swap<\/h3>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:afb26fe6-987a-4c3a-bd9f-54a84e7a3c67\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# swapoff -a\n<\/pre>\n<\/div>\n<p>\u6c38\u4e45\u751f\u6548\u7684\u65b9\u6cd5\u662f\u5728\/etc\/fstab\u4e2d\u6ce8\u91ca\u6389swap\u5bf9\u5e94\u7684\u884c\u3002<\/p>\n<h2>2. \u5b89\u88c5 Docker<\/h2>\n<h3>2.1 \u4f9d\u8d56\u5305<\/h3>\n<p>\u7f51\u4e0a\u641c\u7d22\u4e0b\u8f7d\u8fd9\u4e2acontainer-selinux\u5305\uff1a<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:e6202ce3-b343-4b76-b2fe-21afb24bdc46\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# wget ftp:\/\/bo.mirror.garr.it\/1\/slc\/centos\/7.1.1503\/extras\/x86_64\/Packages\/container-selinux-2.9-4.el7.noarch.rpm\n\n# yum install container-selinux-2.9-4.el7.noarch.rpm \uff08\u4f1a\u5b89\u88c5linux DVD\u4e2d\u7684\u5176\u4ed6\u4f9d\u8d56\u5305\uff09\n<\/pre>\n<\/div>\n<h3>2.2 yum\u5b89\u88c5<\/h3>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:266f58d9-54a2-4736-ac0d-d1fc6eb04e83\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# yum install -y yum-utils device-mapper-persistent-data lvm2\n\n# yum-config-manager --add-repo https:\/\/download.docker.com\/linux\/centos\/docker-ce.repo\n\n# yum install docker-ce\n<\/pre>\n<\/div>\n<h3>2.3 rpm\u5305\u5b89\u88c5<\/h3>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1a https:\/\/download.docker.com\/linux\/centos\/7\/x86_64\/stable\/Packages\/<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:7b06c7f1-6e9c-4af5-a340-54be7dfa57ed\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# yun install &lt;rpm file&gt;\n<\/pre>\n<\/div>\n<p>3\u4e2a\u5305\uff1a<\/p>\n<ul>\n<li>docker-ce-cli.x86_64 1:18.09.2-3.el7<\/li>\n<li>containerd.io.x86_64 0:1.2.2-3.3.el7<\/li>\n<li>docker-ce.x86_64 3:18.09.2-3.el7<\/li>\n<\/ul>\n<p>\u5176\u4ed6\u4f9d\u8d56\u5305\u5728linux DVD\u4e2d\u3002<\/p>\n<h3>2.4 \u542f\u52a8\u670d\u52a1<\/h3>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:9684d8d6-22fc-47e5-b918-dadbb4f54514\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# systemctl enable docker\n\n# systemctl start docker\n<\/pre>\n<\/div>\n<p>\u9a8c\u8bc1\uff1a<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:44331e21-ab6b-4f80-b799-3efdb1be9100\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# docker run hello-world\n<\/pre>\n<\/div>\n<p>\/\/\u4f1a\u4e0b\u8f7dimage\uff0c\u5e76\u8fd0\u884c<\/p>\n<h3>2.5 \u955c\u50cf\u52a0\u901f<\/h3>\n<p>\u5bf9\u4e8e\u4f7f\u7528 systemd \u7684\u7cfb\u7edf\uff0c\u8bf7\u5728 \/etc\/docker\/daemon.json \u4e2d\u5199\u5165\u5982\u4e0b\u5185\u5bb9\uff08\u5982\u679c\u6587\u4ef6\u4e0d\u5b58\u5728\u8bf7\u65b0\u5efa\u8be5\u6587\u4ef6\uff09<\/p>\n<p>\u6ce8\uff1a\u82e5\u5e73\u5e38\u4f7f\u7528\u963f\u91cc\u4e91\u955c\u50cf\u8f83\u4e3a\u9891\u7e41\uff0c\u63a8\u8350\u4f7f\u7528\u963f\u91cc\u4e91\u955c\u50cf\u52a0\u901f\uff0c\u8fd9\u91cc\u4ee5 Docker \u5b98\u65b9\u52a0\u901f\u5668 \u4e3a\u4f8b<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:9f9369af-c5bb-48df-bdd0-af1d6ffcd50a\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# cat &lt;&lt;EOF &gt; \/etc\/docker\/daemon.json\n\n{\n\n&quot;registry-mirrors&quot;: &#x5B;\n\n&quot;https:\/\/registry.docker-cn.com&quot;\n\n]\n\n}\n\nEOF\n\n# systemctl daemon-reload\n\n# systemctl restart docker\n<\/pre>\n<\/div>\n<h2>3.\u5b89\u88c5kubectl, kubeadm, kubelet<\/h2>\n<h3>3.1 Yum \u5b89\u88c5<\/h3>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:eb28a0d6-cb37-4121-879b-928b77700431\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ncat &lt;&lt;EOF &gt; \/etc\/yum.repos.d\/kubernetes.repo\n\n&#x5B;kubernetes]\n\nname=Kubernetes\n\nbaseurl=https:\/\/mirrors.aliyun.com\/kubernetes\/yum\/repos\/kubernetes-el7-x86_64\/\n\nenabled=1\n\ngpgcheck=1\n\nrepo_gpgcheck=1\n\ngpgkey=https:\/\/mirrors.aliyun.com\/kubernetes\/yum\/doc\/yum-key.gpg https:\/\/mirrors.aliyun.com\/kubernetes\/yum\/doc\/rpm-package-key.gpg\n\nEOF\n\n# yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes\n\n# systemctl enable kubelet \uff08\u8fd9\u65f6\u542f\u52a8\u4e0d\u4e86\uff0c\u4f1a\u56e0\u4e3a\u6ca1\u6709\u521d\u59cb\u5316\u51fa\u914d\u7f6e\u6587\u4ef6\u800c\u62a5\u9519\uff09 \n<\/pre>\n<\/div>\n<h3>3.2 \u4fee\u6539\u5185\u6838\u53c2\u6570<\/h3>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:8427c294-3b64-4861-9f90-1657d3e1bdca\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ncat &lt;&lt;EOF &gt; \/etc\/sysctl.d\/k8s.conf\n\nnet.bridge.bridge-nf-call-ip6tables = 1\n\nnet.bridge.bridge-nf-call-iptables = 1\n\nEOF\n\nsysctl --system\n<\/pre>\n<\/div>\n<h3>3.3 \u786e\u8ba4cgroup driver<\/h3>\n<p>\u786e\u4fddEnvironmentFile=-\/var\/lib\/kubelet\/kubeadm-flags.env \u6587\u4ef6\u4e2d\u7684\u503c\u548c<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:b03721be-0963-4c23-bb35-2a89011e6681\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# docker info| grep Cgroup\n<\/pre>\n<\/div>\n<p>\u8fd4\u56de\u7684\u503c\u4e00\u81f4\uff0c\u4e5f\u5c31\u662fcgroupfs\u3002<\/p>\n<p>\u76ee\u524d\u770b\uff0c1.13.3\u7684\u503c\u7f3a\u7701\u5c31\u662f\u548cdocker\u7684\u4e00\u6837\uff0c\u4e0d\u50cf\u524d\u671f\u7248\u672c\uff0c1.13.3\u4e0d\u9700\u8981\u4fee\u6539\u3002<\/p>\n<h2>4.\u914d\u7f6e\u955c\u50cf<\/h2>\n<p>\u67e5\u770b\u9700\u8981\u7684docker images\uff1a<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:97bcf9cc-f798-473c-80f8-c884236bf2d4\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubeadm config images list\n<\/pre>\n<\/div>\n<p>\u4e0b\u8f7d\u5230\u672c\u5730\uff0c\u7136\u540e\u4fee\u6539tag\uff1a<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:bf761534-c211-4809-899d-b286f68ea182\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ndocker pull mirrorgooglecontainers\/kube-apiserver:v1.13.3\n\ndocker pull mirrorgooglecontainers\/kube-controller-manager:v1.13.3\n\ndocker pull mirrorgooglecontainers\/kube-scheduler:v1.13.3\n\ndocker pull mirrorgooglecontainers\/kube-proxy:v1.13.3\n\ndocker pull mirrorgooglecontainers\/pause:3.1\n\ndocker pull mirrorgooglecontainers\/etcd:3.2.24\n\ndocker pull coredns\/coredns:1.2.6\n<\/pre>\n<\/div>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:dbe1151d-244c-4800-8ecf-220ad418016b\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ndocker tag mirrorgooglecontainers\/kube-apiserver:v1.13.3 k8s.gcr.io\/kube-apiserver:v1.13.3\n\ndocker tag mirrorgooglecontainers\/kube-controller-manager:v1.13.3 k8s.gcr.io\/kube-controller-manager:v1.13.3\n\ndocker tag mirrorgooglecontainers\/kube-scheduler:v1.13.3 k8s.gcr.io\/kube-scheduler:v1.13.3\n\ndocker tag mirrorgooglecontainers\/kube-proxy:v1.13.3 k8s.gcr.io\/kube-proxy:v1.13.3\n\ndocker tag mirrorgooglecontainers\/pause:3.1 k8s.gcr.io\/pause:3.1\n\ndocker tag mirrorgooglecontainers\/etcd:3.2.24 k8s.gcr.io\/etcd:3.2.24\n\ndocker tag docker.io\/coredns\/coredns:1.2.6 k8s.gcr.io\/coredns:1.2.6\n<\/pre>\n<\/div>\n<h2>5.\u521d\u59cb\u5316k8s cluster<\/h2>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:bbe514bf-3f49-4201-bc56-a8e2fef721a5\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubeadm init --pod-network-cidr=10.10.0.0\/16\n<\/pre>\n<\/div>\n<p>\u6839\u636e\u4e0a\u4e00\u6b65\u6700\u540e\u7684\u63d0\u793a\uff0c\u6267\u884c\uff1a<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:6d23fe0b-e1ef-40c3-a190-0508b38ddfb2\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nmkdir -p $HOME\/.kube\n\nsudo cp -i \/etc\/kubernetes\/admin.conf $HOME\/.kube\/config\n\nsudo chown $(id -u):$(id -g) $HOME\/.kube\/config\n<\/pre>\n<\/div>\n<h2>6.\u5b89\u88c5calico\u7f51\u7edc\u63d2\u4ef6<\/h2>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:b4e2e446-ed51-42c3-9e4c-991864afe428\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubectl apply -f https:\/\/docs.projectcalico.org\/v3.3\/getting-started\/kubernetes\/installation\/hosted\/rbac-kdd.yaml\n\n# kubectl apply -f https:\/\/docs.projectcalico.org\/v3.3\/getting-started\/kubernetes\/installation\/hosted\/kubernetes-datastore\/calico-networking\/1.7\/calico.yaml\n<\/pre>\n<\/div>\n<p>\u7136\u540e\u518d\u542f\u52a8kubelet\u670d\u52a1\uff1a<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:567256ee-389e-406c-8a5d-f8b63d3a7e97\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# systemctl start kubelet\n<\/pre>\n<\/div>\n<p>\u5982\u679c\u6709\u62a5\u9519\uff0c\u53ef\u80fd\u662fcalico\u7684images\u8fd8\u6ca1\u4e0b\u8f7d\u5b8c\u6210\uff0c\u53ef\u4ee5\u7528docker images\u67e5\u770b\uff1a<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:59a63464-2e15-4a34-8b0a-fc5f109ea4d4\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# docker images |grep calico\n\ncalico\/node v3.3.4 74004ba60cc5 3 days ago 75.3MB\n\ncalico\/cni v3.3.4 d97e9e8e263d 3 days ago 75.4MB\n<\/pre>\n<\/div>\n<p>\u540c\u65f6\u786e\u4fdd\/etc\/cni\/net.d\u76ee\u5f55\u4e0b\u751f\u6210\u4e86\u76f8\u5e94\u7684\u6587\u4ef6<\/p>\n<h2>7.\u67e5\u770bcluster\u72b6\u6001<\/h2>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:175999ab-1a7d-46e5-ac56-f716feafc10d\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubectl cluster-info\n\nKubernetes master is running at https:\/\/192.168.0.41:6443\n\nKubeDNS is running at https:\/\/192.168.0.41:6443\/api\/v1\/namespaces\/kube-system\/services\/kube-dns:dns\/proxy\n\nTo further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.\n<\/pre>\n<\/div>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:3e0d8797-3b1b-44f0-bad8-8caee84177ca\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubectl get pods --all-namespaces\n\nNAMESPACE NAME READY STATUS RESTARTS AGE\n\nkube-system calico-node-nsd5f 2\/2 Running 0 13m\n\nkube-system coredns-86c58d9df4-c7mmm 1\/1 Running 0 22m\n\nkube-system coredns-86c58d9df4-cnmbg 1\/1 Running 0 22m\n\nkube-system etcd-rh75vm41 1\/1 Running 0 21m\n\nkube-system kube-apiserver-rh75vm41 1\/1 Running 0 21m\n\nkube-system kube-controller-manager-rh75vm41 1\/1 Running 0 21m\n\nkube-system kube-proxy-xq9dk 1\/1 Running 0 22m\n\nkube-system kube-scheduler-rh75vm41 1\/1 Running 0 21m\n<\/pre>\n<\/div>\n<h1>worker\u8282\u70b9\u6b65\u9aa4<\/h1>\n<p>\u7b2c1\u52304\u6b65\u548cmaster\u8282\u70b9\u4e00\u6837\u3002<\/p>\n<h2>5.\u5c06worker\u8282\u70b9\u52a0\u5165\u5230\u96c6\u7fa4<\/h2>\n<p>\u5728master\u8282\u70b9\u6267\u884c\uff1a<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:0dcd1838-0fb3-44e2-9169-3e58a59516f7\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubeadm join --token &lt;token&gt; &lt;master-ip&gt;:&lt;master-port&gt; --discovery-token-ca-cert-hash sha256:&lt;hash&gt;\n<\/pre>\n<\/div>\n<p>\u4f8b\u5982\uff1a<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:58ef0402-b798-4560-80f5-4db772085f2d\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubeadm join 192.168.0.41:6443 --token dn85nz.uj7zf8a4qzsz5mev --discovery-token-ca-cert-hash sha256:adfabaf4fe85218d443d46da0577e3769028d8a9e4eb6fd4972555f2ede7228f\n<\/pre>\n<\/div>\n<p>\u52a0\u5165\u6210\u529f\u540e\uff0c\u5728worker\u8282\u70b9\u4e5f\u4f1a\u81ea\u52a8pull \u7f51\u7edc\uff08calico\uff09\u76f8\u5173\u7684images\uff0c\u5728calico \u76f8\u5173images\u6ca1\u6709\u4e0b\u8f7d\u5b8c\u6210\u4e4b\u524d\uff0c\u8282\u70b9\u7684\u72b6\u6001\u4f1a\u662fNotReady\u3002\u5f53\u7f51\u7edcimages\u4e0b\u8f7d\u5b8c\u6210\uff0ckubelet\u72b6\u6001\u6b63\u5e38\u540e\uff0c\u8282\u70b9\u72b6\u6001\u4f1a\u53d8\u4e3aReady:<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:ef685743-30ef-4d6f-a5d6-b90a87f2fa63\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubectl get nodes\n\nNAME STATUS ROLES AGE VERSION\n\nrh75vm41 Ready master 28h v1.13.3\n\nrh75vm42 Ready &lt;none&gt; 6m v1.13.3\n\n\n# kubectl get pods -n kube-system -o wide\n\nNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES\n\ncalico-node-bxvz7 2\/2 Running 0 31m 192.168.0.42 rh75vm42 &lt;none&gt; &lt;none&gt;\n\ncalico-node-nsd5f 2\/2 Running 0 28h 192.168.0.41 rh75vm41 &lt;none&gt; &lt;none&gt;\n\ncoredns-86c58d9df4-c7mmm 1\/1 Running 0 28h 10.10.0.2 rh75vm41 &lt;none&gt; &lt;none&gt;\n\ncoredns-86c58d9df4-cnmbg 1\/1 Running 0 28h 10.10.0.3 rh75vm41 &lt;none&gt; &lt;none&gt;\n\netcd-rh75vm41 1\/1 Running 0 28h 192.168.0.41 rh75vm41 &lt;none&gt; &lt;none&gt;\n\nkube-apiserver-rh75vm41 1\/1 Running 0 28h 192.168.0.41 rh75vm41 &lt;none&gt; &lt;none&gt;\n\nkube-controller-manager-rh75vm41 1\/1 Running 0 28h 192.168.0.41 rh75vm41 &lt;none&gt; &lt;none&gt;\n\nkube-proxy-bw2r2 1\/1 Running 0 31m 192.168.0.42 rh75vm42 &lt;none&gt; &lt;none&gt;\n\nkube-proxy-xq9dk 1\/1 Running 0 28h 192.168.0.41 rh75vm41 &lt;none&gt; &lt;none&gt;\n\nkube-scheduler-rh75vm41 1\/1 Running 0 28h 192.168.0.41 rh75vm41 &lt;none&gt; &lt;none&gt;\n<\/pre>\n<\/div>\n<h1>\u5176\u4ed6<\/h1>\n<h2>1. token \u76f8\u5173<\/h2>\n<h3>\u67e5\u770btoken<\/h3>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:572bdd7c-9cdc-4816-842a-306c01e1a8a8\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubeadm token list\n<\/pre>\n<\/div>\n<h3>\u91cd\u65b0\u751f\u6210token<\/h3>\n<p>Toke\u7684\u6709\u9650\u671f\u5e94\u8be5\u662f23H\uff0c\u5982\u679c\u8fc7\u4e86\u8fd9\u4e2a\u65f6\u95f4\uff0c\u9700\u8981\u91cd\u65b0\u751f\u6210toke, \u53ef\u4ee5\u7528\u547d\u4ee4\uff1a<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:bfee98fc-3c69-4d88-9442-73c14335c540\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubeadm token create\n<\/pre>\n<\/div>\n<h2>2. \u90e8\u7f72k8s dashboard<\/h2>\n<h3>\u51c6\u5907\u955c\u50cf\u53ca\u90e8\u7f72<\/h3>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:2fea1c6a-97aa-4a4f-b1a5-bc0349b7f05a\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# wget https:\/\/raw.githubusercontent.com\/kubernetes\/dashboard\/v1.10.1\/src\/deploy\/recommended\/kubernetes-dashboard.yaml\n<\/pre>\n<\/div>\n<p>\u4ece\u6587\u4ef6\u4e2d\u67e5\u770b\u9700\u8981\u7684docker\u955c\u50cf\uff1a<\/p>\n<p>\u57281.10.1\u7248\u672c\uff0c\u9700\u8981\u7684\u955c\u50cf\u662f k8s.gcr.io\/kubernetes-dashboard-amd64:v1.10.1<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u65b9\u5f0f\u83b7\u5f97\u955c\u50cf\uff1a<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:52115577-205b-4bc6-93d1-6eeb4994e3f7\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# docker pull mirrorgooglecontainers\/kubernetes-dashboard-amd64:v1.10.1\n\n# docker tag mirrorgooglecontainers\/kubernetes-dashboard-amd64:v1.10.1 k8s.gcr.io\/kubernetes-dashboard-amd64:v1.10.1\n<\/pre>\n<\/div>\n<p>\u7136\u540e\u90e8\u7f72dashboard\uff1a<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:b9b53fed-d632-4972-8be4-3fa709ce5b9e\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubectl apply -f kubernetes-dashboard.yaml\n<\/pre>\n<\/div>\n<h3>\u67e5\u770b\u72b6\u6001<\/h3>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:d14aca61-1b90-437c-8597-438fc6e58248\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubectl get deployments --all-namespaces\n\nNAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE\n\ndefault curl 1\/1 1 1 97m\n\nkube-system calico-typha 0\/0 0 0 30h\n\nkube-system coredns 2\/2 2 2 30h\n\nkube-system kubernetes-dashboard 1\/1 1 1 87m\n<\/pre>\n<\/div>\n<h3>\u51c6\u5907proxy\u53ca\u6253\u5f00\u767b\u9646\u9875\u9762<\/h3>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:a6a025da-061f-45b9-bdb6-015248447090\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubectl proxy\n<\/pre>\n<\/div>\n<p>\u7136\u540e\u5728master\u672c\u673a\uff0c\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u4f7f\u7528\u4e0b\u9762\u5730\u5740\u8bbf\u95eedashboard\uff1a<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:1ccf03d8-e492-4af8-83fc-7c3b525a0ae8\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nhttp:\/\/localhost:8001\/api\/v1\/namespaces\/kube-system\/services\/https:kubernetes-dashboard:\/proxy\/\n<\/pre>\n<\/div>\n<p>\u53ef\u4ee5\u6253\u5f00\u767b\u5f55\u9875\u9762\uff0c\u4f46\u662f\u76ee\u524d\u8fd8\u65e0\u6cd5\u767b\u9646\u3002<\/p>\n<h3>\u521b\u5efa\u7528\u6237\u53ca\u89d2\u8272<\/h3>\n<p>\u521b\u5efa\u6587\u4ef6 admin-user.yaml<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:e4fa014c-17ba-4b43-9e7d-e7a1db5d013e\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\napiVersion: v1\nkind: ServiceAccount\nmetadata:\n  name: admin-user\n  namespace: kube-system\n<\/pre>\n<\/div>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:756b5f8c-bdcf-469f-ad96-5c13ac274354\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubectl apply -f admin-user.yaml\n<\/pre>\n<\/div>\n<p>\u521b\u5efa\u6587\u4ef6 admin-role.yaml:<\/p>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:337444f4-79bb-4028-a8d1-f72196d37c4c\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\napiVersion: rbac.authorization.k8s.io\/v1\nkind: ClusterRoleBinding\nmetadata:\n  name: admin-user\nroleRef:\n  apiGroup: rbac.authorization.k8s.io\n  kind: ClusterRole\n  name: cluster-admin\nsubjects:\n- kind: ServiceAccount\n  name: admin-user\n  namespace: kube-system\n<\/pre>\n<\/div>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:75106be8-993e-4fca-9fd1-543d545ad704\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n# kubectl apply -f admin-role.yaml\n<\/pre>\n<\/div>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:d6739372-f3b9-411d-9dd6-5e0a96c34ce0\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubectl apply -f admin-role.yaml\n\n<\/pre>\n<\/div>\n<h6><\/h6>\n<h6><\/h6>\n<h3>\u83b7\u53d6token<\/h3>\n<div class=\"wlWriterEditableSmartContent\" id=\"scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:588fc0e7-6c4e-44f1-8f96-f1a621106a12\" style=\"margin: 0px; padding: 0px; float: none; display: inline;\">\n<pre style=white-space:normal>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')\n\nName: admin-user-token-vsgwz\n\nNamespace: kube-system\n\nLabels: &lt;none&gt;\n\nAnnotations: kubernetes.io\/service-account.name: admin-user\n\nkubernetes.io\/service-account.uid: 392a2ee9-3aa5-11e9-9732-080027fe91e0\n\nType: kubernetes.io\/service-account-token\n\nData\n\n====\n\nca.crt: 1025 bytes\n\nnamespace: 11 bytes\n\ntoken: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXZzZ3d6Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIzOTJhMmVlOS0zYWE1LTExZTktOTczMi0wODAwMjdmZTkxZTAiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.Xfu0COCQZU4ze3DJvGJM6vs10pnTFOj0L5XhMGO_iktvuMsVDv5iQEoxj_cUfen1kh_9gIMNw7zgCzeQnBb-BA21F7_1kmC-MoyQDUfgCsG6hOJBG5qVP4402KqbBW8c89xp3i05lx8UPyxYkk-L4ElDBw7dmHlruFhbw15hnv4_6DeaGeF5EfBZfwdQ_zpQe_6d1I1k83Qs1P63HS52IxwhcURPLV1_oF-YlgGjONPhORRhQr6qs-q4jo_eXoRpN-Il56o7nT-2Nt5p6fvxkS0Y74CDxOr_36u3jEE8Mb_sqYvOp8tCkEzZtkgTtA2Zb4ml4nityEm0gqVhkCqXiw\n<\/pre>\n<\/div>\n<p>\u4f7f\u7528token\u65b9\u5f0f\u767b\u9646\uff0c\u5c06token\u8f93\u5165\u5230\u767b\u5f55\u9875\u9762\uff1a<\/p>\n<p><a href=\"http:\/\/www.rao-bing.cn\/wp-content\/uploads\/2019\/03\/clip_image002.png\"><img loading=\"lazy\" decoding=\"async\" width=\"696\" height=\"302\" title=\"clip_image002\" style=\"display: inline; background-image: none;\" alt=\"clip_image002\" src=\"http:\/\/www.rao-bing.cn\/wp-content\/uploads\/2019\/03\/clip_image002_thumb.png\" border=\"0\"><\/a><\/p>\n<p>\u70b9\u51fbsign in \u767b\u5f55\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>master\u8282\u70b9\u6b65\u9aa4 \u521d\u59cb\u73af\u5883\uff1aredhat 7.5 \u6700\u5c0f\u5b89\u88c5 1.\u51c6\u5907\u5de5\u4f5c\uff1a 1.1 local yum repo cat &lt;&lt;EOF &gt;\/&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"http:\/\/www.rao-bing.cn\/index.php\/2019\/03\/24\/957\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":936,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1],"tags":[40],"class_list":["post-957","post","type-post","status-publish","format-aside","has-post-thumbnail","hentry","category-uncategorized","tag-k8s","post_format-post-format-aside"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"http:\/\/www.rao-bing.cn\/wp-content\/uploads\/2019\/03\/k8s.png","jetpack_shortlink":"https:\/\/wp.me\/p8gSFq-fr","jetpack_likes_enabled":true,"jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/posts\/957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/comments?post=957"}],"version-history":[{"count":5,"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/posts\/957\/revisions"}],"predecessor-version":[{"id":962,"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/posts\/957\/revisions\/962"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/media\/936"}],"wp:attachment":[{"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/media?parent=957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/categories?post=957"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.rao-bing.cn\/index.php\/wp-json\/wp\/v2\/tags?post=957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}