-
Notifications
You must be signed in to change notification settings - Fork 382
Conversation
VERY COOL! On the syntax:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job. I would like to see a demo of these and discuss before we merge this PR, but looks like a promising start.
@@ -0,0 +1,104 @@ | |||
package main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume kubectl_plugins
here is just a place to start hacking on this and not a statement that this code should live where it currently is in this PR.
Precedent for this type of code in kubernetes: the scheduler lives in plugin/cmd/kube-scheduler
. How about plugin/cmd/kubectl/<binary-name>
for these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pmorie I have moved the plugins into the dir you have recommended plugin/cmd/kubectl/...
const USAGE = ` | ||
|
||
Usage: | ||
kubectl plugin bind-service SERVICE_CLASS_NAME SECRET_NAME NAMESPACE/INSTANCE_NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
namespace is a function of the entire binding, not just the instance name. It's preferable to use --namespace
for the whole operation.
Also, this operation should not need to take the service class at all.
Suggest the following order for arguments:
bind-service INSTANCE_NAME SECRET_NAME --namespace <namespace>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of right now, we are not able to leverage the global option flag --namespace
. While kubectl will accept the flag, it is not being passed on the plugin. I have made "namespace" into an argument, with the intention to eventually make it into an option flag, I believe kubectl will soon expose this feature (work is being done).
Regarding your comment of binding service not needing a service class, I wasn't able to get it to work without provide the service class name. This is the error I get without one:
Error binding service instance (Binding.servicecatalog.k8s.io "ups-binding" is invalid: Spec.instanceRef.name: Invalid value: "": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'))
UPDATE: Sorry for the confusion, I see what you and @duglin meant now, I have renamed it to INSTANCE_NAME
from SERVICE_CLASS_NAME
INVALID USAGE: | ||
|
||
Usage: | ||
kubectl plugin create-service-broker BROKER_NAME BROKER_URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a follow-up: We should plumb through auth somehow. We should assume basic auth will be one of many options. Basic auth is stored in a secret, so we will need to plumb through the namespace and name of the secret.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do this in a follow up, however, since option flag is not yet available, the syntax might not be as good as we want. We could have 1 single optional argument and everything (namespace/secret..) will have to go into that argument.
const USAGE = ` | ||
|
||
Usage: | ||
kubectl plugin create-service SERVICE_CLASS_NAME PLAN_NAME NAMESPACE/INSTANCE_NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should decide whether we want create-service-instance
, provision-service-instance
, both, or something else.
Same comments about --namespace
apply here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going with create-service-instance
for now.
See my comment above regarding --namespace
Added to 1.0.0 for now because I'm not sure if work is still happening on this or when we expect it to be merged, but I would like ot have this before we call service-catalog 1.0.0 |
what do you mean by "if" ? |
d3ed19a
to
275eee9
Compare
Currently the secret name will default to the binding name during |
@simonleung8 is this still something you are working on? |
@pmorie Yes, it seems like folks are generally ok with the direction this is going, I am going to finish refining the code and the UX. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simonleung8 looks like a good start. I made 1 small comment, and also I don't think that the binary should be checked in.
plugin/cmd/kubectl/utils/utils.go
Outdated
func CheckNamespaceExists(name, proxyURL string) error { | ||
resp, err := http.Get(fmt.Sprintf("%s/api/v1/namespaces/%s", proxyURL, name)) | ||
if err != nil { | ||
fmt.Errorf("Error looking up namespace from core api server (%s)", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs a return
before the fmt.Errorf
6282d90
to
9838341
Compare
@arschles Thanks, cleaned up the code |
6e2eb13
to
ec1f5b6
Compare
proxyURL := "http://127.0.0.1" | ||
proxyPort := "8881" | ||
|
||
kubeProxy := exec.Command("kubectl", "proxy", "-p", proxyPort) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you can use the KUBECTL_PLUGINS_CALLER
env var, which will give you the full path to the kubectl
binary.
plugin/cmd/kubectl/utils/ui.go
Outdated
import "fmt" | ||
|
||
func Green(str string) string { | ||
return fmt.Sprintf("\x1b[32;1m%s\x1b[0m", str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that these aren't supported and will look bad on most Windows terminals. One of the major reasons we didn't add broader support to colors in kubectl
yet. If you absolutely want them, I suggest using a library like this one.
) | ||
|
||
const USAGE = `Usage: | ||
kubectl plugin bind-service INSTANCE_NAME BINDING_NAME NAMESPACE` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The NAMESPACE you want here is not the global --namespace
flag but one specific to this command, correct?
Just mentioning because you can find the value from the global flag in the KUBECTL_PLUGINS_GLOBAL_FLAG_NAMESPACE
and there's also KUBECTL_PLUGINS_CURRENT_NAMESPACE
which will given the "namespace in use" concept (the one coming from the kubeconfig, or overriden by the --namespace
flag, etc).
I know we're still lacking docs for |
@fabianofranz Thanks, good info! |
Full flags support in plugins + API proxy are PR'ed: |
5672f1f
to
6aa63bd
Compare
rebased to bring the 1.7 rebase into scope. |
kubernetes/kubernetes#47267 flags support is merged. So I'd like to submit a few adjustments here to reflect the current status of plugins. Should I do it by adding commits to this PR, or let's move on to get this merged and I open a separate one after that? |
@fabianofranz I have not tested this one yet myself, adding commits is fine by me if you know what we shoudl be doing. |
rebased on the names stuff. still builds and runs nice. |
rebasing on the new api changes. |
d3a0e16
to
7193ec2
Compare
more work was done on the side in simonleung8#1 I have a simple reconciliation and proposal to PR soon. |
Signed-off-by: Doug Davis <[email protected]>
Signed-off-by: Doug Davis <[email protected]>
Out of date, can be closed or still wanted? |
@jberkhahn is still doing stuff, but perhaps its moved to a new PR. Jonathan? |
@jberkhahn can we close this PR now that #1621 is open? |
Okay, I think we can def close this one now that #1664 is merged. |
Plugin commands
create-service-broker
,create-service
,bind-service
To use, compile the commands, and set the env var KUBECTL_PLUGINS_PATH and SERVICE_CATALOG_URL
** if SERVICE_CATALOG_URL is not set, it defaults to minikube IP
192.168.99.100:30080
USAGE:
Currently I do not intent to include unit tests for these plugins, since the kubectl plugin architecture might still be changing. However, integration test make sense and is coming soon.
Current kubectl plugin limitation:
plugin
command