Skip to content

Commit

Permalink
Update 安装K8S
Browse files Browse the repository at this point in the history
  • Loading branch information
ylighgh committed May 28, 2024
1 parent 504997e commit f53025c
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
<meta name="author" content="三石">
<meta name="keywords" content="">

<meta name="description" content="123def main(): foo() print(&quot;python&quot;)">
<meta name="description" content="初始化12345678910111213141516171819202122232425262728hostnamectl set-hostname k8s-nodemodprobe overlaymodprobe br_netfiltercat &lt;&lt;EOF&gt; &#x2F;etc&#x2F;modules-load.d&#x2F;containerd.confoverlaybr_netfilterEOFcat">
<meta property="og:type" content="article">
<meta property="og:title" content="k8s安装">
<meta property="og:url" content="https://ylighgh.github.io/hexo/2024/05/28/k8s%E5%AE%89%E8%A3%85/index.html">
<meta property="og:title" content="Kubernetes安装">
<meta property="og:url" content="https://ylighgh.github.io/hexo/2024/05/28/Kubernetes%E5%AE%89%E8%A3%85/index.html">
<meta property="og:site_name" content="系统工程师实战">
<meta property="og:description" content="123def main(): foo() print(&quot;python&quot;)">
<meta property="og:description" content="初始化12345678910111213141516171819202122232425262728hostnamectl set-hostname k8s-nodemodprobe overlaymodprobe br_netfiltercat &lt;&lt;EOF&gt; &#x2F;etc&#x2F;modules-load.d&#x2F;containerd.confoverlaybr_netfilterEOFcat">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2024-05-28T13:28:23.000Z">
<meta property="article:modified_time" content="2024-05-28T14:23:44.901Z">
<meta property="article:published_time" content="2024-05-28T14:44:21.000Z">
<meta property="article:modified_time" content="2024-05-28T14:44:48.813Z">
<meta property="article:author" content="三石">
<meta property="article:tag" content="K8S">
<meta property="article:tag" content="Kubernetes">
<meta name="twitter:card" content="summary_large_image">



<title>k8s安装 - 系统工程师实战</title>
<title>Kubernetes安装 - 系统工程师实战</title>

<link rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />

Expand Down Expand Up @@ -197,7 +197,7 @@
<div class="banner-text text-center fade-in-up">
<div class="h2">

<span id="subtitle" data-typed-text="k8s安装"></span>
<span id="subtitle" data-typed-text="Kubernetes安装"></span>

</div>

Expand All @@ -208,7 +208,7 @@

<span class="post-meta">
<i class="iconfont icon-date-fill" aria-hidden="true"></i>
<time datetime="2024-05-28 21:28" pubdate>
<time datetime="2024-05-28 22:44" pubdate>
2024年5月28日 晚上
</time>
</span>
Expand All @@ -220,7 +220,7 @@
<span class="post-meta mr-2">
<i class="iconfont icon-chart"></i>

6
257

</span>

Expand All @@ -231,7 +231,7 @@



1 分钟
3 分钟

</span>

Expand Down Expand Up @@ -268,12 +268,30 @@
<div class="container nopadding-x-md" id="board-ctn">
<div id="board">
<article class="post-content mx-auto">
<h1 id="seo-header">k8s安装</h1>
<h1 id="seo-header">Kubernetes安装</h1>


<div class="markdown-body">

<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">def</span> <span class="hljs-title function_">main</span>():<br> foo()<br> <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;python&quot;</span>)<br></code></pre></td></tr></table></figure>
<h2 id="初始化"><a href="#初始化" class="headerlink" title="初始化"></a>初始化</h2><figure class="highlight accesslog"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><code class="hljs accesslog">hostnamectl set-hostname k8s-node<br><br>modprobe overlay<br>modprobe br_netfilter<br><br>cat &lt;&lt;EOF&gt; /etc/modules-load.d/containerd.conf<br>overlay<br>br_netfilter<br>EOF<br><br>cat &lt;&lt;EOF&gt; /etc/sysctl.d/<span class="hljs-number">99</span>-kubernetes-cri.conf<br>net.bridge.bridge-nf-call-iptables = <span class="hljs-number">1</span><br>net.ipv4.ip_forward = <span class="hljs-number">1</span><br>net.bridge.bridge-nf-call-ip6tables = <span class="hljs-number">1</span><br>EOF<br><br>cat &lt;&lt;EOF&gt;&gt; /etc/hosts<br><span class="hljs-number">192.168.10.242</span> k8s-master<br><span class="hljs-number">192.168.10.245</span> k8s-node1<br><span class="hljs-number">192.168.10.246</span> k8s-node2<br><span class="hljs-number">192.168.10.247</span> k8s-node3<br>EOF<br><br>sysctl --system<br><br>systemctl stop firewalld<br>systemctl disable firewalld<br>systemctl unmask firewalld<br></code></pre></td></tr></table></figure>

