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

GitHub Action for kn #1066

Closed
danielhelfand opened this issue Oct 15, 2020 · 21 comments
Closed

GitHub Action for kn #1066

danielhelfand opened this issue Oct 15, 2020 · 21 comments
Labels
kind/feature New feature or request

Comments

@danielhelfand
Copy link
Contributor

danielhelfand commented Oct 15, 2020

Feature request

It would be helpful for developers using GitHub Actions to have an easy way to use kn. Wondering if there has been any discussion around supporting an official GitHub Action and making it available through the GitHub Actions Marketplace.

Creating a GitHub Action docs: https://docs.github.com/en/free-pro-team@latest/actions/creating-actions

Use case

For developers working with GitHub Actions for CI/CD, having an action that allows users to specify a specific version of kn to use and include in a build would help with automation around working with Knative.

UI Example

N/A

@danielhelfand danielhelfand added the kind/feature New feature or request label Oct 15, 2020
@rhuss
Copy link
Contributor

rhuss commented Oct 27, 2020

I wonder whether we need a dedicated action or if our container image for kn that could be used as an action would be good enough ? (saying that with being a github action noob )

@danielhelfand
Copy link
Contributor Author

I think the challenge with GitHub Actions right now is that there isn't the perfect pattern for including CLIs as part of a build. In a lot of cases, actions have been developed to install CLIs on the host, which is not the most ideal pattern.

And the challenge with using an image (i.e. uses: docker://gcr.io/knative-releases/knative.dev/client/cmd/kn:latest) is properly utilizing things on the host (e.g. resource definitions and a kubeconfig) in an easy way. So if there is a way to abstract this further, I think it would make sense. But what I can do to start with this is look into the nuances of using the image in actions to see if it's worth making something.

@navidshaikh
Copy link
Collaborator

cc @kameshsampath

@kameshsampath
Copy link

thanks @navidshaikh , I have a early version of the action https://github.com/kameshsampath/kn-service-action and an example using it https://github.com/kameshsampath/kn-service-action-example. Right now tested only on OpenShift

@kameshsampath
Copy link

@danielhelfand ^^

@rhuss
Copy link
Contributor

rhuss commented Nov 26, 2020

@kameshsampath thanks a lot @kameshsampath ! Eventually we could move to a knative-sandbox/kn-github-atcion for wider visibility. We can discuss the implementation details over there at kamesh' repo, before moving on. E.g. when it comes to authentication and other configuration requirements.

@mattwelke
Copy link

mattwelke commented Dec 10, 2020

I recently added a step in a GitHub Actions workflow to install kn:

- name: Setup kn
  run: |-
    echo "Downloading kn $KN_VERSION to $KN_INSTALL_PATH..."
    sudo wget --quiet -O $KN_INSTALL_PATH "https://github.com/knative/client/releases/download/$KN_VERSION/kn-linux-amd64"
    sudo chmod +x $KN_INSTALL_PATH
    echo "Installed kn $KN_VERSION"

GitHub Actions has been an area of interest for me lately, and I wanted to try making an action of my own, so I thought this would be a fun project to do. I planned to start it this weekend, but decided to search and found this issue first.

the challenge with using an image (i.e. uses: docker://gcr.io/knative-releases/knative.dev/client/cmd/kn:latest) is properly utilizing things on the host (e.g. resource definitions and a kubeconfig) in an easy way

I think this is why the pattern so far is to have JavaScript actions that mutate the host. That way, CLIs can be installed and used by steps further down in the workflow's job. Docker actions run in a separate container (which has read only access to the host machine's file system), so they can't be used to install CLIs on the host. Docker actions can use CLI tools though, as long as they accept everything they need in the parameters of the action for the CLI tool to do what it needs to do.

Google maintains an action (https://github.com/google-github-actions/setup-gcloud.) for setting up gcloud so that it's available on the host machine for future steps in the job. They also maintain some actions that are self-contained (like https://github.com/google-github-actions/deploy-cloudrun) and used for specific tasks. This self-contained example doesn't use gcloud, but instead uses the Cloud Run API directly.

Knative could create actions with this style as inspiration too. We could have a setup-kn action that makes it available on the host machine, and self-contained actions like deploy-service, deploy-cloudpubsubsource etc. Our self-contained actions would likely use kn from within them because, as far as I know, that's the preferred way to deploy Knative objects into clusters.

@mattwelke
Copy link

I did some more reading on JavaScript vs. Docker actions and I read that Docker actions can actually mutate the host file system too. I was wrong about that before.

I took a stab at creating setup-kn as my first real action: https://github.com/mattwelke/github-action-setup-kn

I made it as a JavaScript action, taking inspiration from the setup-gcloud action from Google. It doesn't have a build pipeline though right now. I just put it in .github/actions in the repo for testing. It lets people specify version, and defaults to v0.19.1 right now (I'd add some smart semver functionality later to make it grab the latest version or latest major version a user specifies).

image

It skips the install if it's already installed and errors out if users specify something invalid:

image

@kameshsampath I'm interested what your thoughts are on it. I do like your action for deploying services because it is self contained.

@kameshsampath
Copy link

@mattwelke - the biggest adv I see with Dockerfile based approach is that you dont need to be JS expert :) and enables people w/o JS knowledge to collaborate easily. But I do feel the native JS actions do have some advantages but never tried

