容器用户指南
目录
商标声明
版权所有© 2020 北京拓林思软件有限公司。Turbolinux是北京拓林思软件有限公司的注册商标。Linux是Linus Torvalds先生的注册商标。openEuler为华为技术有限公司的商标。本文档提及的其他所有商标或注册商标,由各自的所有人拥有。所有其它商标归其相应的所有者所有。
免责声明
本文档仅供信息参考,这里提供的信息可能有所变化,将不另行通知。Turbolinux公司不承诺对于本文档有关的任何保证负责。
概述
TurboLinux Enterprise Server 15是一款基于openEuler开源源码开发的开源操作系统。
TurboLinux Enterprise Server 15中提供容器运行的基础平台 iSula。
iSula 为华为容器技术方案品牌,其原意是一种非常强大的蚂蚁,学术上称为“子弹蚁”,因为被它咬一口,犹如被子弹打到那般疼痛。在居住于中南美洲亚马逊丛林的巴西原住民眼里,iSula 是世界上非常强大的昆虫之一。华为容器技术方案品牌因其含义取名。
iSula 基础容器平台同时提供 Docker engine 与轻量化容器引擎 iSulad,用户可根据需要自主选择。
同时根据不同使用场景,提供多种容器形态,包括:
适合大部分通用场景的普通容器
适合强隔离与多租户场景的安全容器
适合使用systemd管理容器内业务场景的系统容器
本文档提供容器引擎的安装和使用方法以及各个容器形态的部署使用方法。
读者对象
本文档主要适用于使用TurboLinux Enterprise Server 15并需要安装容器的用户。用户需要具备以下经验和技能:
熟悉Linux基本操作
对容器有一定了解
iSula通用容器引擎相比docker,是一种新的容器解决方案,提供统一的架构设计来满足CT和IT领域的不同需求。相比Golang编写的Docker,轻量级容器使用C/C++实现,具有轻、灵、巧、快的特点,不受硬件规格和架构的限制,底噪开销更小,可应用领域更为广泛。
容器统一架构如图所示。
iSulad可以通过yum或rpm命令两种方式安装,由于yum会自动安装依赖,而rpm命令需要手动安装所有依赖,所以推荐使用yum安装。
这里给出两种安装方式的操作方法。
(推荐)使用yum安装iSulad,参考命令如下:
$ sudo yum install -y iSulad
使用rpm安装iSulad,需要下载iSulad及其所有依赖库的RPM包,然后手动安装。安装单个iSulad的RPM包(依赖包安装方式相同),参考命令如下:
$ sudo rpm -ihv iSulad-xx.xx.xx-YYYYmmdd.HHMMSS.gitxxxxxxxx.aarch64.rpm
轻量级容器引擎(iSulad)服务端daemon为isulad,isulad可以通过配置文件进行配置,也可以通过命令行的方式进行配置,例如:isulad –xxx,优先级从高到低是:命令行方式>配置文件>代码中默认配置。
说明:如果采用systemd管理iSulad进程,修改/etc/sysconfig/iSulad文件中的OPTIONS字段,等同于命令行方式进行配置。
命令行方式
在启动服务的时候,直接通过命令行进行配置。其配置选项可通过以下命令查阅:
$
isulad --help
lightweight container runtime daemon
Usage: isulad [global options]
GLOBAL OPTIONS:
--authorization-plugin Use authorization plugin
--cgroup-parent Set parent cgroup for all containers
--cni-bin-dir The full path of the directory in which to search for CNI plugin binaries. Default: /opt/cni/bin
--cni-conf-dir The full path of the directory in which to search for CNI config files. Default: /etc/cni/net.d
--default-ulimit Default ulimits for containers (default [])
-e, --engine Select backend engine
-g, --graph Root directory of the iSulad runtime
-G, --group Group for the unix socket(default is isulad)
--help Show help
--hook-spec Default hook spec file applied to all containers
-H, --host The socket name used to create gRPC server
--image-layer-check Check layer intergrity when needed
--image-opt-timeout Max timeout(default 5m) for image operation
--insecure-registry Disable TLS verification for the given registry
--insecure-skip-verify-enforce Force to skip the insecure verify(default false)
--log-driver Set daemon log driver, such as: file
-l, --log-level Set log level, the levels can be: FATAL ALERT CRIT ERROR WARN NOTICE INFO DEBUG TRACE
--log-opt Set daemon log driver options, such as: log-path=/tmp/logs/ to set directory where to store daemon logs
--native.umask Default file mode creation mask (umask) for containers
--network-plugin Set network plugin, default is null, suppport null and cni
-p, --pidfile Save pid into this file
--pod-sandbox-image The image whose network/ipc namespaces containers in each pod will use. (default "rnd-dockerhub.huawei.com/library/pause-${machine}:3.0")
--registry-mirrors Registry to be prepended when pulling unqualified images, can be specified multiple times
--start-timeout timeout duration for waiting on a container to start before it is killed
-S, --state Root directory for execution state files
--storage-driver Storage driver to use(default overlay2)
-s, --storage-opt Storage driver options
--tls Use TLS; implied by --tlsverify
--tlscacert Trust certs signed only by this CA (default "/root/.iSulad/ca.pem")
--tlscert Path to TLS certificate file (default "/root/.iSulad/cert.pem")
--tlskey Path to TLS key file (default "/root/.iSulad/key.pem")
--tlsverify Use TLS and verify the remote
--use-decrypted-key Use decrypted private key by default(default true)
-V, --version Print the version
--websocket-server-listening-port CRI websocket streaming service listening port (default 10350)
示例: 启动isulad,并将日志级别调整成DEBUG
$ isulad -l DEBUG
配置文件方式
isulad配置文件为/etc/isulad/daemon.json,各配置字段说明如下:
配置参数 |
配置文件示例 |
参数解释 |
备注 |
-e, –engine |
“engine”: “lcr” |
iSulad的运行时,默认是lcr |
无 |
-G, –group |
“group”: “isulad” |
socket所属组 |
无 |
–hook-spec |
“hook-spec”: “/etc/default/isulad/hooks/default.json” |
针对所有容器的默认钩子配置文件 |
无 |
-H, –host |
“hosts”: “unix:///var/run/isulad.sock” |
通信方式 |
除本地socket外,还支持tcp://ip:port方式,port范围(0-65535,排除被占用端口) |
–log-driver |
“log-driver”: “file” |
日志驱动配置 |
无 |
-l, –log-level |
“log-level”: “ERROR” |
设置日志输出级别 |
无 |
–log-opt |
“log-opts”: { “log-file-mode”: “0600”, “log-path”: “/var/lib/isulad”, “max-file”: “1”, “max-size”: “30KB” } |
日志相关的配置 |
可以指定max-file,max-size,log-path。max-file指日志文件个数;max-size指日志触发防爆的阈值,若max-file为1,max-size失效;log-path指定日志文件存储路径;log-file-mode用于设置日志文件的读写权限,格式要求必须为八进制格式,如0666。 |
–start-timeout |
“start-timeout”: “2m” |
启动容器的耗时 |
无 |
-p, –pidfile |
“pidfile”: “/var/run/isulad.pid” |
保存pid的文件 |
当启动一个容器引擎的时候不需要配置,当需要启动两个以上的容器引擎时才需要配置。 |
-g, –graph |
“graph”: “/var/lib/isulad” |
iSulad运行时的根目录 |
|
-S, –state |
“state”: “/var/run/isulad” |
执行文件的根目录 |
|
–storage-driver |
“storage-driver”: “overlay2” |
镜像存储驱动,默认为overlay2 |
当前只支持overlay2 |
-s, –storage-opt |
“storage-opts”: [ “overlay2.override_kernel_check=true” ] |
镜像存储驱动配置选项 |
可使用的选项为:
overlay2.overri说明如下:de_kernel_check=true # 忽略内核版本检查
overlay2.size=${size} # 设置rootfs quota限额为${size}大小
overlay2.basesize=${size} #等价于overlay2.size
|
–image-opt-timeout |
“image-opt-timeout”: “5m” |
镜像操作超时时间,默认为5m |
值为-1表示不限制超时。 |
–registry-mirrors |
“registry-mirrors”: [ “docker.io” ] |
镜像仓库地址 |
无 |
–insecure-registry |
“insecure-registries”: [ ] |
不使用TLS校验的镜像仓库 |
无 |
–native.umask |
“native.umask”: “secure” |
容器umask策略,默认”secure”,normal为不安全配置 |
设置容器umask值。 支持配置空字符(使用默认值0027)、”normal”、”secure”:
normal # 启动的容器umask值为0022
secure # 启动的容器umask值为0027(默认值)
|
–pod-sandbox-image |
“pod-sandbox-image”: “rnd-dockerhub.huawei.com/library/pause-aarch64:3.0” |
pod默认使用镜像,默认为”rnd-dockerhub.huawei.com/library/pause-${machine}:3.0” |
无 |
–network-plugin |
“network-plugin”: “” |
指定网络插件,默认为空字符,表示无网络配置,创建的sandbox只有loop网卡。 |
支持cni和空字符,其他非法值会导致isulad启动失败。 |
–cni-bin-dir |
“cni-bin-dir”: “” |
指定cni插件依赖的二进制的存储位置 |
默认为/opt/cni/bin |
–cni-conf-dir |
“cni-conf-dir”: “” |
指定cni网络配置文件的存储位置 |
默认为/etc/cni/net.d |
–image-layer-check=false |
“image-layer-check”: false |
开启镜像层完整性检查功能,设置为true;关闭该功能,设置为false。默认为关闭。 |
isulad启动时会检查镜像层的完整性,如果镜像层被破坏,则相关的镜像不可用。isulad进行镜像完整性校验时,无法校验内容为空的文件和目录,以及链接文件。因此若镜像因掉电导致上述类型文件丢失,isulad的镜像数据完整性校验可能无法识别。isulad版本变更时需要检查是否支持该参数,如果不支持,需要从配置文件中删除。 |
–insecure-skip-verify-enforce=false |
“insecure-skip-verify-enforce”: false |
Bool类型,是否强制跳过证书的主机名/域名验证,默认为false。当设置为true时,为不安全配置,会跳过证书的主机名/域名验证 |
默认为false(不跳过),注意:因isulad使用的yajl json 解析库限制,若在/etc/isulad/daemon.json配置文件中配置非Bool类型的其他符合json格式的值时,isulad将使用默认值false。 |
–use-decrypted-key=true |
“use-decrypted-key”: true |
Bool类型,指定是否使用不加密的私钥。指定为true,表示使用不加密的私钥;指定为false,表示使用的为加密后的私钥,即需要进行双向认证。 |
默认配置为true(使用不加密的私钥),注意:因isulad使用的yajl json 解析库限制,若在/etc/isulad/daemon.json配置文件中配置非Bool类型的其他符合json格式的值时,isulad将使用默认值true。 |
–tls |
“tls”:false |
Bool类型,是否使用TLS |
默认值为false, 仅用于-H tcp://IP:PORT方式 |
–tlsverify |
“tlsverify”:false |
Bool类型,是否使用TLS,并验证远程访问 |
仅用于-H tcp://IP:PORT方式 |
–tlscacert |