Fix crictl page
This PR fixes a link (at the bottom of the page) to reference. It also fixes the indentation of the number lists, the incorrect syntax tag for code snippets.
This commit is contained in:
@@ -19,15 +19,14 @@ Kubernetes node. `crictl` and its source are hosted in the
|
|||||||
|
|
||||||
## {{% heading "prerequisites" %}}
|
## {{% heading "prerequisites" %}}
|
||||||
|
|
||||||
|
|
||||||
`crictl` requires a Linux operating system with a CRI runtime.
|
`crictl` requires a Linux operating system with a CRI runtime.
|
||||||
|
|
||||||
<!-- steps -->
|
<!-- steps -->
|
||||||
|
|
||||||
## Installing crictl
|
## Installing crictl
|
||||||
|
|
||||||
You can download a compressed archive `crictl` from the cri-tools [release
|
You can download a compressed archive `crictl` from the cri-tools
|
||||||
page](https://github.com/kubernetes-sigs/cri-tools/releases), for several
|
[release page](https://github.com/kubernetes-sigs/cri-tools/releases), for several
|
||||||
different architectures. Download the version that corresponds to your version
|
different architectures. Download the version that corresponds to your version
|
||||||
of Kubernetes. Extract it and move it to a location on your system path, such as
|
of Kubernetes. Extract it and move it to a location on your system path, such as
|
||||||
`/usr/local/bin/`.
|
`/usr/local/bin/`.
|
||||||
@@ -85,6 +84,7 @@ List all pods:
|
|||||||
```shell
|
```shell
|
||||||
crictl pods
|
crictl pods
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -100,6 +100,7 @@ List pods by name:
|
|||||||
```shell
|
```shell
|
||||||
crictl pods --name nginx-65899c769f-wv2gp
|
crictl pods --name nginx-65899c769f-wv2gp
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -112,6 +113,7 @@ List pods by label:
|
|||||||
```shell
|
```shell
|
||||||
crictl pods --label run=nginx
|
crictl pods --label run=nginx
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -126,6 +128,7 @@ List all images:
|
|||||||
```shell
|
```shell
|
||||||
crictl images
|
crictl images
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -141,6 +144,7 @@ List images by repository:
|
|||||||
```shell
|
```shell
|
||||||
crictl images nginx
|
crictl images nginx
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -153,6 +157,7 @@ Only list image IDs:
|
|||||||
```shell
|
```shell
|
||||||
crictl images -q
|
crictl images -q
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -169,6 +174,7 @@ List all containers:
|
|||||||
```shell
|
```shell
|
||||||
crictl ps -a
|
crictl ps -a
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -181,9 +187,10 @@ CONTAINER ID IMAGE
|
|||||||
|
|
||||||
List running containers:
|
List running containers:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
crictl ps
|
crictl ps
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -198,6 +205,7 @@ CONTAINER ID IMAGE
|
|||||||
```shell
|
```shell
|
||||||
crictl exec -i -t 1f73f2d81bf98 ls
|
crictl exec -i -t 1f73f2d81bf98 ls
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -211,6 +219,7 @@ Get all container logs:
|
|||||||
```shell
|
```shell
|
||||||
crictl logs 87d3992f84f74
|
crictl logs 87d3992f84f74
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -224,6 +233,7 @@ Get only the latest `N` lines of logs:
|
|||||||
```shell
|
```shell
|
||||||
crictl logs --tail=1 87d3992f84f74
|
crictl logs --tail=1 87d3992f84f74
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -236,29 +246,29 @@ Using `crictl` to run a pod sandbox is useful for debugging container runtimes.
|
|||||||
On a running Kubernetes cluster, the sandbox will eventually be stopped and
|
On a running Kubernetes cluster, the sandbox will eventually be stopped and
|
||||||
deleted by the Kubelet.
|
deleted by the Kubelet.
|
||||||
|
|
||||||
1. Create a JSON file like the following:
|
1. Create a JSON file like the following:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "nginx-sandbox",
|
"name": "nginx-sandbox",
|
||||||
"namespace": "default",
|
"namespace": "default",
|
||||||
"attempt": 1,
|
"attempt": 1,
|
||||||
"uid": "hdishd83djaidwnduwk28bcsb"
|
"uid": "hdishd83djaidwnduwk28bcsb"
|
||||||
},
|
},
|
||||||
"logDirectory": "/tmp",
|
"logDirectory": "/tmp",
|
||||||
"linux": {
|
"linux": {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Use the `crictl runp` command to apply the JSON and run the sandbox.
|
2. Use the `crictl runp` command to apply the JSON and run the sandbox.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
crictl runp pod-config.json
|
crictl runp pod-config.json
|
||||||
```
|
```
|
||||||
|
|
||||||
The ID of the sandbox is returned.
|
The ID of the sandbox is returned.
|
||||||
|
|
||||||
### Create a container
|
### Create a container
|
||||||
|
|
||||||
@@ -266,68 +276,73 @@ Using `crictl` to create a container is useful for debugging container runtimes.
|
|||||||
On a running Kubernetes cluster, the sandbox will eventually be stopped and
|
On a running Kubernetes cluster, the sandbox will eventually be stopped and
|
||||||
deleted by the Kubelet.
|
deleted by the Kubelet.
|
||||||
|
|
||||||
1. Pull a busybox image
|
1. Pull a busybox image
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
crictl pull busybox
|
crictl pull busybox
|
||||||
Image is up to date for busybox@sha256:141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df416dea4f41046e0f37d47
|
```
|
||||||
```
|
```none
|
||||||
|
Image is up to date for busybox@sha256:141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df416dea4f41046e0f37d47
|
||||||
|
```
|
||||||
|
|
||||||
2. Create configs for the pod and the container:
|
2. Create configs for the pod and the container:
|
||||||
|
|
||||||
**Pod config**:
|
**Pod config**:
|
||||||
```yaml
|
|
||||||
{
|
|
||||||
"metadata": {
|
|
||||||
"name": "nginx-sandbox",
|
|
||||||
"namespace": "default",
|
|
||||||
"attempt": 1,
|
|
||||||
"uid": "hdishd83djaidwnduwk28bcsb"
|
|
||||||
},
|
|
||||||
"log_directory": "/tmp",
|
|
||||||
"linux": {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Container config**:
|
```json
|
||||||
```yaml
|
{
|
||||||
{
|
"metadata": {
|
||||||
"metadata": {
|
"name": "nginx-sandbox",
|
||||||
"name": "busybox"
|
"namespace": "default",
|
||||||
},
|
"attempt": 1,
|
||||||
"image":{
|
"uid": "hdishd83djaidwnduwk28bcsb"
|
||||||
"image": "busybox"
|
},
|
||||||
},
|
"log_directory": "/tmp",
|
||||||
"command": [
|
"linux": {
|
||||||
"top"
|
}
|
||||||
],
|
}
|
||||||
"log_path":"busybox.log",
|
```
|
||||||
"linux": {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Create the container, passing the ID of the previously-created pod, the
|
**Container config**:
|
||||||
container config file, and the pod config file. The ID of the container is
|
|
||||||
returned.
|
|
||||||
|
|
||||||
```shell
|
```json
|
||||||
crictl create f84dd361f8dc51518ed291fbadd6db537b0496536c1d2d6c05ff943ce8c9a54f container-config.json pod-config.json
|
{
|
||||||
```
|
"metadata": {
|
||||||
|
"name": "busybox"
|
||||||
|
},
|
||||||
|
"image":{
|
||||||
|
"image": "busybox"
|
||||||
|
},
|
||||||
|
"command": [
|
||||||
|
"top"
|
||||||
|
],
|
||||||
|
"log_path":"busybox.log",
|
||||||
|
"linux": {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
4. List all containers and verify that the newly-created container has its
|
3. Create the container, passing the ID of the previously-created pod, the
|
||||||
state set to `Created`.
|
container config file, and the pod config file. The ID of the container is
|
||||||
|
returned.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
crictl ps -a
|
crictl create f84dd361f8dc51518ed291fbadd6db537b0496536c1d2d6c05ff943ce8c9a54f container-config.json pod-config.json
|
||||||
```
|
```
|
||||||
The output is similar to this:
|
|
||||||
|
|
||||||
```
|
4. List all containers and verify that the newly-created container has its
|
||||||
CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
|
state set to `Created`.
|
||||||
3e025dd50a72d busybox 32 seconds ago Created busybox 0
|
|
||||||
```
|
```shell
|
||||||
|
crictl ps -a
|
||||||
|
```
|
||||||
|
|
||||||
|
The output is similar to this:
|
||||||
|
|
||||||
|
```
|
||||||
|
CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
|
||||||
|
3e025dd50a72d busybox 32 seconds ago Created busybox 0
|
||||||
|
```
|
||||||
|
|
||||||
### Start a container
|
### Start a container
|
||||||
|
|
||||||
@@ -336,6 +351,7 @@ To start a container, pass its ID to `crictl start`:
|
|||||||
```shell
|
```shell
|
||||||
crictl start 3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
|
crictl start 3e025dd50a72d956c4f14881fbb5b1080c9275674e95fb67f965f6478a957d60
|
||||||
```
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -350,13 +366,12 @@ crictl ps
|
|||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
|
|
||||||
```
|
```
|
||||||
CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
|
CONTAINER ID IMAGE CREATED STATE NAME ATTEMPT
|
||||||
3e025dd50a72d busybox About a minute ago Running busybox 0
|
3e025dd50a72d busybox About a minute ago Running busybox 0
|
||||||
```
|
```
|
||||||
|
|
||||||
## {{% heading "whatsnext" %}}
|
## {{% heading "whatsnext" %}}
|
||||||
|
|
||||||
* [Learn more about `crictl`](https://github.com/kubernetes-sigs/cri-tools).
|
* [Learn more about `crictl`](https://github.com/kubernetes-sigs/cri-tools).
|
||||||
* [Map `docker` CLI commands to `crictl`](/reference/tools/map-crictl-dockercli/).
|
* [Map `docker` CLI commands to `crictl`](/docs/reference/tools/map-crictl-dockercli/).
|
||||||
|
|
||||||
<!-- discussion -->
|
|
||||||
Reference in New Issue
Block a user