Registry 和 RegistryUI 轻量级组合分享
## Registry UI 简易部署Registry UI 让操作 Registry 更方便,以下是使用 k3s 部署的步骤:
**镜像地址:**
* Registry: (https://hub.docker.com/_/registry)
* Registry UI: (https://hub.docker.com/r/dqzboy/docker-registry-ui)
**运行配置:**
* **Registry**
* [更多配置](https://distribution.github.io/distribution)
* **Registry UI**
* [更多配置](https://github.com/klausmeyer/docker-registry-browser/blob/master/docs/README.md)
**Registry 部署示例:**
```yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
...
spec:
...
template:
metadata:
...
spec:
containers:
- env:
- name: REGISTRY_AUTH
value: htpasswd
- name: REGISTRY_AUTH_HTPASSWD_PATH
value: /auth/htpasswd
- name: REGISTRY_AUTH_HTPASSWD_REALM
value: Registry Realm
- name: DOCKER_DEBUG
value: '1'
- name: OTEL_TRACES_EXPORTER
value: none
image: 'registry:latest'
imagePullPolicy: Always
livenessProbe:
...
name: registry
ports:
- containerPort: 5000
name: registry
protocol: TCP
readinessProbe:
...
resources:
limits:
cpu: '1'
memory: 1Gi
requests:
cpu: 200m
memory: 200Mi
startupProbe:
...
volumeMounts:
- mountPath: /auth
name: volume-r2
subPath: auth
- mountPath: /var/lib/registry
name: volume-r2
subPath: data
dnsConfig:
...
dnsPolicy: ClusterFirst
...
```
**Registry UI 部署示例:**
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
...
spec:
containers:
- env:
- name: DOCKER_REGISTRY_URL
value: 'http://registry:5000'
- name: SECRET_KEY_BASE
value: eZBT6nL9bo16s24Xwifs9r
- name: ENABLE_DELETE_IMAGES
value: 'true'
- name: NO_SSL_VERIFICATION
value: 'true'
image: 'dqzboy/docker-registry-ui:latest'
imagePullPolicy: Always
livenessProbe:
...
name: registry-ui
ports:
- containerPort: 8080
name: registry-ui
protocol: TCP
readinessProbe:
...
resources:
limits:
cpu: '1'
memory: 1Gi
requests:
cpu: 200m
memory: 200Mi
startupProbe:
...
dnsConfig:
...
dnsPolicy: ClusterFirst
...
```
**生成 Registry 仓库密码:**
* 使用 `httpd` 生成授权,写入 `htpasswd` 文件,Registry 自动读取。
* 脚本使用 `podman`,若使用 `docker` 需要修改。
```sh
#!/bin/bash
# 检查是否提供了用户名和密码
if [ "$#" -ne 2 ]; then
echo "Usage: $0 "
exit 1
fi
# 读取用户名和密码
USERNAME=$1
PASSWORD=$2
# 清空配置
> htpasswd
# 生成 .htpasswd 文件
podman run --rm --entrypoint htpasswd httpd -Bbn "$USERNAME" "$PASSWORD" > htpasswd
# 检查 .htpasswd 文件是否成功生成
if [ $? -eq 0 ]; then
echo "htpasswd file has been created successfully."
else
echo "Failed to create htpasswd file."
exit 2
fi
```
**Registry UI 效果:**
[GitHub - klausmeyer/docker-registry-browser:
页:
[1]