Added k3s stuff

This commit is contained in:
2023-10-18 11:57:13 +02:00
parent b6c1fc25b2
commit ca469860f9
2 changed files with 46 additions and 0 deletions

View File

@@ -8,6 +8,7 @@
* [Android](./android.md)
* [containerization](./containerization)
* [Docker](./containerization/docker.md)
* [k3s](./containerization/k3s.md)
* [Podman](./containerization/podman/README.md)
* [curl](./curl.md)
* [git](./git/README.md)

45
containerization/k3s.md Normal file
View File

@@ -0,0 +1,45 @@
# K3s
### Import image into containerd
#### Offline
On a host where one can pull the image:
```
podman save -o <image_file_name>.tar <image_name>:<image_version>
gzip <image_file_name>.tar
```
Copy the file to target host(s) and then run:
```
zcat <image_file_name>.tar.gz | /usr/local/bin/k3s ctr images import -
```
#### Online
```
crictl pull <image_name_or_url>:<image_version>
```
If one needs to supply credentials for the registry, use:
```
--auth AUTH_STRING Use AUTH_STRING for accessing the registry. AUTH_STRING is a base64
encoded 'USERNAME[:PASSWORD]' [$CRICTL_AUTH]
--creds USERNAME[:PASSWORD] Use USERNAME[:PASSWORD] for accessing the registry [$CRICTL_CREDS]
--username USERNAME, -u USERNAME Use USERNAME for accessing the registry. The password will be
requested on the command line
```
`-u` is most secure, as the password is not supplied on the command line.
### Access shell of container with root rights (uid 0)
Get container ID in the running pod:
```
kubectl -n hydra get pod <pod_name> -o jsonpath="{.status.containerStatuses[].containerID}" | sed 's,.*//,,'; echo ''
k3s ctr task exec -t --exec-id <random_name> --user root <container_id> bash
```