{"id":64,"date":"2022-04-02T18:21:33","date_gmt":"2022-04-02T10:21:33","guid":{"rendered":"https:\/\/h4ckm310n.com\/?p=64"},"modified":"2022-08-14T18:40:44","modified_gmt":"2022-08-14T10:40:44","slug":"%e3%80%90%e6%8c%96%e5%9d%91%e3%80%91%e5%9c%a8%e8%99%9a%e6%8b%9f%e6%9c%ba%e5%ae%89%e8%a3%85kubernetes%e9%9b%86%e7%be%a4","status":"publish","type":"post","link":"https:\/\/h4ckm310n.com\/?p=64","title":{"rendered":"\u5728\u865a\u62df\u673a\u5b89\u88c5Kubernetes\u96c6\u7fa4"},"content":{"rendered":"<p>\u4e4b\u524d\u5728\u65e7\u535a\u5ba2\u4e0a\u5199\u8fc7\u4f46\u8fd8\u6ca1\u5199\u5b8c\uff0c\u4e0d\u8fc7\u5f53\u65f6\u662f\u5728VMware\u4e0a\u642d\u5efa\u7684\uff0c\u524d\u6bb5\u65f6\u95f4\u6211\u5728\u95f2\u7f6e\u7684\u795e\u8239\u4e0a\u9762\u642d\u5efa\u4e86\u4e00\u4e2aProxmox VE\uff0c\u5c31\u8d81\u8fd9\u4e2a\u673a\u4f1a\u5728PVE\u4e0a\u91cd\u65b0\u642d\u5efa\u4e00\u904d\uff0c\u53ea\u4e0d\u8fc7\u7528\u7684\u662fKVM\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u865a\u62df\u673a\u914d\u7f6e\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91\" src=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_vmdev.png\" alt=\"\" width=\"931\" height=\"347\" srcset=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_vmdev.png 931w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_vmdev-300x112.png 300w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_vmdev-768x286.png 768w\" sizes=\"auto, (max-width: 931px) 100vw, 931px\" \/><\/p>\n<p>\u8bbe\u7f6ehostname\uff1a<\/p>\n<pre>hostnamectl set-hostname k8s-master<\/pre>\n<p>\u4e3a\u4e86\u65b9\u4fbf\u56fd\u5185\u73af\u5883\u7684\u914d\u7f6e\uff0c\u5148\u628aapt\u7684\u6e90\u6362\u4e3a\u56fd\u5185\u955c\u50cf\uff0c\u6211\u8fd9\u91cc\u7528\u7684\u662f\u963f\u91cc\u7684\uff0c\u76f4\u63a5\u628a\/etc\/apt\/sources.list\u6587\u4ef6\u66ff\u6362\u6210\u5982\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre>\r\ndeb http:\/\/mirrors.aliyun.com\/ubuntu\/ bionic main restricted universe multiverse\r\ndeb-src http:\/\/mirrors.aliyun.com\/ubuntu\/ bionic main restricted universe multiverse\r\n\r\ndeb http:\/\/mirrors.aliyun.com\/ubuntu\/ bionic-security main restricted universe multiverse\r\ndeb-src http:\/\/mirrors.aliyun.com\/ubuntu\/ bionic-security main restricted universe multiverse\r\n\r\ndeb http:\/\/mirrors.aliyun.com\/ubuntu\/ bionic-updates main restricted universe multiverse\r\ndeb-src http:\/\/mirrors.aliyun.com\/ubuntu\/ bionic-updates main restricted universe multiverse\r\n\r\ndeb http:\/\/mirrors.aliyun.com\/ubuntu\/ bionic-proposed main restricted universe multiverse\r\ndeb-src http:\/\/mirrors.aliyun.com\/ubuntu\/ bionic-proposed main restricted universe multiverse\r\n\r\ndeb http:\/\/mirrors.aliyun.com\/ubuntu\/ bionic-backports main restricted universe multiverse\r\ndeb-src http:\/\/mirrors.aliyun.com\/ubuntu\/ bionic-backports main restricted universe multiverse\r\n<\/pre>\n<p>update\u4e4b\u540e\uff0c\u6dfb\u52a0\u963f\u91cc\u7684docker\u6e90\u5e76\u5b89\u88c5\uff1a<\/p>\n<pre>\r\nsudo apt-get update\r\nsudo apt-get install -y apt-transport-https\r\ncurl -fsSL https:\/\/mirrors.aliyun.com\/docker-ce\/linux\/ubuntu\/gpg | sudo apt-key add -\r\nsudo add-apt-repository \"deb [arch=amd64] https:\/\/mirrors.aliyun.com\/docker-ce\/linux\/ubuntu $(lsb_release -cs) stable\"\r\nsudo apt-get install docker-ce=5:18.09.0~3-0~ubuntu-bionic\r\n<\/pre>\n<p>\u5728\/etc\/apt\/sources.list.d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2akubernetes.list\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre>\r\ndeb https:\/\/mirrors.aliyun.com\/kubernetes\/apt\/ kubernetes-xenial main\r\n<\/pre>\n<p>\u5b89\u88c5k8s\uff1a<\/p>\n<pre>\r\ncurl https:\/\/mirrors.aliyun.com\/kubernetes\/apt\/doc\/apt-key.gpg | sudo apt-key add - \r\nsudo apt-get install kubelet=1.15.0-00 kubeadm=1.15.0-00 kubectl=1.15.0-00\r\n<\/pre>\n<p>\u7528free\u67e5\u770b\u5185\u5b58\u72b6\u6001\uff0c\u53ef\u4ee5\u770b\u5230\u6709\u4e00\u884cswap\uff0c\u56e0\u6b64\u9700\u8981\u7f16\u8f91\/etc\/fstab\uff0c\u628aswap\u6240\u5728\u7684\u8fd9\u4e00\u884c\u6ce8\u91ca\u6389\uff0c\u5173\u95edswap\u3002<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_free.png\" alt=\"\" width=\"1128\" height=\"122\" class=\"alignnone size-full wp-image-86\" srcset=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_free.png 1128w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_free-300x32.png 300w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_free-1024x111.png 1024w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_free-768x83.png 768w\" sizes=\"auto, (max-width: 1128px) 100vw, 1128px\" \/><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_fstabswap.png\" alt=\"\" width=\"1590\" height=\"381\" class=\"alignnone size-full wp-image-87\" srcset=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_fstabswap.png 1590w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_fstabswap-300x72.png 300w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_fstabswap-1024x245.png 1024w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_fstabswap-768x184.png 768w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_fstabswap-1536x368.png 1536w\" sizes=\"auto, (max-width: 1590px) 100vw, 1590px\" \/><\/p>\n<p>\u514b\u9686\u4e24\u4e2aworker\u865a\u62df\u673a\uff0c\u5206\u522b\u8bbe\u7f6ehostname\u4e3ak8s-worker1\u548ck8s-worker2\u3002<\/p>\n<p>\u521d\u59cb\u5316k8s\uff1a<\/p>\n<pre>sudo kubeadm init --image-repository=registry.aliyuncs.com\/google_containers --pod-network-cidr=10.244.0.0\/16 --kubernetes-version=v1.15.0<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubectlinit.png\" alt=\"\" width=\"1742\" height=\"1279\" class=\"alignnone size-full wp-image-90\" srcset=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubectlinit.png 1742w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubectlinit-300x220.png 300w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubectlinit-1024x752.png 1024w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubectlinit-768x564.png 768w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubectlinit-1536x1128.png 1536w\" sizes=\"auto, (max-width: 1742px) 100vw, 1742px\" \/><\/p>\n<p>\u4e3a\u4e86\u65b9\u4fbf\u5728\u975eroot\u7528\u6237\u4e0b\u4f7f\u7528\uff0c\u53ef\u4ee5\u5728$HOME\u4e0b\u521b\u5efa\u4e00\u4e2a.kube\u76ee\u5f55\uff1a<\/p>\n<pre>\r\nmkdir -p $HOME\/.kube\r\nsudo cp -i \/etc\/kubernetes\/admin.conf $HOME\/.kube\/config\r\nsudo chown $(id -u):$(id -g) $HOME\/.kube\/config\r\n<\/pre>\n<p>\u5b89\u88c5flannel\uff1a<\/p>\n<pre>kubectl apply -f https:\/\/raw.githubusercontent.com\/flannel-io\/flannel\/v0.12.0\/Documentation\/kube-flannel.yml<\/pre>\n<p>\u5728master\u521d\u59cb\u5316k8s\u65f6\uff0c\u8f93\u51fa\u7ed3\u679c\u7684\u6700\u4e0b\u9762\u7ed9\u51fa\u4e86\u4e00\u4e2a\u5e26token\u7684join\u547d\u4ee4\uff0c\u590d\u5236\u4e0b\u6765\uff0c\u5728\u4e24\u4e2aworker\u865a\u62df\u673a\u4e2d\u5206\u522b\u6267\u884c\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubeadmjoin.png\" alt=\"\" width=\"1775\" height=\"335\" class=\"alignnone size-full wp-image-88\" srcset=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubeadmjoin.png 1775w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubeadmjoin-300x57.png 300w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubeadmjoin-1024x193.png 1024w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubeadmjoin-768x145.png 768w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubeadmjoin-1536x290.png 1536w\" sizes=\"auto, (max-width: 1775px) 100vw, 1775px\" \/><\/p>\n<p>\u5728master\u4e2d\u53ef\u4ee5\u770b\u5230\u4e24\u4e2aworker\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubectl_getnodes.png\" alt=\"\" width=\"461\" height=\"99\" class=\"alignnone size-full wp-image-89\" srcset=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubectl_getnodes.png 461w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2022\/04\/k8s_kubectl_getnodes-300x64.png 300w\" sizes=\"auto, (max-width: 461px) 100vw, 461px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e4b\u524d\u5728\u65e7\u535a\u5ba2\u4e0a\u5199\u8fc7\u4f46\u8fd8\u6ca1\u5199\u5b8c\uff0c\u4e0d\u8fc7\u5f53\u65f6\u662f\u5728VMware\u4e0a\u642d\u5efa\u7684\uff0c\u524d\u6bb5\u65f6\u95f4\u6211\u5728\u95f2\u7f6e\u7684\u795e\u8239\u4e0a\u9762\u642d\u5efa\u4e86\u4e00\u4e2aProxm [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[6],"tags":[9,11,10,12],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-6","tag-docker","tag-k8s","tag-kubernets","tag-pve"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"h4ckm310n","author_link":"https:\/\/h4ckm310n.com\/?author=1"},"uagb_comment_info":0,"uagb_excerpt":"\u4e4b\u524d\u5728\u65e7\u535a\u5ba2\u4e0a\u5199\u8fc7\u4f46\u8fd8\u6ca1\u5199\u5b8c\uff0c\u4e0d\u8fc7\u5f53\u65f6\u662f\u5728VMware\u4e0a\u642d\u5efa\u7684\uff0c\u524d\u6bb5\u65f6\u95f4\u6211\u5728\u95f2\u7f6e\u7684\u795e\u8239\u4e0a\u9762\u642d\u5efa\u4e86\u4e00\u4e2aProxm&hellip;","_links":{"self":[{"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=64"}],"version-history":[{"count":5,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/posts\/64\/revisions"}],"predecessor-version":[{"id":98,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/posts\/64\/revisions\/98"}],"wp:attachment":[{"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}