Skip to content

Commit 8d9849c

Browse files
committed
更新k8s搭建
1 parent a6b3ecc commit 8d9849c

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

_posts/2023-07-30-k8s-init.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ title: k8s服务初始化记录
1010
2. 设置自动完成
1111

1212

13-
```bash
13+
```bash
1414
kubeadm completion bash > /etc/bash_completion.d/kubeadm
1515
kubectl completion bash > /etc/bash_completion.d/kubectl
16-
```
16+
```
1717

1818
3. [镜像服务器设置](https://www.geekery.cn/free-service/docker-hub-mirror.html)
1919

20-
```/etc/docker/daemon.json
20+
```/etc/docker/daemon.json
2121
{
22-
"registry-mirrors": [
23-
"https://hub.geekery.cn/",
24-
"https://ghcr.geekery.cn"
25-
]
22+
"registry-mirrors": [
23+
"https://hub.geekery.cn/",
24+
"https://ghcr.geekery.cn"
25+
]
2626
}
27-
```
27+
```
2828

2929
4. 修改 containerd 默认设置
3030

@@ -45,21 +45,21 @@ kubectl completion bash > /etc/bash_completion.d/kubectl
4545
可选步骤, 提前拉取k8s用的镜像
4646

4747
```
48-
#!/bin/bash
48+
#!/bin/bash
4949

50-
REPO=registry.cn-hangzhou.aliyuncs.com/google_containers
51-
REPO_LEN=${#REPO}
52-
K8SREPO=registry.k8s.io
50+
REPO=registry.cn-hangzhou.aliyuncs.com/google_containers
51+
REPO_LEN=${#REPO}
52+
K8SREPO=registry.k8s.io
5353

54-
kubeadm config images pull --image-repository "${REPO}"
54+
kubeadm config images pull --image-repository "${REPO}"
5555

56-
for full_name in $(kubeadm config images list --image-repository "${REPO}") ; do
57-
name=${full_name:${REPO_LEN}}
58-
if [ "${name#/coredns}" != "${name}" ]; then
59-
name="/coredns$name"
60-
fi
61-
ctr -n k8s.io image tag "${full_name}" "${K8SREPO}$name"
62-
done
56+
for full_name in $(kubeadm config images list --image-repository "${REPO}") ; do
57+
name=${full_name:${REPO_LEN}}
58+
if [ "${name#/coredns}" != "${name}" ]; then
59+
name="/coredns$name"
60+
fi
61+
ctr -n k8s.io image tag "${full_name}" "${K8SREPO}$name"
62+
done
6363
```
6464

6565
初始化集群
@@ -70,11 +70,11 @@ kubectl completion bash > /etc/bash_completion.d/kubectl
7070
下面命令使用的镜像, 可以自己下载, 版本根据 `kube-flannel.yml` 而定
7171

7272
```
73-
for x in docker.io/flannel/flannel:v0.26.1 docker.io/flannel/flannel-cni-plugin:v1.5.1-flannel2; do
74-
echo $x
75-
docker pull $x
76-
docker save $x | ctr --namespace k8s.io images import -
77-
done
73+
for x in docker.io/flannel/flannel:v0.26.1 docker.io/flannel/flannel-cni-plugin:v1.5.1-flannel2; do
74+
echo $x
75+
docker pull $x
76+
docker save $x | ctr --namespace k8s.io images import -
77+
done
7878
```
7979

8080
7. 安装网络插件

0 commit comments

Comments
 (0)