Skip to content

GitHub Action to deploy Knative Service using Knative Client

License

Notifications You must be signed in to change notification settings

vinamra28/kn-service-deploy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Knative Service Deploy

CI checks workflow App Build and Push

tag badge license badge

GitHub Action to deploy Knative Service using Knative Client.

Pre-requisites

Kubernetes Cluster with Knative, if you dont have an OpenShift cluster see try.openshift.com or try our new Developer Sandbox.

Action Inputs

Input Required Description
service_name Yes The Knative Service Name.
service_namespace No The Kubernetes Namespace to deploy to. Defaults to current context's namespace.
service_operation No The `kn` service operation create, update, delete, etc. Defaults to create
container_image Yes The container image to use for service.
service_params No The extra service parameters to pass to the service.
registry_user No The registry user to use to create image pull secret. Required if image registry is private.
registry_password No The registry user password or token. Required if image registry is private.

Action Outputs

Output Description
service_url Knative Service URL of the service created.

NOTE: When username and password or token is provided to pull the image, then the action will create a Kubernetes Secret of type docker-registry with the docker-username to be registry_user and docker-password to be registry_password. The docker-server value will be the first part of the container_image value.

Passing extra service arguments

This action provides basic options such as namespace, service name, image and operation to be configured. There might be cases where you might want to pass extra arguments to the kn service <command>, in those cases you can use service_params as shown:

Consider an example that you want to add --max-scale=5 and --min-scale=1, then your action snippet will be:

- name: Knative Service Deploy
  id: kn_service_deploy
  uses: redhat-actions/kn-service-deploy@v1
  with: 
    service_name: fruits-app
    container_image: "${{ steps.push-tag-to-quay.outputs.registry-path }}"
    service_params: >
      --max-scale=5
      --min-scale=1

Example

The example below shows how the kn-service-deploy action can be used to deploy knative service using openshift cluster.

Here OpenShift is used as the Kubernetes platform, you can use the oc-login action, to login into the OpenShift cluster to perform kn actions.

# Login into the Openshift cluster
# with your username and password/token
- name: Authenticate and set context
  id: oc_login
  uses: redhat-actions/oc-login@v1
  with:
    openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
    openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
    insecure_skip_tls_verify: true
    namespace: ${{ env.NAMESPACE }}

# Deploy knative service using container image
- name: Knative Service Deploy
  id: kn_service_deploy
  uses: redhat-actions/kn-service-deploy@v1
  with: 
    service_name: fruits-app
    container_image: "${{ env.IMAGE_NAME }}"

For a complete example see the example workflow.

Contributing

This is an open source project open to anyone. This project welcomes contributions and suggestions!

Feedback & Questions

If you discover an issue please file a bug in GitHub Issues and we will fix it as soon as possible.

License

MIT, See LICENSE for more information.

About

GitHub Action to deploy Knative Service using Knative Client

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 76.6%
  • Dockerfile 23.4%