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

docs: add design for adding new arguments for TLS #173

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bipuladh
Copy link

Describe what this PR does

This PR adds a design doc, proposing the introduction of Services in front of pods that have addons sidecar container running in them.

Is there anything that requires special attention

Do you have any questions?

Is the change backward compatible?
Yes

Are there concerns around backward compatibility?
No

Provide any external context for the change, if any.

The addition of Service is required to allow secure communication between the add-ons manager and the sidecar. Related PR on the addons repo: csi-addons/kubernetes-csi-addons#692

Related issues

csi-addons/kubernetes-csi-addons#692
#172

Checklist:

  • Commit Message Formatting: Commit titles and messages follow
    guidelines in the developer
    guide
    .
  • Reviewed the developer guide on Submitting a Pull
    Request
  • Pending release
    notes

    updated with breaking and/or notable changes for the next major release.
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.

Copy link
Collaborator

@Madhu-1 Madhu-1 left a comment

Choose a reason for hiding this comment

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

Creating a unique service per pod in Kubernetes when using a Deployment/Damoneset (which typically manages multiple replicas) is not a common pattern. However, it is possible to do so and it will be very tricky, lets see if we can get to the state.


To address the above challenges, this proposal suggests creating a dedicated Kubernetes Service for each add-ons sidecar Pod. This Service will:

- Provide a consistent DNS name, eliminating the dependency on IP addresses.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this works when both deployment and daemonset runs on the host networking? You need to use service with nodePort and the accessibility will be with hostIP+port.

- Enable TLS certificates to be issued with a stable DNS name.
- Allow secure connectivity between the manager and the sidecar by abstracting away the networking specifics, especially when host networking is enabled.

The Service could be of type `ClusterIP`, as the primary objective is intra-cluster communication between the manager and sidecar.
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we are trying to stick to a single IP for accessing the pod, using clusterIP can be a problem for edge case where the service is deleted and recreated.


- The sidecar Pod will have an annotation, e.g., `csi.addons.service/name`, that stores the corresponding Service name.
- The CSI Addons Manager will parse this annotation and resolve the Service DNS name.
- The TLS certificate will then be generated using this DNS name, enabling secure and verifiable communication.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Who is going to generate it? Is it user or the csi operator?


## Implementation Details

1. **Service Creation**: Modify the ceph-csi-operator configuration to create a Service for each sidecar Pod, with the appropriate pod-selectors.
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the service need to be created before hand , this could be very tricky especially for Daemonset with taints and toleration. where the user can just go and a taint to a node to schedule a new csi plugin pod on the node.

Comment on lines 80 to 94
#### Pod annotations

```yaml
apiVersion: v1
kind: Pod
metadata:
name: addon-sidecar
namespace: <namespace>
annotations:
csi.addons.service/name: addon-sidecar-service
spec:
containers:
- name: addon-sidecar
image: <sidecar-image>
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add an example how this looks with deployment and daemonset.

@bipuladh
Copy link
Author

bipuladh commented Nov 19, 2024

Creating a unique service per pod in Kubernetes when using a Deployment/Damoneset (which typically manages multiple replicas) is not a common pattern. However, it is possible to do so and it will be very tricky, lets see if we can get to the state.

Do we need a unique service per pod or could the pod selector route work as well?

@bipuladh
Copy link
Author

@Madhu-1 if these replicas of these Deployments need to be identified uniquely and connected could we perhaps use StatefulSets?

@Madhu-1
Copy link
Collaborator

Madhu-1 commented Nov 19, 2024

@Madhu-1 if these replicas of these Deployments need to be identified uniquely and connected could we perhaps use StatefulSets?

As per kubernetes-csi community we are using deployment, we cannot switch to statefulset

@Madhu-1
Copy link
Collaborator

Madhu-1 commented Nov 19, 2024

Creating a unique service per pod in Kubernetes when using a Deployment/Damoneset (which typically manages multiple replicas) is not a common pattern. However, it is possible to do so and it will be very tricky, lets see if we can get to the state.

Do we need a unique service per pod or could the pod selector route work as well?

Anything works We need a way to connect to the sidecar container.

@nb-ohad
Copy link
Collaborator

nb-ohad commented Nov 21, 2024

@Madhu-1 @bipuladh
We need to be very careful in deciding what additional responsibilities Ceph CSI Operator is taking upon itself. Not everything can or needs to be done at this layer, especially if the changes are tied to ODF-only features or to OCP-only features.

This design needs to be discussed and drilled down in one of our upcoming ceph csi operator meeting before we commit to it

@Madhu-1
Copy link
Collaborator

Madhu-1 commented Nov 21, 2024

@Madhu-1 @bipuladh We need to be very careful in deciding what additional responsibilities Ceph CSI Operator is taking upon itself. Not everything can or needs to be done at this layer, especially if the changes are tied to ODF-only features or to OCP-only features.

This design needs to be discussed and drilled down in one of our upcoming ceph csi operator meeting before we commit to it

@nb-ohad nothing is committed, the above was just a review, @bipuladh is planning to have a meeting to talk more about it.

@bipuladh bipuladh changed the title docs: add design for using services for addons pods docs: add design for adding new arguments for TLS Dec 4, 2024
@bipuladh bipuladh requested a review from Madhu-1 December 4, 2024 07:36

### Operator changes

The Ceph CSI Operator is only responsible for taking in the information mounted to it and project those as volumes in the CSI Addons sidecar. The deployer of CSI Addons should create these certificates and mount it at `/etc/tls/tls.crt` and `/etc/tls/tls.key`. We keep this hardcoded to reduce the number of new arguments introduced. The logger should provide enough information if the user is not mounting this correctly for easy debugging.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@bipuladh I am not sure I understand

The deployer of CSI Addons should create these certificates

Can you please elaborate or rephrase?

Copy link
Author

Choose a reason for hiding this comment

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

This is not possible. I have updated the doc to reflect that client operator would pass the certificate using a secret. The locator for the secret will be added in a new field that I propose in the latest commit.

# Add support for TLS certificates for CSI Addons communication

The Kubernetes CSI Addons project currently connects the CSI Addons Manager to the add-on sidecar without TLS in place.
We propose a introduction of an arugment which enabled should mount the TLS certificates into the sidecar container.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please provide a code snippet that describes the desired outcome of this new field within the API you would like to augment.

The code snippet should be descriptive enough so the following will be clear:

  1. The name of the new field
  2. The type of the new field
  3. The API is being introduced into
  4. The location (path) in the API where the new field will be added
  5. An explanation of what the field is describing
  6. And validation rules needed on the field (can be provided as standalone text or as a comment within the snippet)

Comment on lines +30 to +31
certificateSecretname string
cretificateSecretNamespace string
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is just a Namespaced Name. But I would prefer to use a LocalObjectReference instead

type TLSConfiguration struct {
certificateSecretname string
cretificateSecretNamespace string
enableTLS bool
Copy link
Collaborator

@nb-ohad nb-ohad Dec 5, 2024

Choose a reason for hiding this comment

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

Why do we need an enable flag? The existance of the section is a good enough indication that we should use TLD

// Allow overwrite of hardcoded defaults for any driver managed by this operator
//+kubebuilder:validation:Optional
DriverSpecDefaults *DriverSpec `json:"driverSpecDefaults,omitempty"`
TLSConfiguration *TLSConfiguration // Conigure TLS certificates for CSI addons
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this needs to have a Driver scope, not an operator scope. The decision to use or not use TLS should be determined on a driver basis

@bipuladh
Copy link
Author

bipuladh commented Dec 5, 2024

/hold

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.

3 participants