synchronization

This commit is contained in:
2025-08-25 17:53:08 +08:00
commit c201eb5ef9
318 changed files with 23092 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
> 本文作者:丁辉
# Ctr命令使用
- 查看镜像
```bash
ctr -n k8s.io images ls
```
- 更改镜像 TAG
```bash
ctr -n k8s.io image tag nginx:v1 nginx:v2
```
- 拉取镜像
```bash
ctr -n k8s.io images pull docker.io/library/nginx:latest
```
**更多参数**
- `--hosts-dir "/etc/containerd/certs.d"`:指定了包含镜像仓库证书的目录的路径。
- `-k`:忽略 TLS 验证过程中的证书错误。
- `--plain-http=true`:此选项指明在拉取镜像时使用未加密的 HTTP 协议,而不是加密的 HTTPS。
- 推送镜像
```bash
ctr -n k8s.io image push -u <账户>:<密码> docker.io/library/nginx:latest
```
**更多参数**
- `--plain-http=true`:此选项指明在拉取镜像时使用未加密的 HTTP 协议,而不是加密的 HTTPS。

View File

@@ -0,0 +1,65 @@
> 本文作者:丁辉
# Nerdctl工具
[Github](https://github.com/containerd/nerdctl)
## 开始安装
1. 下载软件
```bash
wget https://github.com/containerd/nerdctl/releases/download/v1.7.6/nerdctl-1.7.6-linux-amd64.tar.gz
```
2. 解压文件
```bash
tar -zxvf nerdctl-*-linux-amd64.tar.gz
```
3. 安装
```bash
install -o root -g root -m 0755 nerdctl /usr/local/bin/nerdctl
```
## 基本使用
- 查看 Containerd 镜像
```bash
nerdctl -n k8s.io images
```
- 登录镜像仓库
```bash
nerdctl -n k8s.io login <仓库地址> -u <账号> -p<密码>
```
- 退出镜像仓库登录
```bash
nerdctl -n k8s.io logout <仓库地址>
```
- 拉取镜像
```bash
nerdctl -n k8s.io pull nginx:latest
```
- 更改镜像 TAG
```bash
nerdctl -n k8s.io tag nginx:v1 nginx:v2
```
- 推送镜像
```bash
nerdctl -n k8s.io push nginx:latest --insecure-registry
```
> `--insecure-registry` 表示目标仓库是一个不安全的私有仓库不需要进行TLS证书验证

View File

@@ -0,0 +1,94 @@
> 本文作者:丁辉
## Ubuntu部署Containerd配置Apt源
> 我部署 containerd 的时候遇到了各个版本 apt 源无法下载的问题,所以本次记录 Ubuntu 源配置步骤
### Ubuntu 22.04
```bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable"
```
### Ubuntu 21.10
```bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu impish stable"
```
### Ubuntu 21.04
```bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu hirsute stable"
```
### Ubuntu 20.10
```bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu groovy stable"
```
### Ubuntu 20.04
```bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
```
### Ubuntu 19.10
```bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu eoan stable"
```
### Ubuntu 19.04
```bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu disco stable"
```
### Ubuntu 18.10
```bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu cosmic test"
```
### Ubuntu 18.04
```bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
```
### Ubuntu 17.10
```bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu artful stable"
```
### Ubuntu 16.04
```bash
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
```

View File

@@ -0,0 +1,87 @@
> 本文作者:丁辉
# 二进制安装Containerd
## 安装 Containerd
[containerd软件包](https://github.com/containerd/containerd/releases)
[cni插件包](https://github.com/containernetworking/plugins/releases)
1. 下载二进制文件
```bash
wget https://github.com/containerd/containerd/releases/download/v1.6.33/cri-containerd-cni-1.6.33-linux-amd64.tar.gz
```
2. 解压
```bash
mkdir containerd
tar -zxvf cri-containerd-cni-*-linux-amd64.tar.gz -C containerd
cd containerd
```
3. 移动文件至安装目录
```bash
\cp usr/local/bin/* /usr/local/bin/
\cp etc/systemd/system/containerd.service /usr/lib/systemd/system/containerd.service
mkdir /opt/cni/bin -p
\cp /root/containerd/opt/cni/bin/* /opt/cni/bin/
```
4. 备份配置文件
```bash
mkdir /etc/containerd
containerd config default > /etc/containerd/config.toml
```
5. 修改驱动和镜像地址
```bash
vi /etc/containerd/config.toml
```
内容如下
```toml
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
...
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true #修改这里
[plugins."io.containerd.grpc.v1.cri"]
sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.9"
```
6. 配置 crictl 配置文件
```bash
curl -so /etc/crictl.yaml https://gitee.com/offends/Kubernetes/raw/main/Containerd/Files/crictl.yaml
```
7. 启动
```bash
systemctl enable containerd
systemctl start containerd
systemctl status containerd
```
## 安装 RunC
[Github软件包下载](https://github.com/opencontainers/runc/releases)
1. 下载
```bash
wget https://github.com/opencontainers/runc/releases/download/v1.1.12/runc.amd64
```
2. 安装
```bash
install -m 755 runc.amd64 /usr/local/bin/runc
```

View File

@@ -0,0 +1,69 @@
> 本文作者:丁辉
[Github安装文档](https://github.com/containerd/containerd/blob/main/docs/getting-started.md)
[Containerd软件包](https://github.com/containerd/containerd/releases) [Runc软件包](https://github.com/opencontainers/runc/releases) [Cni插件包](https://github.com/containernetworking/plugins/releases)
## 网络源安装Containerd
1. 设置存储库
[阿里源配置文件](https://developer.aliyun.com/mirror/docker-ce?spm=a2c6h.13651102.0.0.4eac1b11shXBpr)
```bash
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
```
> 国内
>
> ```bash
> yum install -y yum-utils
> yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
> ```
2. 安装
```bash
yum install -y containerd.io
```
3. 备份配置文件
```bash
mv /etc/containerd/config.toml /etc/containerd/config.toml.bak
containerd config default > /etc/containerd/config.toml
```
4. 修改驱动和镜像地址
```bash
vi /etc/containerd/config.toml
```
内容如下
```toml
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
...
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true #修改这里
[plugins."io.containerd.grpc.v1.cri"]
sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.9"
```
5. 配置 crictl 配置文件
```bash
curl -so /etc/crictl.yaml https://gitee.com/offends/Kubernetes/raw/main/Containerd/Files/crictl.yaml
```
6. 启动
```bash
systemctl enable containerd
systemctl start containerd
systemctl status containerd
```