diff options
| -rw-r--r-- | f3s/registry/Makefile | 11 | ||||
| -rw-r--r-- | f3s/registry/README.md | 39 | ||||
| -rw-r--r-- | f3s/registry/deployment.yaml | 29 | ||||
| -rw-r--r-- | f3s/registry/pv.yaml | 11 | ||||
| -rw-r--r-- | f3s/registry/pvc.yaml | 12 | ||||
| -rw-r--r-- | f3s/registry/service.yaml | 13 |
6 files changed, 115 insertions, 0 deletions
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 `<your-image>` with the name of your local Docker image and `<node-ip>` with the IP address of any node in your Kubernetes cluster and `<node-port>` with the port obtained in the previous step. + + ```bash + docker tag <your-image> <node-ip>:<node-port>/<your-image> + ``` + +3. **Push the image to the registry:** + + ```bash + docker push <node-ip>:<node-port>/<your-image> + ``` + +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/<your-image>`. 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 |
