Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Vck initializer #61

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Vck initializer #61

wants to merge 8 commits into from

Conversation

sudeshsh
Copy link

@sudeshsh sudeshsh commented Jul 5, 2018

Adding code for vck web-hook Issue #15

Copy link
Contributor

@Ajay191191 Ajay191191 left a comment

Choose a reason for hiding this comment

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

I have a few questions and changes I posted below. Apart from them I would suggest changing the directory structure.
Instead of having a different package for the initializer, WDYT about this:

  1. The main.go be part of a package in pkg.
  2. Re-use the helm charts and keep the yaml's there and control it's installation with a flag.
  3. Re-use the docker folder to keep your Dockerfile
  4. Re-use the makefile to generate the dockerfile as well as the go binary.

That way you can also use some of the interfaces like hooks and also have this be part of the circleci build process. WDYT?

"name": "vck-example3",
"id": "vol2",
"containers": ["helloworld-1"],
"mount-path": "/var/datasets"
Copy link
Contributor

Choose a reason for hiding this comment

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

why not have a different mount path for each container? So for example it can be:

"mount": {"helloworld-1": "/var/datasets"}

Copy link
Author

Choose a reason for hiding this comment

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

how about this
"initializer.kubernetes.io/vck": '{
"name": "vck-example",
"id": "vol2",
"containers": [
{
name: "helloworld-1",
mount: "/var/datasets"
}],
}'

spec:
containers:
- name: vck-initializer
image: gcr.io/constant-cubist-173123/vck-initializer:0.0.1
Copy link
Contributor

Choose a reason for hiding this comment

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

We have all of our images in the volumecontroller docker hub for now, do you want to maybe use the same one?

```

```
kubectl delete deployment vck-initializer helloworld helloworld-with-annotation
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should go in the with the examples documentation.

@@ -0,0 +1,25 @@
# Deploy The VCK Initializer

The VCK Initializer is a [Kubernetes Initializer](https://kubernetes.io/docs/admin/extensible-admission-controllers/#what-are-initializers) that injects an [Envoy](https://lyft.github.io/envoy) proxy into Deployments based on containers and volumes defined in a [ConfigMap](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap).
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it still use Envoy?

Copy link
Author

Choose a reason for hiding this comment

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

Nope it doesn't, old comments need to remove


## Deploy the VCK Initializer

Deploy the VCK Initializer with the `-require-annotation` flag set. This will ensure the volume manager data is only injected into Deployments with an `initializer.kubernetes.io/vck` annotation set to a non-empty value as given below.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need that flag? What's the use of the initializer without -require-annotation?

Copy link
Author

Choose a reason for hiding this comment

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

it was 2 step process I merged it, forgot to remove the documentation

if deployment.ObjectMeta.GetInitializers() != nil {
pendingInitializers := deployment.ObjectMeta.GetInitializers().Pending

if initializerName == pendingInitializers[0].Name {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it always the case that the first pending initializer is always going to be this initializer?

Copy link
Author

Choose a reason for hiding this comment

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

yes, I think the controller waits till it reaches first in the queue

if len(pendingInitializers) == 1 {
initializedDeployment.ObjectMeta.Initializers = nil
} else {
initializedDeployment.ObjectMeta.Initializers.Pending = append(pendingInitializers[:0], pendingInitializers[1:]...)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it always the case that the first pending initializer is always going to be this initializer?

Copy link
Author

Choose a reason for hiding this comment

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

we need to wait till other initialisers are processed, correct me if I am wrong, isn't that the purpose of the queue.

return nil
}

func addVolumesAffinity(vckVM *vckv1.VolumeManager, info *data) (*corev1.Volume, *corev1.Affinity, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to maybe rename this to getVolumesAffinity?

Copy link
Author

Choose a reason for hiding this comment

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

won't get just get the information but we are adding the object to the deployment?
not sure still.


}

func addVolumeMount(deployment *v1beta1.Deployment, vckVM *vckv1.VolumeManager, container string, mountPath string) (*corev1.VolumeMount, int, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think vckVM is not used here.

Copy link
Author

Choose a reason for hiding this comment

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

yea I changed the implementation

containerID = id
volumeMount := corev1.VolumeMount{
MountPath: mountPath,
Name: "dataset-claim",
Copy link
Contributor

Choose a reason for hiding this comment

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

You can pass in the volumeVCK and extract name from that instead of explicitly specifying it here.

Copy link
Author

Choose a reason for hiding this comment

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

yes I agree, did that

Copy link
Contributor

@Ajay191191 Ajay191191 left a comment

Choose a reason for hiding this comment

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

A few comments.

docs/user.md Outdated
@@ -169,6 +169,32 @@ $ kubectl create -f resources/deployments/vck-deployment.yaml
deployment "vck-example-deployment" created
```

## Create a Deployment using the VCK initializer
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add this topic at the top too?

Copy link
Author

Choose a reason for hiding this comment

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

I dint get this, do you want me to push this topic to the top?

Copy link
Contributor

Choose a reason for hiding this comment

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

| container.name | yes | Name of the container to append the VCK volume | |
| container.mount-path | no | Path for the VCK to mount the volume | /var/dataset |

The id key is optional it picks the first volume by default, similarly the container object is optional it picks all containers by default and appends it to default mount path "/var/datasets". If the container object just contains the name,vck is appended to default mount path "/var/datasets".
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add an example here which would cover the cases described?

Copy link
Author

Choose a reason for hiding this comment

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

so we have an examples folder where we could add this? I would rather have an example file than paste the yams here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I meant an example like we have for the source types at the bottom: https://github.com/IntelAI/vck/pull/61/files/69b16c782919477bbc63340f56f2e9e51e89b358#diff-2872b51e38bcd053c0e88c4fe5c28fd2L215. Just like snippets of the important parts.

AddFunc: func(obj interface{}) {
o := obj.(*v1beta1.Deployment)
err := initializeDeployment(o, i)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that we delete the deployment if the vck initializer is not specified in the right way?

Copy link
Author

Choose a reason for hiding this comment

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

yes I am deleting the deployment, as I told you if I do not delete the deployment it gets stuck in the limbo state and not allowing user to create a new deployment with same name.

var (
annotation string
initializerName string
requireAnnotation bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this and the defaultRequireAnnotation?. Where is requireAnnotation set?

Copy link
Author

Choose a reason for hiding this comment

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

ohh yea I deleted some necessary code, ill correct that

} else {
initializedDeployment.ObjectMeta.Initializers.Pending = append(pendingInitializers[:0], pendingInitializers[1:]...)
}
if requireAnnotation {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this?

Copy link
Author

Choose a reason for hiding this comment

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

removed it


func getVolumesAffinity(vckVM *vckv1.VolumeManager, info *data) (*corev1.Volume, *corev1.Affinity, error) {
if len(info.ID) == 0 {
item := vckVM.Status.Volumes[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should error check before doing this, i.e. check if the VCK CR has a status and that it is Running and here check if the Volumes[0] exists.

Copy link
Author

Choose a reason for hiding this comment

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

yes I agree, it skipped my mind

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants