feat(docker-registry): add registry
This commit is contained in:
parent
5832b208f3
commit
1b4f9114a1
14 changed files with 406 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ The private keys are:
|
||||||
|
|
||||||
- K8s cluster as a secret
|
- K8s cluster as a secret
|
||||||
- MacOS - `$HOME/Library/Application Support/sops/age/keys.txt`
|
- MacOS - `$HOME/Library/Application Support/sops/age/keys.txt`
|
||||||
|
- Linux - `$HOME/.config/sops/age/keys.txt`
|
||||||
|
|
||||||
## 1. Create the resource
|
## 1. Create the resource
|
||||||
|
|
||||||
|
|
|
||||||
24
apps/docker-registry/base/config.yml
Normal file
24
apps/docker-registry/base/config.yml
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
health:
|
||||||
|
storagedriver:
|
||||||
|
enabled: true
|
||||||
|
interval: 10s
|
||||||
|
threshold: 3
|
||||||
|
http:
|
||||||
|
addr: :5000
|
||||||
|
debug:
|
||||||
|
addr: :5001
|
||||||
|
prometheus:
|
||||||
|
enabled: false
|
||||||
|
path: /metrics
|
||||||
|
headers:
|
||||||
|
X-Content-Type-Options:
|
||||||
|
- nosniff
|
||||||
|
log:
|
||||||
|
fields:
|
||||||
|
service: registry
|
||||||
|
storage:
|
||||||
|
cache:
|
||||||
|
blobdescriptor: inmemory
|
||||||
|
version: 0.1
|
||||||
|
|
||||||
|
|
||||||
85
apps/docker-registry/base/cronjob.yaml
Normal file
85
apps/docker-registry/base/cronjob.yaml
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
---
|
||||||
|
# Source: docker-registry/templates/cronjob.yaml
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: CronJob
|
||||||
|
metadata:
|
||||||
|
name: docker-registry-garbage-collector
|
||||||
|
namespace: gitops
|
||||||
|
labels:
|
||||||
|
app: docker-registry
|
||||||
|
chart: docker-registry-2.2.3
|
||||||
|
release: docker-registry
|
||||||
|
heritage: Helm
|
||||||
|
spec:
|
||||||
|
schedule: "0 1 * * *"
|
||||||
|
jobTemplate:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: docker-registry
|
||||||
|
release: docker-registry
|
||||||
|
annotations:
|
||||||
|
checksum/config: 7768037b11264d8a85079c7389faa0b2846b55771ae7ea102d41f7ea868676fb
|
||||||
|
checksum/secret: cf8de4fbecd435bc3788328888b074e895540fd0a0681fa391ee2d3f42e1e599
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
securityContext:
|
||||||
|
fsGroup: 1000
|
||||||
|
runAsUser: 1000
|
||||||
|
containers:
|
||||||
|
- name: docker-registry
|
||||||
|
image: "registry:2.8.1"
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command:
|
||||||
|
- /bin/registry
|
||||||
|
- garbage-collect
|
||||||
|
- --delete-untagged=true
|
||||||
|
- /etc/docker/registry/config.yml
|
||||||
|
env:
|
||||||
|
- name: REGISTRY_HTTP_SECRET
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: docker-registry-secret
|
||||||
|
key: haSharedSecret
|
||||||
|
- name: REGISTRY_AUTH
|
||||||
|
value: "htpasswd"
|
||||||
|
- name: REGISTRY_AUTH_HTPASSWD_REALM
|
||||||
|
value: "Registry Realm"
|
||||||
|
- name: REGISTRY_AUTH_HTPASSWD_PATH
|
||||||
|
value: "/auth/htpasswd"
|
||||||
|
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
|
||||||
|
value: "/var/lib/registry"
|
||||||
|
- name: REGISTRY_PROXY_REMOTEURL
|
||||||
|
value: https://registry-1.docker.io
|
||||||
|
- name: REGISTRY_PROXY_USERNAME
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: docker-registry-secret
|
||||||
|
key: proxyUsername
|
||||||
|
- name: REGISTRY_PROXY_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: docker-registry-secret
|
||||||
|
key: proxyPassword
|
||||||
|
volumeMounts:
|
||||||
|
- name: "docker-registry-config"
|
||||||
|
mountPath: "/etc/docker/registry"
|
||||||
|
- name: auth
|
||||||
|
mountPath: /auth
|
||||||
|
readOnly: true
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/lib/registry/
|
||||||
|
restartPolicy: OnFailure
|
||||||
|
volumes:
|
||||||
|
- name: docker-registry-config
|
||||||
|
configMap:
|
||||||
|
name: docker-registry-config
|
||||||
|
- name: auth
|
||||||
|
secret:
|
||||||
|
secretName: docker-registry-secret
|
||||||
|
items:
|
||||||
|
- key: htpasswd
|
||||||
|
path: htpasswd
|
||||||
|
- name: data
|
||||||
|
emptyDir: {}
|
||||||
|
|
||||||
102
apps/docker-registry/base/deployment.yaml
Normal file
102
apps/docker-registry/base/deployment.yaml
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
---
|
||||||
|
# Source: docker-registry/templates/deployment.yaml
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: docker-registry
|
||||||
|
namespace: gitops
|
||||||
|
labels:
|
||||||
|
app: docker-registry
|
||||||
|
chart: docker-registry-2.2.3
|
||||||
|
release: docker-registry
|
||||||
|
heritage: Helm
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: docker-registry
|
||||||
|
release: docker-registry
|
||||||
|
replicas: 1
|
||||||
|
strategy:
|
||||||
|
rollingUpdate:
|
||||||
|
maxSurge: 1
|
||||||
|
maxUnavailable: 0
|
||||||
|
type: RollingUpdate
|
||||||
|
minReadySeconds: 5
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: docker-registry
|
||||||
|
release: docker-registry
|
||||||
|
annotations:
|
||||||
|
updated-at/secret: 2024-10-16T14:38:25-04:00
|
||||||
|
spec:
|
||||||
|
securityContext:
|
||||||
|
fsGroup: 1000
|
||||||
|
runAsUser: 1000
|
||||||
|
containers:
|
||||||
|
- name: docker-registry
|
||||||
|
image: "registry:2.8.1"
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command:
|
||||||
|
- /bin/registry
|
||||||
|
- serve
|
||||||
|
- /etc/docker/registry/config.yml
|
||||||
|
ports:
|
||||||
|
- containerPort: 5000
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: 5000
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: 5000
|
||||||
|
resources:
|
||||||
|
{}
|
||||||
|
env:
|
||||||
|
- name: REGISTRY_HTTP_SECRET
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: docker-registry-secret
|
||||||
|
key: haSharedSecret
|
||||||
|
- name: REGISTRY_AUTH
|
||||||
|
value: "htpasswd"
|
||||||
|
- name: REGISTRY_AUTH_HTPASSWD_REALM
|
||||||
|
value: "Registry Realm"
|
||||||
|
- name: REGISTRY_AUTH_HTPASSWD_PATH
|
||||||
|
value: "/auth/htpasswd"
|
||||||
|
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
|
||||||
|
value: "/var/lib/registry"
|
||||||
|
- name: REGISTRY_PROXY_REMOTEURL
|
||||||
|
value: https://registry-1.docker.io
|
||||||
|
- name: REGISTRY_PROXY_USERNAME
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: docker-registry-secret
|
||||||
|
key: proxyUsername
|
||||||
|
- name: REGISTRY_PROXY_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: docker-registry-secret
|
||||||
|
key: proxyPassword
|
||||||
|
volumeMounts:
|
||||||
|
- name: "docker-registry-config"
|
||||||
|
mountPath: "/etc/docker/registry"
|
||||||
|
- name: auth
|
||||||
|
mountPath: /auth
|
||||||
|
readOnly: true
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/lib/registry/
|
||||||
|
volumes:
|
||||||
|
- name: docker-registry-config
|
||||||
|
configMap:
|
||||||
|
name: docker-registry-config
|
||||||
|
- name: auth
|
||||||
|
secret:
|
||||||
|
secretName: docker-registry-secret
|
||||||
|
items:
|
||||||
|
- key: htpasswd
|
||||||
|
path: htpasswd
|
||||||
|
- name: data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: docker-registry
|
||||||
33
apps/docker-registry/base/ingress.yaml
Normal file
33
apps/docker-registry/base/ingress.yaml
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
---
|
||||||
|
# Source: docker-registry/templates/ingress.yaml
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: docker-registry
|
||||||
|
namespace: gitops
|
||||||
|
labels:
|
||||||
|
app: docker-registry
|
||||||
|
chart: docker-registry-2.2.3
|
||||||
|
release: docker-registry
|
||||||
|
heritage: Helm
|
||||||
|
annotations:
|
||||||
|
cert-manager.io/cluster-issuer: letsencrypt-issuer
|
||||||
|
nginx.ingress.kubernetes.io/whitelist-source-range: 192.168.1.1/16
|
||||||
|
spec:
|
||||||
|
ingressClassName: nginx
|
||||||
|
rules:
|
||||||
|
- host: registry.int.nc.landry.land
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: docker-registry
|
||||||
|
port:
|
||||||
|
name: http
|
||||||
|
tls:
|
||||||
|
- hosts:
|
||||||
|
- registry.int.nc.landry.land
|
||||||
|
secretName: registry-tls
|
||||||
|
|
||||||
15
apps/docker-registry/base/kustomization.yaml
Normal file
15
apps/docker-registry/base/kustomization.yaml
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
- ingress.yaml
|
||||||
|
- pvc.yaml
|
||||||
|
- service.yaml
|
||||||
|
- pdb.yaml
|
||||||
|
- cronjob.yaml
|
||||||
|
|
||||||
|
configMapGenerator:
|
||||||
|
- name: docker-registry-config
|
||||||
|
files:
|
||||||
|
- config.yml
|
||||||
19
apps/docker-registry/base/pdb.yaml
Normal file
19
apps/docker-registry/base/pdb.yaml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
---
|
||||||
|
# Source: docker-registry/templates/poddisruptionbudget.yaml
|
||||||
|
apiVersion: policy/v1
|
||||||
|
kind: PodDisruptionBudget
|
||||||
|
metadata:
|
||||||
|
name: docker-registry
|
||||||
|
namespace: gitops
|
||||||
|
labels:
|
||||||
|
app: docker-registry
|
||||||
|
chart: docker-registry-2.2.3
|
||||||
|
release: docker-registry
|
||||||
|
heritage: Helm
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: docker-registry
|
||||||
|
release: docker-registry
|
||||||
|
maxUnavailable: 1
|
||||||
|
|
||||||
19
apps/docker-registry/base/pvc.yaml
Normal file
19
apps/docker-registry/base/pvc.yaml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
---
|
||||||
|
# Source: docker-registry/templates/pvc.yaml
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: docker-registry
|
||||||
|
namespace: gitops
|
||||||
|
labels:
|
||||||
|
app: docker-registry
|
||||||
|
chart: "docker-registry-2.2.3"
|
||||||
|
release: "docker-registry"
|
||||||
|
heritage: "Helm"
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- "ReadWriteOnce"
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: "10Gi"
|
||||||
|
|
||||||
23
apps/docker-registry/base/service.yaml
Normal file
23
apps/docker-registry/base/service.yaml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
# Source: docker-registry/templates/service.yaml
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: docker-registry
|
||||||
|
namespace: gitops
|
||||||
|
labels:
|
||||||
|
app: docker-registry
|
||||||
|
chart: docker-registry-2.2.3
|
||||||
|
release: docker-registry
|
||||||
|
heritage: Helm
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
ports:
|
||||||
|
- port: 5000
|
||||||
|
protocol: TCP
|
||||||
|
name: http
|
||||||
|
targetPort: 5000
|
||||||
|
selector:
|
||||||
|
app: docker-registry
|
||||||
|
release: docker-registry
|
||||||
|
|
||||||
11
apps/docker-registry/overlays/system/config.json
Normal file
11
apps/docker-registry/overlays/system/config.json
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"appName": "docker-registry",
|
||||||
|
"userGivenName": "docker-registry",
|
||||||
|
"destNamespace": "gitops",
|
||||||
|
"destServer": "https://kubernetes.default.svc",
|
||||||
|
"srcPath": "apps/docker-registry/overlays/system",
|
||||||
|
"srcRepoURL": "ssh://git@gitea-ssh.gitops.svc.cluster.local:2222/davad/argo.git",
|
||||||
|
"srcTargetRevision": "",
|
||||||
|
"labels": null,
|
||||||
|
"annotations": null
|
||||||
|
}
|
||||||
10
apps/docker-registry/overlays/system/deployment.patch.yaml
Normal file
10
apps/docker-registry/overlays/system/deployment.patch.yaml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: docker-registry
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
updated-at/secret: 2024-10-16T15:23-04:00
|
||||||
|
|
||||||
10
apps/docker-registry/overlays/system/kustomization.yaml
Normal file
10
apps/docker-registry/overlays/system/kustomization.yaml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- ../../base
|
||||||
|
|
||||||
|
generators:
|
||||||
|
- ./secret-generator.yaml
|
||||||
|
|
||||||
|
patches:
|
||||||
|
- path: ./deployment.patch.yaml
|
||||||
15
apps/docker-registry/overlays/system/secret-generator.yaml
Normal file
15
apps/docker-registry/overlays/system/secret-generator.yaml
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
apiVersion: viaduct.ai/v1
|
||||||
|
kind: ksops
|
||||||
|
metadata:
|
||||||
|
# Specify a name
|
||||||
|
name: example-secret-generator
|
||||||
|
annotations:
|
||||||
|
config.kubernetes.io/function: |
|
||||||
|
exec:
|
||||||
|
# if the binary is in your PATH, you can do
|
||||||
|
path: ksops
|
||||||
|
# otherwise, path should be relative to manifest files, like
|
||||||
|
# path: ../../../ksops
|
||||||
|
files:
|
||||||
|
- ./secret.enc.yaml
|
||||||
|
|
||||||
39
apps/docker-registry/overlays/system/secret.enc.yaml
Normal file
39
apps/docker-registry/overlays/system/secret.enc.yaml
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
# htpasswd is what our docker client uses to authenticate
|
||||||
|
# haSharedSecret, I _think_ is used internally by the registry
|
||||||
|
# proxyUsername and proxyPassword are used to pull from the upstream registry
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: docker-registry-secret
|
||||||
|
namespace: gitops
|
||||||
|
labels:
|
||||||
|
app: docker-registry
|
||||||
|
chart: docker-registry-2.2.3
|
||||||
|
heritage: Helm
|
||||||
|
release: docker-registry
|
||||||
|
type: Opaque
|
||||||
|
data:
|
||||||
|
htpasswd: ENC[AES256_GCM,data:UnlnZU6jYITgVdinR6IMpirR85ewV5dcmJhC7hlRc0eqWXuD+5WpktFI7S6Uki5qKKesftD8zYvsxLH+FdYYKOQKsVwJx1kLGf2XY52/siAFAn3xQqilhQ==,iv:cF2GhzrJhgpOqjMJdWdqqpSS0DHY/qLZPfDn3ZrRgd0=,tag:pBJ+DbP/733U3abPWyWlrQ==,type:str]
|
||||||
|
haSharedSecret: ENC[AES256_GCM,data:zEl3ztvuhXQpBTAnf7CzuSSwdvQFOfLA,iv:Saka/heNDTUmZyPTo4sBjmy/epCMIZgF4aOzNPmkVtI=,tag:6PWelWs6jOBY2bVCThJKJg==,type:str]
|
||||||
|
proxyUsername: ""
|
||||||
|
proxyPassword: ""
|
||||||
|
sops:
|
||||||
|
kms: []
|
||||||
|
gcp_kms: []
|
||||||
|
azure_kv: []
|
||||||
|
hc_vault: []
|
||||||
|
age:
|
||||||
|
- recipient: age1y26vr5qt6th3wu92rnsgkqcpxxah3pqkqa4khcjjycm3kg40aqyqjgfzx9
|
||||||
|
enc: |
|
||||||
|
-----BEGIN AGE ENCRYPTED FILE-----
|
||||||
|
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB1V1FKR1pWdzg2UkloUmJv
|
||||||
|
ZnU0b0hUQmZqUk04T3ZhT2pFYys3VTJNZW1nCmV2QkQ4WEhsbHl2MDVEWGtHY3Zz
|
||||||
|
Y2hXMnRkTGRRTlJZdnJWYS8yNVcvaGcKLS0tIGNUSnpIbEMrdW92eVJWdjhLbXNF
|
||||||
|
anYrWjFIN3kxM1k0TTV5REhyMXZYNW8KCK7diWMKH6HiizVKZVevjVSEYPVolm84
|
||||||
|
bqbvxoR+YZ+OmKoHG5DtXwMSAvjjG2pz6GrteInRSb/WqtWKuldrfQ==
|
||||||
|
-----END AGE ENCRYPTED FILE-----
|
||||||
|
lastmodified: "2024-10-16T19:22:05Z"
|
||||||
|
mac: ENC[AES256_GCM,data:yqFueJcs6Ja6qFE9y6Q/SRQaIcXERdRCUo6iqpzJaNiDW9346sGMkBTvIvGXv/E22wABLTfJ/xe+jgK3BzdEm6DvW7UnBwJ0hRq0d9G+7c94If4km+ZADh3EHCweSv8RiF525UR2R38kENKsZ6xppfXSi2iVwqPXwHeMmf2pTwY=,iv:6dk/M60HSxxwi4PI7fT2bQYYlT4YPXpWJYNejNwCn1c=,tag:AI446UtFceDQyeuX0zplVQ==,type:str]
|
||||||
|
pgp: []
|
||||||
|
encrypted_regex: ^(data|stringData)$
|
||||||
|
version: 3.9.1
|
||||||
Loading…
Add table
Add a link
Reference in a new issue