Skip to content

Commit

Permalink
clair: Consume CA certs provided in configBundleSecret (PROJQUAY-3589)
Browse files Browse the repository at this point in the history
- Add CA cert to mounted secret in clair config
- This is required to connect to external db behind custom tls
- Include cluster-trusted-ca in Quay, Clair, Mirror, and Editor pods
  • Loading branch information
jonathankingfc committed Apr 19, 2022
1 parent 622c25a commit e7011f7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bin
tmp
cover.out
kubeconfig
kubeconfig
.DS_Store
8 changes: 6 additions & 2 deletions kustomize/base/config.deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ spec:
- secret:
name: quay-config-tls
- name: extra-ca-certs
configMap:
name: cluster-service-ca
projected:
sources:
- configMap:
name: cluster-service-ca
- configMap:
name: cluster-trusted-ca
containers:
- name: quay-config-editor
image: quay.io/projectquay/quay@sha256:5660d7174218e1cb21bf6ef406602dbe8c01c878c630a9f310fe3e5560d4c2cd
Expand Down
8 changes: 6 additions & 2 deletions kustomize/base/quay.deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ spec:
- secret:
name: quay-config-tls
- name: extra-ca-certs
configMap:
name: cluster-service-ca
projected:
sources:
- configMap:
name: cluster-service-ca
- configMap:
name: cluster-trusted-ca
containers:
- name: quay-app
image: quay.io/projectquay/quay@sha256:5660d7174218e1cb21bf6ef406602dbe8c01c878c630a9f310fe3e5560d4c2cd
Expand Down
4 changes: 4 additions & 0 deletions kustomize/components/clair/clair.deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ spec:
secretKeyRef:
name: quay-proxy-config
key: NO_PROXY
- name: SSL_CERT_DIR
value: $SSL_CERT_DIR:/clair/
ports:
- containerPort: 8080
name: clair-http
Expand Down Expand Up @@ -93,4 +95,6 @@ spec:
name: quay-config-tls
- configMap:
name: cluster-service-ca
- configMap:
name: cluster-trusted-ca

4 changes: 2 additions & 2 deletions kustomize/components/mirror/mirror.deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ spec:
sources:
- configMap:
name: cluster-service-ca
- secret:
name: quay-config-tls
- configMap:
name: cluster-trusted-ca
initContainers:
- name: quay-mirror-init
image: quay.io/projectquay/quay@sha256:5660d7174218e1cb21bf6ef406602dbe8c01c878c630a9f310fe3e5560d4c2cd
Expand Down
11 changes: 10 additions & 1 deletion pkg/kustomize/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ func componentConfigFilesFor(log logr.Logger, qctx *quaycontext.QuayRegistryCont
"database-root-password": []byte(databaseRootPassword),
}, nil
case v1.ComponentClair:
cfgFiles := make(map[string][]byte)

quayHostname := ""
if v1.ComponentIsManaged(quay.Spec.Components, "route") {
config := decode(configFiles["route.config.yaml"])
Expand All @@ -350,6 +352,12 @@ func componentConfigFilesFor(log logr.Logger, qctx *quaycontext.QuayRegistryCont
}
}

for key, val := range configFiles {
if strings.HasPrefix(key, "clair_extra_ca_cert_") {
cfgFiles[strings.TrimPrefix(key, "clair_extra_ca_cert_")] = val
}
}

if quayHostname == "" {
return nil, fmt.Errorf("cannot configure managed security scanner, `SERVER_HOSTNAME` is not set anywhere")
}
Expand All @@ -364,8 +372,9 @@ func componentConfigFilesFor(log logr.Logger, qctx *quaycontext.QuayRegistryCont
if err != nil {
return nil, err
}
cfgFiles["config.yaml"] = cfg

return map[string][]byte{"config.yaml": cfg}, nil
return cfgFiles, nil
default:
return nil, nil
}
Expand Down

0 comments on commit e7011f7

Please sign in to comment.