-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add PersistentVolume support to Habitat type #195
Conversation
Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
When the Spec.Persistence.Field is "true". Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
So that we can use it to mount a PeristentVolume in the Deployment. Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
Adding reviewers for early feedback, feel free to ignore if you're only interesed in the finished product :) |
@asymmetric here's an interesting article that describes how even though PersistentVolumes are certainly available for use in Deployments, they make most sense in StatefulSets. https://blog.thecodeteam.com/2017/08/16/technical-dive-statefulsets-deployments-kubernetes/ Thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned before I think going the way of StatefulSets
would be better IMHO.
One of the problems I see is with this is the ReadWriteOnce
which is the access kind you are using, and that means the volume can be mounted as read-write by only a single node. And because most types support only ReadWriteOnce
access mode, we could only support a few volume plugins.
pkg/controller/controller.go
Outdated
@@ -701,6 +744,26 @@ func (hc *HabitatController) newDeployment(h *habv1beta1.Habitat) (*appsv1beta1. | |||
base.Spec.Template.Spec.Volumes = append(base.Spec.Template.Spec.Volumes, *secretVolume) | |||
} | |||
|
|||
// Mount Persistent Volume, if requesed. | |||
if h.Spec.Persistence.Enabled { | |||
pv := &apiv1.Volume{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you want a Volume
, judging by this PR description and the comment above you want type PersistentVolume
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is a Pod's Volume. In a manifest it would be the volumes
key:
kind: Pod
apiVersion: v1
metadata:
name: mypod
spec:
containers:
- name: myfrontend
image: dockerfile/nginx
volumeMounts:
- mountPath: "/var/www/html"
name: mypd
volumes:
- name: mypd
persistentVolumeClaim:
claimName: myclaim
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I can rename the variable from pv
to v
to make this less confusing.
@lilic Isn't the |
If the flag is enabled. Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
1e3def1
to
a152285
Compare
So that we can make it optional, and remove the `Enabled` sub-key. Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
8c293d2
to
a1d0aba
Compare
@asymmetric In a |
Hmm...can you explain that a bit? Wouldn't that be just trying to reimplement |
@lilic yes, but I was trying to figure out if it's possible to do that without the other changes in semantics (mainly ordered creation/removal). It seems pointless though, guess we have to accept those as a tradeoff. |
@asymmetric According to the docs from 1.7 onwards that works fine https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#pod-management-policies |
Closing in favor of |
This PR adds a
Persistence
key to the Habitat type, which allows users to setup persistent storage.TODO
PersistentVolume
in eachPod
.Size
field, so that the Habitat object creation fails if it's invalid. Right now, the Habitat gets created, while the Deployment fails. Either here or as part of Use Schema for validation instead of ad-hoc code #185.StatefulSet
would require less work?StorageClass
esSpec.Persistence.Enabled
is a good idea. Normally, the field presence is enough to signal intent: the presence ofSpec.Persistence
would mean that the user wants it.HostPath
provides no data replication on multi-node clustersCloses #181.
Ref https://github.com/kinvolk/habitat-operator/pull/195.