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

Allow for addons to prompt for data input #1143

Merged
merged 4 commits into from
Feb 27, 2017

Conversation

stevesloka
Copy link
Contributor

@stevesloka stevesloka commented Feb 17, 2017

This allows for an addon to prompt for data. My use case is registry-creds needs additional secrets to enable pulling credentials from a registry. This should vastly simplify this need by prompting the user.

Looking for feedback on the implementation as well as I need to update the registry-creds repo to handle correctly before merging this in.

Here's a screenshot of what it looks like:

screen shot 2017-02-17 at 1 53 12 pm

// cc #901 upmc-enterprises/registry-creds#34 @aaron-prindle

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 17, 2017
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@aaron-prindle
Copy link
Contributor

@minikube-bot ok to test

Copy link
Contributor

@aaron-prindle aaron-prindle left a comment

Choose a reason for hiding this comment

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

Thanks @stevesloka for the PR! I left some comments.

@@ -0,0 +1,76 @@
package config
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 the Apache License to the top of this file? We have a test that this is at the top of every .go file in our repo, that's why the travis test is failing. This is the header: https://github.com/kubernetes/minikube/blob/master/pkg/minikube/cluster/cluster.go#L1

enableGCR := AskForYesNoConfirmation("\nDo you want to enable Google Container Registry?", posResponses, negResponses)
if enableGCR {
fmt.Println("-- Enter applicatoin_default_credentials.json as base64 by running following command:")
gcrApplicationDefaultCredentials := AskForStaticValue(" base64 -w $HOME/.config/gcloud/application_default_credentials.json: ")
Copy link
Contributor

Choose a reason for hiding this comment

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

There needs to be a 0 arg in the base64 command, it is base64 -w 0 $HOME/.config/gcloud/application_default_credentials.json. This was a typo I made in the README


cluster.CreateSecret(
"kube-system",
"gcr-creds",
Copy link
Contributor

@aaron-prindle aaron-prindle Feb 22, 2017

Choose a reason for hiding this comment

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

The name of the secret that registry-creds look for now is gcr-secret.

} else {
// Cleanup existing secrets
cluster.DeleteSecret("kube-system", "awsecr-creds")
cluster.DeleteSecret("kube-system", "gcr-creds")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

awsRegion := AskForStaticValue("-- Enter AWS Region: ")
awsAccount := AskForStaticValue("-- Enter 12 digit AWS Account ID: ")

cluster.CreateSecret(
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that for GCR/ECR to work in registry-creds current state, both secrets will need to be created for the pod to start properly. This was the case in my experience at least. Maybe empty values can be used for secrets specify which mode is enabled? We can also make changes to registry-creds itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm working on some changes to make this easier, will get back to you when I do. I just finished cleaning up the k8s interfaces and implemented the client-go. Will get back soon!

@stevesloka stevesloka force-pushed the registryCredsPrompt branch 2 times, most recently from c79c116 to 3ec41da Compare February 25, 2017 03:45
@stevesloka
Copy link
Contributor Author

stevesloka commented Feb 25, 2017

Hey @aaron-prindle, I did a bunch of rework on the registry-creds addon. We can now run both registries at the same time. Each cloud gets their own secret.

I can't get GCR to work for me, the credentials don't work. But they also don't match the path you have in the readme. Not sure if my setup is wrong, or something else.

Could you give it a shot? I think the only remaining item I need to add to registry-creds is to watch the secrets in kube-system. What I've found is you enable the addon, then create the secrets, but the addon won't have the correct secrets until the pod is restarted. So I want to make that experience a bit better.

Oh, and for GCR creds, I couldn't get the copy / paste to work. So to avoid all the base64 encode on users machines, just prompted for path on disk. So it reads it from there. Let me know what you think about that.

@aaron-prindle
Copy link
Contributor

aaron-prindle commented Feb 27, 2017

GCR is working for me on registry-creds:1.6 if I try to build and run it from: https://github.com/upmc-enterprises/registry-creds. It worked after I copied my ~/.config/gcloud/application_default_credentials.json files into the secret.yaml. I did have to run gcloud auth application-default login to get an updated application_default_credentials.json file though in order to pull my GCR image. I was able to pull my private image with it:

apiVersion: v1
kind: Pod
metadata: 
  name: foo
  namespace: default
spec: 
  containers: 
    - image: gcr.io/aprindle-vm-test/hellonode:latest
      name: foo

I definitely agree the ability to watch for a secret would be a great addition instead of having to create the secret prior.

@aaron-prindle
Copy link
Contributor

aaron-prindle commented Feb 27, 2017

Currently I cannot build the updated version of this addon branch though as there seems to be a build issue with client-go:
https://travis-ci.org/kubernetes/minikube/builds/205196451#L332

@aaron-prindle
Copy link
Contributor

This is working for me. It seems there is a boilerplate license issue though:
I believe that the text needs to match exactly the boilerplate of the other files including the newline format:
https://github.com/kubernetes/minikube/blob/master/hack/boilerplate/boilerplate.go.txt
Probably easiest to just copy it directly from another file and keep the newlines.

@stevesloka
Copy link
Contributor Author

@aaron-prindle yeah somehow the spacing was off, just fixed and pushed up now.

@stevesloka stevesloka changed the title [WIP] Allow for addons to prompt for data input Allow for addons to prompt for data input Feb 27, 2017
@codecov-io
Copy link

Codecov Report

Merging #1143 into master will decrease coverage by -0.84%.
The diff coverage is 0%.

@@            Coverage Diff             @@
##           master    #1143      +/-   ##
==========================================
- Coverage   44.86%   44.02%   -0.84%     
==========================================
  Files          47       47              
  Lines        2113     2151      +38     
==========================================
- Hits          948      947       -1     
- Misses       1010     1049      +39     
  Partials      155      155
Impacted Files Coverage Δ
pkg/minikube/service/service.go 34.52% <0%> (-10.1%)
pkg/minikube/kubeconfig/config.go 55.38% <0%> (-1.54%)

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 6bd1b25...50cb1f2. Read the comment docs.

@aaron-prindle
Copy link
Contributor

LGTM

@aaron-prindle aaron-prindle merged commit 9b539db into kubernetes:master Feb 27, 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants