---
name: codeengine-knative
title: Using Knative with Code Engine
description: IBM Cloud&reg; Code Engine is designed so that you do not need to interact with the underlying technology it is built upon. However, if you have existing tools that are based on Knative, you can still use it with Code Engine. Code Engine supports the Knative APIs (and Kubernetes) and their CLI commands. For more information about Kubernetes, see Using Kubernetes with Code Engine.
last-updated: 2024-10-09
---

> ## Documentation Index
> The table of contents for this documentation set is at https://cloud.ibm.com/docs/codeengine?format=markdown
> The index for all IBM Cloud docs is at: https://cloud.ibm.com/docs/llms.txt
> Use these files to discover more information as needed.

# Using Knative with Code Engine
{: #knative}

IBM Cloud&reg; Code Engine is designed so that you do not need to interact with the underlying technology it is built upon. However, if you have existing tools that are based on Knative, you can still use it with Code Engine. Code Engine supports the Knative APIs (and Kubernetes) and their CLI commands. For more information about Kubernetes, see [Using Kubernetes with Code Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-kubernetes&format=markdown).
{: shortdesc}

## What is the supported version of Knative?
{: #knative-version}

Code Engine supports the version 1.15 Knative APIs and its CLI commands.

## Installing the Knative command-line interface
{: #knative-kubectl}

To install Knative (`kn`), download and install the [Knative CLI](https://github.com/knative/client/blob/main/docs/README.md){: external}.

To use Knative with Code Engine, you must first set up your environment to interact with the Kubernetes API of Code Engine. For more information, see [Installing the Kubernetes command-line interface](https://cloud.ibm.com/docs/codeengine?topic=codeengine-kubernetes&format=markdown#kubernetes-kubectl).

For more information about Kubernetes and Knative and how they work with Code Engine architecture, see [Learning about Code Engine architecture and workload isolation](https://cloud.ibm.com/docs/codeengine?topic=codeengine-architecture&format=markdown).
{: important}

## Interacting with Kubernetes API
{: #kubectl-kubeconfig-knative}


To interact with your project from the Kubernetes command-line interface, `kubectl`, or with Knative, `kn` you must set up your environment to interact with the Kubernetes API of Code Engine.

Before you begin

- You must [create your project](https://cloud.ibm.com/docs/codeengine?topic=codeengine-manage-project&format=markdown#create-a-project) and the project must be in `active` status.
- Install the [Kubernetes CLI (`kubectl`)](https://kubernetes.io/docs/tasks/tools/) and the [Knative CLI (`kn`)](https://knative.dev/docs/client/install-kn/).

You can set up your environment in the following ways. 

- You can add the `--kubecfg` option to your **`project select`** command. For example, 

    ```txt
    ibmcloud ce project select --name PROJECT_NAME --kubecfg
    ```
    {: pre}

- You can export the `kubeconfig` file directly. Run the **`ibmcloud ce project current`** command to find the project that you are currently targeting. This command also returns the **`export`** command for your `kubeconfig` file. For example,

    ```txt
    ibmcloud ce project current
    ```
    {: pre}

    Example output

    ```txt
    Getting the current project context...
    OK

    Name:       myproject
    ID:         01234567-abcd-abcd-abcd-abcdabcd1111
    Subdomain:  aabon2dfwa0
    Domain:     us-south.codeengine.appdomain.cloud
    Region:     us-south
    Kubectl Context:  4svg40kna19

    Kubernetes Config:
    Context:             aabon2dfwa0
    Environment Variable: export KUBECONFIG=/user/myusername/.bluemix/plugins/code-engine/myproject-01234567-abcd-abcd-abcd-abcdabcd1111.yaml
    ```
    {: screen}

    Then, copy the export command, paste it into your command-line interface, and run it.

Verify that your environment is set correctly by running the **`kubectl config`** command.

```txt
kubectl config current-context
```
{: pre}

If the context is correctly set, the output matches the `Kubectl Context` value of your project. For example, if your `Kubectl Context` value of your project is `4svg40kna19`, the command returns `4svg40kna19`.

For more information about Kubernetes and how it works with Code Engine architecture, see [Learning about Code Engine architecture and workload isolation](https://cloud.ibm.com/docs/codeengine?topic=codeengine-architecture&format=markdown).
{: important}

## Required access authorities to work with Knative API
{: #knative-api}

After you set up your environment, you can interact with Knative API. You must have the correct level of authority for specific tasks. These roles are set in Identity and access management. See [IBM Cloud service roles](https://cloud.ibm.com/docs/codeengine?topic=codeengine-iam&format=markdown#service).

| Resource |  Manager role | Writer role | Reader role |
| --------- | -------------- | ------------ | ------------ |
| `services.serving.knative.dev` | `get`, `list`, `watch`, `create`, `delete`, `update`, `patch`, `apply`, `edit` | `get`, `list`, `watch`, `create`, `delete`, `update`, `patch`, `apply`, `edit` | `get`, `list`, `watch` |
| `configurations.serving.knative.dev` | `get`, `list`, `watch`, `create`, `delete`, `update`, `patch`, `apply`, `edit` | `get`, `list`, `watch`, `create`, `delete`, `update`, `patch`, `apply`, `edit` | `get`, `list`, `watch` |
| `routes.serving.knative.dev` | `get`, `list`, `watch`, `create`, `delete`, `update`, `patch`, `apply`, `edit` | `get`, `list`, `watch`, `create`, `delete`, `update`, `patch`, `apply`, `edit` | `get`, `list`, `watch` |
| `revisions.serving.knative.dev` | `get`, `list`, `watch`, `create`, `delete`, `update`, `patch`, `apply`, `edit`  | `get`, `list`, `watch`, `create`, `delete`, `update`, `patch`, `apply`, `edit` | `get`, `list`, `watch` |
| `pingsource.serving.knative.dev` | `get`, `list`, `watch`, `create`, `delete`, `update`, `patch`, `apply`, `edit` | `get`, `list`, `watch`, `create`, `delete`, `update`, `patch`, `apply`, `edit` | `get`, `list`, `watch` |
| `kafkasource.serving.knative.dev` | `get`, `list`, `watch`, `create`, `delete`, `update`, `patch`, `apply`, `edit` | `get`, `list`, `watch`, `create`, `delete`, `update`, `patch`, `apply`, `edit` | `get`, `list`, `watch` |
{: caption="Knative authorities" caption-side=ottom"}