<h2 id="安装Containerd"><a href="#安装Containerd" class="headerlink" title="安装Containerd"></a>安装Containerd</h2><figure class="highlight vim"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs vim">dnf config-manager --<span class="hljs-built_in">add</span>-repo=https://download.docker.<span class="hljs-keyword">com</span>/linux/centos/docker-<span class="hljs-keyword">ce</span>.repo<br>dnf <span class="hljs-keyword">update</span><br>dnf install -<span class="hljs-keyword">y</span> containerd<br></code></pre></td></tr></table></figure>

<h2 id="配置Containerd"><a href="#配置Containerd" class="headerlink" title="配置Containerd"></a>配置Containerd</h2><figure class="highlight swift"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs swift">mkdir <span class="hljs-operator">-</span>p <span class="hljs-regexp">/etc/</span>containerd<br>containerd config <span class="hljs-keyword">default</span> <span class="hljs-operator">&gt;</span> <span class="hljs-regexp">/etc/</span>containerd<span class="hljs-operator">/</span>config.toml<br><br>sed <span class="hljs-operator">-</span>i &#x27;s<span class="hljs-regexp">/SystemdCgroup = false/</span><span class="hljs-type">SystemdCgroup</span> <span class="hljs-operator">=</span> <span class="hljs-literal">true</span><span class="hljs-regexp">/g&#x27; /</span>etc<span class="hljs-regexp">/containerd/</span>config.toml<br></code></pre></td></tr></table></figure>

<h2 id="重启containerd"><a href="#重启containerd" class="headerlink" title="重启containerd"></a>重启containerd</h2><figure class="highlight nsis"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs nsis"><span class="hljs-params">system</span>ctl daemon-reload<br><span class="hljs-params">system</span>ctl restart containerd<br><span class="hljs-params">system</span>ctl enable --now containerd<br><span class="hljs-params">system</span>ctl status containerd<br></code></pre></td></tr></table></figure>

<h2 id="安装kubeadm"><a href="#安装kubeadm" class="headerlink" title="安装kubeadm"></a>安装kubeadm</h2><figure class="highlight routeros"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><code class="hljs routeros">cat &lt;&lt;EOF&gt;/etc/yum.repos.d/kubernetes.repo<br>[kubernetes]<br><span class="hljs-attribute">name</span>=Kubernetes<br><span class="hljs-attribute">baseurl</span>=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/<br><span class="hljs-attribute">enabled</span>=1<br><span class="hljs-attribute">gpgcheck</span>=1<br><span class="hljs-attribute">gpgkey</span>=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/repodata/repomd.xml.key<br><span class="hljs-attribute">exclude</span>=kubelet kubeadm kubectl cri-tools kubernetes-cni<br>EOF<br><br>dnf install -y kubelet kubeadm kubectl <span class="hljs-attribute">--disableexcludes</span>=kubernetes<br><br>systemctl <span class="hljs-built_in">enable</span> --now kubelet<br></code></pre></td></tr></table></figure>

<h2 id="master节点执行"><a href="#master节点执行" class="headerlink" title="master节点执行"></a>master节点执行</h2><figure class="highlight routeros"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs routeros">kubeadm init \<br><span class="hljs-attribute">--apiserver-advertise-address</span>=192.168.10.242 \<br>--image-repository registry.aliyuncs.com/google_containers \<br><span class="hljs-attribute">--service-cidr</span>=10.96.0.0/12 \<br><span class="hljs-attribute">--pod-network-cidr</span>=10.244.0.0/16<br></code></pre></td></tr></table></figure>
<p>执行成功</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-built_in">mkdir</span> -p <span class="hljs-variable">$HOME</span>/.kube<br><span class="hljs-built_in">cp</span> -i /etc/kubernetes/admin.conf <span class="hljs-variable">$HOME</span>/.kube/config<br><span class="hljs-built_in">chown</span> $(<span class="hljs-built_in">id</span> -u):$(<span class="hljs-built_in">id</span> -g) <span class="hljs-variable">$HOME</span>/.kube/config<br><span class="hljs-built_in">export</span> KUBECONFIG=/etc/kubernetes/admin.conf<br></code></pre></td></tr></table></figure>

<h2 id="将其他node加入集群"><a href="#将其他node加入集群" class="headerlink" title="将其他node加入集群"></a>将其他node加入集群</h2><p>在其他节点执行</p>
<figure class="highlight mipsasm"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs mipsasm">kubeadm <span class="hljs-keyword">join </span><span class="hljs-number">192</span>.<span class="hljs-number">168</span>.<span class="hljs-number">10</span>.<span class="hljs-number">242</span>:<span class="hljs-number">6443</span> --token ijblbd.<span class="hljs-keyword">bmnaf8xcl38iwxbz </span>\<br> --<span class="hljs-keyword">discovery-token-ca-cert-hash </span><span class="hljs-keyword">sha256:1d76ad35d2d95c6b381ada3d03b15f230201e9e0af41db4db33700d7de604e1d </span><br></code></pre></td></tr></table></figure>


