Skip to content

Conversation

@tolusha
Copy link
Contributor

@tolusha tolusha commented Aug 4, 2025

What does this PR do?

This PR enables external tools (e.g., cert-manager) to inject TLS configuration into workspace ingresses/routes.
When externalTLSConfig=true:

  1. The operator applies the provided annotations and labels.
  2. For Kubernetes: the operator sets a unique secret name for each ingress (but does not create the secrets; they must be created by the external tool).
  3. For OpenShift: the operator respects certificates injected by the external tool to prevent endless reconciliation loops.

Screenshot/screencast of this PR

N/A

What issues does this PR fix or reference?

eclipse-che/che#22935

How to test this PR?

  1. Deploy the operator:

OpenShift

Create the CatalogSource and deploy Eclipse Che

apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: eclipse-che-22935-4
  namespace: openshift-marketplace
spec:
  image: 'quay.io/eclipse/eclipse-che-olm-catalog:22935_4'
  sourceType: grpc

Deploy cert-manager

helm repo add jetstack https://charts.jetstack.io --force-update
helm install \
  cert-manager jetstack/cert-manager \
  --namespace cert-manager \
  --create-namespace \
  --set crds.enabled=true  
helm install openshift-routes -n cert-manager oci://ghcr.io/cert-manager/charts/openshift-routes

on Minikube

./build/scripts/minikube-tests/test-operator-from-sources.sh
  1. Log into Eclipse Che

  2. Create Issuer/Certificate resources

USER_NAMESPACE=<USER_NAMESPACE>

oc apply -f - <<EOF
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: test-selfsigned
  namespace: ${USER_NAMESPACE}
spec:
  selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: test-selfsigned
  namespace: ${USER_NAMESPACE}
spec:
  isCA: true
  commonName: test-selfsigned-ca
  privateKey:
    algorithm: ECDSA
    size: 256
  issuerRef:
    name: test-selfsigned
    kind: Issuer
    group: cert-manager.io
  secretName: ca.crt
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: test
  namespace: ${USER_NAMESPACE}
spec:
  ca:
    secretName: ca.crt
EOF
  1. Start and stop a workspace

  2. Check that:

  • all ingresses has the same tls secret (for minikube)
  • routes doesn't contain certificates injected (for openshift)
  1. Update CheCluster CR
    For minikube:
spec:
  devEnvironments:
    networking:
      externalTLSConfig:
        annotations:
          cert-manager.io/issuer: test
        enabled: true

For OpenShift:

spec:
  devEnvironments:
    networking:
      externalTLSConfig:
        annotations:
          cert-manager.io/issuer-name: test
        enabled: true
  1. Start the same workspace workspace again

  2. Check that:

  • ingresses has its own tls secrets and all secrets are created (for minikube)
  • routes contain certificates injected (for openshift)
  1. Start a new workspace.

  2. Check that:

  • ingresses has its own tls secrets and all secrets are created (for minikube)
  • routes contain certificates injected (for openshift)

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

@openshift-ci
Copy link

openshift-ci bot commented Aug 4, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

// in order avoid resyncing by devworkspace controller
clusterIngress := &networkingv1.Ingress{}
if err := cl.Get(ctx, client.ObjectKey{Name: ingress.Name, Namespace: ingress.Namespace}, clusterIngress); err == nil {
ingress.Spec.TLS = clusterIngress.Spec.TLS

Choose a reason for hiding this comment

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

Is it possible to append the endpoint name to the secret-name ? It would allow the use of different secret name and allow Cert Manager to inject the certificate in the namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I am not very familiar how cert-manager works in details.
Does it create and set the secret? If there there are several ingress, will the same secret used?
What if secret is set TLS config?

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 see, cert-manager doen't set secret, it uses the on from the TLS config.

Choose a reason for hiding this comment

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

Yes, and the best use case is to have one Secret by FQDN/Ingress

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Yes it is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you provide steps to deploy and configure cert-manager on OpenShift cluster? I would like to test.

Copy link

@batleforc batleforc Aug 13, 2025

Choose a reason for hiding this comment

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

This repo containe the needed step to have Cert manager handle Openshift Routes https://github.com/cert-manager/openshift-routes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@batleforc
Minor changes, tested.
Please have a look.

Choose a reason for hiding this comment

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

Look's good to me !

},
})

assert.Equal(t, 3, len(objs.Ingresses))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, Maybe we can replace assert with require for critical assertions here so that we fail fast.

Suggested change
assert.Equal(t, 3, len(objs.Ingresses))
require.Equal(t, 3, len(objs.Ingresses))

Signed-off-by: Anatolii Bazko <[email protected]>
@openshift-ci openshift-ci bot removed the lgtm label Aug 13, 2025
Signed-off-by: Anatolii Bazko <[email protected]>
Signed-off-by: Anatolii Bazko <[email protected]>
@tolusha
Copy link
Contributor Author

tolusha commented Aug 21, 2025

/retest

Copy link
Contributor

@vinokurig vinokurig left a comment

Choose a reason for hiding this comment

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

Tested according to the PR description.

@openshift-ci
Copy link

openshift-ci bot commented Aug 25, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rohanKanojia, tolusha, vinokurig

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tolusha tolusha merged commit f1d91dc into main Aug 27, 2025
23 checks passed
@tolusha tolusha deleted the 22935 branch August 27, 2025 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants