|
| 1 | +# TLS Configuration |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +When your S3 endpoint uses TLS with certificates signed by a private or internal CA, |
| 6 | +the CSI driver needs access to the CA certificate to validate the connection. |
| 7 | +The Scality CSI Driver supports injecting custom CA certificates via Kubernetes ConfigMaps. |
| 8 | + |
| 9 | +This is required when: |
| 10 | + |
| 11 | +- Your RING S3 endpoint uses HTTPS with a self-signed or internally-signed certificate |
| 12 | +- Your organization uses a private CA for internal services |
| 13 | +- The S3 endpoint's certificate chain is not in the default system trust store |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | + |
| 17 | +- A PEM-encoded CA certificate file (the root or intermediate CA that signed your S3 server certificate) |
| 18 | +- The CSI driver Helm chart installed or ready to install |
| 19 | + |
| 20 | +## Configuration |
| 21 | + |
| 22 | +### Step 1: Create the CA Certificate ConfigMap |
| 23 | + |
| 24 | +Create a ConfigMap containing your CA certificate in **both** the CSI driver namespace |
| 25 | +(typically `kube-system`) and the mounter pod namespace (typically `mount-s3`): |
| 26 | + |
| 27 | +```bash |
| 28 | +# Create in the CSI driver namespace (controller uses this) |
| 29 | +kubectl create configmap s3-ca-cert \ |
| 30 | + --from-file=ca-bundle.crt=/path/to/your/ca.crt \ |
| 31 | + -n kube-system |
| 32 | + |
| 33 | +# Create in the mounter pod namespace (mounter pods use this) |
| 34 | +kubectl create configmap s3-ca-cert \ |
| 35 | + --from-file=ca-bundle.crt=/path/to/your/ca.crt \ |
| 36 | + -n mount-s3 |
| 37 | +``` |
| 38 | + |
| 39 | +<!-- markdownlint-disable MD046 --> |
| 40 | +!!! important "Key Name" |
| 41 | + The ConfigMap key **must** be `ca-bundle.crt`. This is the key the driver expects. |
| 42 | +<!-- markdownlint-enable MD046 --> |
| 43 | + |
| 44 | +### Step 2: Install or Upgrade the Helm Chart |
| 45 | + |
| 46 | +Set the `tls.caCertConfigMap` value to the name of your ConfigMap: |
| 47 | + |
| 48 | +```bash |
| 49 | +helm upgrade --install scality-s3-csi \ |
| 50 | + ./charts/scality-mountpoint-s3-csi-driver \ |
| 51 | + --namespace kube-system \ |
| 52 | + --set s3.endpointUrl=https://s3.example.com:443 \ |
| 53 | + --set tls.caCertConfigMap=s3-ca-cert |
| 54 | +``` |
| 55 | + |
| 56 | +### Step 3: Verify |
| 57 | + |
| 58 | +Check that the controller pod has the CA certificate mounted: |
| 59 | + |
| 60 | +```bash |
| 61 | +kubectl exec -n kube-system deploy/s3-csi-controller \ |
| 62 | + -c s3-csi-controller -- ls /etc/ssl/custom-ca/ |
| 63 | +``` |
| 64 | + |
| 65 | +Expected output: `ca-bundle.crt` |
| 66 | + |
| 67 | +## How It Works |
| 68 | + |
| 69 | +The TLS configuration operates at two levels: |
| 70 | + |
| 71 | +### Controller Pod (Dynamic Provisioning) |
| 72 | + |
| 73 | +The controller pod uses the CA certificate for S3 API calls (bucket creation/deletion) |
| 74 | +during dynamic provisioning: |
| 75 | + |
| 76 | +- The ConfigMap is mounted at `/etc/ssl/custom-ca/` in the `s3-csi-controller` container |
| 77 | +- The `AWS_CA_BUNDLE` environment variable is set to `/etc/ssl/custom-ca/ca-bundle.crt` |
| 78 | +- AWS SDK Go v2 reads this variable and uses the CA certificate for TLS validation |
| 79 | + |
| 80 | +### Mounter Pods (Volume Mounting) |
| 81 | + |
| 82 | +Mounter pods use `mount-s3` (which uses s2n-tls) to mount S3 buckets. |
| 83 | +s2n-tls reads CA certificates from the system trust store (`/etc/ssl/certs/`), |
| 84 | +so a simple volume mount is not sufficient. Instead: |
| 85 | + |
| 86 | +1. An **initContainer** (`install-ca-cert`) runs before the main `mountpoint` container |
| 87 | +2. The initContainer copies the system CA bundle from the Alpine image to a shared emptyDir volume |
| 88 | +3. It appends the custom CA certificate from the ConfigMap to the combined bundle |
| 89 | +4. The main container mounts the shared volume at `/etc/ssl/certs/` (read-only) |
| 90 | +5. `mount-s3` reads the combined trust store and validates the S3 endpoint certificate |
| 91 | + |
| 92 | +The initContainer runs as non-root and complies with the PodSecurity `restricted` policy |
| 93 | +enforced on the mounter pod namespace. |
| 94 | + |
| 95 | +## Helm Values Reference |
| 96 | + |
| 97 | +| Parameter | Description | Default | |
| 98 | +| --------- | ----------- | ------- | |
| 99 | +| `tls.caCertConfigMap` | Name of the ConfigMap containing the CA certificate | `""` (disabled) | |
| 100 | +| `tls.initImage.repository` | Image repository for the CA cert init container | `alpine` | |
| 101 | +| `tls.initImage.tag` | Image tag for the CA cert init container | `3.21` | |
| 102 | +| `tls.initImage.pullPolicy` | Pull policy for the init image | `IfNotPresent` | |
| 103 | +| `tls.initResources.requests.cpu` | CPU request for the init container | `10m` | |
| 104 | +| `tls.initResources.requests.memory` | Memory request for the init container | `16Mi` | |
| 105 | +| `tls.initResources.limits.memory` | Memory limit for the init container | `64Mi` | |
| 106 | + |
| 107 | +## Why ConfigMap Instead of Secret |
| 108 | + |
| 109 | +CA certificates are public configuration data, not confidential information. |
| 110 | +Using ConfigMaps instead of Secrets: |
| 111 | + |
| 112 | +- Follows the Kubernetes convention of using ConfigMaps for non-sensitive configuration |
| 113 | +- Avoids unnecessary RBAC complexity for managing Secrets |
| 114 | +- Makes the certificates easier to inspect and manage |
| 115 | + |
| 116 | +## Troubleshooting |
| 117 | + |
| 118 | +### Certificate Not Found |
| 119 | + |
| 120 | +If mounter pods fail with TLS errors, verify: |
| 121 | + |
| 122 | +1. The ConfigMap exists in the mounter pod namespace: |
| 123 | + |
| 124 | + ```bash |
| 125 | + kubectl get configmap s3-ca-cert -n mount-s3 |
| 126 | + ``` |
| 127 | + |
| 128 | +2. The ConfigMap has the correct key: |
| 129 | + |
| 130 | + ```bash |
| 131 | + kubectl get configmap s3-ca-cert -n mount-s3 -o jsonpath='{.data}' | head -c 100 |
| 132 | + ``` |
| 133 | + |
| 134 | +### Certificate Chain Issues |
| 135 | + |
| 136 | +If you see certificate verification errors despite having the CA cert configured: |
| 137 | + |
| 138 | +- Ensure you are providing the **root CA** certificate, not the server certificate |
| 139 | +- If using an intermediate CA, include the full chain in the `ca-bundle.crt` file |
| 140 | +- Verify the certificate is in PEM format (starts with `-----BEGIN CERTIFICATE-----`) |
| 141 | + |
| 142 | +### Init Container Failures |
| 143 | + |
| 144 | +If the init container fails, check its logs: |
| 145 | + |
| 146 | +```bash |
| 147 | +kubectl logs <mounter-pod-name> -n mount-s3 -c install-ca-cert |
| 148 | +``` |
| 149 | + |
| 150 | +Common issues: |
| 151 | + |
| 152 | +- The init image must include a system CA bundle at `/etc/ssl/certs/ca-certificates.crt` |
| 153 | + (Alpine includes this by default via the `ca-certificates` package) |
| 154 | +- The ConfigMap may not be mounted correctly |
0 commit comments