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

feature(service describe): Output of service details #252

Merged
merged 17 commits into from
Aug 8, 2019

Conversation

rhuss
Copy link
Contributor

@rhuss rhuss commented Jul 9, 2019

kn service describe mimics kubectl describe <sth> as that it output detail information in human-readable output. It also adds the possibility to print the service in machine-readable output e.g. via -o yaml. This is a difference to kubectl describe but necessary as kn list -o yaml will always print a list, not a single object. You can get the single object now with kn describe -o yaml, which also makes for a clear separation between list operations (multiple entities always) and single entity operation (one entity only). Hopefully, this is less confusing than kubectl get operation which has either list or single entity output depending on arguments.

This command shows information about the service itself, but also a summary of the associated revisions.

kn service describe has the following features:

  • Show basic info like
    • name
    • namespace
    • external and internal URLs
    • age
    • annotations and labels of the service itself (shortened)
  • Shows the list of attached revisions which gets traffic
    • name
    • traffic split percentage
    • image name
    • configuration generation when created
    • environment variables (shortened)
    • scale (min ... max)
    • concurrency options
    • resource requests and limits
    • age
  • With --details more information can be printed:
    • annotation, labels, and envs are not shortened but all are printed
    • image digest is shown for revisions
    • all revisions are shown, not only those getting traffic
  • Machine-readable output with -o yaml|json|... or --template of this single service

This PR is a subset of and replacement for #75. There is no color option included nor any hipster stuff 🤓

Examle output

kn service describe hello

Name:         hello
Namespace:    default
URL:          http://hello.default.example.com
Address:      http://hello.default.svc.cluster.local
Annotations:  serving.knative.dev/creator=minikube-user, serving.knative.dev/lastModifier=minikube-user
Age:          1h

Revisions:
  100%  Name:   hello-tw5ds [3] (1h)
        Image:  gcr.io/knative-samples/helloworld-go
        Env:    hello=world, foo=bar
        Scale:  0 ... 10
        Memory: 50 Mb ... 100 Mb

Conditions:
  OK TYPE                   AGE REASON
  ++ ConfigurationsReady     1h
  ++ Ready                   1h
  ++ RoutesReady             1h

kn service describe hello --details

Name:         hello
Namespace:    default
URL:          http://hello.default.example.com
Address:      http://hello.default.svc.cluster.local
Annotations:  serving.knative.dev/creator=minikube-user
              serving.knative.dev/lastModifier=minikube-user
Age:          4m

Revisions:
  100%  Name:   hello-tw5ds [3] (16s)
        Image:  gcr.io/knative-samples/helloworld-go (5ea96ba4b872)
        Env:    hello=world
                foo=bar
        Scale:  0 ... 10
     -  Name:   hello-nc8xz [2] (3m)
        Image:  gcr.io/knative-samples/helloworld-go (5ea96ba4b872)
        Env:    hello=world
                foo=bar
     -  Name:   hello-fkl6l [1] (4m)
        Image:  gcr.io/knative-samples/helloworld-go (5ea96ba4b872)

Conditions:
  OK TYPE                   AGE REASON
  ++ ConfigurationsReady    13s
  ++ Ready                  13s
  ++ RoutesReady            13s

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 9, 2019
@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 9, 2019
@knative-prow-robot knative-prow-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 9, 2019
@mattmoor mattmoor removed their request for review July 10, 2019 00:57
@rhuss rhuss changed the title feature(service show): Output of service details feature(service show): Output of service details [vanilla] Jul 10, 2019
pkg/printers/prefixwriter.go Outdated Show resolved Hide resolved
pkg/kn/commands/service/service_show.go Outdated Show resolved Hide resolved
pkg/kn/commands/service/service_show.go Outdated Show resolved Hide resolved
@rhuss rhuss added this to the v0.8.0 milestone Jul 16, 2019
go.sum Outdated Show resolved Hide resolved
@rhuss rhuss changed the title feature(service show): Output of service details [vanilla] feature(service describe): Output of service details Jul 24, 2019
@knative-prow-robot knative-prow-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 24, 2019
@rhuss
Copy link
Contributor Author

rhuss commented Jul 25, 2019

@sixolet @cppforlife @maximilien All features are now implemented, please have a look at the updated issue description for all data that is shown. The focus was to show everything which also can be provided with kn service create as options.

What is missing is the unit test. However, because it really depends highly on the output to be shown I wanted to wait for first feedback if the current format is ok.

I would then also do the unit tests on then KnClient level, i.e. using a mock implementation of the KnClient interface (which needs to be introduced). Or is this something which we should leave for another PR? (this one is already huge). In that case, I would make a simplified test here (to keep the code coverage test happy), and work on another PR for the full coverage including mock support for KnClient.

pkg/kn/commands/service/service_describe.go Outdated Show resolved Hide resolved
pkg/kn/commands/service/service_describe.go Outdated Show resolved Hide resolved
pkg/kn/commands/service/service_describe.go Outdated Show resolved Hide resolved
@rhuss rhuss force-pushed the pr/svc-show-1 branch 2 times, most recently from 8858eee to de38225 Compare July 26, 2019 20:21
rhuss added 6 commits August 6, 2019 22:32
`kn service show` mimics `kubectl describe <sth>` as that it output detail information in human readable output.

A future extension should add machine readable output with `-o` to export
a single object in json/yaml (that is missing from `kn service list`)

This command shows information about the service itself, but also a summary about the associated revisions.

It also knows about scaling and concurrency options.

Options:

`--details`    : Print more information. By default only are shorter summary is shown
@rhuss
Copy link
Contributor Author

rhuss commented Aug 7, 2019

/retest

@rhuss
Copy link
Contributor Author

rhuss commented Aug 7, 2019

@sixolet @cppforlife @maximilien @navidshaikh Uff, finally I think the PR is ready for prime time. Some tests have been added (coverage 84%), please have another look at the PR. 'would be super awesome to get it merged until Friday before I head off to PTO and the PR would lie around for another three weeks.

Copy link
Collaborator

@navidshaikh navidshaikh left a comment

Choose a reason for hiding this comment

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

I think this is good to go.

@@ -47,7 +45,7 @@ func TestServiceCreateImageMock(t *testing.T) {
r.GetService("foo", getServiceWithUrl("foo", "http://foo.example.com"), nil)

// Testing:
output, err := executeCommand(client, "create", "foo", "--image", "gcr.io/foo/bar:baz")
output, err := executeServiceCommand(client, "create", "foo", "--image", "gcr.io/foo/bar:baz")
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

cmd.SetArgs(args)
cmd.SetOutput(output)
err := cmd.Execute()
return output.String(), err
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this order. ❤️

@navidshaikh
Copy link
Collaborator

/lint

Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@navidshaikh: 15 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.

pkg/kn/commands/service/service_describe.go Outdated Show resolved Hide resolved
pkg/kn/commands/service/service_describe.go Outdated Show resolved Hide resolved
pkg/kn/commands/service/service_describe.go Outdated Show resolved Hide resolved
pkg/kn/commands/service/service_describe.go Outdated Show resolved Hide resolved
pkg/serving/v1alpha1/client_mock.go Outdated Show resolved Hide resolved
pkg/printers/prefixwriter.go Outdated Show resolved Hide resolved
pkg/printers/prefixwriter.go Outdated Show resolved Hide resolved
pkg/printers/prefixwriter.go Outdated Show resolved Hide resolved
pkg/kn/commands/service/service_describe_test.go Outdated Show resolved Hide resolved
pkg/kn/commands/service/service_describe_test.go Outdated Show resolved Hide resolved
@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-client-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/kn/commands/service/service_describe.go 78.3% 85.2% 6.9
pkg/serving/v1alpha1/client.go 86.0% 86.0% -0.0
pkg/serving/v1alpha1/client_mock.go 96.0% 96.8% 0.8

@rhuss
Copy link
Contributor Author

rhuss commented Aug 8, 2019

/lint

Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@rhuss: 0 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.

Copy link
Collaborator

@navidshaikh navidshaikh left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks Roland for working on multiple rounds for this feature 👍

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: navidshaikh, rhuss

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@navidshaikh
Copy link
Collaborator

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 8, 2019
@knative-prow-robot knative-prow-robot merged commit b4b254f into knative:master Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants