-
Notifications
You must be signed in to change notification settings - Fork 23
[kn-admin]Added utils to update configmap #40
Conversation
zhanggbj
commented
Jun 4, 2020
- Added utils to update configmp, as this is very common for kn-admin operations
- Chores to refine vars or logs
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.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)
@rhuss @maximilien
|
Yep, I will give a look later today (have some meetings soon) |
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.
Missing unit tests and integration tests. Thanks.
@@ -120,15 +120,15 @@ Use "kn admin autoscaling [command] --help" for more information about a comman | |||
==== | |||
---- | |||
$ kn admin domain set --custom-domain mydomain.com | |||
Updated Knative route domain mydomain.com | |||
Set Knative route domain mydomain.com |
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.
Change to “... route to domain ...”
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.
Same question as below.
---- | ||
==== | ||
|
||
.Update a custom domain with --selector and Service with a label app=v1 will use test.com | ||
==== | ||
---- | ||
$ kn admin domain set --custom-domain test.com --selector app=v1 | ||
Updated Knative route domain test.com | ||
Set Knative route domain test.com with selector [app=v1] |
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.
Same as above add “to”
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.
@maximilien
As Knative supports multiple domains, I'm wondering if set route domain to
is more like Knative only support one domain?
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.
IMO if use "set" it implies setting the single value. Otherwise, I would expect an "Add route".
How would one manage multiple routes here ? If this is only about a 'default' route maybe "Set default Knative route domain ..." is better choice.
Also, I wonder whether the "Knative" is not redundant and maybe we should talk about a "service" instead of a "route" here, as route is an internal concept mostly hidden in kn. We are always talking about a service's or revsion's 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.
@rhuss
In fact, I think in this context it is more about domain
other than route
.
Knative support to have multiple domains as below, in kn-admin we want to help with add and remove domains. I'm thinking maybe kn admin domain add
is more proper here and perhaps also change route domain
to domain
as it may be a little bit confusing with the Knative Route resource.
@rhuss @maximilien what do you think? Thanks!
data:
# example.org will be used for routes having app=prod.
example.org: |
selector:
app: prod
# Default value for domain, for routes that does not have app=prod labels.
# Although it will match all routes, it is the least-specific rule so it
# will only be used if no other domain matches.
example.com: ""
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.
Yeah, the "route" confused me a bit. Maybe just referring to the domain without any revision/service prefix makes more sense.
For this example, "Add" makes more sense as it also emphasises that you add a domain with the selector.
For general wording of the command itself (set/unset), it's a bit tricky.
As you can have multiple things that can be identified, having "create/delete" is typically a better wording for commands than "set/unset" as this more implies a single entity to manage. This is how we do it for the Knative entities like service or sources.
However, as you also can override with "set" then "add" would be misleading. Not sure if an "create/update/delete" makes sense, as this would add a possibly too fine-grained workflow (and would require the user to know whether a domain already is adder).
I hope we can implement the knative story that introduces an "apply" verb soon, which would be useful here, too: "apply" essentially mean, create-or-update and is idempotent (you can call it with the same argument many times, but only get a single result). This is the case for you command here.
So, if this were a core kn command, I probably would suggest a
# Add or update the given domain with the given selector
kn admin domain apply ....
# Remove the domain
kn admin domain remove ....
as this aligns with the other verbs used in kn.
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.
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.
IMO, set/unset suit better for properties like domain,
while create/update/apply/deploy operates on the actual resources.
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.
@navidshaikh thanks and we can continue subcommand wording in #53
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.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)
@maximilien
|
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.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)
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.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)
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.
Change looks good to, thanks !
Only a small question about the wording and also I'm not clear how multiple domains can be managed (e.g also be deleted)
@rhuss |
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.
Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)
- Added utils to update configmp - Chores to refine vars or logs
@@ -0,0 +1,19 @@ | |||
/* | |||
Copyright 2014 The Kubernetes Authors. |
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.
Incorrect copyright year:
Copyright 2014 The Kubernetes Authors. | |
Copyright 2020 The Kubernetes Authors. |
@@ -0,0 +1,512 @@ | |||
/* | |||
Copyright 2014 The Kubernetes Authors. |
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.
Incorrect copyright year:
Copyright 2014 The Kubernetes Authors. | |
Copyright 2020 The Kubernetes Authors. |
@@ -0,0 +1,105 @@ | |||
/* | |||
Copyright 2016 The Kubernetes Authors. |
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.
Incorrect copyright year:
Copyright 2016 The Kubernetes Authors. | |
Copyright 2020 The Kubernetes Authors. |
@rhuss As discussed in #40 (comment), I opened another chore item to follow command wording create/apply/update (#53). @rhuss @maximilien Please help to review again and hope we can merge this first before the vendor pkg change. thanks! |
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.
looks good for me, let's check in a follow PR about the concrete wording.
/lgtm
/hold |
@maximilien please unhold if this looks ok for you, so that it gets merged. |
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.
LGTM let me ask @navidshaikh if he has not seen this before.
I also don’t see tests for registry/add. Please address and let me know and I can do final pass.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: maximilien, rhuss, zhanggbj The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@maximilien Thanks Max. For test, we have UT for each command and also for registry/add |
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.
suggested a few nits.
Unrelated to the changes in PR, noticed error returned by splitByEqualSign
is not handled.
If incorrect selector is given, the error is reported from configmap update API call instead of plugin flag handling (can be fixed in a separate PR).
k, v, _ := splitByEqualSign(label) |
kn admin autoscaling update --scale-to-zero | ||
# To disable scale-to-zero |
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.
kn admin autoscaling update --scale-to-zero | |
# To disable scale-to-zero | |
kn admin autoscaling update --scale-to-zero | |
# To disable scale-to-zero |
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.
@navidshaikh yes, I agree, this is a known issue and will be handled #41
kn admin domain set - to set Knative route domain | ||
|
||
kn admin domain unset - to unset Knative route domain`, | ||
Long: `Manage default route domain or custom route domain for Service with selectors.`, |
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.
Long: `Manage default route domain or custom route domain for Service with selectors.`, | |
Long: `Manage default route domain or custom route domain for service(s) with selectors`, |
# To set a default route domain | ||
kn admin domain set --custom-domain mydomain.com | ||
|
||
# To set a route domain for service having label app=v1 |
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.
# To set a route domain for service having label app=v1 | |
# To set a route domain for service(s) having label 'app=v1' |
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.
@navidshaikh Thanks for the suggestion. Will update in another PR to refine #41
"knative.dev/client-contrib/plugins/admin/pkg/command/utils" | ||
|
||
"knative.dev/client-contrib/plugins/admin/pkg" |
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.
"knative.dev/client-contrib/plugins/admin/pkg/command/utils" | |
"knative.dev/client-contrib/plugins/admin/pkg" | |
"knative.dev/client-contrib/plugins/admin/pkg/command/utils" | |
"knative.dev/client-contrib/plugins/admin/pkg" |
Long: `Manage autoscaling provided by Knative Pod Autoscaler (KPA). For example: | ||
|
||
kn admin autoscaling update - to manage autoscaling config`, | ||
Long: `Manage autoscaling provided by Knative Pod Autoscaler (KPA).`, |
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.
Long: `Manage autoscaling provided by Knative Pod Autoscaler (KPA).`, | |
Long: `Manage autoscaling provided by Knative Pod Autoscaler (KPA)`, |
--username=[REGISTRY_USER] \ | ||
--password=[REGISTRY_PASSWORD]`, | ||
Short: "Add registry with credentials", | ||
Long: `Add registry with credentials to enable Service deployment from it`, |
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.
Long: `Add registry with credentials to enable Service deployment from it`, | |
Long: `Add registry with credentials to enable service deployment from it`, |
--email=[REGISTRY_EMAIL] \ | ||
--username=[REGISTRY_USER] \ | ||
--password=[REGISTRY_PASSWORD]`, | ||
Long: `Manage Service deployment from a registry with credentials`, |
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.
Long: `Manage Service deployment from a registry with credentials`, | |
Long: `Manage service deployment from a registry with credentials`, |
"k8s.io/client-go/util/retry" | ||
) | ||
|
||
func UpdateConfigMap(client kubernetes.Interface, desiredCm *corev1.ConfigMap) error { |
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.
/lint
---- | ||
==== | ||
|
||
.Update a custom domain with --selector and Service with a label app=v1 will use test.com | ||
==== | ||
---- | ||
$ kn admin domain set --custom-domain test.com --selector app=v1 | ||
Updated Knative route domain test.com | ||
Set Knative route domain test.com with selector [app=v1] |
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.
IMO, set/unset suit better for properties like domain,
while create/update/apply/deploy operates on the actual resources.
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.
@navidshaikh: 6 warnings.
In response to this:
/lint
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.
"k8s.io/apimachinery/pkg/util/runtime" | ||
) | ||
|
||
// For any test of the style: |
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.
Golint comments: comment on exported var ForeverTestTimeout should be of the form "ForeverTestTimeout ...". More info.
wg sync.WaitGroup | ||
} | ||
|
||
func (g *Group) Wait() { |
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.
Golint comments: exported method Group.Wait should have comment or be unexported. More info.
|
||
// WaitFunc creates a channel that receives an item every time a test | ||
// should be executed and is closed when the last test should be invoked. | ||
type WaitFunc func(done <-chan struct{}) <-chan struct{} |
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.
type WaitFunc func(done <-chan struct{}) <-chan struct{} | |
type Func func(done <-chan struct{}) <-chan struct{} |
Golint naming: type name will be used as wait.WaitFunc by other packages, and that stutters; consider calling this Func. More info.
// When the done channel is closed, because the golang `select` statement is | ||
// "uniform pseudo-random", the `fn` might still run one or multiple time, | ||
// though eventually `WaitFor` will return. | ||
func WaitFor(wait WaitFunc, fn ConditionFunc, done <-chan struct{}) error { |
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.
func WaitFor(wait WaitFunc, fn ConditionFunc, done <-chan struct{}) error { | |
func For(wait WaitFunc, fn ConditionFunc, done <-chan struct{}) error { |
Golint naming: func name will be used as wait.WaitFor by other packages, and that stutters; consider calling this For. More info.
// ... | ||
// | ||
// TODO: Make Backoff an interface? | ||
func RetryOnConflict(backoff wait.Backoff, fn func() error) error { |
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.
func RetryOnConflict(backoff wait.Backoff, fn func() error) error { | |
func OnConflict(backoff wait.Backoff, fn func() error) error { |
Golint naming: func name will be used as retry.RetryOnConflict by other packages, and that stutters; consider calling this OnConflict. More info.
"k8s.io/client-go/util/retry" | ||
) | ||
|
||
func UpdateConfigMap(client kubernetes.Interface, desiredCm *corev1.ConfigMap) error { |
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.
Golint comments: exported function UpdateConfigMap should have comment or be unexported. More info.
OK cool. Let me know when you address the last comments from @navidshaikh and we can merge this. Thx. |
/unhold |