Skip to content

Commit 318a69c

Browse files
committed
docs: add files to setup private registry
Signed-off-by: Alessio Greggi <alessio.greggi@suse.com>
1 parent fae9405 commit 318a69c

6 files changed

Lines changed: 168 additions & 1 deletion

File tree

docs/private_registry.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Private Registries
2+
3+
SBOMbastic supports private registries to scan for images. In order to make it work, please follow the steps listed below.
4+
5+
## Create the Secret
6+
7+
SBOMbastic relies on the docker `config.json` file to manage the authentication to the registries.
8+
9+
The first step to setup a private registry is to create a `Secret` with the `config.json` content, having the following structure:
10+
11+
```yaml
12+
apiVersion: v1
13+
kind: Secret
14+
metadata:
15+
name: my-auth-secret
16+
namespace: default
17+
data:
18+
.dockerconfigjson: ewoJImF1dGhzIjogewoJCSJkZXYtcmVnaXN0cnkuZGVmYXVsdC5zdmMuY2x1c3Rlci5sb2NhbDo1MDAwIjogewoJCQkiYXV0aCI6ICJkWE5sY2pwd1lYTnpkMjl5WkE9PSIKCQl9Cgl9Cn0KCg==
19+
type: kubernetes.io/dockerconfigjson
20+
```
21+
22+
The `.dockerconfigjson` field is a base64 value, with the `config.json` content.
23+
24+
Here's an example:
25+
26+
```json
27+
{
28+
"auths": {
29+
"myprivateregistry.example": {
30+
"auth": "dXNlcjpwYXNzd29yZA=="
31+
}
32+
}
33+
}
34+
```
35+
36+
For more info, please take a look to the Kubernetes [documentation](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/).
37+
38+
### Tip
39+
40+
Save the `config.json` into a file and use the following command to save it into the `Secret` file:
41+
42+
```sh
43+
cat dockerconfig.json | base64 -w 0 | xclip -sel clipboard
44+
```
45+
46+
## Create the Registry
47+
48+
Once your `Secret` is ready, you can reference it on the `Registry` configuration, specifying the name in the `Registry` field `spec.authSecret`.
49+
50+
```yaml
51+
apiVersion: sbombastic.rancher.io/v1alpha1
52+
kind: Registry
53+
metadata:
54+
name: my-first-registry
55+
namespace: default
56+
spec:
57+
uri: dev-registry.default.svc.cluster.local:5000
58+
scanInterval: 1h
59+
authSecret: my-auth-secret
60+
```
61+
62+
This will allow SBOMbastic to scan for images from private registries.
63+
64+
**Please, note**:
65+
66+
The `Secret` and the `Registry` must be defined inside of the very same `Namespace`.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"auths": {
3+
"myprivateregistry.example": {
4+
"auth": "dXNlcjpwYXNzd29yZA=="
5+
}
6+
}
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: sbombastic.rancher.io/v1alpha1
2+
kind: Registry
3+
metadata:
4+
name: my-first-registry
5+
namespace: default
6+
spec:
7+
uri: dev-registry.default.svc.cluster.local:5000
8+
scanInterval: 1h
9+
authSecret: my-auth-secret

examples/private-registry/secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: Secret
33
metadata:
4-
name: myregistrykey
4+
name: my-auth-secret
55
namespace: default
66
data:
77
.dockerconfigjson: ewoJImF1dGhzIjogewoJCSJkZXYtcmVnaXN0cnkuZGVmYXVsdC5zdmMuY2x1c3Rlci5sb2NhbDo1MDAwIjogewoJCQkiYXV0aCI6ICJkWE5sY2pwd1lYTnpkMjl5WkE9PSIKCQl9Cgl9Cn0KCg==

hack/private-registry.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: registry-auth
6+
namespace: default
7+
type: Opaque
8+
data:
9+
# user:$2y$10$nTQigvLRGGHCBQwZB4MPPe2SA6GYG218uTe1ntHusNcEjLaAfBive -> user:password
10+
htpasswd: dXNlcjokMnkkMTAkblRRaWd2TFJHR0hDQlF3WkI0TVBQZTJTQTZHWUcyMTh1VGUxbnRIdXNOY0VqTGFBZkJpdmUK
11+
12+
---
13+
apiVersion: v1
14+
kind: PersistentVolumeClaim
15+
metadata:
16+
name: registry-storage-pvc
17+
namespace: default
18+
spec:
19+
accessModes:
20+
- ReadWriteOnce
21+
resources:
22+
requests:
23+
storage: 10Gi
24+
25+
---
26+
apiVersion: v1
27+
kind: Pod
28+
metadata:
29+
name: dev-registry
30+
namespace: default
31+
labels:
32+
app: dev-registry
33+
spec:
34+
containers:
35+
- name: registry
36+
image: registry:2.8.3
37+
ports:
38+
- containerPort: 5000
39+
name: http
40+
env:
41+
# Basic authentication configuration
42+
- name: REGISTRY_AUTH
43+
value: htpasswd
44+
- name: REGISTRY_AUTH_HTPASSWD_PATH
45+
value: /auth/htpasswd
46+
- name: REGISTRY_AUTH_HTPASSWD_REALM
47+
value: Registry Realm
48+
# Optional: Enable deletion
49+
- name: REGISTRY_STORAGE_DELETE_ENABLED
50+
value: "true"
51+
volumeMounts:
52+
- name: auth-volume
53+
mountPath: /auth
54+
readOnly: true
55+
- name: registry-storage
56+
mountPath: /var/lib/registry
57+
resources:
58+
requests:
59+
memory: "256Mi"
60+
cpu: "100m"
61+
limits:
62+
memory: "512Mi"
63+
cpu: "500m"
64+
volumes:
65+
- name: auth-volume
66+
secret:
67+
secretName: registry-auth
68+
- name: registry-storage
69+
persistentVolumeClaim:
70+
claimName: registry-storage-pvc
71+
72+
---
73+
apiVersion: v1
74+
kind: Service
75+
metadata:
76+
name: dev-registry
77+
namespace: default
78+
spec:
79+
selector:
80+
app: dev-registry
81+
ports:
82+
- protocol: TCP
83+
port: 5000
84+
targetPort: http

tilt-settings.yaml.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
registry: ghcr.io
2+
use_private_registry: false
23
storage:
34
image: <username>/sbombastic/storage
45
controller:

0 commit comments

Comments
 (0)