@mattwelke
Copy link

After talking on Slack, we decided it would be worth looking more into Docker actions for all actions, including setting up kn. I will look more into them before continuing with this and collaborating.

Another goal is to use the existing kn Docker image as is, as the Docker action, or with the refactorong needed to use it both as it's used right now and as a Docker action.

@github-actions
Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 17, 2021
@rhuss
Copy link
Contributor

rhuss commented Mar 17, 2021

Is there still interest in this feature, or can we close this issue ? (asking because it went stale)

@divyansh42
Copy link

@danielhelfand we have created an action https://github.com/redhat-actions/kn-service-manager to manage knative services, but knative should be installed in your kubernetes cluster to work with this action. May be this action can partially fulfill your requirement.
We would love to see your views on this and do let us know if you want some improvements/features in this, we can discuss that further.

P.S. Initial work is done by @kameshsampath (he has already mentioned that repos earlier in comments) we have tried to add some other features to make it more usable.

@github-actions github-actions bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 18, 2021
@github-actions
Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 17, 2021
@rhuss
Copy link
Contributor

rhuss commented Jul 5, 2021

/remove-lifecycle stale

@knative-prow-robot knative-prow-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 5, 2021
@divyansh42
Copy link

divyansh42 commented Jul 5, 2021

@mattwelke Based on your comment:

I made it as a JavaScript action, taking inspiration from the setup-gcloud action from Google. It doesn't have a build pipeline though right now. I just put it in .github/actions in the repo for testing. It lets people specify version, and defaults to v0.19.1 right now (I'd add some smart semver functionality later to make it grab the latest version or latest major version a user specifies).

OpenShift Tools Installer action can install kn and it has semver support too and also caches the binary for the faster installation in the future jobs. You can give this a try!

@rhuss
Copy link
Contributor

rhuss commented Jul 9, 2021

@kameshsampath @mattwelke If you don't mind I'm closing this issue as there is a good, fully-featured implementation provided by the OpenShift Tools installer (which despite the name also includes vanilla non-openshift tools like kubectl or kn) that is actively maintained.

For the near future, I don't think we have the people to work on our own GitHub action. It's not so much about the initial implementation, more about the constant maintenance effort. This might change when we offer Kn distributions that come included with various plugins.

Feel free to reopen the issue if I'm wrong.

@rhuss rhuss closed this as completed Jul 9, 2021
@rhuss
Copy link
Contributor

rhuss commented Jul 9, 2021

One caveat though is, that the OpenShift Tools Installer references the Red Hat productized version of kn (that include some plugins and is two minor versions behind the upstream version). @divyansh42 , I guess there are no plans to add the possibility to download upstream binaries ?

@divyansh42
Copy link

divyansh42 commented Jul 9, 2021

@rhuss It can also install upstream binaries that are present here https://github.com/knative/client/releases
You can use it in your workflow as shown in the example workflow.

@rhuss
Copy link
Contributor

rhuss commented Jul 9, 2021

@rhuss It can also install upstream binaries that are present here https://github.com/knative/client/releases

Cool, thanks ! That's awesome and really helpful.

dsimansk added a commit to dsimansk/client that referenced this issue Jun 6, 2022
* [release-v1.2.0] Add kn-plugin-func v0.24.0

* Update vendor dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants