<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>微服务 &#8211; wqh博客</title>
	<atom:link href="https://wangqianhong.com/tag/%E5%BE%AE%E6%9C%8D%E5%8A%A1/feed/" rel="self" type="application/rss+xml" />
	<link>https://wangqianhong.com</link>
	<description>和而不同</description>
	<lastBuildDate>Sat, 30 Dec 2023 01:28:27 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://wangqianhong.com/wp-content/uploads/2020/09/cropped-1-1-1-32x32.png</url>
	<title>微服务 &#8211; wqh博客</title>
	<link>https://wangqianhong.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>微服务（二）&#124; k8s安装</title>
		<link>https://wangqianhong.com/2022/02/%e5%be%ae%e6%9c%8d%e5%8a%a1%ef%bc%88%e4%ba%8c%ef%bc%89-k8s%e5%ae%89%e8%a3%85/</link>
					<comments>https://wangqianhong.com/2022/02/%e5%be%ae%e6%9c%8d%e5%8a%a1%ef%bc%88%e4%ba%8c%ef%bc%89-k8s%e5%ae%89%e8%a3%85/#respond</comments>
		
		<dc:creator><![CDATA[wqh_work]]></dc:creator>
		<pubDate>Sun, 13 Feb 2022 01:26:00 +0000</pubDate>
				<category><![CDATA[技术文章]]></category>
		<category><![CDATA[k8s]]></category>
		<category><![CDATA[微服务]]></category>
		<guid isPermaLink="false">https://wangqianhong.com/?p=2829</guid>

					<description><![CDATA[<p>安装Kubeadm cat &#60;&#60;EOF &#124; tee /etc/yum.repos.d/k&#8230; <a href="https://wangqianhong.com/2022/02/%e5%be%ae%e6%9c%8d%e5%8a%a1%ef%bc%88%e4%ba%8c%ef%bc%89-k8s%e5%ae%89%e8%a3%85/" class="more-link read-more" rel="bookmark">继续阅读 <span class="screen-reader-text">微服务（二）&#124; k8s安装</span><i class="fa fa-arrow-right"></i></a></p>
<p><a rel="nofollow" href="https://wangqianhong.com/2022/02/%e5%be%ae%e6%9c%8d%e5%8a%a1%ef%bc%88%e4%ba%8c%ef%bc%89-k8s%e5%ae%89%e8%a3%85/">微服务（二）| k8s安装</a>最先出现在<a rel="nofollow" href="https://wangqianhong.com">wqh博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<h3>安装Kubeadm</h3>



<pre class="wp-block-preformatted"><code>cat &lt;&lt;EOF | tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
#repo_gpgcheck=1
gpgkey=https://mirrors. aliyun.com/kubernetes/yum/doc/yum-key.gpg
EOF</code>

<code>yum install -y kubelet-1.28.0 kubeadm-1.28.0 kubectl-1.28.0 --disableexcludes=kubernetes</code>

<code>systemctl enable --now containerd
systemctl enable --now kubelet</code>
</pre>



<h3>初始化master</h3>



<p>生成token</p>



<pre class="wp-block-code"><code>kubeadm token generate</code></pre>



<p>使用配置文件</p>



<pre class="wp-block-code"><code>kubeadm config print init-defaults --component-configs KubeletConfiguration,KubeProxyConfiguration > kubeadm.yaml</code></pre>



<p>修改kubeadm.yaml</p>



<pre class="wp-block-code"><code>token: 上面生成的token
localAPIEndpoint:
  advertiseAddress: 192.168.0.15
nodeRegistration:
  name: k8s-master1
imageRepository: registry.aliyuncs.com/google_containers
kubernetesVersion: 1.28.0
ipvs:
  strictARP: true
mode: "ipvs"</code></pre>



<p>然后安装</p>



<pre class="wp-block-code"><code>kubeadm init --config kubeadm.yaml --v 6</code></pre>



<p>看到下面的内容表示安装成功了</p>



<pre class="wp-block-preformatted">.....
Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

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

Alternatively, if you are the root user, you can run:

  export KUBECONFIG=/etc/kubernetes/admin.conf

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can join any number of worker nodes by running the following on each as root:

<code>kubeadm join 192.168.0.11:6443 --token vpbpo2.a73mc0asxjy7b5xe \
        --discovery-token-ca-cert-hash sha256:70ba6173c9e2ce7b285342afb456e566f03fd8eb99edc7609edd86ae1e82c335</code></pre>



<p>记住上面的kubeadm join的命令，其它服务器可以通过这个命令加入到集群中</p>



<p>安装命令</p>



<pre class="wp-block-code"><code>mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config</code></pre>



<h3>安装网络插件calico</h3>



<pre class="wp-block-code"><code>wget https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/calico.yaml</code></pre>



<p>修改为kubeadm.yaml中的podSubnet:</p>



<pre class="wp-block-code"><code>- name: CALICO_IPV4POOL_CIDR
  value: "10.96.0.0/12"</code></pre>



<p>在master主机上安装即可</p>



<pre class="wp-block-code"><code>kubectl apply -f calico.yaml</code></pre>



<p>等待所有节点status变成Ready</p>



<pre class="wp-block-preformatted"><code>watch kubectl get pods -n kube-system</code>

NAME READY STATUS RESTARTS AGE
calico-kube-controllers-7ddc4f45bc-lcbx6 1/1 Running 0 65s
calico-node-pvpbx 1/1 Running 0 65s
coredns-66f779496c-8xplr 1/1 Running 0 2m9s
coredns-66f779496c-gnq7l 1/1 Running 0 2m9s
etcd-k8s-master 1/1 Running 0 2m15s
kube-apiserver-k8s-master 1/1 Running 0 2m15s
kube-controller-manager-k8s-master 1/1 Running 0 2m15s
kube-proxy-98kx5 1/1 Running 0 2m10s
kube-scheduler-k8s-master 1/1 Running 0 2m15s</pre>



<h3>初始化node</h3>



<pre class="wp-block-code"><code>kubeadm join 192.168.0.11:6443 --token vpbpo2.a73mc0asxjy7b5xe --discovery-token-ca-cert-hash sha256:70ba6173c9e2ce7b285342afb456e566f03fd8eb99edc7609edd86ae1e82c335</code></pre>
<p><a rel="nofollow" href="https://wangqianhong.com/2022/02/%e5%be%ae%e6%9c%8d%e5%8a%a1%ef%bc%88%e4%ba%8c%ef%bc%89-k8s%e5%ae%89%e8%a3%85/">微服务（二）| k8s安装</a>最先出现在<a rel="nofollow" href="https://wangqianhong.com">wqh博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://wangqianhong.com/2022/02/%e5%be%ae%e6%9c%8d%e5%8a%a1%ef%bc%88%e4%ba%8c%ef%bc%89-k8s%e5%ae%89%e8%a3%85/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>微服务（一）&#124; 环境配置</title>
		<link>https://wangqianhong.com/2022/02/%e5%be%ae%e6%9c%8d%e5%8a%a1%ef%bc%88%e4%b8%80%ef%bc%89-%e7%8e%af%e5%a2%83%e9%85%8d%e7%bd%ae/</link>
					<comments>https://wangqianhong.com/2022/02/%e5%be%ae%e6%9c%8d%e5%8a%a1%ef%bc%88%e4%b8%80%ef%bc%89-%e7%8e%af%e5%a2%83%e9%85%8d%e7%bd%ae/#respond</comments>
		
		<dc:creator><![CDATA[wqh_work]]></dc:creator>
		<pubDate>Sat, 05 Feb 2022 01:13:00 +0000</pubDate>
				<category><![CDATA[技术文章]]></category>
		<category><![CDATA[k8s]]></category>
		<category><![CDATA[微服务]]></category>
		<guid isPermaLink="false">https://wangqianhong.com/?p=2818</guid>

					<description><![CDATA[<p>官方地址 https://kubernetes.io/zh-cn/docs/home/ 版本需求 c&#8230; <a href="https://wangqianhong.com/2022/02/%e5%be%ae%e6%9c%8d%e5%8a%a1%ef%bc%88%e4%b8%80%ef%bc%89-%e7%8e%af%e5%a2%83%e9%85%8d%e7%bd%ae/" class="more-link read-more" rel="bookmark">继续阅读 <span class="screen-reader-text">微服务（一）&#124; 环境配置</span><i class="fa fa-arrow-right"></i></a></p>
<p><a rel="nofollow" href="https://wangqianhong.com/2022/02/%e5%be%ae%e6%9c%8d%e5%8a%a1%ef%bc%88%e4%b8%80%ef%bc%89-%e7%8e%af%e5%a2%83%e9%85%8d%e7%bd%ae/">微服务（一）| 环境配置</a>最先出现在<a rel="nofollow" href="https://wangqianhong.com">wqh博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>官方地址 <a href="https://kubernetes.io/zh-cn/docs/home/" target="_blank" rel="noreferrer noopener">https://kubernetes.io/zh-cn/docs/home/</a></p>



<h3>版本需求</h3>



<p>centos stream 9<br>k8s 1.28.0<br>istio 1.18.2<br>calico 3.26.1</p>



<h3>安装条件</h3>



<p>一台兼容的 Linux 主机。Kubernetes 项目为基于 Debian 和 Red Hat 的 Linux 发行版以及一些不提供包管理器的发行版提供通用的指令。<br>每台机器 2 GB 或更多的 RAM（如果少于这个数字将会影响你应用的运行内存）。<br>CPU 2 核心及以上。<br>集群中的所有机器的网络彼此均能相互连接（公网和内网都可以）。<br>节点之中不可以有重复的主机名、MAC 地址或 product_uuid。请参见这里了解更多详细信息。<br>开启机器上的某些端口。请参见这里了解更多详细信息。<br>禁用交换分区。为了保证 kubelet 正常工作，你必须禁用交换分区。<br>例如，sudo swapoff -a 将暂时禁用交换分区。要使此更改在重启后保持不变，请确保在如 /etc/fstab、systemd.swap 等配置文件中禁用交换分区，具体取决于你的系统如何配置。</p>



<pre class="wp-block-code"><code>yum -y update
yum install -y iproute-tc</code></pre>



<h3>安装Docker</h3>



<pre class="wp-block-code"><code>yum install -y yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce containerd.io</code></pre>



<p>这里我们只使用container，不需要启动docker</p>



<pre class="wp-block-code"><code>mkdir -p /etc/containerd
containerd config default | tee /etc/containerd/config.toml</code></pre>



<p>修改SystemdCgroup</p>



<pre class="wp-block-code"><code>&#91;plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
  ...
  &#91;plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
    SystemdCgroup = true

&#91;plugins."io.containerd.grpc.v1.cri"]
  sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.9"

&#91;plugins.”io.containerd.grpc.v1.cri”.registry]
  &#91;plugins."io.containerd.grpc.v1.cri".registry.mirrors]
    &#91;plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
      endpoint = &#91;"https://mirrors.ivolces.com"]
    &#91;plugins."io.containerd.grpc.v1.cri".registry.mirrors."k8s.gcr.io"]
      endpoint = &#91;"https://registry.aliyuncs.com/google_containers"]</code></pre>



<h3>配置Host</h3>



<p>其他服务器修改成对应的hostname</p>



<pre class="wp-block-code"><code>hostnamectl set-hostname k8s-master1</code></pre>



<p>修改/etc/hosts</p>



<pre class="wp-block-code"><code>192.168.0.13 k8s-master1
192.168.0.14 k8s-node1
192.168.0.15 k8s-node2</code></pre>



<h3>修改网络</h3>



<pre class="wp-block-code"><code>cat &lt;&lt;EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF

modprobe overlay
modprobe br_netfilter
modprobe ip_tables
modprobe iptable_filter
modprobe -- ip_vs
modprobe -- ip_vs_sh
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- nf_conntrack

cat &lt;&lt;EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward                 = 1
EOF

sysctl -p /etc/sysctl.d/k8s.conf</code></pre>



<p>以上操作所有服务器都要执行</p>
<p><a rel="nofollow" href="https://wangqianhong.com/2022/02/%e5%be%ae%e6%9c%8d%e5%8a%a1%ef%bc%88%e4%b8%80%ef%bc%89-%e7%8e%af%e5%a2%83%e9%85%8d%e7%bd%ae/">微服务（一）| 环境配置</a>最先出现在<a rel="nofollow" href="https://wangqianhong.com">wqh博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://wangqianhong.com/2022/02/%e5%be%ae%e6%9c%8d%e5%8a%a1%ef%bc%88%e4%b8%80%ef%bc%89-%e7%8e%af%e5%a2%83%e9%85%8d%e7%bd%ae/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
