Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement addition CA config maps merge and propagation to Che server #531

Merged
merged 6 commits into from
Nov 27, 2020

Conversation

mmorhun
Copy link
Contributor

@mmorhun mmorhun commented Nov 16, 2020

Signed-off-by: Mykola Morhun mmorhun@redhat.com

What does this PR do?

This PR merged all config maps with CA certificates that marked with che-ca-certs:true label into single config and then pass resulting config map to Che server.
spec.server.serverTrustStoreConfigMapName CR field is supported too and the config map, if any, added into resulting one as well.

What issues does this PR fix or reference?

eclipse-che/che#17634

How to test

  1. Deploy Eclipse Che
  2. Create a few config maps in che namespace with CA certs
  3. Mark some of them with app.kubernetes.io/component:ca-bundle and app.kubernetes.io/part-of:che.eclipse.org labels
  4. Start a workspace, check /public-certs folder

To generate CA certs, one may use the following script:

#!/bin/bash

# CA certs generator

OPENSSL_CNF='/etc/pki/tls/openssl.cnf'
if [ ! -f $OPENSSL_CNF ]; then
    OPENSSL_CNF='/etc/ssl/openssl.cnf'
fi

for ((i=1;i<=5;i++)); do
  openssl genrsa -out ${i}.key 4096
  openssl req -batch -new -x509 -nodes -key ${i}.key -sha256 -subj /CN="TestCA${i}" -days 1024 -reqexts SAN -extensions SAN -config <(cat ${OPENSSL_CNF} <(printf '[SAN]\nbasicConstraints=critical, CA:TRUE\nkeyUsage=keyCertSign, cRLSign, digitalSignature')) -outform PEM -out ${i}.crt
done

Then create config maps:

kubectl create configmap ca1 --from-file=1.crt -n che
kubectl create configmap ca23 --from-file=2.crt --from-file=3.crt -n che
kubectl create configmap ca4 --from-file=4.crt -n che
kubectl create configmap ca5 --from-file=5.crt -n che

Finally, add the label:

kubectl label configmap ca1 app.kubernetes.io/part-of=che.eclipse.org -n che && kubectl label configmap ca1 app.kubernetes.io/component=ca-bundle -n che
kubectl label configmap ca23 app.kubernetes.io/part-of=che.eclipse.org -n che && kubectl label configmap ca23 app.kubernetes.io/component=ca-bundle -n che

and/or patch CR:

spec:
  server:
    serverTrustStoreConfigMapName: ca5

It is expected, then certs from ca1, ca23 and ca5 will be propagated into a workspace under /public-certs directory. ca4 should not be propagated.

@mmorhun
Copy link
Contributor Author

mmorhun commented Nov 18, 2020

@l0rd do you have some corrections for label name?

@l0rd
Copy link
Contributor

l0rd commented Nov 19, 2020

@l0rd do you have some corrections for label name?

@mmorhun yes :-)

I think that we have agreed using recommended kubernetes labels with platform team. cc @skabashnyuk. See in docs. In this case I would use the following labels:

app.kubernetes.io/part-of: che.eclipse.org
app.kubernetes.io/component: ca-bundle

@mmorhun
Copy link
Contributor Author

mmorhun commented Nov 20, 2020

@l0rd do you mean that Che admin should add 2 labels to a config map in order to have it recognized by Che as trusted CA source?

@l0rd
Copy link
Contributor

l0rd commented Nov 20, 2020

@mmorhun
Copy link
Contributor Author

mmorhun commented Nov 23, 2020

@l0rd done

Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
…o Che server

Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
…rt-of=che.eclipse.org label

Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
pkg/controller/che/che_controller.go Show resolved Hide resolved
pkg/deploy/tls.go Show resolved Hide resolved
return nil, err
}
mergedCAConfigMapSpec.ObjectMeta.Labels[CheMergedCAConfigMapRevisionsLabelKey] = revisions
mergedCAConfigMapSpec.ObjectMeta.Labels["warning"] = "do-not-edit-manually"
Copy link
Contributor

Choose a reason for hiding this comment

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

app.kubernetes.io/part-of=che.eclipse.org

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to warn users not to edit the config map. But if you think that it is redundant, then I'll delete the label.

pkg/deploy/tls.go Outdated Show resolved Hide resolved
pkg/deploy/tls.go Outdated Show resolved Hide resolved
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
@openshift-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@mmorhun mmorhun merged commit 3d9c611 into master Nov 27, 2020
@mmorhun mmorhun deleted the che-17634 branch November 27, 2020 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants