Open gkaskonas opened 1 year ago
@gkaskonas A StatefulSet
, like any workload resource, has access to its containers via sts.containers
, and then the container has support for PVC via container.mount
.
import * as kplus from 'cdk8s-plus-29';
import * as cdk8s from 'cdk8s';
const sts = new kplus.StatefulSet(chart, 'StatefulSet', { ... });
const container = sts.addContainer({ image: 'node' });
// create the storage request
const claim = new kplus.PersistentVolumeClaim(chart, 'Claim', {
storage: cdk8s.Size.gibibytes(50),
});
// mount a volume based on the request to the container
// this will also add the volume itself to the pod spec.
container.mount('/data', kplus.Volume.fromPersistentVolumeClaim(claim));
Is that not sufficient? Or are you looking for more direct support via its properties?
@iliapolo That's not how StatefulSet
s are supposed to work. With STS you get a PVC per pod, so you'd give it a PVC template to manage and it will automatically assign and track storage identities for the pods. You can still assign volumes to pods, but it'll be a shared volume between all of the pods.
What @rassie said. I want the template to be exposed. This means that your Statefulset construct is not in sync with Statefulset API
@rassie @gkaskonas thanks, I see now that we are indeed missing this feature.
Description of the feature or enhancement:
STS supports PVC templates and cdk8s should do
Use Case:
To deploy multiple pods with storage
Proposed Solution:
Update StatefulSetProps to allow PVC template
Other:
This is a :rocket: Feature Request