Simple Private Docker Registry via Helm (as Helm Chart)

Hits: 20

Overview

Overwiew

Installation

volume.yaml (PV and PVC )

apiVersion: v1
kind: PersistentVolume
metadata:
  name: {{ .Chart.Name }}-pv
  labels:
    type: local
spec:
  capacity:
    storage: "{{ .Values.storageSize }}"
  accessModes:
  - ReadWriteOnce
  hostPath:
    path: "/tmp/registry"
  volumeMode: Filesystem
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: {{ .Chart.Name }}-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: {{ .Values.storageSize }}

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Chart.Name }}-deploy
spec:
  replicas: 1
  selector:
    matchLabels:
      app: {{ .Chart.Name }}
  template:
    metadata:
      labels:
        app: {{ .Chart.Name }}
    spec:
      containers:
        - name: private-registry-container
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          ports:
            - containerPort: 5000
          volumeMounts:
            - name: registry-data
              mountPath: /var/lib/registry
      volumes:
        - name: registry-data
          persistentVolumeClaim:
            claimName: {{ .Chart.Name }}-pvc

service.yaml

apiVersion: v1
kind: Service
metadata:
  name: {{ .Chart.Name }}-service
spec:
  selector:
    app: {{ .Chart.Name }}
  ports:
    - protocol: TCP
      port: 80
      targetPort: 5000
      name: http

ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: {{ .Chart.Name }}-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/proxy-body-size: "0"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
spec:
  rules:
    - host: {{ .Values.hostname }}
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: {{ .Chart.Name }}-service
                port:
                  number: 80

values.yaml

hostname: your.localdockerregistry.doma.in

image:
  repository: registry
  tag: 2

storageSize: 10Gi

Directory structure (in my case privateDockerRegistry):

├── Chart.yaml
├── templates
│   ├── deployment.yaml
│   ├── ingress.yaml
│   ├── volume.yaml
│   └── service.yaml
└── values.yaml

Installation:

d8devs.com@kubernetes:/var/privateDockerRegistry$ helm upgrade --install docker-registry -f values.yaml .

Testing

d8devs.com@kubernetes:/var/privateDockerRegistry$  curl -X GET your.localdockerregistry.doma.in/v2/_catalog
{"repositories":[]} 

Done !