https://kubernetes.io/zh-cn/docs/tasks/tools/install-kubectl-linux/#enable-shell-autocompletion

1
2
3
4
5
6
7
8
版本替换:
1.28.3
1.26.3
1.24.6
1.22.15
1.20.11
1.18.8
1.16.9

下载

1
2
3
4
5
6
7
8
9
10
$ wget -q --no-check-certificate -O kubernetes-1.26.3-aliyun.1-linux-amd64.tar.gz \
--tries 5 --connect-timeout 5 \
http://aliacs-k8s-cn-hangzhou.oss-cn-hangzhou-internal.aliyuncs.com/public/pkg/kubernetes/kubernetes-1.26.3-aliyun.1-linux-amd64.tar.gz

# 脚本
$ wget --no-check-certificate -O run-1.26-linux-amd64.tar.gz \
--tries 1 --connect-timeout 5 \
http://aliacs-k8s-cn-hangzhou.oss-cn-hangzhou-internal.aliyuncs.com/public/pkg/run/run-1.26-linux-amd64.tar.gz

$ cp pkg/kubernetes/1.26.3-aliyun.1/bin/kubectl/usr/bin/kubectl /usr/bin/

配置自动补全

1
2
3
4
$ yum install bash-completion
$ kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null
$ chmod a+r /etc/bash_completion.d/kubectl
$ source ~/.bashrc

docker多平台构建像参考文档:
https://docs.docker.com/build/building/multi-platform/

安装docker

二进制安装docker

https://download.docker.com/linux/static/stable/
https://download.docker.com/linux/static/stable/x86_64/docker-24.0.7.tgz

docker 安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ wget https://download.docker.com/linux/static/stable/x86_64/docker-24.0.7.tgz
$ tar zxvf docker-24.0.7.tgz
docker/
docker/docker-init
docker/containerd-shim-runc-v2
docker/ctr
docker/docker-proxy
docker/dockerd
docker/docker
docker/containerd
docker/runc
$ mv docker/* /usr/bin

$ wget -O /usr/lib/systemd/system/docker.service \
https://raw.githubusercontent.com/docker/packaging/main/pkg/docker-engine/common/systemd/docker.service
# 删除 Requires=docker.socket containerd.service
# 替换 ExecStart=/usr/bin/dockerd --exec-opt native.cgroupdriver=systemd

$ systemctl daemon-reload
$ systemctl enable docker
阅读全文 »

contained安装

通过containerd 来创建一个容器,会创建一个 containerd-shim 的进程(垫片),containerd-shim启动后会去启动/usr/bin/containerd-shim-runc-v2,然后立即退出,此时containerd-shim-runc-v2的父进程就变成了systemd(1),这样containerd-shim-runc-v2就和containerd脱离了关系,即便containerd退出也不会影响到容器(这也是containerd-shim套件的作用)。OCI标准(Open Container Initiative 开放容器协议)的具体实现就是runc,真正创建和维护容器最终便是由runc来完成的。/usr/bin/containerd-shim-runc-v2会启动runc去create、start容器,然后runc立即退出,容器的父进程就变成了containerd-shim-runc-v2,这也是容器内部可以看到的PID=1的进程。

containerd

https://github.com/containerd/containerd
https://github.com/containerd/containerd/releases
https://github.com/containerd/containerd/blob/main/docs/cri/crictl.md
https://github.com/containerd/containerd/blob/main/docs/getting-started.md

阅读全文 »

go环境安装

pprof工具是go tool里的工具, 所以需要提前安装golang环境

官方文档: https://go.dev/doc/install

1
2
3
4
$ wget https://go.dev/dl/go1.20.5.linux-amd64.tar.gz
$ rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.5.linux-amd64.tar.gz
$ echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
$ source /etc/profile
阅读全文 »

背景

Dockershim从Kubernetes 1.20版本开始废弃,计划在Kubernetes 1.24版本移除,所以目前1.24+的ACK集群只能containerd作为运行时,但是docker build构建的镜像是可以正常使用的, docker build 创建的镜像适用于任何 CRI 实现, 参考 Dockershim Removal FAQ

本文介绍一下containerd运行的节点上如何拉取公共镜像镜像,私有仓库镜像,便于排查containerd节点的免密或者自建镜像仓库的镜像

工具介绍

提示 很多时候我们都可以通过–help来查看工具都提供了哪些功能,因为版本之间直接可能存在兼容性问题

本文对应的软件版本信息(基于阿里云的ACK)

ACK版本 containerd版本
v1.24.6-aliyun.1 containerd 1.6.20

containerd 支持的客户端工具有很多, 比如 ctr、nerdctl、crictl、能调用cri接口的如kubelet等,其中是ctr、nerdctl是不支持CRI Plugin,比如镜像加速, 但是可以通过--hosts-dir的方式指定

本文就通过介绍ctr和crictl, ACK 中默认安装的。

阅读全文 »