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

Feature: Configuring rest components for TLS #622

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

Johnaius
Copy link

@Johnaius Johnaius commented Feb 5, 2025

This pull request introduces the configuration of certificates for TLS in REST
before enabling TLS, changes to control plane will have to be pulled in as well. I will link PR here

Description

REST API Component:

  • TLS Configuration:
  1. Added support for enabling TLS by configuring certificate paths and volume mounts.
  2. Removed the --dummy-certificates argument when TLS is enabled.
  3. Introduced new command-line arguments for specifying certificate and key files.
  4. Included configuration to mount the CA certificate for client verification with core agent (commented out for now).

CSI and Diskpool Operator:

Added support for reading CA certificate and configuring TLS for HTTPS endpoints.
Introduced new command-line arguments for specifying the CA certificate file path.

Values.yaml:

Added enable TLS switch. And configured components to only load tls info when enabled.

Certs/Secrets :

Introduced a script to create certificates and a Kubernetes Secret for testing purposes.
Further discussion needed on how certificate deployment will be handled (e.g., using cert-manager or manual setup).

Motivation and Context

These changes enhance the security of the REST API, CSI, and Diskpool Operator components by enabling TLS communication, ensuring secure data transmission

How Has This Been Tested?

I have deployed these changes along with the changes I implemented in the control plane to an AKS cluster. I need some direction on how to appropriately test.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • [x ] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added unit tests to cover my changes.

John Zakrzewski added 4 commits February 5, 2025 14:24
Signed-off-by: John Zakrzewski <Jozakrzewski@microsoft.com>
Signed-off-by: John Zakrzewski <Jozakrzewski@microsoft.com>
Signed-off-by: John Zakrzewski <Jozakrzewski@microsoft.com>
Signed-off-by: John Zakrzewski <Jozakrzewski@microsoft.com>
@Johnaius Johnaius force-pushed the tls branch 2 times, most recently from 9b6796d to e81716c Compare February 5, 2025 20:40
Signed-off-by: John Zakrzewski <Jozakrzewski@microsoft.com>
Signed-off-by: John Zakrzewski <Jozakrzewski@microsoft.com>
Copy link
Contributor

@tiagolobocastro tiagolobocastro left a comment

Choose a reason for hiding this comment

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

I think call-home also needs to have the certificate?
Also, the kubectl plugin?

@@ -0,0 +1,4163 @@
# Source: cert-manager/templates/templates.out
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to apply the CRDs? Are they not installed via cert-manager itself?
Handling CRDs via helm has been painful in the past

Copy link
Author

Choose a reason for hiding this comment

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

Do you remember what the pain points were and why? I'll look into it, cert-manager installs fine without any certificate or issuer etc. resources being created. But when attempting to deploy with certs in the chart I was seeing errors where these resources were attempting to be created before the CRDs were installed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think mostly to do with updates of the CRD. CC @niladrih and @Abhinandan-Purkait

But when attempting to deploy with certs in the chart I was seeing errors where these resources were attempting to be created before the CRDs were installed.

Yeah, makes sense..
What were the resources being created? Is it something we can configure to be done by the pods rather than via helm?

Copy link
Author

@Johnaius Johnaius Feb 11, 2025

Choose a reason for hiding this comment

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

I'm trying to create issuer and certificate resources. We will create a root cert file and seperate files for each cert. I created a new branch here where i'm working on getting cert-manager installed as a subchart as well as certificates. You can see the server-root-cert and rest api cert here

Comment on lines +4 to +5
NAMESPACE="openebs"
APP_NAME="api-rest"
Copy link
Contributor

Choose a reason for hiding this comment

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

This would have to be configurable?

Copy link
Author

Choose a reason for hiding this comment

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

for clarification, I created this cert file for testing purposes only until we get cert-manager installed... The plan is to not rely on this script and to use cert-manager to create all the certs. I am open to discuss and direction on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough, though might be worth keeping for devel

