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

Run storage provisioner as pod #2137

Merged
merged 4 commits into from
Nov 1, 2017

Conversation

priyawadhwa
Copy link

No description provided.

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://github.com/kubernetes/kubernetes/wiki/CLA-FAQ to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 30, 2017
Copy link
Contributor

@r2d4 r2d4 left a comment

Choose a reason for hiding this comment

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

Code looks good so far! One final check needed

Remove the conditional here, since the test is actually being skipped on kubeadm right now.
https://github.com/kubernetes/minikube/blob/master/test/integration/functional_test.go#L39-L42

# See the License for the specific language governing permissions and
# limitations under the License.

FROM ubuntu:16.04
Copy link
Contributor

Choose a reason for hiding this comment

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

A slimmer image would be nice. Maybe scratch?

@@ -206,6 +209,9 @@ func GetKubeadmCachedImages(version string) []string {
"gcr.io/google_containers/kube-scheduler-amd64:" + version,
"gcr.io/google_containers/kube-controller-manager-amd64:" + version,
"gcr.io/google_containers/kube-apiserver-amd64:" + version,

//Storage provisioner
"gcr.io/k8s-minikube/storage-provisioner:" + version,
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 can just leave this as whatever is above. The version here is actually from the --kubernetes-version parameter, so if you use --kubernetes-version v1.8.1 it will try to cache the 1.8.1 tag of the storage provisioner.

We probably won't publish one of these for every version of kubernetes, so make this the hardcoded
"gcr.io/k8s-minikube/storage-provisioner:v1.8.0"

namespace: kube-system
labels:
integration-test: storage-provisioner
addonmanager.kubernetes.io/mode: Reconcile
Copy link
Contributor

@r2d4 r2d4 Oct 30, 2017

Choose a reason for hiding this comment

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

I think you want this to be addonmanager.kubernetes.io/mode: EnsureExists, so we can disable it.

wg.Add(2)
go func() {
defer wg.Done()
storageProvisionerServer.Start()
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 just call this directly, no need to put it in a waitgroup

Copy link
Author

Choose a reason for hiding this comment

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

So I tried that initially, but it didn't work. I looked it up and I think the main program ends before the server has a chance to start?

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 thats due to a few things i mentioned above.
Once you do that, then you can see that its actually just exiting since there are errors

$ ./main --v 10 --logtostderr
F1030 14:08:28.887110  152274 main.go:30] unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined

@r2d4
Copy link
Contributor

r2d4 commented Oct 30, 2017

ref #2134

@r2d4
Copy link
Contributor

r2d4 commented Oct 30, 2017

The other thing we'll need to think about is how we're going to test changes to the storage provisioner addon in minikube CI tests. I don't think this is super important now, but we should start thinking about it.

Currently:
No integration tests on initial code changes to the storage provisioner, tests are ran when version is bumped

Ideally:
Minikube CI builds both minikube and the storage provisioner image, and subsequently uses that image in that CI run.

Challenges:
How to template the addon? We can pass through version information through a CLI flag or buildtime ldflag to minikube, but the addon is in plain YAML, which makes it difficult to template the version.

At a higher level, should addons be:

  1. Pulled from a remote location
  2. Templated within the minikube binary itself.

One thing we've talked about for kube-dns (which also needs templating) is to remove it from go-bin-data and template it in the minikube binary itself.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 30, 2017
Makefile Outdated
@@ -300,6 +300,14 @@ $(ISO_BUILD_IMAGE): deploy/iso/minikube-iso/Dockerfile
@echo ""
@echo "$(@) successfully built"

storage-provisioner-main: cmd/storage-provisioner/main.go
go build cmd/storage-provisioner/main.go
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to storage-provisioner and can you make this output to our build dir? go build ... -o $(BUILD_DIR)/storage-provisioner

Makefile Outdated
@@ -300,6 +300,14 @@ $(ISO_BUILD_IMAGE): deploy/iso/minikube-iso/Dockerfile
@echo ""
@echo "$(@) successfully built"

storage-provisioner-main: cmd/storage-provisioner/main.go
Copy link
Contributor

Choose a reason for hiding this comment

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

This should technically depend on all the storage-provisioner files.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not great, but you'll need do add something that computes the dependencies,

STORAGE_PROVISIONER_FILES := GOPATH=$(GOPATH) go list -f '{{join .Deps "\n"}}' k8s.io/minikube/cmd/storage-provisioner | grep k8s.io | GOPATH=$(GOPATH) xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}'


func main() {
localkubeServer := cmd.NewLocalkubeServer()
storageProvisionerServer := localkubeServer.NewStorageProvisionerServer()
Copy link
Contributor

Choose a reason for hiding this comment

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

main should look something like

	flag.Parse()
	if err := localkube.StartStorageProvisioner(); err != nil {
		glog.Exit(err)
	}

Here, instead of creating a new localkube server, change the signature to be func StartStorageProvisioner() error and call that directly.

func StartStorageProvisioner(lk LocalkubeServer) func() error {

Copy link
Author

Choose a reason for hiding this comment

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

SGTM, but we don't need the flag.Parse() in this case, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

glog (the logging library) adds some flags to set verbosity, which would be nice to have on this binary (you might want to run the container command as storage-provisioner --v 10 --logtostderr)

Unfortunately, some of the localkube dependencies also register their flags, so theres some extra crap that gets added, but thats fine.

wg.Add(2)
go func() {
defer wg.Done()
storageProvisionerServer.Start()
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 thats due to a few things i mentioned above.
Once you do that, then you can see that its actually just exiting since there are errors

$ ./main --v 10 --logtostderr
F1030 14:08:28.887110  152274 main.go:30] unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined

@codecov-io
Copy link

codecov-io commented Oct 30, 2017

Codecov Report

Merging #2137 into master will increase coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2137      +/-   ##
=========================================
+ Coverage   28.59%   28.6%   +0.01%     
=========================================
  Files          82      82              
  Lines        5372    5369       -3     
=========================================
  Hits         1536    1536              
+ Misses       3640    3637       -3     
  Partials      196     196
Impacted Files Coverage Δ
pkg/localkube/storage_provisioner.go 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 38e719a...c342ed4. Read the comment docs.

}

func StartStorageProvisioner(lk LocalkubeServer) func() error {
func StartStorageProvisioner() func() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "unwrap" this, and just return an error instead of a func() error

Copy link
Contributor

@r2d4 r2d4 left a comment

Choose a reason for hiding this comment

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

LGTM, nice!

@r2d4 r2d4 merged commit f368ac4 into kubernetes:master Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants