Skip to content

Commit 1c00a9d

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 1c00a9d

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-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: 21 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,14 @@ func (v *volume) split() (corev1.Volume, corev1.VolumeMount) {
269278
}
270279

271280
var items []corev1.KeyToPath
281+
// maps' keys are random, we need to sort the output to prevent redeployment hotloops
282+
for _, key := range sets.StringKeySet(v.mappedKeys).List() {
283+
items = append(items, corev1.KeyToPath{
284+
Key: key,
285+
Path: v.mappedKeys[key],
286+
})
287+
}
288+
272289
for _, key := range v.keys {
273290
items = append(items, corev1.KeyToPath{
274291
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)