Skip to content

Commit df55535

Browse files
committed
Inject operator's trust store with trusted-ca-bundle
1 parent dbd3427 commit df55535

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

manifests/03_configmap.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ data:
1010
---
1111
apiVersion: v1
1212
kind: ConfigMap
13+
metadata:
14+
namespace: openshift-authentication-operator
15+
name: trusted-ca-bundle
16+
annotations:
17+
release.openshift.io/create-only: "true"
18+
labels:
19+
config.openshift.io/inject-trusted-cabundle: "true"
20+
---
21+
apiVersion: v1
22+
kind: ConfigMap
1323
metadata:
1424
namespace: openshift-authentication
1525
name: v4-0-config-system-trusted-ca-bundle

manifests/07_deployment.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ spec:
3636
name: config
3737
- mountPath: /var/run/secrets/serving-cert
3838
name: serving-cert
39+
- mountPath: /var/run/configmaps/trusted-ca-bundle
40+
name: trusted-ca-bundle
41+
readOnly: true
3942
env:
4043
- name: IMAGE
4144
value: quay.io/openshift/origin-oauth-server:v4.2
@@ -53,6 +56,10 @@ spec:
5356
configMap:
5457
defaultMode: 440
5558
name: authentication-operator-config
59+
- name: trusted-ca-bundle
60+
configMap:
61+
name: trusted-ca-bundle
62+
optional: true
5663
- name: serving-cert
5764
secret:
5865
secretName: serving-cert

pkg/operator2/idp.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ package operator2
33
import (
44
"encoding/json"
55
"fmt"
6+
"io/ioutil"
67
"net/http"
78
"net/url"
89
"strings"
910

11+
"k8s.io/klog"
12+
1013
corev1 "k8s.io/api/core/v1"
1114
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1215
"k8s.io/apimachinery/pkg/runtime"
@@ -293,7 +296,7 @@ func (c *authOperator) discoverOpenIDURLs(issuer, key string, ca configv1.Config
293296

294297
func (c *authOperator) transportForCARef(ca configv1.ConfigMapNameReference, key string) (http.RoundTripper, error) {
295298
if len(ca.Name) == 0 {
296-
return transportFor("", nil, nil, nil)
299+
return transportFor("", trustedCABytes(), nil, nil)
297300
}
298301
cm, err := c.configMaps.ConfigMaps(userConfigNamespace).Get(ca.Name, metav1.GetOptions{})
299302
if err != nil {
@@ -343,3 +346,12 @@ func encodeOrDie(obj runtime.Object) []byte {
343346
}
344347
return bytes
345348
}
349+
350+
func trustedCABytes() []byte {
351+
caData, err := ioutil.ReadFile(operatorTrustedCAFile)
352+
if err != nil {
353+
klog.Infof("could not read %s, it won't be used in transport", operatorTrustedCAFile)
354+
return nil
355+
}
356+
return caData
357+
}

pkg/operator2/operator.go

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

65-
rootCAFile = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
66-
67-
systemTrustStoreDirPath = "/etc/pki/ca-trust/extracted/pem"
65+
rootCAFile = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
66+
operatorTrustedCAFile = "/var/run/configmaps/trusted-ca-bundle/ca-bundle.crt"
6867

6968
systemConfigPath = "/var/config/system"
7069
systemConfigPathConfigMaps = systemConfigPath + "/configmaps"
@@ -114,7 +113,7 @@ const (
114113
// trustedCABundleName part of manifests, if changing this, need to change that, too
115114
trustedCABundleName = systemConfigPrefix + "trusted-ca-bundle"
116115
trustedCABundleKey = "ca-bundle.crt"
117-
trustedCABundleMountDir = systemTrustStoreDirPath
116+
trustedCABundleMountDir = "/etc/pki/ca-trust/extracted/pem"
118117
trustedCABundleMountFile = "tls-ca-bundle.pem"
119118

120119
ocpBrandingSecretName = systemConfigPrefix + "ocp-branding-template"
@@ -533,7 +532,8 @@ func (c *authOperator) checkDeploymentReady(deployment *appsv1.Deployment, opera
533532
func (c *authOperator) checkRouteHealthy(route *routev1.Route, routerSecret *corev1.Secret, ingress *configv1.Ingress) (ready bool, msg, reason string, err error) {
534533
caData := routerSecretToCA(route, routerSecret, ingress)
535534

536-
rt, err := transportFor("", caData, nil, nil)
535+
// merge trustedCA data with router cert in case TLS intercept proxy is in place
536+
rt, err := transportFor("", append(caData, trustedCABytes()...), nil, nil)
537537
if err != nil {
538538
return false, "", "FailedTransport", fmt.Errorf("failed to build transport for route: %v", err)
539539
}

0 commit comments

Comments
 (0)