Overview
Updated: 07.12.2022 – etc/hosts step added, all metada-name with release.name refactored, hostPath in values.yaml defined.
Installation
volume.yaml (PV and PVC )
apiVersion: v1 kind: PersistentVolume metadata: name: {{ .Release.Name }}-pv labels: type: local spec: capacity: storage: "{{ .Values.storageSize }}" accessModes: - ReadWriteOnce hostPath: path: {{ .Values.hostPath }} volumeMode: Filesystem --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: {{ .Release.Name }}-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: {{ .Values.storageSize }}
deployment.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Release.Name }}-deploy spec: replicas: 1 selector: matchLabels: app: {{ .Release.Name }} template: metadata: labels: app: {{ .Release.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: {{ .Release.Name }}-pvc
service.yaml
apiVersion: v1 kind: Service metadata: name: {{ .Release.Name }}-service spec: selector: app: {{ .Release.Name }} ports: - protocol: TCP port: 80 targetPort: 5000 name: http
ingress.yaml
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ .Release.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: {{ .Release.Name }}-service port: number: 80
values.yaml
hostname: private-registry.local image: repository: registry tag: 2 storageSize: 20Gi hostPath: '/home/user/projects/privateDockerRegistry'
Directory structure (in my case privateDockerRegistry):
├── Chart.yaml
├── templates
│ ├── deployment.yaml
│ ├── ingress.yaml
│ ├── volume.yaml
│ └── service.yaml
└── values.yaml
Installation:
d8devs.com@kubernetes:/home/user/projects/privateDockerRegistry$ helm upgrade --install docker-registry -f values.yaml .
Hostname in etc/hosts
Open your /etc/hosts with text editor in administrator mode, add the ip address and hostname
d8devs.com@kubernetes:/var/privateDockerRegistry$ sudo vim /etc/hosts # /etc/hosts # ... # ... 127.0.0.1 private-registry.local
Testing
d8devs.com@kubernetes:/var/privateDockerRegistry$ curl -X GET private-registry.local/v2/_catalog {"repositories":[]}
Done !
Views: 1894