Skip to content

Commit 308e9a7

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 308e9a7

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

pkg/operator2/deployment.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,24 @@ func defaultDeployment(
8181
volumes, mounts = toVolumesAndMounts(syncData.idpSecrets, volumes, mounts)
8282
volumes, mounts = toVolumesAndMounts(syncData.tplSecrets, volumes, mounts)
8383

84+
volumes = append(volumes, corev1.Volume{
85+
Name: trustedCABundleLocalName,
86+
VolumeSource: corev1.VolumeSource{
87+
ConfigMap: &corev1.ConfigMapVolumeSource{
88+
LocalObjectReference: corev1.LocalObjectReference{
89+
Name: trustedCABundleLocalName,
90+
},
91+
Items: []corev1.KeyToPath{{Key: trustedCABundleKey, Path: trustedCABundleMountFile}},
92+
},
93+
},
94+
})
95+
96+
mounts = append(mounts, corev1.VolumeMount{
97+
Name: trustedCABundleLocalName,
98+
ReadOnly: true,
99+
MountPath: trustedCABundleMountDir,
100+
})
101+
84102
// force redeploy when any associated resource changes
85103
// we use a hash to prevent this value from growing indefinitely
86104
// need to sort first in order to get a stable array

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)