bhouse-nexthop opened a new pull request, #14906:
URL: https://github.com/apache/cloudstack/pull/14906
### Description
On a zone whose primary storage is Ceph RBD, a CKS cluster that should get
its PersistentVolumes from Ceph needs ceph-csi installed by hand after every
create: the driver's manifests and images, a ConfigMap with the monitors, a
Secret with a Ceph user and key, and a StorageClass. The only storage CKS sets
up is the CloudStack CSI driver (`enablecsi`), which attaches volumes through
the hypervisor.
`createKubernetesCluster` takes four new parameters. When they are given,
CKS deploys the ceph-csi RBD driver into the cluster with a default
StorageClass `ceph-rbd` on the given pool.
| Parameter | Value |
| --- | --- |
| `cephcsimonitors` | Monitor addresses, `host` or `host:port` with the v1
port (6789, the default), comma-separated |
| `cephcsipool` | RBD pool for the cluster's volumes |
| `cephcsiuser` | Ceph user, without `client.` (refused with it), e.g. one
made with `mon 'profile rbd' osd 'profile rbd pool=<pool>' mgr 'profile rbd
pool=<pool>'` |
| `cephcsisecretkey` | That user's key, as printed by `ceph auth get-key` |
All four or none; each is checked against a character set that cannot break
the generated manifests.
How it works:
- **Images and manifests come from the binaries ISO.**
`create-kubernetes-binaries-iso.sh` adds the ceph-csi RBD manifests (namespace
`ceph-csi-rbd`) and their images when `CEPH_CSI_VERSION` is set, e.g.
`CEPH_CSI_VERSION=3.18.2`, so nodes pull nothing from the internet. It is
opt-in because the images add about 370 MB to every node's import. The control
node copies `ceph-csi/` from the ISO to `/opt/ceph-csi`, like the CloudStack
CSI manifests.
- **The cluster's settings are a template**, `cks/conf/ceph-csi-rbd.yml`,
next to the node templates, so an operator can change the StorageClass. After
the cluster is up, CKS fills it in, copies it to the control node and runs
`kubectl apply --server-side` on it and on `/opt/ceph-csi/`. A cluster whose
ISO has no ceph-csi fails with kubectl's `the path "/opt/ceph-csi/" does not
exist`, before anything is applied.
- **The key is never on a command line, in the node's user data or in the
management server log.**
- It is stored in `kubernetes_cluster_details`, encrypted with the
database key and not displayed, until the driver is deployed; then that detail
is removed.
- It is copied over SCP as a file only the login user can read. The file
is opened as kubectl's stdin and unlinked before kubectl runs; if the apply
fails, CKS removes it.
- Server-side apply, so kubectl does not copy the Secret into a
`last-applied-configuration` annotation.
- The parameter name ends in `secretkey`, so the API access log masks it.
`createKubernetesCluster` is now marked `requestHasSensitiveInfo`, so its async
job parameters are stored encrypted (with database encryption on), which also
covers the existing registry password.
- As for the registry password, async-job events on the event bus carry
the request parameters and mask only fields named `password`. Changing that is
a separate change.
- **StorageClass:** default (a new cluster has no other), `reclaimPolicy:
Delete`, volume expansion on, `imageFeatures:
layering,exclusive-lock,object-map,fast-diff`, ext4 with `discard`.
- **Delete:** a cluster with ceph-csi runs the same PVC cleanup as one with
the CloudStack CSI driver, so the provisioner deletes the RBD images of volumes
with reclaim policy Delete. Two changes to that cleanup, which help both
drivers:
- It runs once, before any node is destroyed. It used to run when the loop
reached a control node, and etcd nodes come first in that list, so with
external etcd the API server was already gone.
- The script waits up to 120 s for the deleted PVCs' PVs to go. Before, it
returned right after deleting the PVCs, and the nodes could be destroyed before
the driver deleted the backing volumes.
- A cluster that is stopped when it is deleted can't run the cleanup, as
before.
- **No schema change:** the settings live in `kubernetes_cluster_details`.
Not included: CephFS, the snapshot controller (the provisioner's snapshotter
sidecar is there, but VolumeSnapshots need the CRDs and controller),
csi-addons, UI fields, and a response field. The upstream provisioner
Deployment asks for 3 replicas on separate nodes, so on a cluster with fewer
workers the extra replicas stay Pending until workers are added. Every
Kubernetes version ISO used by such a cluster, for upgrades too, should be
built with `CEPH_CSI_VERSION`.
Fixes: #14905
### Types of changes
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Enhancement (improves an existing feature and functionality)
- [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
- [ ] Build/CI
- [ ] Test (unit or integration test code)
### Feature/Enhancement Scale or Bug Severity
#### Feature/Enhancement Scale
- [ ] Major
- [x] Minor
#### Bug Severity
- [ ] BLOCKER
- [ ] Critical
- [ ] Major
- [ ] Minor
- [ ] Trivial
### Screenshots (if appropriate):
### How Has This Been Tested?
- Unit tests: `mvn test -pl plugins/integrations/kubernetes-service -am`:
141 tests, 0 failures. The new tests cover:
- parameter validation: none given, all given, a missing key, a monitor,
pool or key that would break the manifest, an empty monitor entry, commas only,
a `client.` prefix;
- the template filled with the cluster's values and the decrypted key;
- the copy as a mode 0600 file, the unlink before `kubectl apply
--server-side`, and the key detail removed afterwards;
- a failed apply failing the cluster, removing the file and keeping the
detail.
- ISO builder: ran the ceph-csi part with `CEPH_CSI_VERSION=3.18.2` and
`v3.18.2`. It downloads the five RBD manifests, moves every object to
`ceph-csi-rbd`, and adds the six images (cephcsi and the five sidecars) to the
image list. With the variable unset, nothing is added.
- Not yet tested on a real cluster. I will add a test report from a KVM lab
with Ceph: create a cluster with the parameters, a PVC binds, a pod writes and
a second pod reads the data, the RBD image is in the pool, and deleting the
PVC, then the cluster, removes the images.
#### How did you try to break this feature and the system with this change?
- Values with quotes, spaces, empty monitor entries or a `client.` prefix
are refused before anything is created.
- Without the parameters, nothing changes: no detail is stored and nothing
is applied.
- An ISO without ceph-csi makes `kubectl apply` fail on the missing
`/opt/ceph-csi/` before it contacts the API server (checked with kubectl
against an unreachable server), and the create fails with that reason.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]