Skip to content

[Istio/Security]: Flex volume driver#3370

Merged
wattli merged 12 commits intoistio:masterfrom
colabsaumoh:fvolume-driver-review
Feb 15, 2018
Merged

[Istio/Security]: Flex volume driver#3370
wattli merged 12 commits intoistio:masterfrom
colabsaumoh:fvolume-driver-review

Conversation

@saumoh
Copy link
Copy Markdown
Contributor

@saumoh saumoh commented Feb 9, 2018

Add the flex volume driver that will be used by node agent in k8s environment to get notifications from kubelet about workloads getting added/deleted.
This version supports:

  • notification both via filesystem or gRPC.
  • configuration knobs to influence the behavior of the driver
  • Unit tests.

@saumoh saumoh self-assigned this Feb 9, 2018
@saumoh saumoh requested review from a team, myidpt and wattli February 9, 2018 19:35
@istio-merge-robot
Copy link
Copy Markdown

@saumoh PR needs rebase

@istio-merge-robot istio-merge-robot added the needs-rebase Indicates a PR needs to be rebased before being merged label Feb 9, 2018
@istio-merge-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
We suggest the following additional approver: sebastienvas

Assign the PR to them by writing /assign @sebastienvas in a comment when ready.

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

Details Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@istio-merge-robot istio-merge-robot removed the needs-rebase Indicates a PR needs to be rebased before being merged label Feb 9, 2018
mountCmd = &cobra.Command{
Use: "mount",
Short: "Flex volume unmount command.",
Long: "Flex volume unmount command.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: s/unmount/mount/

@munnerz
Copy link
Copy Markdown
Member

munnerz commented Feb 10, 2018

Just taking a look at this PR to keep up to speed with changes to Istio-CA/security/how istio works.

Is there a corresponding design doc for the flexvolume? From what I understand, this will eventually mean that the nodeagent (usually used for bare metal/VMs) will run even for Kubernetes workloads, and a flex volume can then be used to provide certificates etc.? Or perhaps I've completely misunderstood 😄

@saumoh
Copy link
Copy Markdown
Contributor Author

saumoh commented Feb 12, 2018

@munnerz
You have it right. The flexvolume give the node agent a method to bootstrap the identity of the workload by being aware of the attributes associated with the workload.
if u have access to the community drive then you can get details here:
https://docs.google.com/document/d/1J67aol2phtZdBwbfuyk36fqLzRHn8c7k_2rAxwGslCk/edit#

return failure("mount", inp, sErr)
}
} else {
if err := addCredentialFile(ninputs); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i think we can combine this else with previous if.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@wattli Thanks for the review. I've pushed a commit to address it.

@@ -0,0 +1,515 @@
// Copyright 2018 Istio Authors
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I noticed this PR puts flexvolume under cmd/, which is reasonable. I will remove the one under node_agent_k8s once this one is submitted.

@wattli wattli mentioned this pull request Feb 12, 2018
if err != nil {
return err
}
fmt.Println(string(resp))
Copy link
Copy Markdown

@myidpt myidpt Feb 13, 2018

Choose a reason for hiding this comment

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

Can you use printAndLog?


// checkValidMountOpts checks if there are sufficient inputs to
// call node agent.
func checkValidMountOpts(opts string) (*pb.WorkloadInfo, bool) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Instead of returning bool, you can just return the error.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This function converts the options string to WorkloadInfo proto message. Can you change the function name to something like produceWorkloadInfo?

err := cmd.Run()
if err != nil {
return err
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actually you can avoid this function. It is equivalent to:
getExecCmd("/bin/umount", dir).Run()

var emsgs []string
// Stop the listener.
// /var/lib/kubelet/pods/20154c76-bf4e-11e7-8a7e-080027631ab3/volumes/nodeagent~uds/test-volume/
// /var/lib/kubelet/pods/2dc75e9a-cbec-11e7-b158-0800270da466/volumes/nodeagent~uds/test-volume
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove these lines?

}

// logToSys is to write to syslog.
func logToSys(caller, inp, opts string) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A general question: can we use golang "log" here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@myidpt. Thanks for the review.
The reason to use fmt.Print is because the interface between the kubelet and flexvolume drivers is standard output stdout. The kubelet expects the flexvolume driver to put json string as output, without it being prefixed by date/time.
Hope that clarifies.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the clarification. That makes sense!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@myidpt Thanks for the review comments. I've incorporated them and pushed the changes.

@wattli wattli merged commit 3c0ae24 into istio:master Feb 15, 2018
"path/filepath"
"strings"

nagent "istio.io/istio/security/cmd/node_agent_k8s/nodeagentmgmt"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems like this should be moved up in a pkg/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants