diff options
| author | Paul Buetow <paul@buetow.org> | 2025-10-02 11:28:53 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-10-02 11:28:53 +0300 |
| commit | c0f9ecf5e0b075db8e54ef1235ec80878e418398 (patch) | |
| tree | d729aef5835fdfa173277c4189342976e33c6446 /gemfeed/examples/conf/f3s/registry | |
| parent | a96adfd84d903c50d75c8771cdcc78dd5e942618 (diff) | |
Update content for html
Diffstat (limited to 'gemfeed/examples/conf/f3s/registry')
8 files changed, 166 insertions, 0 deletions
diff --git a/gemfeed/examples/conf/f3s/registry/Justfile b/gemfeed/examples/conf/f3s/registry/Justfile new file mode 100644 index 00000000..297d95a7 --- /dev/null +++ b/gemfeed/examples/conf/f3s/registry/Justfile @@ -0,0 +1,12 @@ +NAMESPACE := "infra" +RELEASE_NAME := "registry" +CHART_PATH := "./helm-chart" + +install: + helm install {{RELEASE_NAME}} {{CHART_PATH}} --namespace {{NAMESPACE}} --create-namespace + +upgrade: + helm upgrade {{RELEASE_NAME}} {{CHART_PATH}} --namespace {{NAMESPACE}} + +delete: + helm uninstall {{RELEASE_NAME}} --namespace {{NAMESPACE}} diff --git a/gemfeed/examples/conf/f3s/registry/README.md b/gemfeed/examples/conf/f3s/registry/README.md new file mode 100644 index 00000000..bcf30a3a --- /dev/null +++ b/gemfeed/examples/conf/f3s/registry/README.md @@ -0,0 +1,69 @@ +# Private Docker Registry + +This document describes how to push Docker images to the private registry deployed in your Kubernetes cluster. + +## Prerequisites + +* A running Kubernetes cluster. +* `kubectl` configured to connect to your cluster. +* Docker installed and running on your local machine. + +## Steps + +0. **Create the registry directory in the NFS share** + +1. **Tag your Docker image:** + + Replace `<your-image>` with the name of your local Docker image and `<node-ip>` with the IP address of any node in your Kubernetes cluster. The registry is available on NodePort `30001`. + + ```bash + docker tag <your-image> <node-ip>:30001/<your-image> + ``` + +2. **Push the image to the registry:** + + ```bash + docker push <node-ip>:30001/<your-image> + ``` + +3. **Pull the image from the registry (from a Kubernetes pod):** + + You can now use the image in your Kubernetes deployments by referencing it as `docker-registry-service:5000/<your-image>`. + +## Communication + +The Docker registry is exposed via a static NodePort (`30001`) and uses plain HTTP. It is not configured for TLS. + + + First, run this command to create or update the configuration file. This command will overwrite the file if it exists. + + 1 sudo bash -c 'echo "{ \\"insecure-registries\\": [\\"r0.lan.buetow.org:30001\\",\\"r1.lan.buetow.org:30001\\",\\"r2.lan.buetow.org:30001\\"] }" > /etc/docker/daemon.json' + + After running that command, you need to restart your Docker daemon for the changes to take effect. + + 1 sudo systemctl restart docker + + +And afterwards I could push the anky-sync-server image. + +## K3s Configuration + +To use the private registry from within the k3s cluster, you need to configure each k3s node. + +### 1. Update /etc/hosts +On each k3s node, you must ensure that `registry.lan.buetow.org` resolves to the node's loopback address. You can do this by adding an entry to the `/etc/hosts` file. + +Run the following command, which will add the entry to `r0`, `r1`, and `r2`: +```bash +for node in r0 r1 r2; do ssh root@$node "echo '127.0.0.1 registry.lan.buetow.org' >> /etc/hosts"; done +``` + +### 2. Configure K3s to trust the insecure registry +You need to configure each k3s node to trust the insecure registry. This is done by creating a `registries.yaml` file in `/etc/rancher/k3s/` on each node. + +The following command will create the file and restart the k3s service. You will need to run this for each node (`r0`, `r1`, `r2`): + +```bash +ssh root@<node> "echo -e 'mirrors:\n "registry.lan.buetow.org:30001":\n endpoint:\n - "http://localhost:30001"' > /etc/rancher/k3s/registries.yaml && systemctl restart k3s" +``` + diff --git a/gemfeed/examples/conf/f3s/registry/helm-chart/Chart.yaml b/gemfeed/examples/conf/f3s/registry/helm-chart/Chart.yaml new file mode 100644 index 00000000..0f7d68fa --- /dev/null +++ b/gemfeed/examples/conf/f3s/registry/helm-chart/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: registry +description: A Helm chart for deploying a private Docker registry. +version: 0.1.0 +appVersion: "2.0" diff --git a/gemfeed/examples/conf/f3s/registry/helm-chart/README.md b/gemfeed/examples/conf/f3s/registry/helm-chart/README.md new file mode 100644 index 00000000..42694360 --- /dev/null +++ b/gemfeed/examples/conf/f3s/registry/helm-chart/README.md @@ -0,0 +1,11 @@ +# Docker Registry Helm Chart + +This chart deploys a simple Docker registry. + +## Installing the Chart + +To install the chart with the release name `my-release`, run the following command: + +```bash +helm install registry . +``` diff --git a/gemfeed/examples/conf/f3s/registry/helm-chart/templates/deployment.yaml b/gemfeed/examples/conf/f3s/registry/helm-chart/templates/deployment.yaml new file mode 100644 index 00000000..70522f8d --- /dev/null +++ b/gemfeed/examples/conf/f3s/registry/helm-chart/templates/deployment.yaml @@ -0,0 +1,29 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: docker-registry + namespace: infra + labels: + app: docker-registry +spec: + replicas: 1 + selector: + matchLabels: + app: docker-registry + template: + metadata: + labels: + app: docker-registry + spec: + containers: + - name: registry + image: registry:2 + ports: + - containerPort: 5000 + volumeMounts: + - name: registry-storage + mountPath: /var/lib/registry + volumes: + - name: registry-storage + persistentVolumeClaim: + claimName: docker-registry-pvc diff --git a/gemfeed/examples/conf/f3s/registry/helm-chart/templates/pv.yaml b/gemfeed/examples/conf/f3s/registry/helm-chart/templates/pv.yaml new file mode 100644 index 00000000..fb747ca0 --- /dev/null +++ b/gemfeed/examples/conf/f3s/registry/helm-chart/templates/pv.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: docker-registry-pv +spec: + capacity: + storage: 5Gi + volumeMode: Filesystem + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + hostPath: + path: /data/nfs/k3svolumes/registry + type: Directory diff --git a/gemfeed/examples/conf/f3s/registry/helm-chart/templates/pvc.yaml b/gemfeed/examples/conf/f3s/registry/helm-chart/templates/pvc.yaml new file mode 100644 index 00000000..e769c893 --- /dev/null +++ b/gemfeed/examples/conf/f3s/registry/helm-chart/templates/pvc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: docker-registry-pvc + namespace: infra +spec: + storageClassName: "" + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi diff --git a/gemfeed/examples/conf/f3s/registry/helm-chart/templates/service.yaml b/gemfeed/examples/conf/f3s/registry/helm-chart/templates/service.yaml new file mode 100644 index 00000000..a97f14e0 --- /dev/null +++ b/gemfeed/examples/conf/f3s/registry/helm-chart/templates/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: docker-registry-service + namespace: infra +spec: + selector: + app: docker-registry + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 + nodePort: 30001 + type: NodePort |