# Create a self-signed root CA
echo "Creating a self-signed root CA"
openssl genrsa -out "${CERT_DIR}/ca.key" 4096
openssl req -x509 -new -nodes -key "${CERT_DIR}/ca.key" -sha256 -days 3650 -out "${CERT_DIR}/ca.crt" -subj "/CN=api-rest-ca" -addext "subjectAltName=DNS:${NAMESPACE}-${APP_NAME}-${NAMESPACE}.svc.cluster.local,DNS:${NAMESPACE}-${APP_NAME},DNS:${NAMESPACE}-${APP_NAME}-${NAMESPACE}.svc"
Copy link
Contributor

Choose a reason for hiding this comment

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

cluster.local needs to be configurable?

scripts/certs.sh Show resolved Hide resolved
echo "Creating a TLS certificate for the API REST"
openssl genrsa -out "${CERT_DIR}/server.key" 4096
openssl req -new -key "${CERT_DIR}/server.key" -out "${CERT_DIR}/server.csr" -subj "/CN=${NAMESPACE}-${APP_NAME}" -addext "subjectAltName=DNS:${NAMESPACE}-${APP_NAME}-${NAMESPACE}.svc.cluster.local,DNS:${NAMESPACE}-${APP_NAME},DNS:${NAMESPACE}-${APP_NAME}-${NAMESPACE}.svc"
openssl x509 -req -in "${CERT_DIR}/server.csr" -CA "${CERT_DIR}/ca.crt" -CAkey "${CERT_DIR}/ca.key" -CAcreateserial -out "${CERT_DIR}/server.crt" -days 3650 -sha256 -extfile <(printf "subjectAltName=DNS:${NAMESPACE}-${APP_NAME}-${NAMESPACE}.svc.cluster.local,DNS:${NAMESPACE}-${APP_NAME},DNS:${NAMESPACE}-${APP_NAME}-${NAMESPACE}.svc")
Copy link
Member

Choose a reason for hiding this comment

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

Should the time period be configurable?

version: v1.17.0
repository: https://charts.jetstack.io
alias: cert-manager
condition: base.cert-manager.enabled
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why we had used base for jaeger, but seems since then we've used the actual name, eg: loki-stack.
So maybe let's use the actual name?

Suggested change
condition: base.cert-manager.enabled
condition: cert-manager.enabled

@@ -0,0 +1,4163 @@
# Source: cert-manager/templates/templates.out
Copy link
Contributor

Choose a reason for hiding this comment

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

I think mostly to do with updates of the CRD. CC @niladrih and @Abhinandan-Purkait

But when attempting to deploy with certs in the chart I was seeing errors where these resources were attempting to be created before the CRDs were installed.

Yeah, makes sense..
What were the resources being created? Is it something we can configure to be done by the pods rather than via helm?

1. Push images from [rest_tls][rest_tls] branch on control plane.
- ```./scripts/release.sh --registry <registry url> --alias-tag <tag> --image rest operators.diskpool csi.controller```
1. Enable TLS in values.yaml [here][enableTls].
1. With cluster in current context, run certs.sh from scripts dir. This will create certs and ultimately a kubernetes secret containing those certs.
Copy link
Contributor

Choose a reason for hiding this comment

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

If someone intends to use CA certificates instead of self signed, can we have a provision to create Secrets with that?

Copy link
Author

Choose a reason for hiding this comment

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

I think we will use self-signed certs as default. If user's want to use their own cert-manager install they will need to make sure that mayastor cert-manager is disabled. We should document how to configure in this case

Signed-off-by: John Zakrzewski <Jozakrzewski@microsoft.com>
@Johnaius Johnaius requested review from a team as code owners February 13, 2025 23:25
@Johnaius
Copy link
Author

I think call-home also needs to have the certificate? Also, the kubectl plugin?

I just added configurations for callhome. Not sure how I can get the certs to the kubectl plugin on first glance, I see this but where are the args being passed in?

@Johnaius
Copy link
Author

Looks like csi-node will need to be configured as well

@tiagolobocastro
Copy link
Contributor

I think call-home also needs to have the certificate? Also, the kubectl plugin?

I just added configurations for callhome. Not sure how I can get the certs to the kubectl plugin on first glance, I see this but where are the args being passed in?

That's using a separate crate as it's going via the apiserver.
We have two crates for this, kube-forward and kube-proxy, here.

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.

4 participants