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

Package kn in a container image #80

Closed
imjasonh opened this issue Apr 26, 2019 · 10 comments
Closed

Package kn in a container image #80

imjasonh opened this issue Apr 26, 2019 · 10 comments

Comments

@imjasonh
Copy link
Member

This would enable users of Tekton and Google Cloud Build to more easily invoke kn, e.g.:

...
steps
- name: kn-deploy-image
  image: gcr.io/knative-something/kn:v0.X.Y
  command: ['kn', 'service', 'update', 'foo', '--image', 'gcr.io/my/image']
...

Assuming kn doesn't depend on any other tools, you could build and push the image using ko publish (and crane copy to shorten the image name):

$ KO_DOCKER_REPO=gcr.io/knative-something/ ko publish -P github.com/knative/client/cmd/kn
$ crane copy gcr.io/knative-something/github.com/knative/client/cmd/kn gcr.io/knative-something/kn:${RELEASE}
@imjasonh
Copy link
Member Author

Related: #52 #53

It'd be great to get nightly-built images tagged with the latest commit SHA (or just :latest), and release-tagged images built during releases.

@houshengbo
Copy link

houshengbo commented May 30, 2019

We can directly run the command "ko publish github.com/knative/client/cmd/kn -B -t ${tag}" to name the image <KO_DOCKER_REPO>/kn in the image registry. No need of crane copy.

We can define <KO_DOCKER_REPO> as gcr.io/[gcloud-project], docker.io/, etc. So where do we put this image officially for knative client? Do we have a public directory somewhere to host knative images?

@houshengbo
Copy link

houshengbo commented May 30, 2019

I have succeeded in creating the image in my own dockerhub repository, docker.io/houshengbo/kn:latest, with the command:

ko publish github.com/knative/client/cmd/kn -B -t latest

When I pulled the image, and did the taskrun run for the following section:

steps
- name: kn-deploy-image
  image: docker.io/houshengbo/kn:latest
  command: ['kn', 'service', 'create', 'foo', '--image', 'gcr.io/knative-samples/helloworld-go', '--env', 'TARGET=Knative']

I have got:

Error executing command: exec: "kn": executable file not found in $PATH

I was wondering what I have done wrong or I am missing. @imjasonh Do you have any ideas? Thx.

@rhuss
Copy link
Contributor

rhuss commented May 30, 2019

@houshengbo just shot in the dark, but could you use ./kn instead of plain kn ? Thoug, I'm not sure what working directory ko sets for the generated image, nor what working directory Tekton is using.

@houshengbo
Copy link

houshengbo commented May 30, 2019

It looks like I need to install crane first to check the path of kn. This is what I have done:

go get github.com/google/go-containerregistry/cmd/crane

crane should be install under $GOPATH/bin.

Then run

crane config ${image}

Here is the output for the image of kn:

{"architecture":"amd64","author":"Bazel","created":"1970-01-01T00:00:00Z","history":[{"author":"Bazel","created":"1970-01-01T00:00:00Z","created_by":"bazel build ..."},{"created":"0001-01-01T00:00:00Z"},{"created":"0001-01-01T00:00:00Z"}],"os":"linux","rootfs":{"type":"layers","diff_ids":["sha256:01092e5921c5543a918d54d9df752ee09a84c912a1d914b7eb37e7152f20b951","sha256:8f8d58d9708807553434fbd82014ea40b5ee0dc8b2eeefcde561a363461d3e66","sha256:0d411545791d984190d7488cad58d30fa9ae1aec52eda3262d65ecd1aa58d1dc"]},"config":{"AttachStderr":false,"AttachStdin":false,"AttachStdout":false,"Cmd":null,"Healthcheck":null,"Domainname":"","Entrypoint":["/ko-app/kn"],"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt","KO_DATA_PATH=/var/run/ko"],"Hostname":"","Image":"","Labels":null,"OnBuild":null,"OpenStdin":false,"StdinOnce":false,"Tty":false,"User":"","Volumes":null,"WorkingDir":"","ExposedPorts":null,"ArgsEscaped":false,"NetworkDisabled":false,"MacAddress":"","StopSignal":"","Shell":null},"container_config":{"AttachStderr":false,"AttachStdin":false,"AttachStdout":false,"Cmd":null,"Healthcheck":null,"Domainname":"","Entrypoint":null,"Env":null,"Hostname":"","Image":"","Labels":null,"OnBuild":null,"OpenStdin":false,"StdinOnce":false,"Tty":false,"User":"","Volumes":null,"WorkingDir":"","ExposedPorts":null,"ArgsEscaped":false,"NetworkDisabled":false,"MacAddress":"","StopSignal":"","Shell":null}}

The most important thing we need to look up is Entrypoint":["/ko-app/kn"], which tells us the path of the command.

I will try /ko-app/kn instead of kn to see how it goes. Thanks to @imjasonh.

@houshengbo
Copy link

/assign @houshengbo

@knative-prow-robot
Copy link
Contributor

@houshengbo: GitHub didn't allow me to assign the following users: houshengbo.

Note that only knative members and repo collaborators can be assigned and that issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @houshengbo

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.

@sixolet
Copy link
Contributor

sixolet commented Jul 11, 2019

We have it now!

@sixolet sixolet closed this as completed Jul 11, 2019
@imjasonh
Copy link
Member Author

That's gcr.io/knative-releases/github.com/knative/client/cmd/kn correct?

@rhuss
Copy link
Contributor

rhuss commented Jul 25, 2019

Yes. With the gotcha that kn version is broken (we need to propagate ldflags to ko) --> #257

coryrc pushed a commit to coryrc/client that referenced this issue May 14, 2020
…to let the tool magically download kubernetes and start the cluster. (knative#86)

To ensure that our tests don't unexpectedly break, we don't pin the kubernetes version to a particular one (knative/serving#1294) but always use `latest`.

However, the concept of `latest` for kubetests means "kubernetes head", which can be broken (didn't happen so far) or doesn't support all platforms (OS X is the most common case).

Unfortunately, switching to `default` or `release/stable` translates to kubernetes 1.9, which is not recommended for Knative according to the docs.

This PR adds the function `download_k8s()`: it will download the latest public, stable GKE binary supported by the test cluster and the client machine.

As a bonus, the function knocks out the `kubernetes-test.tar.gz` package; this 1.2GB package is not used by Knative tests, and is a severe burden on slower connections (anedoctal evidence: 20+ min download on my home network).

Fixes knative#40.

Bonus: fixes knative#80.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants