Fix errors

This commit is contained in:
Baohua Yang
2026-02-16 18:45:40 -08:00
parent acc74f17bb
commit f68795f34c
6 changed files with 120 additions and 42 deletions

View File

@@ -80,7 +80,7 @@ $ echo \
## "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ ## "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
## $lsb_release -cs stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ## $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
``` ```

View File

@@ -59,7 +59,7 @@ $ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo gpg --
然后我们需要向 `sources.list` 中添加 Docker 软件源 然后我们需要向 `sources.list` 中添加 Docker 软件源
> 在一些基于 Debian Linux 发行版中 `$(lsb_release -cs)` 可能不会返回 Debian 的版本代号例如 [Kail Linux](https://www.kali.org/docs/policy/kali-linux-relationship-with-debian/)、 [BunsenLabs Linux](https://www.bunsenlabs.org/)。在这些发行版中我们需要将下面命令中的 `$(lsb_release -cs)` 替换为 https://mirrors.aliyun.com/docker-ce/linux/debian/dists/ 中支持的 Debian 版本代号,例如 `buster`。 > 在一些基于 Debian Linux 发行版中 `$(lsb_release -cs)` 可能不会返回 Debian 的版本代号例如 [Kali Linux](https://www.kali.org/docs/policy/kali-linux-relationship-with-debian/)、 [BunsenLabs Linux](https://www.bunsenlabs.org/)。在这些发行版中我们需要将下面命令中的 `$(lsb_release -cs)` 替换为 https://mirrors.aliyun.com/docker-ce/linux/debian/dists/ 中支持的 Debian 版本代号,例如 `buster`。
```bash ```bash
$ echo \ $ echo \
@@ -73,7 +73,7 @@ $ echo \
## "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \ ## "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
## $lsb_release -cs stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ## $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
``` ```

View File

@@ -31,9 +31,8 @@ $ sudo apt-get install \
apt-transport-https \ apt-transport-https \
ca-certificates \ ca-certificates \
curl \ curl \
gnupg2 \ gnupg \
lsb-release \ lsb-release
software-properties-common
``` ```
鉴于国内网络问题强烈建议使用国内源官方源请在注释中查看 鉴于国内网络问题强烈建议使用国内源官方源请在注释中查看
@@ -41,12 +40,16 @@ $ sudo apt-get install \
为了确认所下载软件包的合法性需要添加软件源的 GPG 密钥 为了确认所下载软件包的合法性需要添加软件源的 GPG 密钥
```bash ```bash
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/raspbian/gpg | sudo apt-key add - $ sudo install -m 0755 -d /etc/apt/keyrings
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/raspbian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
$ sudo chmod a+r /etc/apt/keyrings/docker.gpg
## 官方源 ## 官方源
## $ curl -fsSL https://download.docker.com/linux/raspbian/gpg | sudo apt-key add - ## $ sudo install -m 0755 -d /etc/apt/keyrings
## $ curl -fsSL https://download.docker.com/linux/raspbian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
## $ sudo chmod a+r /etc/apt/keyrings/docker.gpg
``` ```
@@ -54,21 +57,16 @@ $ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/raspbian/gpg | sudo apt-
然后我们需要向 `sources.list` 中添加 Docker 软件源 然后我们需要向 `sources.list` 中添加 Docker 软件源
```bash ```bash
$ sudo add-apt-repository \ $ echo \
"deb [arch=armhf] https://mirrors.aliyun.com/docker-ce/linux/raspbian \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.aliyun.com/docker-ce/linux/raspbian \
$(lsb_release -cs) \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
stable"
## 官方源 ## 官方源
## $ sudo add-apt-repository \ ## $ echo \
## "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/raspbian \
## "deb [arch=armhf] https://download.docker.com/linux/raspbian \ ## $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
## $lsb_release -cs \
## stable"
``` ```
@@ -77,7 +75,7 @@ $ sudo add-apt-repository \
#### 报错解决办法 #### 报错解决办法
`Raspberry Pi OS Bullseye/Bookworm` 添加 Docker 软件源的步骤可能会出现如下报错: `Raspberry Pi OS Bullseye/Bookworm` 如果你使用 `add-apt-repository` 添加源可能会出现如下报错推荐改用上面的 `tee` 方式来写入 `/etc/apt/sources.list.d/docker.list`可避免此问题
```bash ```bash
Traceback (most recent call last): Traceback (most recent call last):
@@ -95,12 +93,12 @@ aptsources.distro.NoDistroTemplateException: Error: could not find a distributio
通过以下命令手动添加镜像源到 `/etc/apt/sources.list` 文件中即可解决: 通过以下命令手动添加镜像源到 `/etc/apt/sources.list` 文件中即可解决:
```bash ```bash
$ sudo echo "deb [arch=armhf] https://mirrors.aliyun.com/docker-ce/linux/raspbian $(lsb_release -cs) stable" | sudo tee -a /etc/apt/sources.list $ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.aliyun.com/docker-ce/linux/raspbian $(lsb_release -cs) stable" | sudo tee -a /etc/apt/sources.list
## 官方源 ## 官方源
## $ sudo echo "deb [arch=armhf] https://download.docker.com/linux/raspbian $lsb_release -cs stable" | sudo tee -a /etc/apt/sources.list ## $ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/raspbian $(lsb_release -cs) stable" | sudo tee -a /etc/apt/sources.list
``` ```

View File

@@ -216,6 +216,12 @@ $ docker compose scale web=3 db=2
将启动 3 个容器运行 web 服务2 个容器运行 db 服务 将启动 3 个容器运行 web 服务2 个容器运行 db 服务
> **提示**部分版本的 Compose 可能不再提供独立的 `scale` 子命令或不推荐使用此时可使用 `docker compose up` `--scale` 选项达到同样效果
>
> ```bash
> $ docker compose up -d --scale web=3 --scale db=2
> ```
一般的当指定数目多于该服务当前实际运行容器将新创建并启动容器反之将停止容器 一般的当指定数目多于该服务当前实际运行容器将新创建并启动容器反之将停止容器
选项 选项

View File

@@ -2,6 +2,10 @@
`kubeadm` 提供了 `kubeadm init` 以及 `kubeadm join` 这两个命令作为快速创建 `kubernetes` 集群的最佳实践 `kubeadm` 提供了 `kubeadm init` 以及 `kubeadm join` 这两个命令作为快速创建 `kubernetes` 集群的最佳实践
> **重要说明** Kubernetes 1.24 内置 `dockershim` 已被移除Kubernetes 默认不再直接使用 Docker Engine 作为容器运行时CRI因此**更推荐参考**同目录下的[使用 kubeadm 部署 kubernetesCRI 使用 containerd](kubeadm.md)
>
> 本文档主要用于历史环境/学习目的如果你确实需要在较新版本中继续使用 Docker Engine通常需要额外部署 `cri-dockerd` 并在 `kubeadm init/join` 中指定 `--cri-socket`
### 安装 Docker ### 安装 Docker
参考 [安装 Docker](../../03_install/README.md) 一节安装 Docker 参考 [安装 Docker](../../03_install/README.md) 一节安装 Docker
@@ -15,15 +19,21 @@
运行以下命令 运行以下命令
```bash ```bash
$ apt-get update && apt-get install -y apt-transport-https $ K8S_MINOR="v1.35"
$ curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
$ cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list $ sudo apt-get update
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main $ sudo apt-get install -y ca-certificates curl gpg
EOF
$ apt-get update $ sudo install -m 0755 -d /etc/apt/keyrings
$ apt-get install -y kubelet kubeadm kubectl $ curl -fsSL "https://pkgs.k8s.io/core:/stable:/${K8S_MINOR}/deb/Release.key" | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
$ sudo chmod a+r /etc/apt/keyrings/kubernetes-apt-keyring.gpg
$ echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/${K8S_MINOR}/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list > /dev/null
$ sudo apt-get update
$ sudo apt-get install -y kubelet kubeadm kubectl
$ sudo apt-mark hold kubelet kubeadm kubectl
``` ```
#### CentOS/Fedora #### CentOS/Fedora
@@ -31,14 +41,16 @@ $ apt-get install -y kubelet kubeadm kubectl
运行以下命令 运行以下命令
```bash ```bash
$ K8S_MINOR="v1.35"
$ cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo $ cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes] [kubernetes]
name=Kubernetes name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ baseurl=https://pkgs.k8s.io/core:/stable:/${K8S_MINOR}/rpm/
enabled=1 enabled=1
gpgcheck=1 gpgcheck=1
repo_gpgcheck=1 repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg gpgkey=https://pkgs.k8s.io/core:/stable:/${K8S_MINOR}/rpm/repodata/repomd.xml.key
EOF EOF
$ sudo yum install -y kubelet kubeadm kubectl $ sudo yum install -y kubelet kubeadm kubectl
@@ -46,6 +58,30 @@ $ sudo yum install -y kubelet kubeadm kubectl
### 修改内核的运行参数 ### 修改内核的运行参数
#### 加载内核模块
运行以下命令
```bash
$ cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
$ sudo modprobe overlay
$ sudo modprobe br_netfilter
```
#### 禁用 swap必须
kubelet 默认要求禁用 swap否则可能导致初始化失败或节点无法加入集群
```bash
$ sudo swapoff -a
## 如需永久禁用,可在 /etc/fstab 中注释 swap 对应行
```
运行以下命令 运行以下命令
```bash ```bash
@@ -185,7 +221,7 @@ $ kubectl get node -o yaml | grep CIDR
``` ```
```bash ```bash
$ kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.11.0/Documentation/kube-flannel.yml $ kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/v0.26.1/Documentation/kube-flannel.yml
``` ```
### master 节点默认不能运行 pod ### master 节点默认不能运行 pod
@@ -195,6 +231,9 @@ $ kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.11.0/Docu
```bash ```bash
$ kubectl taint nodes --all node-role.kubernetes.io/master- $ kubectl taint nodes --all node-role.kubernetes.io/master-
## 部分较新版本使用 control-plane taint
## $ kubectl taint nodes --all node-role.kubernetes.io/control-plane-
## 恢复默认值 ## 恢复默认值
## $ kubectl taint nodes NODE_NAME node-role.kubernetes.io/master=true:NoSchedule ## $ kubectl taint nodes NODE_NAME node-role.kubernetes.io/master=true:NoSchedule

View File

@@ -219,15 +219,21 @@ oom_score = 0
运行以下命令 运行以下命令
```bash ```bash
$ apt-get update && apt-get install -y apt-transport-https $ K8S_MINOR="v1.35"
$ curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
$ cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list $ sudo apt-get update
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main $ sudo apt-get install -y ca-certificates curl gpg
EOF
$ apt-get update $ sudo install -m 0755 -d /etc/apt/keyrings
$ apt-get install -y kubelet kubeadm kubectl $ curl -fsSL "https://pkgs.k8s.io/core:/stable:/${K8S_MINOR}/deb/Release.key" | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
$ sudo chmod a+r /etc/apt/keyrings/kubernetes-apt-keyring.gpg
$ echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/${K8S_MINOR}/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list > /dev/null
$ sudo apt-get update
$ sudo apt-get install -y kubelet kubeadm kubectl cri-tools kubernetes-cni
$ sudo apt-mark hold kubelet kubeadm kubectl
``` ```
#### CentOS/Fedora #### CentOS/Fedora
@@ -235,21 +241,47 @@ $ apt-get install -y kubelet kubeadm kubectl
运行以下命令 运行以下命令
```bash ```bash
$ K8S_MINOR="v1.35"
$ cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo $ cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes] [kubernetes]
name=Kubernetes name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ baseurl=https://pkgs.k8s.io/core:/stable:/${K8S_MINOR}/rpm/
enabled=1 enabled=1
gpgcheck=1 gpgcheck=1
repo_gpgcheck=1 repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg gpgkey=https://pkgs.k8s.io/core:/stable:/${K8S_MINOR}/rpm/repodata/repomd.xml.key
EOF EOF
$ sudo yum install -y kubelet kubeadm kubectl $ sudo yum install -y kubelet kubeadm kubectl cri-tools kubernetes-cni
``` ```
### 修改内核的运行参数 ### 修改内核的运行参数
#### 加载内核模块
运行以下命令
```bash
$ cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
$ sudo modprobe overlay
$ sudo modprobe br_netfilter
```
#### 禁用 swap必须
kubelet 默认要求禁用 swap否则可能导致初始化失败或节点无法加入集群
```bash
$ sudo swapoff -a
## 如需永久禁用,可在 /etc/fstab 中注释 swap 对应行
```
运行以下命令 运行以下命令
```bash ```bash
@@ -415,6 +447,9 @@ $ kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/v0.26.1/
```bash ```bash
$ kubectl taint nodes --all node-role.kubernetes.io/master- $ kubectl taint nodes --all node-role.kubernetes.io/master-
## 部分较新版本使用 control-plane taint
## $ kubectl taint nodes --all node-role.kubernetes.io/control-plane-
## 恢复默认值 ## 恢复默认值
## $ kubectl taint nodes NODE_NAME node-role.kubernetes.io/master=true:NoSchedule ## $ kubectl taint nodes NODE_NAME node-role.kubernetes.io/master=true:NoSchedule