Skip to content

Commit c53ab1d

Browse files
committed
Insert trusted-ca-bundle from managed config NS into oauth-server trust store
This uses the ResourceSyncer to get the trusted-ca-bundle from the openshift-config-managed into openshift-authentication namespace with name prefixed in a way so that the config map's resourceVersion is watched and oauth-server is reloaded upon its change.
1 parent b8280b8 commit c53ab1d

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

pkg/operator2/deployment.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ func defaultDeployment(
7171
path: ocpBrandingSecretMount,
7272
keys: []string{configv1.LoginTemplateKey, configv1.ProviderSelectionTemplateKey, configv1.ErrorsTemplateKey},
7373
},
74+
{
75+
name: trustedCABundleLocalName,
76+
configmap: true,
77+
path: trustedCABundleMountDir,
78+
mappedKeys: map[string]string{
79+
trustedCABundleKey: trustedCABundleMountFile,
80+
},
81+
},
7482
} {
7583
v, m := data.split()
7684
volumes = append(volumes, v)
@@ -257,10 +265,11 @@ func appendEnvVar(envVars []corev1.EnvVar, envName, envVal string) []corev1.EnvV
257265
}
258266

259267
type volume struct {
260-
name string
261-
configmap bool
262-
path string
263-
keys []string
268+
name string
269+
configmap bool
270+
path string
271+
keys []string
272+
mappedKeys map[string]string
264273
}
265274

266275
func (v *volume) split() (corev1.Volume, corev1.VolumeMount) {
@@ -276,6 +285,13 @@ func (v *volume) split() (corev1.Volume, corev1.VolumeMount) {
276285
})
277286
}
278287

288+
for key, val := range v.mappedKeys {
289+
items = append(items, corev1.KeyToPath{
290+
Key: key,
291+
Path: val,
292+
})
293+
}
294+
279295
if v.configmap {
280296
vol.ConfigMap = &corev1.ConfigMapVolumeSource{
281297
LocalObjectReference: corev1.LocalObjectReference{

pkg/operator2/operator.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ const (
6262
kasServiceAndEndpointName = "kubernetes"
6363
kasServiceFullName = kasServiceAndEndpointName + "." + corev1.NamespaceDefault + ".svc"
6464

65-
rootCAFile = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
65+
systemTrustStoreDirPath = "/etc/pki/ca-trust/extracted/pem"
66+
rootCAFile = systemTrustStoreDirPath + "/tls-ca-bundle.pem"
6667

6768
systemConfigPath = "/var/config/system"
6869
systemConfigPathConfigMaps = systemConfigPath + "/configmaps"
@@ -109,6 +110,12 @@ const (
109110
consoleConfigMapLocalName = systemConfigPrefix + consoleConfigMapSharedName
110111
consoleConfigKey = consoleConfigMapSharedName + ".yaml"
111112

113+
trustedCABundleSharedName = "trusted-ca-bundle"
114+
trustedCABundleLocalName = systemConfigPrefix + trustedCABundleSharedName
115+
trustedCABundleKey = "ca-bundle.crt"
116+
trustedCABundleMountDir = systemTrustStoreDirPath
117+
trustedCABundleMountFile = "tls-ca-bundle.pem"
118+
112119
ocpBrandingSecretName = systemConfigPrefix + "ocp-branding-template"
113120
ocpBrandingSecretMount = systemConfigPathSecrets + "/" + ocpBrandingSecretName
114121
ocpBrandingLoginPath = ocpBrandingSecretMount + "/" + configv1.LoginTemplateKey

pkg/operator2/starter.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ func RunOperator(ctx *controllercmd.ControllerContext) error {
122122
return err
123123
}
124124

125+
// add syncing for the console-config ConfigMap (indirect watch for changes)
126+
if err := resourceSyncer.SyncConfigMap(
127+
resourcesynccontroller.ResourceLocation{Namespace: targetNamespace, Name: trustedCABundleLocalName},
128+
resourcesynccontroller.ResourceLocation{Namespace: machineConfigNamespace, Name: trustedCABundleSharedName},
129+
); err != nil {
130+
return err
131+
}
132+
125133
versionGetter := status.NewVersionGetter()
126134

127135
operator := NewAuthenticationOperator(

0 commit comments

Comments
 (0)