Skip to content
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 mounts to nodes #302

Closed
wants to merge 5 commits into from

Conversation

BenTheElder
Copy link
Member

fixes #62

TODO: actually add the mounts 😉

I restarted this after #299.

/cc @neolit123

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Feb 14, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BenTheElder

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 14, 2019
@@ -54,6 +56,9 @@ type Node struct {
// KubeadmConfigPatchesJSON6902 are applied to the generated kubeadm config
// as patchesJson6902 to `kustomize build`
KubeadmConfigPatchesJSON6902 []kustomize.PatchJSON6902
// Mounts describes additional mount points for the node container
// These may be used to EG bind a hostpath
Mounts []cri.Mount `json:"mounts,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK there is a API "rule" somewhere in k8s (i don't know where it is), which says that you cannot embed an API in another API and graduate the second API to beta if the embedded API stays at alpha.
that's one of the reasons we had the component configs in kubeadm (e.g. KubeProxyConfiguration) as separate structures in the YAML before we moved to v1beta1.

this forces a structure in the lines of:

kind: Config
version: kind.sigs.k8s.io/v1beta1 # eventually
---
kind: HostMountConfig
version: kind.sigs.k8s.io/v1alphaX # has to stay alpha

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I'm debating if we should have just copied the types instead since we need our own shim to docker as well. looking around for that doc. 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically having an alpha level field seems to be preferred now, though is expected to be feature gated.

Also: we're not actually embedding an kubernetes API per-se, Mount has no type meta, it is only a substructure that is also in another GRPC API used internally.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically having an alpha level field seems to be preferred now, though is expected to be feature gated.

yes, although we were still blocked graduating to beta if we were embedding kubeproxy - i cannot find an exact "clause for that" in the above docs.
possibly this is the corner case where kubeproxy was not gated because it's an essential addon.
others from the SIG have more context here.

but i think this should be a pointer to a slice if omitifempty is used on the field.
marshaling omitempty has weird side effects:
kubernetes/kubeadm#1358 (comment)

Also: we're not actually embedding an kubernetes API per-se, Mount has no type meta, it is only a substructure that is also in another GRPC API used internally.

indeed, it does not have metadata but the structure is tagged as alpha and is a subject to change. so it might be a requirement for kind to gate the field. if we want to follow the rules that is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type is actually:

type Mount struct {
    ContainerPath    string    `protobuf:"bytes,1,opt,name=container_path,json=containerPath,proto3" json:"container_path,omitempty"`
    HostPath    string    `protobuf:"bytes,2,opt,name=host_path,json=hostPath,proto3" json:"host_path,omitempty"`
    Readonly    bool    `protobuf:"varint,3,opt,name=readonly,proto3" json:"readonly,omitempty"`
    SelinuxRelabel    bool    `protobuf:"varint,4,opt,name=selinux_relabel,json=selinuxRelabel,proto3" json:"selinux_relabel,omitempty"`
    Propagation    MountPropagation    `protobuf:"varint,5,opt,name=propagation,proto3,enum=runtime.v1alpha2.MountPropagation" json:"propagation,omitempty"`
}

But I'm switching to using this type within the Node:

// Mount describes a container mount
type Mount struct {
	cri.Mount `json:",inline"`
}

That way we can always 100% inline the fields and break with CRI if we have to (besides the fact that we should upgrade CRI carefully).

Realistically it sounds like CRI is more or less beta. There haven't been any breaking changes from our POV at all since it was bumped to v1alpha2 a year ago (and not many changes in general)
https://github.com/kubernetes/kubernetes/commits/master/pkg/kubelet/apis/cri/runtime/v1alpha2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, it does not have metadata but the structure is tagged as alpha and is a subject to change. so it might be a requirement for kind to gate the field. if we want to follow the rules that is.

We should follow the rules. It's not clear to me that they apply to a vendored type w/o typemeta etc.
If it does apply then we might need to featuregate. The field is optional so we have that part.

From a marshalling POV we can avoid breakage by wrapping the type like I mentioned above. This won't work in memory though. 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I'm switching to using this type within the Node:

well but this doesn't really makes the alpha type opague.

it should be:

type Mount struct {
	mount cri.Mount
	...
	// add private state vars if needed.
}

and use composition with public getters and setters

but i think we should consult API machinery here too.
¯\_(ツ)_/¯

@BenTheElder
Copy link
Member Author

Also FWIW I sent out some feelers about moving CRI to a staging library, it seems like this would be acceptable, it just isn't a priority right now. If we start using it more than just this one type, then perhaps we can pitch in to move it to staging :-)

@BenTheElder
Copy link
Member Author

/hold
I think I have a better idea forming to deal with CRI being alpha... standby...

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 15, 2019
@BenTheElder
Copy link
Member Author

#313 implements an alternate route.

@BenTheElder