<h2 id="部署CNI网络组件"><a href="#部署CNI网络组件" class="headerlink" title="部署CNI网络组件"></a>部署CNI网络组件</h2><figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs awk">wget https:<span class="hljs-regexp">//</span>docs.projectcalico.org<span class="hljs-regexp">/manifests/</span>calico.yaml<br><br>- 修改IPV4POOL地址<br><br>kubectl create -f calico.yaml<br></code></pre></td></tr></table></figure>

</div>

Expand All @@ -285,7 +303,7 @@ <h1 id="seo-header">k8s安装</h1>
<div class="post-meta">
<i class="iconfont icon-tags"></i>

<a href="/hexo/tags/K8S/" class="print-no-link">#K8S</a>
<a href="/hexo/tags/Kubernetes/" class="print-no-link">#Kubernetes</a>

</div>

Expand All @@ -297,8 +315,8 @@ <h1 id="seo-header">k8s安装</h1>

<div class="license-box my-3">
<div class="license-title">
<div>k8s安装</div>
<div>https://ylighgh.github.io/hexo/2024/05/28/k8s安装/</div>
<div>Kubernetes安装</div>
<div>https://ylighgh.github.io/hexo/2024/05/28/Kubernetes安装/</div>
</div>
<div class="license-meta">

Expand Down
4 changes: 2 additions & 2 deletions hexo/archives/2024/05/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@

<p class="h5">2024</p>

<a href="/hexo/2024/05/28/k8s%E5%AE%89%E8%A3%85/" class="list-group-item list-group-item-action">
<a href="/hexo/2024/05/28/Kubernetes%E5%AE%89%E8%A3%85/" class="list-group-item list-group-item-action">
<time>05-28</time>
<div class="list-group-item-title">k8s安装</div>
<div class="list-group-item-title">Kubernetes安装</div>
</a>

</div>
Expand Down
4 changes: 2 additions & 2 deletions hexo/archives/2024/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@

<p class="h5">2024</p>

<a href="/hexo/2024/05/28/k8s%E5%AE%89%E8%A3%85/" class="list-group-item list-group-item-action">
<a href="/hexo/2024/05/28/Kubernetes%E5%AE%89%E8%A3%85/" class="list-group-item list-group-item-action">
<time>05-28</time>
<div class="list-group-item-title">k8s安装</div>
<div class="list-group-item-title">Kubernetes安装</div>
</a>

</div>
Expand Down
4 changes: 2 additions & 2 deletions hexo/archives/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@

<p class="h5">2024</p>

<a href="/hexo/2024/05/28/k8s%E5%AE%89%E8%A3%85/" class="list-group-item list-group-item-action">
<a href="/hexo/2024/05/28/Kubernetes%E5%AE%89%E8%A3%85/" class="list-group-item list-group-item-action">
<time>05-28</time>
<div class="list-group-item-title">k8s安装</div>
<div class="list-group-item-title">Kubernetes安装</div>
</a>

</div>
Expand Down
12 changes: 6 additions & 6 deletions hexo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,23 @@
<article class="col-12 col-md-12 mx-auto index-info">
<h2 class="index-header">

<a href="/hexo/2024/05/28/k8s%E5%AE%89%E8%A3%85/" target="_self">
k8s安装
<a href="/hexo/2024/05/28/Kubernetes%E5%AE%89%E8%A3%85/" target="_self">
Kubernetes安装
</a>
</h2>


<a class="index-excerpt index-excerpt__noimg" href="/hexo/2024/05/28/k8s%E5%AE%89%E8%A3%85/" target="_self">
<a class="index-excerpt index-excerpt__noimg" href="/hexo/2024/05/28/Kubernetes%E5%AE%89%E8%A3%85/" target="_self">
<div>
123def main(): foo() print(&quot;python&quot;)
初始化12345678910111213141516171819202122232425262728hostnamectl set-hostname k8s-nodemodprobe overlaymodprobe br_netfiltercat &lt;&lt;EOF&gt; /etc/modules-load.d/containerd.confoverlaybr_netfilterEOFcat
</div>
</a>

<div class="index-btm post-metas">

<div class="post-meta mr-3">
<i class="iconfont icon-date"></i>
<time datetime="2024-05-28 21:28" pubdate>
<time datetime="2024-05-28 22:44" pubdate>
2024-05-28
</time>
</div>
Expand All @@ -250,7 +250,7 @@ <h2 class="index-header">
<div class="post-meta">
<i class="iconfont icon-tags"></i>

<a href="/hexo/tags/K8S/">#K8S</a>
<a href="/hexo/tags/Kubernetes/">#Kubernetes</a>

</div>

Expand Down
Loading

0 comments on commit f53025c

Please sign in to comment.