Skip to content

Commit 8649f95

Browse files
committed
Insert trusted-ca-bundle from managed config NS into oauth-server trust store
This uses the CVO to create and watch a CM in openshift-authentication namespace, the name of the CM is prefixed in a way so that the config map's resourceVersion is watched by the authn operator and oauth-server is reloaded upon its change.
1 parent b8280b8 commit 8649f95

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

manifests/03_configmap.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@ data:
77
operator-config.yaml: |
88
apiVersion: operator.openshift.io/v1alpha1
99
kind: GenericOperatorConfig
10+
---
11+
apiVersion: v1
12+
kind: ConfigMap
13+
metadata:
14+
namespace: openshift-authentication
15+
name: v4-0-config-trusted-ca-bundle
16+
annotations:
17+
release.openshift.io/create-only: "true"
18+
labels:
19+
config.openshift.io/inject-trusted-cabundle: "true"

pkg/operator2/deployment.go

Lines changed: 27 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: trustedCABundleName,
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) {
@@ -269,6 +278,20 @@ func (v *volume) split() (corev1.Volume, corev1.VolumeMount) {
269278
}
270279

271280
var items []corev1.KeyToPath
281+
for key, val := range v.mappedKeys {
282+
items = append(items, corev1.KeyToPath{
283+
Key: key,
284+
Path: val,
285+
})
286+
}
287+
// maps' keys are random, need to sort the output to prevent redeployment hotloops
288+
sort.Slice(items, func(i, j int) bool {
289+
if items[i].Key == items[j].Key {
290+
return items[i].Path < items[j].Path
291+
}
292+
return items[i].Key < items[j].Key
293+
})
294+
272295
for _, key := range v.keys {
273296
items = append(items, corev1.KeyToPath{
274297
Key: key,

pkg/operator2/operator.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ const (
6464

6565
rootCAFile = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
6666

67+
systemTrustStoreDirPath = "/etc/pki/ca-trust/extracted/pem"
68+
6769
systemConfigPath = "/var/config/system"
6870
systemConfigPathConfigMaps = systemConfigPath + "/configmaps"
6971
systemConfigPathSecrets = systemConfigPath + "/secrets"
@@ -109,6 +111,12 @@ const (
109111
consoleConfigMapLocalName = systemConfigPrefix + consoleConfigMapSharedName
110112
consoleConfigKey = consoleConfigMapSharedName + ".yaml"
111113

114+
// trustedCABundleName part of manifests, if changing this, need to change that, too
115+
trustedCABundleName = systemConfigPrefix + "trusted-ca-bundle"
116+
trustedCABundleKey = "ca-bundle.crt"
117+
trustedCABundleMountDir = systemTrustStoreDirPath
118+
trustedCABundleMountFile = "tls-ca-bundle.pem"
119+
112120
ocpBrandingSecretName = systemConfigPrefix + "ocp-branding-template"
113121
ocpBrandingSecretMount = systemConfigPathSecrets + "/" + ocpBrandingSecretName
114122
ocpBrandingLoginPath = ocpBrandingSecretMount + "/" + configv1.LoginTemplateKey

0 commit comments

Comments
 (0)