You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently this policy inspects the creation/update of PersistentVolumeClass objects to prevent the usage of certain storage classes.
The StatefulSet Kubernetes resource has a spec.volumeClaimTemplates attribute which holds a list of PersistentVolumeClaim objects.
The policy should be extended to be able to inspect also StatefulSet resources.
Basically, inside of its validate, the policy should look at what kind of object is the subject of the admission request. If that's a PVC, the current code is going to used, otherwise, if it's a StatefulSet, the new code will be handled.
The configuration of the policy is not going to be changed.
Examples
Given the following configuration
# the list of storage classes that cannot be useddeniedStorageClasses:
- fast
- nvme
The following StatefulSet request is going to be accepted:
apiVersion: apps/v1kind: StatefulSetmetadata:
name: webspec:
selector:
matchLabels:
app: nginx # has to match .spec.template.metadata.labelsserviceName: "nginx"replicas: 3# by default is 1minReadySeconds: 10# by default is 0template:
metadata:
labels:
app: nginx # has to match .spec.selector.matchLabelsspec:
terminationGracePeriodSeconds: 10containers:
- name: nginximage: registry.k8s.io/nginx-slim:0.8ports:
- containerPort: 80name: webvolumeMounts:
- name: wwwmountPath: /usr/share/nginx/htmlvolumeClaimTemplates:
- metadata:
name: wwwspec:
accessModes: [ "ReadWriteOnce" ]storageClassName: "cheap"resources:
requests:
storage: 1Gi
While the following one is going to be rejected:
apiVersion: apps/v1kind: StatefulSetmetadata:
name: webspec:
selector:
matchLabels:
app: nginx # has to match .spec.template.metadata.labelsserviceName: "nginx"replicas: 3# by default is 1minReadySeconds: 10# by default is 0template:
metadata:
labels:
app: nginx # has to match .spec.selector.matchLabelsspec:
terminationGracePeriodSeconds: 10containers:
- name: nginximage: registry.k8s.io/nginx-slim:0.8ports:
- containerPort: 80name: webvolumeMounts:
- name: wwwmountPath: /usr/share/nginx/html
- name: uploadsmountPath: /usr/share/nginx/uploadsvolumeClaimTemplates:
- metadata:
name: wwwspec:
accessModes: [ "ReadWriteOnce" ]storageClassName: "cheap"resources:
requests:
storage: 1Gi
- uploads:
name: uploadsspec:
accessModes: [ "ReadWriteOnce" ]storageClassName: "fast"resources:
requests:
storage: 1Gi
Mutation
Given the following configuration:
# the list of storage classes that cannot be useddeniedStorageClasses:
- fast
- nvme# optional - the storage class to be used when a denied is requestedfallbackStorageClass: cheap
The following StatefulSet definition:
apiVersion: apps/v1kind: StatefulSetmetadata:
name: webspec:
selector:
matchLabels:
app: nginx # has to match .spec.template.metadata.labelsserviceName: "nginx"replicas: 3# by default is 1minReadySeconds: 10# by default is 0template:
metadata:
labels:
app: nginx # has to match .spec.selector.matchLabelsspec:
terminationGracePeriodSeconds: 10containers:
- name: nginximage: registry.k8s.io/nginx-slim:0.8ports:
- containerPort: 80name: webvolumeMounts:
- name: wwwmountPath: /usr/share/nginx/html
- name: uploadsmountPath: /usr/share/nginx/uploadsvolumeClaimTemplates:
- metadata:
name: wwwspec:
accessModes: [ "ReadWriteOnce" ]storageClassName: "cheap"resources:
requests:
storage: 1Gi
- uploads:
name: uploadsspec:
accessModes: [ "ReadWriteOnce" ]storageClassName: "fast"resources:
requests:
storage: 1Gi
Is going to be accepted, but it will be mutated to create this object:
apiVersion: apps/v1kind: StatefulSetmetadata:
name: webspec:
selector:
matchLabels:
app: nginx # has to match .spec.template.metadata.labelsserviceName: "nginx"replicas: 3# by default is 1minReadySeconds: 10# by default is 0template:
metadata:
labels:
app: nginx # has to match .spec.selector.matchLabelsspec:
terminationGracePeriodSeconds: 10containers:
- name: nginximage: registry.k8s.io/nginx-slim:0.8ports:
- containerPort: 80name: webvolumeMounts:
- name: wwwmountPath: /usr/share/nginx/html
- name: uploadsmountPath: /usr/share/nginx/uploadsvolumeClaimTemplates:
- metadata:
name: wwwspec:
accessModes: [ "ReadWriteOnce" ]storageClassName: "cheap"resources:
requests:
storage: 1Gi
- uploads:
name: uploadsspec:
accessModes: [ "ReadWriteOnce" ]storageClassName: "cheap"resources:
requests:
storage: 1Gi
The text was updated successfully, but these errors were encountered:
Currently this policy inspects the creation/update of
PersistentVolumeClass
objects to prevent the usage of certain storage classes.The
StatefulSet
Kubernetes resource has aspec.volumeClaimTemplates
attribute which holds a list ofPersistentVolumeClaim
objects.The policy should be extended to be able to inspect also
StatefulSet
resources.Basically, inside of its validate, the policy should look at what kind of object is the subject of the admission request. If that's a PVC, the current code is going to used, otherwise, if it's a StatefulSet, the new code will be handled.
The configuration of the policy is not going to be changed.
Examples
Given the following configuration
The following
StatefulSet
request is going to be accepted:While the following one is going to be rejected:
Mutation
Given the following configuration:
The following StatefulSet definition:
Is going to be accepted, but it will be mutated to create this object:
The text was updated successfully, but these errors were encountered: