Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit f16b4da

Browse files
authored
fix: rename the certificate secret and fix mounting of the root certificate (#57)
1 parent ba85a4e commit f16b4da

File tree

9 files changed

+15
-62
lines changed

9 files changed

+15
-62
lines changed

.goreleaser.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ changelog:
3737
# for more information on what this target does: https://goreleaser.com/errors/docker-build/
3838
dockers:
3939
- id: linux-build
40-
extra_files:
41-
- ./hack/entrypoint.sh
4240
image_templates:
4341
- "{{ .Env.REGISTRY }}/open-component-model/{{ .ProjectName }}:{{ .Tag }}"
4442
- "{{ .Env.REGISTRY }}/open-component-model/{{ .ProjectName }}:latest"

Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o ma
2929
FROM gcr.io/distroless/static:nonroot
3030
WORKDIR /
3131
COPY --from=builder /workspace/manager .
32-
COPY hack/entrypoint.sh /entrypoint.sh
3332
USER 65532:65532
3433

35-
ENTRYPOINT ["/entrypoint.sh"]
36-
CMD ["/manager"]
34+
ENTRYPOINT ["/manager"]

Tiltfile

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,15 @@ kubectl_cmd = "kubectl"
66
if str(local("command -v " + kubectl_cmd + " || true", quiet = True)) == "":
77
fail("Required command '" + kubectl_cmd + "' not found in PATH")
88

9-
# set defaults
10-
settings = {
11-
"root_certificate_secret": {
12-
"enable": True,
13-
"name": "registry-certs",
14-
},
15-
}
16-
17-
# global settings
18-
tilt_file = "./tilt-settings.yaml" if os.path.exists("./tilt-settings.yaml") else "./tilt-settings.json"
19-
settings.update(read_yaml(
20-
tilt_file,
21-
default = {},
22-
))
23-
249
# Use kustomize to build the install yaml files
2510
install = kustomize('config/default')
2611

2712
# Update the root security group. Tilt requires root access to update the
2813
# running process.
2914
objects = decode_yaml_stream(install)
30-
root_certificate = settings.get("root_certificate_secret")
3115
for o in objects:
3216
if o.get('kind') == 'Deployment' and o.get('metadata').get('name') == 'git-controller':
3317
o['spec']['template']['spec']['securityContext']['runAsNonRoot'] = False
34-
if root_certificate.get("enable"):
35-
print('updating git-controller deployment to add generated certificates')
36-
o['spec']['template']['spec']['volumes'] = [{'name': 'root-certificate', 'secret': {'secretName': root_certificate.get("name"), 'items': [{'key': 'caFile', 'path': 'ca.pem'}]}}]
37-
o['spec']['template']['spec']['containers'][0]['volumeMounts'] = [{'mountPath': '/certs', 'name': 'root-certificate'}]
3818
break
3919

4020
updated_install = encode_yaml_stream(objects)
@@ -62,7 +42,6 @@ local_resource(
6242
"apis",
6343
"controllers",
6444
"pkg",
65-
"hack/entrypoint.sh",
6645
],
6746
)
6847

@@ -72,7 +51,7 @@ local_resource(
7251
# on _any_ file change. We only want to monitor the binary.
7352
# If debugging is enabled, we switch to a different docker file using
7453
# the delve port.
75-
entrypoint = ['/entrypoint.sh', '/manager']
54+
entrypoint = ['/manager']
7655
dockerfile = 'tilt.dockerfile'
7756
docker_build_with_restart(
7857
'ghcr.io/open-component-model/git-controller',
@@ -81,10 +60,8 @@ docker_build_with_restart(
8160
entrypoint = entrypoint,
8261
only=[
8362
'./bin',
84-
'./hack/entrypoint.sh',
8563
],
8664
live_update = [
8765
sync('./bin/manager', '/manager'),
88-
sync('./hack/entrypoint.sh', '/entrypoint.sh'),
8966
],
9067
)

config/manager/kustomization.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ images:
1111
newTag: latest
1212

1313
# Comment to disable HTTPS for the registry
14-
# patches:
15-
# - path: ./patches/add_root_certificates.yaml
14+
patches:
15+
- path: ./patches/add_root_certificates.yaml

config/manager/patches/add_root_certificates.yaml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ kind: Deployment
33
metadata:
44
name: git-controller
55
labels:
6-
control-plane: controller
6+
app: git-controller
7+
namespace: ocm-system
78
spec:
89
selector:
910
matchLabels:
@@ -13,16 +14,14 @@ spec:
1314
containers:
1415
- name: manager
1516
image: open-component-model/git-controller
16-
env:
17-
- name: REGISTRY_ROOT_CERTIFICATE # optionally define to override default location
18-
value: /certs/ca.pem
1917
volumeMounts:
20-
- mountPath: "/certs"
18+
- mountPath: "/etc/ssl/certs/registry-root.pem"
19+
subPath: "registry-root.pem"
2120
name: "certificates"
2221
volumes:
2322
- name: "certificates"
2423
secret:
25-
secretName: "registry-certs"
24+
secretName: "ocm-registry-tls-certs"
2625
items:
27-
- key: "ca.pem"
28-
path: "ca.pem"
26+
- key: "caFile"
27+
path: "registry-root.pem"

goreleaser.dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
FROM gcr.io/distroless/static:nonroot
22
WORKDIR /
33
COPY git-controller /manager
4-
COPY ./hack/entrypoint.sh /entrypoint.sh
54
USER 65532:65532
65

7-
ENTRYPOINT ["/entrypoint.sh"]
8-
CMD ["/manager"]
6+
ENTRYPOINT ["/manager"]

hack/entrypoint.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func main() {
6161
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
6262
flag.StringVar(&storagePath, "storage-path", "/data", "The location which to use for temporary storage. Should be mounted into the pod.")
6363
flag.StringVar(&ociRegistryAddr, "oci-registry-addr", ":5000", "The address of the OCI registry.")
64-
flag.StringVar(&ociRegistryCertSecretName, "certificate-secret-name", v1alpha1.DefaultRegistryCertificateSecretName, "")
64+
flag.StringVar(&ociRegistryCertSecretName, "certificate-secret-name", "ocm-registry-tls-certs", "")
6565
flag.StringVar(&ociRegistryNamespace, "oci-registry-namespace", "ocm-system", "The namespace in which the registry is running in.")
6666
flag.StringVar(&eventsAddr, "events-addr", "", "The address of the events receiver.")
6767

tilt.dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
FROM alpine
22
WORKDIR /
33
COPY ./bin/manager /manager
4-
COPY ./hack/entrypoint.sh /entrypoint.sh
54

6-
ENTRYPOINT ["/entrypoint.sh"]
7-
CMD ["/manager"]
5+
ENTRYPOINT ["/manager"]
6+

0 commit comments

Comments
 (0)