Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions bindata/v4.1.0/kube-apiserver/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ spec:
image: ${IMAGE}
imagePullPolicy: IfNotPresent
terminationMessagePolicy: FallbackToLogsOnError
command: ["hyperkube", "kube-apiserver"]
command: ["/bin/bash", "-ec"]
args:
- --openshift-config=/etc/kubernetes/static-pod-resources/configmaps/config/config.yaml
- |
if [ -f /etc/kubernetes/static-pod-resources/kube-apiserver-certs/configmaps/trusted-ca-bundle/tls-ca-bundle.pem ]; then
echo "Copying system trust bundle"
cp -f /etc/kubernetes/static-pod-resources/kube-apiserver-certs/configmaps/trusted-ca-bundle/tls-ca-bundle.pem /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
fi
exec hyperkube kube-apiserver --openshift-config=/etc/kubernetes/static-pod-resources/configmaps/config/config.yaml
resources:
requests:
memory: 1Gi
Expand Down
7 changes: 7 additions & 0 deletions bindata/v4.1.0/kube-apiserver/trusted-ca-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
namespace: openshift-kube-apiserver
name: trusted-ca-bundle
labels:
config.openshift.io/inject-trusted-cabundle: "true"
3 changes: 3 additions & 0 deletions pkg/operator/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ var RevisionSecrets = []revision.RevisionResource{
var CertConfigMaps = []revision.RevisionResource{
{Name: "aggregator-client-ca"},
{Name: "client-ca"},

// this is a copy of trusted-ca-bundle CM but with key modified to "tls-ca-bundle.pem" so that we can mount it the way we need
{Name: "trusted-ca-bundle", Optional: true},
}

var CertSecrets = []revision.RevisionResource{
Expand Down
29 changes: 29 additions & 0 deletions pkg/operator/targetconfigcontroller/targetconfigcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"k8s.io/klog"

corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -194,6 +196,11 @@ func createTargetConfig(c TargetConfigController, recorder events.Recorder, oper
errors = append(errors, fmt.Errorf("%q: %v", "configmap/kube-apiserver-server-ca", err))
}

err = ensureKubeAPIServerTrustedCA(c.kubeClient.CoreV1(), recorder)
if err != nil {
errors = append(errors, fmt.Errorf("%q: %v", "configmap/trusted-ca-bundle", err))
}

if len(errors) > 0 {
condition := operatorv1.OperatorCondition{
Type: "TargetConfigControllerDegraded",
Expand Down Expand Up @@ -343,6 +350,28 @@ func manageKubeAPIServerCABundle(lister corev1listers.ConfigMapLister, client co
return resourceapply.ApplyConfigMap(client, recorder, requiredConfigMap)
}

func ensureKubeAPIServerTrustedCA(client coreclientv1.CoreV1Interface, recorder events.Recorder) error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do believe these should have comments describing their purpose.

required := resourceread.ReadConfigMapV1OrDie(v410_00_assets.MustAsset("v4.1.0/kube-apiserver/trusted-ca-cm.yaml"))
cmCLient := client.ConfigMaps(operatorclient.TargetNamespace)

cm, err := cmCLient.Get("trusted-ca-bundle", metav1.GetOptions{})
if err != nil {
if apierrors.IsNotFound(err) {
_, err = cmCLient.Create(required)
}
return err
}

// update if modified by the user
if val, ok := cm.Labels["config.openshift.io/inject-trusted-cabundle"]; !ok || val != "true" {
cm.Labels["config.openshift.io/inject-trusted-cabundle"] = "true"
_, err = cmCLient.Update(cm)
return err
}

return err
}

// Run starts the kube-apiserver and blocks until stopCh is closed.
func (c *TargetConfigController) Run(workers int, stopCh <-chan struct{}) {
defer utilruntime.HandleCrash()
Expand Down
36 changes: 34 additions & 2 deletions pkg/operator/v410_00_assets/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.