mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
translated
This commit is contained in:
parent
533f0657d4
commit
d2e7d1a3ef
@ -1,295 +0,0 @@
|
|||||||
[#]: subject: "How to Install CRI-O (Container Runtime) on Ubuntu 22.04"
|
|
||||||
[#]: via: "https://www.linuxtechi.com/install-crio-container-runtime-on-ubuntu/"
|
|
||||||
[#]: author: "James Kiarie https://www.linuxtechi.com/author/james/"
|
|
||||||
[#]: collector: "lkxed"
|
|
||||||
[#]: translator: "geekpi"
|
|
||||||
[#]: reviewer: " "
|
|
||||||
[#]: publisher: " "
|
|
||||||
[#]: url: " "
|
|
||||||
|
|
||||||
How to Install CRI-O (Container Runtime) on Ubuntu 22.04
|
|
||||||
======
|
|
||||||
|
|
||||||
CRI-O is an opensource and lightweight container runtime for Kubernetes. It is an implementation of the Kubernetes Container Runtime Interface (CRI) using Open Container Initiative (OCI) compatible runtimes. It’s a perfect alternative to Docker when running Kubernetes.
|
|
||||||
|
|
||||||
In this guide, we will demonstrate how to install CRI-O on Ubuntu 22.04 LTS step by step.
|
|
||||||
|
|
||||||
##### Prerequisites
|
|
||||||
|
|
||||||
Before you start out, here is what you need:
|
|
||||||
|
|
||||||
- An instance of Ubuntu 22.04 with SSH access
|
|
||||||
- A sudo user configured on the instance
|
|
||||||
- Fast and stable internet connectivity
|
|
||||||
|
|
||||||
With that out of the way, let us get started out.
|
|
||||||
|
|
||||||
### Step 1: Update the system and Install dependencies
|
|
||||||
|
|
||||||
Right off the bat, log into your server instance and update the package lists as follows.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo apt update
|
|
||||||
```
|
|
||||||
|
|
||||||
Once the local package index has been updated, install the dependencies as follows.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common -y
|
|
||||||
```
|
|
||||||
|
|
||||||
### Step 2: Add CRI-O repository
|
|
||||||
|
|
||||||
To install CRI-O, we need to add or enable its repository on Ubuntu. But first, you need to define the variables based on the operating systems and the CRI-O version that you want to install.
|
|
||||||
|
|
||||||
As such, define the variables as shown below.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ export OS=xUbuntu_22.04
|
|
||||||
$ export CRIO_VERSION=1.24
|
|
||||||
```
|
|
||||||
|
|
||||||
Once that is done, run the following set of commands to add the CRI-O Kubic repository.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /"| sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
|
|
||||||
$ echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$CRIO_VERSION/$OS/ /"|sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$CRIO_VERSION.list
|
|
||||||
```
|
|
||||||
|
|
||||||
Thereafter, import the GPG key for the CRI-O repository
|
|
||||||
|
|
||||||
```
|
|
||||||
$ curl -L https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:$CRIO_VERSION/$OS/Release.key | sudo apt-key add -
|
|
||||||
$ curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/Release.key | sudo apt-key add -
|
|
||||||
```
|
|
||||||
|
|
||||||
This yields the following output as shown below.
|
|
||||||
|
|
||||||
Once again update the package index to synchronize the system with the newly added CRI-O Kubic repositories.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo apt update
|
|
||||||
```
|
|
||||||
|
|
||||||
### Step 3: Install CRI-O On Ubuntu 22.04
|
|
||||||
|
|
||||||
With the repositories added, install CRI-O and the runtime client using the APT package manager.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo apt install cri-o cri-o-runc -y
|
|
||||||
```
|
|
||||||
|
|
||||||
Once installed, start and enable the CRI-O daemon.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo systemctl start crio
|
|
||||||
$ sudo systemctl enable crio
|
|
||||||
```
|
|
||||||
|
|
||||||
Next, verify if the CRI-O service is running:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo systemctl status crio
|
|
||||||
```
|
|
||||||
|
|
||||||
You should get the following output which shows that the CRI-O service is running as expected.
|
|
||||||
|
|
||||||
### Step 4: Install CNI Plugins For CRI-O
|
|
||||||
|
|
||||||
Next, you need to install the CNI (Container Network Interface) as well as the CNI plugins. Keep in mind that the loopback and bridge configurations are enabled and sufficient for running pods using CRI-O.
|
|
||||||
|
|
||||||
Therefore, to install the CNI plugins, run the following command.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo apt install containernetworking-plugins -y
|
|
||||||
```
|
|
||||||
|
|
||||||
Once installed, edit the CRI-O configuration file
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo nano /etc/crio/crio.conf
|
|
||||||
```
|
|
||||||
|
|
||||||
Uncomment network_dir & plugin_dirs section and also add ‘/usr/lib/cni/’ under plugin_dirs section.
|
|
||||||
|
|
||||||
Save the changes and exit the configuration file.
|
|
||||||
|
|
||||||
Next, restart the CRIO service.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo systemctl restart crio
|
|
||||||
```
|
|
||||||
|
|
||||||
### Step 5: Install CRI-O tools
|
|
||||||
|
|
||||||
In addition, you also need to install the cri-tools package which provides the crictl command-line utility which is used for interacting and managing containers and pods.
|
|
||||||
|
|
||||||
To do so, run the command:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo apt install -y cri-tools
|
|
||||||
```
|
|
||||||
|
|
||||||
Once installed, confirm the version of crictl and RunTimeVersion as follows.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo crictl --runtime-endpoint unix:///var/run/crio/crio.sock version
|
|
||||||
```
|
|
||||||
|
|
||||||
Be sure to also check if CRI-O is ready to deploy pods using the following command:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo crictl info
|
|
||||||
```
|
|
||||||
|
|
||||||
The crictl command provides an autocompletion feature that lets you autocomplete commands by pressing the TAB key. To enable command completion run the following command.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo su -
|
|
||||||
|
|
||||||
# crictl completion > /etc/bash_completion.d/crictl
|
|
||||||
```
|
|
||||||
|
|
||||||
Then reload the current bash session.
|
|
||||||
|
|
||||||
```
|
|
||||||
# source ~/.bashrc
|
|
||||||
```
|
|
||||||
|
|
||||||
To use the auto-completion feature, you will need to log out or start a new terminal session. Then simply type the crictl command and press the TABkey to view all the options.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ crictl
|
|
||||||
```
|
|
||||||
|
|
||||||
### Step 6: Create a Pod using crictl utility
|
|
||||||
|
|
||||||
Up to this point, CRI-O is fully installed and configured and ready to spin up a pod. In this section, we will create an Apache web server inside a pod and confirm if it is serving requests.
|
|
||||||
|
|
||||||
First, we are going to set up a pod sandbox or an isolated environment using a pod configuration file as follows.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo nano apache_sandbox.json
|
|
||||||
```
|
|
||||||
|
|
||||||
We will then add the following configuration to the file.
|
|
||||||
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"metadata": {
|
|
||||||
"name": "apache-sandbox",
|
|
||||||
"namespace": "default",
|
|
||||||
"attempt": 1,
|
|
||||||
"uid": "hdishd83djaidwnduwk28bcsb"
|
|
||||||
},
|
|
||||||
"linux": {
|
|
||||||
},
|
|
||||||
"log_directory": "/tmp"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Save and exit. Next create the pod using the following command. This prints out long alphanumeric number which is the pod ID.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo crictl runp apache_sandbox.json
|
|
||||||
```
|
|
||||||
|
|
||||||
To confirm that the pod has been created, run the command.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo crictl pods
|
|
||||||
```
|
|
||||||
|
|
||||||
To retrieve more information about the created pod, run the command:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo crictl inspectp --output table 05ba2f0704f22
|
|
||||||
```
|
|
||||||
|
|
||||||
This prints out the ID, Name, UID, Namespace, date of creation, internal pod IP among other details.
|
|
||||||
|
|
||||||
### Step 7: Create a container inside a pod
|
|
||||||
|
|
||||||
In section we are going to create an Apache web server container inside the pod. So, use the crictl utility to pull an Apache web server image from Docker Hub.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo crictl pull httpd
|
|
||||||
```
|
|
||||||
|
|
||||||
You can verify the image pulled as shown.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo crictl images
|
|
||||||
```
|
|
||||||
|
|
||||||
Next, we are going to define a container configuration file for the Apache web server.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo nano container_apache.json
|
|
||||||
```
|
|
||||||
|
|
||||||
Copy and paste the following code.
|
|
||||||
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"metadata": {
|
|
||||||
"name": "apache"
|
|
||||||
},
|
|
||||||
"image":{
|
|
||||||
"image": "httpd"
|
|
||||||
},
|
|
||||||
"log_path":"apache.0.log",
|
|
||||||
"linux": {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Save and exit the configuration file.
|
|
||||||
|
|
||||||
Finally, to attach the container to the sand box pod created earlier, run the command:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo crictl create 05ba2f0704f22 container_apache.json apache_sandbox.json
|
|
||||||
```
|
|
||||||
|
|
||||||
This outputs a large alphanumeric ID to the terminal.. Take note of this ID.
|
|
||||||
|
|
||||||
Finally, use the ID to start the Apache web server container as follows.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo crictl start 37f4d26510965452aa918f04d629f5332a1cd398d4912298c796942e22f964a7
|
|
||||||
```
|
|
||||||
|
|
||||||
To check the container status, run the command:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo crictl ps
|
|
||||||
```
|
|
||||||
|
|
||||||
To verify that the Apache web server is running, send a HTTP request to the web server using the curl command and the pod’s internal ID.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ curl -I 10.85.0.2
|
|
||||||
```
|
|
||||||
|
|
||||||
The following output confirms that the web server is running.
|
|
||||||
|
|
||||||
##### Conclusion
|
|
||||||
|
|
||||||
That’s all from this, guide. We have successfully installed CRI-O on Ubuntu 22.04 and gone ahead to create a pod and container. Your comments and feedback are welcome.
|
|
||||||
|
|
||||||
Also Read: How to Install Docker on Ubuntu 22.04 / 20.04 LTS
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: https://www.linuxtechi.com/install-crio-container-runtime-on-ubuntu/
|
|
||||||
|
|
||||||
作者:[James Kiarie][a]
|
|
||||||
选题:[lkxed][b]
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]: https://www.linuxtechi.com/author/james/
|
|
||||||
[b]: https://github.com/lkxed/
|
|
@ -0,0 +1,339 @@
|
|||||||
|
[#]: subject: "How to Install CRI-O (Container Runtime) on Ubuntu 22.04"
|
||||||
|
[#]: via: "https://www.linuxtechi.com/install-crio-container-runtime-on-ubuntu/"
|
||||||
|
[#]: author: "James Kiarie https://www.linuxtechi.com/author/james/"
|
||||||
|
[#]: collector: "lkxed"
|
||||||
|
[#]: translator: "geekpi"
|
||||||
|
[#]: reviewer: " "
|
||||||
|
[#]: publisher: " "
|
||||||
|
[#]: url: " "
|
||||||
|
|
||||||
|
如何在 Ubuntu 22.04 上安装 CRI-O(容器运行时)
|
||||||
|
======
|
||||||
|
|
||||||
|
CRI-O 是 Kubernetes 的开源轻量级容器运行时。它是使用 Open Container Initiative (OCI) 兼容运行时的 Kubernetes 容器运行时接口 (CRI) 的实现。在运行 Kubernetes 时,它是 Docker 的完美替代品。
|
||||||
|
|
||||||
|
在本指南中,我们将逐步演示如何在 Ubuntu 22.04 LTS 上安装 CRI-O。
|
||||||
|
|
||||||
|
##### 先决条件
|
||||||
|
|
||||||
|
在开始之前,这是你需要的:
|
||||||
|
|
||||||
|
- 具有 SSH 访问权限的 Ubuntu 22.04 实例
|
||||||
|
- 在实例上配置的 sudo 用户
|
||||||
|
- 快速稳定的互联网连接
|
||||||
|
|
||||||
|
有了这个,让我们开始吧。
|
||||||
|
|
||||||
|
### 步骤 1:更新系统并安装依赖
|
||||||
|
|
||||||
|
立即登录你的服务器实例并按如下方式更新包列表。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo apt update
|
||||||
|
```
|
||||||
|
|
||||||
|
更新本地包索引后,按如下方式安装依赖项。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common -y
|
||||||
|
```
|
||||||
|
|
||||||
|
### 步骤 2:添加 CRI-O 存储库
|
||||||
|
|
||||||
|
要安装 CRI-O,我们需要在 Ubuntu 上添加或启用它的仓库。但首先,你需要根据操作系统和要安装的 CRI-O 版本定义变量。
|
||||||
|
|
||||||
|
因此,定义如下变量。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ export OS=xUbuntu_22.04
|
||||||
|
$ export CRIO_VERSION=1.24
|
||||||
|
```
|
||||||
|
|
||||||
|
完成后,运行以下命令集以添加 CRI-O Kubic 仓库。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /"| sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
|
||||||
|
$ echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$CRIO_VERSION/$OS/ /"|sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$CRIO_VERSION.list
|
||||||
|
```
|
||||||
|
|
||||||
|
![][1]
|
||||||
|
|
||||||
|
此后,为 CRI-O 仓库导入 GPG 密钥。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ curl -L https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:$CRIO_VERSION/$OS/Release.key | sudo apt-key add -
|
||||||
|
$ curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/Release.key | sudo apt-key add -
|
||||||
|
```
|
||||||
|
|
||||||
|
这会产生如下输出。
|
||||||
|
|
||||||
|
![][2]
|
||||||
|
|
||||||
|
再次更新包索引,使系统与新添加的 CRI-O Kubic 仓库同步。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo apt update
|
||||||
|
```
|
||||||
|
|
||||||
|
### 步骤 3:在 Ubuntu 22.04 上安装 CRI-O
|
||||||
|
|
||||||
|
添加仓库后,使用 APT 包管理器安装 CRI-O 和运行时客户端。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo apt install cri-o cri-o-runc -y
|
||||||
|
```
|
||||||
|
|
||||||
|
![][3]
|
||||||
|
|
||||||
|
安装后,启动并启用 CRI-O 守护程序。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo systemctl start crio
|
||||||
|
$ sudo systemctl enable crio
|
||||||
|
```
|
||||||
|
|
||||||
|
接下来,验证 CRI-O 服务是否正在运行:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo systemctl status crio
|
||||||
|
```
|
||||||
|
|
||||||
|
你应该看到以下输出,表明 CRI-O 服务正在按预期运行。
|
||||||
|
|
||||||
|
![][4]
|
||||||
|
|
||||||
|
### 步骤 4:为 CRI-O 安装 CNI 插件
|
||||||
|
|
||||||
|
接下来,你需要安装 CNI(容器网络接口)以及 CNI 插件。请记住,环回和桥接配置已启用并且足以使用 CRI-O 运行 pod。
|
||||||
|
|
||||||
|
因此,要安装 CNI 插件,请运行以下命令。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo apt install containernetworking-plugins -y
|
||||||
|
```
|
||||||
|
|
||||||
|
安装后,编辑 CRI-O 配置文件。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo nano /etc/crio/crio.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
取消注释 network_dir 和 plugin_dirs 部分,并在 plugin_dirs 下添加 “/usr/lib/cni/”。
|
||||||
|
|
||||||
|
![][5]
|
||||||
|
|
||||||
|
保存更改并退出配置文件。
|
||||||
|
|
||||||
|
接下来,重启 CRIO 服务。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo systemctl restart crio
|
||||||
|
```
|
||||||
|
|
||||||
|
### 步骤 5:安装 CRI-O 工具
|
||||||
|
|
||||||
|
此外,你还需要安装 cri-tools 包,它提供了 crictl 命令行程序,用于交互和管理容器和 pod。
|
||||||
|
|
||||||
|
为此,请运行以下命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo apt install -y cri-tools
|
||||||
|
```
|
||||||
|
|
||||||
|
安装后,确认 crictl 和 RunTimeVersion 的版本如下。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo crictl --runtime-endpoint unix:///var/run/crio/crio.sock version
|
||||||
|
```
|
||||||
|
|
||||||
|
![][6]
|
||||||
|
|
||||||
|
一定要检查 CRI-O 是否准备好使用以下命令部署 pod:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo crictl info
|
||||||
|
```
|
||||||
|
|
||||||
|
![][7]
|
||||||
|
|
||||||
|
crictl 命令提供自动补全功能,让你可以通过按 TAB 键自动补全命令。要启用命令补全,请运行以下命令。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo su -
|
||||||
|
|
||||||
|
# crictl completion > /etc/bash_completion.d/crictl
|
||||||
|
```
|
||||||
|
|
||||||
|
然后重新加载当前的 bash 会话。
|
||||||
|
|
||||||
|
```
|
||||||
|
# source ~/.bashrc
|
||||||
|
```
|
||||||
|
|
||||||
|
![][8]
|
||||||
|
|
||||||
|
要使用自动补全功能,你需要注销或启动新的终端会话。然后只需键入 crictl 命令并按 TAB 键即可查看所有选项。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ crictl
|
||||||
|
```
|
||||||
|
|
||||||
|
![][9]
|
||||||
|
|
||||||
|
### 步骤 6:使用 crictl 程序创建 Pod
|
||||||
|
|
||||||
|
至此,CRI-O 已完全安装和配置并准备好启动 pod。在本节中,我们将在 pod 中创建一个 Apache Web 服务器并确认它是否正在处理请求。
|
||||||
|
|
||||||
|
首先,我们将使用 pod 配置文件设置一个 pod 沙箱或隔离环境,如下所示。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo nano apache_sandbox.json
|
||||||
|
```
|
||||||
|
|
||||||
|
然后我们将以下配置添加到文件中。
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"metadata": {
|
||||||
|
"name": "apache-sandbox",
|
||||||
|
"namespace": "default",
|
||||||
|
"attempt": 1,
|
||||||
|
"uid": "hdishd83djaidwnduwk28bcsb"
|
||||||
|
},
|
||||||
|
"linux": {
|
||||||
|
},
|
||||||
|
"log_directory": "/tmp"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
保存并退出。接下来使用以下命令创建 pod。这会打印出很长的字母数字,它是 pod ID。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo crictl runp apache_sandbox.json
|
||||||
|
```
|
||||||
|
|
||||||
|
要确认 Pod 已创建,请运行命令。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo crictl pods
|
||||||
|
```
|
||||||
|
|
||||||
|
![][10]
|
||||||
|
|
||||||
|
要检索有关创建的 pod 的更多信息,请运行以下命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo crictl inspectp --output table 05ba2f0704f22
|
||||||
|
```
|
||||||
|
|
||||||
|
这将打印出 ID、名称、UID、命名空间、创建日期、内部 pod IP 等详细信息。
|
||||||
|
|
||||||
|
![][11]
|
||||||
|
|
||||||
|
### 步骤 7:在 pod 中创建容器
|
||||||
|
|
||||||
|
这部分中,我们将在 pod 中创建一个 Apache Web 服务器容器。因此,使用 crictl 程序从 Docker Hub 拉取 Apache Web 服务器镜像。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo crictl pull httpd
|
||||||
|
```
|
||||||
|
|
||||||
|
你可以如图所示验证拉取的镜像。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo crictl images
|
||||||
|
```
|
||||||
|
|
||||||
|
![][12]
|
||||||
|
|
||||||
|
接下来,我们将为 Apache Web 服务器定义一个容器配置文件。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo nano container_apache.json
|
||||||
|
```
|
||||||
|
|
||||||
|
复制并粘贴以下代码。
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"metadata": {
|
||||||
|
"name": "apache"
|
||||||
|
},
|
||||||
|
"image":{
|
||||||
|
"image": "httpd"
|
||||||
|
},
|
||||||
|
"log_path":"apache.0.log",
|
||||||
|
"linux": {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
保存并退出配置文件。
|
||||||
|
|
||||||
|
最后,要将容器连接到之前创建的沙盒 pod,请运行以下命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo crictl create 05ba2f0704f22 container_apache.json apache_sandbox.json
|
||||||
|
```
|
||||||
|
|
||||||
|
这会向终端输出一长串字母数字 ID。请记下此 ID。
|
||||||
|
|
||||||
|
最后,使用 ID 启动 Apache Web 服务器容器,如下所示。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo crictl start 37f4d26510965452aa918f04d629f5332a1cd398d4912298c796942e22f964a7
|
||||||
|
```
|
||||||
|
|
||||||
|
![][13]
|
||||||
|
|
||||||
|
要检查容器状态,请运行以下命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo crictl ps
|
||||||
|
```
|
||||||
|
|
||||||
|
![][14]
|
||||||
|
|
||||||
|
要验证 Apache Web 服务器是否正在运行,请使用 curl 命令和 pod 的内部 ID 向 Web 服务器发送 HTTP 请求。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ curl -I 10.85.0.2
|
||||||
|
```
|
||||||
|
|
||||||
|
以下输出确认 Web 服务器正在运行。
|
||||||
|
|
||||||
|
![][15]
|
||||||
|
|
||||||
|
##### 结论
|
||||||
|
|
||||||
|
这就是全部的指南。我们已经在 Ubuntu 22.04 上成功安装了 CRI-O,并继续创建 pod 和容器。欢迎你提出意见和反馈。
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://www.linuxtechi.com/install-crio-container-runtime-on-ubuntu/
|
||||||
|
|
||||||
|
作者:[James Kiarie][a]
|
||||||
|
选题:[lkxed][b]
|
||||||
|
译者:[geekpi](https://github.com/geekpi)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]: https://www.linuxtechi.com/author/james/
|
||||||
|
[b]: https://github.com/lkxed/
|
||||||
|
[1]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Set-Crio-Repository-Ubuntu-Linux.png
|
||||||
|
[2]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Import-GPG-Keys-for-Crio-Repository-Ubuntu-Linux.png?ezimgfmt=ng:webp/ngcb22
|
||||||
|
[3]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Apt-Install-Crio-Ubuntu-Linux.png?ezimgfmt=ng:webp/ngcb22
|
||||||
|
[4]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Start-Enable-Crio-Service-Ubuntu.png?ezimgfmt=ng:webp/ngcb22
|
||||||
|
[5]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Crio-Conf-Network-Plugins-Directory-Ubuntu.png?ezimgfmt=ng:webp/ngcb22
|
||||||
|
[6]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Crictl-Crio-Version-Check-Ubuntu-Linux.png?ezimgfmt=ng:webp/ngcb22
|
||||||
|
[7]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Crictl-Info-Command-Ubuntu.png?ezimgfmt=ng:webp/ngcb22
|
||||||
|
[8]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Enable-Bash-Completion-Crictl-Command-Ubuntu.png?ezimgfmt=ng:webp/ngcb22
|
||||||
|
[9]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Crictl-Command-Options-Ubuntu.png?ezimgfmt=ng:webp/ngcb22
|
||||||
|
[10]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Crictl-Pods-Status-Ubuntu.png?ezimgfmt=ng:webp/ngcb22
|
||||||
|
[11]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Crictl-Inspect-Pod-Ubuntu-Linux.png?ezimgfmt=ng:webp/ngcb22
|
||||||
|
[12]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Crictl-pull-image-ubuntu.png?ezimgfmt=ng:webp/ngcb22
|
||||||
|
[13]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Create-Container-Inside-Pod-Ubuntu-Linux.png?ezimgfmt=ng:webp/ngcb22
|
||||||
|
[14]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Pods-Status-Crictl-Command-Ubuntu.png?ezimgfmt=ng:webp/ngcb22
|
||||||
|
[15]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Curl-Command-Httpd-Pod-Ubuntu.png?ezimgfmt=ng:webp/ngcb22
|
Loading…
Reference in New Issue
Block a user