|
| 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 in the Controller Namespace |
| 23 | + |
| 24 | +Create a ConfigMap containing your CA certificate in the CSI driver namespace |
| 25 | +(typically `kube-system`): |
| 26 | + |
| 27 | +```bash |
| 28 | +kubectl create configmap s3-ca-cert \ |
| 29 | + --from-file=ca-bundle.crt=/path/to/your/ca.crt \ |
| 30 | + -n kube-system |
| 31 | +``` |
| 32 | + |
| 33 | +<!-- markdownlint-disable MD046 --> |
| 34 | +!!! important "Key Name" |
| 35 | + The ConfigMap key **must** be `ca-bundle.crt`. This is the key the driver expects. |
| 36 | + |
| 37 | +!!! info "Why Two Namespaces?" |
| 38 | + The CA certificate ConfigMap must exist in **two** namespaces because the controller and |
| 39 | + mounter pods run in separate namespaces: |
| 40 | + |
| 41 | + 1. **Controller namespace** (e.g., `kube-system`) — mounted by the `s3-csi-controller` for |
| 42 | + AWS SDK S3 API calls (bucket creation/deletion during dynamic provisioning). |
| 43 | + 2. **Mounter pod namespace** (e.g., `mount-s3`) — mounted by mounter pod init containers |
| 44 | + that inject the CA into the `mount-s3` trust store. |
| 45 | + |
| 46 | + The mounter pod namespace (`mount-s3`) is created by the Helm chart, so you cannot create |
| 47 | + the ConfigMap there until after the Helm install (see Step 3). |
| 48 | + |
| 49 | +!!! warning "Namespace Ordering" |
| 50 | + Do **not** attempt to create the ConfigMap in the `mount-s3` namespace before the Helm install — |
| 51 | + the namespace does not exist yet. If a ConfigMap is missing from either namespace, the |
| 52 | + respective pod will be stuck in `ContainerCreating` with a `configmap not found` event. |
| 53 | +<!-- markdownlint-enable MD046 --> |
| 54 | + |
| 55 | +### Step 2: Install or Upgrade the Helm Chart |
| 56 | + |
| 57 | +Set the `tls.caCertConfigMap` value to the name of your ConfigMap: |
| 58 | + |
| 59 | +```bash |
| 60 | +helm upgrade --install scality-s3-csi \ |
| 61 | + ./charts/scality-mountpoint-s3-csi-driver \ |
| 62 | + --namespace kube-system \ |
| 63 | + --set s3.endpointUrl=https://s3.example.com:443 \ |
| 64 | + --set tls.caCertConfigMap=s3-ca-cert |
| 65 | +``` |
| 66 | + |
| 67 | +### Step 3: Create the CA Certificate ConfigMap in the Mounter Namespace |
| 68 | + |
| 69 | +After Helm creates the `mount-s3` namespace, create the same ConfigMap there: |
| 70 | + |
| 71 | +```bash |
| 72 | +kubectl create configmap s3-ca-cert \ |
| 73 | + --from-file=ca-bundle.crt=/path/to/your/ca.crt \ |
| 74 | + -n mount-s3 |
| 75 | +``` |
| 76 | + |
| 77 | +Mounter pods are created on-demand when workloads mount S3 volumes, so this ConfigMap |
| 78 | +just needs to exist before any workload pod starts. |
| 79 | + |
| 80 | +### Step 4: Verify |
| 81 | + |
| 82 | +Check that the controller pod has the CA certificate mounted: |
| 83 | + |
| 84 | +```bash |
| 85 | +kubectl exec -n kube-system deploy/s3-csi-controller \ |
| 86 | + -c s3-csi-controller -- ls /etc/ssl/custom-ca/ |
| 87 | +``` |
| 88 | + |
| 89 | +Expected output: `ca-bundle.crt` |
| 90 | + |
| 91 | +Verify the ConfigMap exists in the mounter pod namespace: |
| 92 | + |
| 93 | +```bash |
| 94 | +kubectl get configmap s3-ca-cert -n mount-s3 |
| 95 | +``` |
| 96 | + |
| 97 | +## How It Works |
| 98 | + |
| 99 | +The TLS configuration operates at two levels: |
| 100 | + |
| 101 | +### Controller Pod (Dynamic Provisioning) |
| 102 | + |
| 103 | +The controller pod uses the CA certificate for S3 API calls (bucket creation/deletion) |
| 104 | +during dynamic provisioning: |
| 105 | + |
| 106 | +- The ConfigMap is mounted at `/etc/ssl/custom-ca/` in the `s3-csi-controller` container |
| 107 | +- The `AWS_CA_BUNDLE` environment variable is set to `/etc/ssl/custom-ca/ca-bundle.crt` |
| 108 | +- AWS SDK Go v2 reads this variable and uses the CA certificate for TLS validation |
| 109 | + |
| 110 | +### Mounter Pods (Volume Mounting) |
| 111 | + |
| 112 | +Mounter pods use `mount-s3` (which uses s2n-tls) to mount S3 buckets. |
| 113 | +s2n-tls reads CA certificates from the system trust store (`/etc/ssl/certs/`), |
| 114 | +so a simple volume mount is not sufficient. Instead: |
| 115 | + |
| 116 | +1. An **initContainer** (`install-ca-cert`) runs before the main `mountpoint` container |
| 117 | +2. The initContainer copies the system CA bundle from the Alpine image to a shared emptyDir volume |
| 118 | +3. It appends the custom CA certificate from the ConfigMap to the combined bundle |
| 119 | +4. The main container mounts the shared volume at `/etc/ssl/certs/` (read-only) |
| 120 | +5. `mount-s3` reads the combined trust store and validates the S3 endpoint certificate |
| 121 | + |
| 122 | +The initContainer runs as non-root and complies with the PodSecurity `restricted` policy |
| 123 | +enforced on the mounter pod namespace. |
| 124 | + |
| 125 | +## Helm Values Reference |
| 126 | + |
| 127 | +| Parameter | Description | Default | |
| 128 | +| --------- | ----------- | ------- | |
| 129 | +| `tls.caCertConfigMap` | Name of the ConfigMap containing the CA certificate | `""` (disabled) | |
| 130 | +| `tls.initImage.repository` | Image repository for the CA cert init container | `alpine` | |
| 131 | +| `tls.initImage.tag` | Image tag for the CA cert init container | `3.21` | |
| 132 | +| `tls.initImage.pullPolicy` | Pull policy for the init image | `IfNotPresent` | |
| 133 | +| `tls.initResources.requests.cpu` | CPU request for the init container | `10m` | |
| 134 | +| `tls.initResources.requests.memory` | Memory request for the init container | `16Mi` | |
| 135 | +| `tls.initResources.limits.memory` | Memory limit for the init container | `64Mi` | |
| 136 | + |
| 137 | +## Why ConfigMap Instead of Secret |
| 138 | + |
| 139 | +CA certificates are public configuration data, not confidential information. |
| 140 | +Using ConfigMaps instead of Secrets: |
| 141 | + |
| 142 | +- Follows the Kubernetes convention of using ConfigMaps for non-sensitive configuration |
| 143 | +- Avoids unnecessary RBAC complexity for managing Secrets |
| 144 | +- Makes the certificates easier to inspect and manage |
| 145 | + |
| 146 | +## Troubleshooting |
| 147 | + |
| 148 | +### Pod Stuck in ContainerCreating |
| 149 | + |
| 150 | +If a controller or mounter pod is stuck in `ContainerCreating` after enabling TLS, the CA |
| 151 | +certificate ConfigMap is likely missing from that pod's namespace. Check the pod events: |
| 152 | + |
| 153 | +```bash |
| 154 | +kubectl describe pod <pod-name> -n <namespace> |
| 155 | +``` |
| 156 | + |
| 157 | +Look for an event like: `configmap "s3-ca-cert" not found`. |
| 158 | + |
| 159 | +To fix, create the ConfigMap in the correct namespace: |
| 160 | + |
| 161 | +```bash |
| 162 | +# For controller pods stuck in ContainerCreating |
| 163 | +kubectl create configmap s3-ca-cert \ |
| 164 | + --from-file=ca-bundle.crt=/path/to/your/ca.crt \ |
| 165 | + -n kube-system |
| 166 | + |
| 167 | +# For mounter pods stuck in ContainerCreating |
| 168 | +kubectl create configmap s3-ca-cert \ |
| 169 | + --from-file=ca-bundle.crt=/path/to/your/ca.crt \ |
| 170 | + -n mount-s3 |
| 171 | +``` |
| 172 | + |
| 173 | +### Certificate Not Found |
| 174 | + |
| 175 | +If mounter pods fail with TLS errors, verify the ConfigMap exists in **both** namespaces: |
| 176 | + |
| 177 | +1. Controller namespace: |
| 178 | + |
| 179 | + ```bash |
| 180 | + kubectl get configmap s3-ca-cert -n kube-system |
| 181 | + ``` |
| 182 | + |
| 183 | +2. Mounter pod namespace: |
| 184 | + |
| 185 | + ```bash |
| 186 | + kubectl get configmap s3-ca-cert -n mount-s3 |
| 187 | + ``` |
| 188 | + |
| 189 | +3. The ConfigMap has the correct key: |
| 190 | + |
| 191 | + ```bash |
| 192 | + kubectl get configmap s3-ca-cert -n mount-s3 -o jsonpath='{.data}' | head -c 100 |
| 193 | + ``` |
| 194 | + |
| 195 | +### Certificate Chain Issues |
| 196 | + |
| 197 | +If you see certificate verification errors despite having the CA cert configured: |
| 198 | + |
| 199 | +- Ensure you are providing the **root CA** certificate, not the server certificate |
| 200 | +- If using an intermediate CA, include the full chain in the `ca-bundle.crt` file |
| 201 | +- Verify the certificate is in PEM format (starts with `-----BEGIN CERTIFICATE-----`) |
| 202 | + |
| 203 | +### Init Container Failures |
| 204 | + |
| 205 | +If the init container fails, check its logs: |
| 206 | + |
| 207 | +```bash |
| 208 | +kubectl logs <mounter-pod-name> -n mount-s3 -c install-ca-cert |
| 209 | +``` |
| 210 | + |
| 211 | +Common issues: |
| 212 | + |
| 213 | +- The init image must include a system CA bundle at `/etc/ssl/certs/ca-certificates.crt` |
| 214 | + (Alpine includes this by default via the `ca-certificates` package) |
| 215 | +- The ConfigMap may not be mounted correctly |
0 commit comments