From 0801cfdf018b003f9cceddb5254fbe5f24d9232b Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 30 Jul 2025 14:29:51 +0300 Subject: initial registry --- f3s/registry/Makefile | 11 +++++++++++ f3s/registry/README.md | 39 +++++++++++++++++++++++++++++++++++++++ f3s/registry/deployment.yaml | 29 +++++++++++++++++++++++++++++ f3s/registry/pv.yaml | 11 +++++++++++ f3s/registry/pvc.yaml | 12 ++++++++++++ f3s/registry/service.yaml | 13 +++++++++++++ 6 files changed, 115 insertions(+) create mode 100644 f3s/registry/Makefile create mode 100644 f3s/registry/README.md create mode 100644 f3s/registry/deployment.yaml create mode 100644 f3s/registry/pv.yaml create mode 100644 f3s/registry/pvc.yaml create mode 100644 f3s/registry/service.yaml diff --git a/f3s/registry/Makefile b/f3s/registry/Makefile new file mode 100644 index 0000000..e0ff425 --- /dev/null +++ b/f3s/registry/Makefile @@ -0,0 +1,11 @@ +apply: + kubectl apply -f pv.yaml + kubectl apply -f pvc.yaml + kubectl apply -f deployment.yaml + kubectl apply -f service.yaml + +delete: + kubectl delete -f service.yaml + kubectl delete -f deployment.yaml + kubectl delete -f pvc.yaml + kubectl delete -f pv.yaml diff --git a/f3s/registry/README.md b/f3s/registry/README.md new file mode 100644 index 0000000..a5f6a16 --- /dev/null +++ b/f3s/registry/README.md @@ -0,0 +1,39 @@ +# Private Docker Registry + +This document describes how to push Docker images to the private registry deployed in your Kubernetes cluster. + +## Prerequisites + +* The `infra` namespace must exist in your cluster. If it doesn't, create it with `kubectl create namespace infra`. + +* 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. **Get the NodePort of the registry service:** + + ```bash + kubectl get svc docker-registry-service -o jsonpath='{.spec.ports[0].nodePort}' + ``` + +2. **Tag your Docker image:** + + Replace `` with the name of your local Docker image and `` with the IP address of any node in your Kubernetes cluster and `` with the port obtained in the previous step. + + ```bash + docker tag :/ + ``` + +3. **Push the image to the registry:** + + ```bash + docker push :/ + ``` + +4. **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/`. diff --git a/f3s/registry/deployment.yaml b/f3s/registry/deployment.yaml new file mode 100644 index 0000000..70522f8 --- /dev/null +++ b/f3s/registry/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/f3s/registry/pv.yaml b/f3s/registry/pv.yaml new file mode 100644 index 0000000..74a6583 --- /dev/null +++ b/f3s/registry/pv.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: docker-registry-pv +spec: + capacity: + storage: 5Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/data/nfs/k3svolumes/registry" diff --git a/f3s/registry/pvc.yaml b/f3s/registry/pvc.yaml new file mode 100644 index 0000000..192013c --- /dev/null +++ b/f3s/registry/pvc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: docker-registry-pvc + namespace: infra +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi + storageClassName: local-storage diff --git a/f3s/registry/service.yaml b/f3s/registry/service.yaml new file mode 100644 index 0000000..35c6fac --- /dev/null +++ b/f3s/registry/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: docker-registry-service + namespace: infra +spec: + selector: + app: docker-registry + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 + type: NodePort -- cgit v1.2.3