Skip to content

Commit 5e67403

Browse files
committed
Separate CA configuration for pulls vs catalogd services
Rename the flags that provide CAs to image pulling to indicate the use. Keep the old flag around (for backward compatibility), but prefer the new flag(s). Signed-off-by: Todd Short <[email protected]>
1 parent 10e2754 commit 5e67403

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

catalogd/cmd/catalogd/main.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func main() {
9898
keyFile string
9999
webhookPort int
100100
caCertDir string
101+
pullCertDir string
101102
globalPullSecret string
102103
)
103104
flag.StringVar(&metricsAddr, "metrics-bind-address", "", "The address for the metrics endpoint. Requires tls-cert and tls-key. (Default: ':7443')")
@@ -115,7 +116,8 @@ func main() {
115116
flag.StringVar(&certFile, "tls-cert", "", "The certificate file used for serving catalog and metrics. Required to enable the metrics server. Requires tls-key.")
116117
flag.StringVar(&keyFile, "tls-key", "", "The key file used for serving catalog contents and metrics. Required to enable the metrics server. Requires tls-cert.")
117118
flag.IntVar(&webhookPort, "webhook-server-port", 9443, "The port that the mutating webhook server serves at.")
118-
flag.StringVar(&caCertDir, "ca-certs-dir", "", "The directory of CA certificate to use for verifying HTTPS connections to image registries.")
119+
flag.StringVar(&caCertDir, "ca-certs-dir", "", "The directory of CA certificate to use for verifying HTTPS connections to image registries (deprecated).")
120+
flag.StringVar(&pullCertDir, "pull-certs-dir", "", "The directory of CA certificate to use for verifying HTTPS connections to image registries.")
119121
flag.StringVar(&globalPullSecret, "global-pull-secret", "", "The <namespace>/<name> of the global pull secret that is going to be used to pull bundle images.")
120122

121123
klog.InitFlags(flag.CommandLine)
@@ -130,6 +132,12 @@ func main() {
130132
os.Exit(0)
131133
}
132134

135+
// if the old flag is specified, but not the new flag
136+
// use the old flag
137+
if caCertDir != "" && pullCertDir == "" {
138+
pullCertDir = caCertDir
139+
}
140+
133141
ctrl.SetLogger(textlogger.NewLogger(textlogger.NewConfig()))
134142

135143
authFilePath := filepath.Join(os.TempDir(), fmt.Sprintf("%s-%s.json", authFilePrefix, apimachineryrand.String(8)))
@@ -271,8 +279,8 @@ func main() {
271279
BaseCachePath: unpackCacheBasePath,
272280
SourceContextFunc: func(logger logr.Logger) (*types.SystemContext, error) {
273281
srcContext := &types.SystemContext{
274-
DockerCertPath: caCertDir,
275-
OCICertPath: caCertDir,
282+
DockerCertPath: pullCertDir,
283+
OCICertPath: pullCertDir,
276284
}
277285
if _, err := os.Stat(authFilePath); err == nil && globalPullSecretKey != nil {
278286
logger.Info("using available authentication information for pulling image")

catalogd/config/components/ca/patches/manager_deployment_cacerts.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
value: {"name":"olmv1-certificate", "readOnly": true, "mountPath":"/var/ca-certs/"}
77
- op: add
88
path: /spec/template/spec/containers/0/args/-
9-
value: "--ca-certs-dir=/var/ca-certs"
9+
value: "--pull-certs-dir=/var/ca-certs"

cmd/operator-controller/main.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,15 @@ func main() {
102102
operatorControllerVersion bool
103103
systemNamespace string
104104
caCertDir string
105+
catalogdCertDir string
106+
pullCertDir string
105107
globalPullSecret string
106108
)
107109
flag.StringVar(&metricsAddr, "metrics-bind-address", "", "The address for the metrics endpoint. Requires tls-cert and tls-key. (Default: ':8443')")
108110
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
109-
flag.StringVar(&caCertDir, "ca-certs-dir", "", "The directory of TLS certificate to use for verifying HTTPS connections to the Catalogd and docker-registry web servers.")
111+
flag.StringVar(&caCertDir, "ca-certs-dir", "", "The directory of TLS certificate to use for verifying HTTPS connections to the Catalogd and docker-registry web servers (deprecated).")
112+
flag.StringVar(&catalogdCertDir, "catalogd-certs-dir", "", "The directory of TLS certificate to use for verifying HTTPS connections to the Catalogd web service.")
113+
flag.StringVar(&pullCertDir, "pull-certs-dir", "", "The directory of TLS certificates to use for verifying HTTPS connections to image registries.")
110114
flag.StringVar(&certFile, "tls-cert", "", "The certificate file used for the metrics server. Required to enable the metrics server. Requires tls-key.")
111115
flag.StringVar(&keyFile, "tls-key", "", "The key file used for the metrics server. Required to enable the metrics server. Requires tls-cert")
112116
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
@@ -128,6 +132,13 @@ func main() {
128132
os.Exit(0)
129133
}
130134

135+
// if the old flag is specified, but neither of the new flags
136+
// use the old flag
137+
if caCertDir != "" && catalogdCertDir == "" && pullCertDir == "" {
138+
catalogdCertDir = caCertDir
139+
pullCertDir = caCertDir
140+
}
141+
131142
if (certFile != "" && keyFile == "") || (certFile == "" && keyFile != "") {
132143
setupLog.Error(nil, "unable to configure TLS certificates: tls-cert and tls-key flags must be used together")
133144
os.Exit(1)
@@ -283,7 +294,7 @@ func main() {
283294
os.Exit(1)
284295
}
285296

286-
certPoolWatcher, err := httputil.NewCertPoolWatcher(caCertDir, ctrl.Log.WithName("cert-pool"))
297+
certPoolWatcher, err := httputil.NewCertPoolWatcher(catalogdCertDir, ctrl.Log.WithName("cert-pool"))
287298
if err != nil {
288299
setupLog.Error(err, "unable to create CA certificate pool")
289300
os.Exit(1)
@@ -301,8 +312,8 @@ func main() {
301312
BaseCachePath: filepath.Join(cachePath, "unpack"),
302313
SourceContextFunc: func(logger logr.Logger) (*types.SystemContext, error) {
303314
srcContext := &types.SystemContext{
304-
DockerCertPath: caCertDir,
305-
OCICertPath: caCertDir,
315+
DockerCertPath: pullCertDir,
316+
OCICertPath: pullCertDir,
306317
}
307318
if _, err := os.Stat(authFilePath); err == nil && globalPullSecretKey != nil {
308319
logger.Info("using available authentication information for pulling image")

config/components/tls/patches/manager_deployment_cert.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
value: {"name":"olmv1-certificate", "readOnly": true, "mountPath":"/var/certs/"}
77
- op: add
88
path: /spec/template/spec/containers/0/args/-
9-
value: "--ca-certs-dir=/var/certs"
9+
value: "--catalogd-certs-dir=/var/certs"
10+
- op: add
11+
path: /spec/template/spec/containers/0/args/-
12+
value: "--pull-certs-dir=/var/certs"
1013
- op: add
1114
path: /spec/template/spec/containers/0/args/-
1215
value: "--tls-cert=/var/certs/tls.cert"

0 commit comments

Comments
 (0)