copyright | lastupdated | keywords | subcollection | ||
---|---|---|---|---|---|
|
2023-11-09 |
command-line interface, kubernetes and code engine cli, knative and code engine cli, kubectl and code engine cli, kubernetes, knative |
codeengine |
{{site.data.keyword.attribute-definition-list}}
{: #knative}
{{site.data.keyword.codeenginefull}} 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 {{site.data.keyword.codeengineshort}}. {{site.data.keyword.codeengineshort}} supports the Knative APIs (and Kubernetes) and their CLI commands. For more information about Kubernetes, see Using Kubernetes with Code Engine. {: shortdesc}
{: #knative-version}
{{site.data.keyword.codeengineshort}} supports the version 1.11 Knative APIs and its CLI commands.
{: #knative-kubectl}
To install Knative (kn
), download and install the Knative CLI{: external}.
To use Knative with {{site.data.keyword.codeengineshort}}, you must first set up your environment to interact with the Kubernetes API of {{site.data.keyword.codeengineshort}}. For more information, see Installing the Kubernetes command-line interface.
For more information about Kubernetes and Knative and how they work with {{site.data.keyword.codeengineshort}} architecture, see Learning about {{site.data.keyword.codeengineshort}} architecture and workload isolation. {: important}
{: #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 {{site.data.keyword.codeengineshort}}.
Before you begin
- You must create your project and the project must be in
active
status. - Install the Kubernetes CLI (
kubectl
) and the Knative CLI (kn
).
You can set up your environment in the following ways.
-
You can add the
--kubecfg
option to yourproject select
command. For example,ibmcloud ce project select --name PROJECT_NAME --kubecfg
{: pre}
-
You can export the
kubeconfig
file directly. Run theibmcloud ce project current
command to find the project that you are currently targeting. This command also returns theexport
command for yourkubeconfig
file. For example,ibmcloud ce project current
{: pre}
Example output
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.
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 {{site.data.keyword.codeengineshort}} architecture, see Learning about {{site.data.keyword.codeengineshort}} architecture and workload isolation. {: important}
{: #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 {{site.data.keyword.cloud_notm}} service roles.
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="Table 1. Knative authorities" caption-side=ottom"} |