1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00

Improvements to Knative Services section (serverless apps)

This commit is contained in:
abrennan
2020-04-21 14:15:18 -05:00
committed by openshift-cherrypick-robot
parent 541083dff2
commit 59a1a905b0
17 changed files with 175 additions and 117 deletions

View File

@@ -1658,6 +1658,12 @@ Topics:
File: installing-kn
- Name: Removing OpenShift Serverless
File: removing-openshift-serverless
# Apps
- Name: Creating and managing serverless applications
File: serving-creating-managing-apps
# HA
- Name: Configuring high-availability components
File: serverless-config-HA
# Knative CLI
- Name: Knative CLI
Dir: knative_cli
@@ -1670,10 +1676,7 @@ Topics:
Topics:
- Name: How Knative Serving works
File: serverless-knative-serving
- Name: Getting started with Knative services
File: getting-started-knative-services
- Name: Creating serverless applications
File: creating-serverless-applications
### Knative services
- Name: Interacting with serverless applications
File: interacting-serverless-apps
- Name: Configuring Knative Serving autoscaling
@@ -1706,9 +1709,6 @@ Topics:
# Channels
- Name: Using channels
File: serverless-channels
# HA
- Name: Configuring high-availability components
File: serverless-config-HA
# Metering
- Name: Using metering with OpenShift Serverless
File: serverless-metering

View File

@@ -19,7 +19,7 @@ image::odc_add_view.png[Add View]
ifdef::openshift-enterprise,openshift-webscale,openshift-origin[]
[NOTE]
====
The serverless sections in the above options are displayed only if the xref:../../serverless/installing_serverless/installing-openshift-serverless.adoc#installing-openshift-serverless[*Serverless Operator*] is installed in your cluster. OpenShift Serverless is a Technology Preview feature.
Serverless options in the *Developer* perspective are displayed only if the xref:../../serverless/installing_serverless/installing-openshift-serverless.adoc#serverless-install-web-console_installing-openshift-serverless[*OpenShift Serverless Operator*] is installed in your cluster.
====
endif::[]
@@ -32,7 +32,7 @@ To create applications using the *Developer* perspective ensure that:
ifdef::openshift-enterprise,openshift-webscale,openshift-origin[]
To create serverless applications, in addition to the above, ensure that:
To create serverless applications, in addition to the preceeding prerequisites, ensure that:
* You have xref:../../serverless/installing_serverless/installing-openshift-serverless.adoc#installing-openshift-serverless[installed the Openshift Serverless Operator].
* You have xref:../../serverless/installing_serverless/installing-knative-serving.adoc#installing-knative-serving[created a knative-serving namespace and a KnativeServing resource in the knative-serving namespace].

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

View File

@@ -1,33 +0,0 @@
// Module included in the following assemblies:
//
// * serverless/getting-started-knative-services.adoc
[id="creating-knative-services_{context}"]
= Creating a Knative service
To create a service, you must create the `service.yaml` file.
You can copy the sample below. This sample will create a sample golang application called `helloworld-go` and allows you to specify the image for that application.
[source,yaml]
----
apiVersion: serving.knative.dev/v1alpha1 <1>
kind: Service
metadata:
name: helloworld-go <2>
namespace: default <3>
spec:
template:
spec:
containers:
- image: gcr.io/knative-samples/helloworld-go <4>
env:
- name: TARGET <5>
value: "Go Sample v1"
----
<1> Current version of Knative
<2> The name of the application
<3> The namespace the application will use
<4> The URL to the image of the application
<5> The environment variable printed out by the sample application

View File

@@ -0,0 +1,23 @@
// Module included in the following assemblies:
//
// serverless/serving-creating-managing-apps.adoc
[id="creating-serverless-apps-admin-console_{context}"]
= Creating serverless applications using the Administrator perspective
.Prerequisites
To create serverless applications using the *Administrator* perspective, ensure that you have completed the following steps.
* The {ServerlessOperatorName} and Knative Serving are installed.
* You have logged in to the web console and are in the *Administrator* perspective.
.Procedure
. Navigate to the *Serverless* → *Services* page.
+
image::serverless-create-service-admin.png[Services page]
. Click *Create Service*.
. Manually enter YAML or JSON definitions, or by dragging and dropping a file into the editor.
+
image::service-yaml-admin.png[Text editor]
. Click *Create*.

View File

@@ -0,0 +1,35 @@
// Module included in the following assemblies:
//
// serverless/serving-creating-managing-apps.adoc
[id="creating-serverless-apps-kn_{context}"]
= Creating serverless applications using the kn CLI
.Prerequisites
* You have installed the {ServerlessOperatorName} and Knative Serving.
* You have installed `kn` CLI.
.Procedure
. Create the Knative service by entering the following command:
+
----
$ kn service create <SERVICE-NAME> --image <IMAGE> --env <KEY=VALUE>
----
+
.Example
+
----
$ kn service create hello --image gcr.io/knative-samples/helloworld-go --env TARGET=Knative
Creating service 'hello' in namespace 'default':
0.271s The Route is still working to reflect the latest desired specification.
0.580s Configuration "hello" is waiting for a Revision to become ready.
3.857s ...
3.861s Ingress has not yet been reconciled.
4.270s Ready to serve.
Service 'hello' created with latest revision 'hello-bxshg-1' and URL:
http://hello-default.apps-crc.testing
----

View File

@@ -0,0 +1,43 @@
// Module included in the following assemblies:
//
// serverless/serving-creating-managing-apps.adoc
[id="creating-serverless-apps-yaml_{context}"]
= Creating serverless applications using YAML
To create a serverless application, you can create a YAML file and apply it using `oc apply`.
You can create a YAML file by copying the following example:
.Example Knative service YAML
[source,yaml]
----
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
namespace: default
spec:
template:
spec:
containers:
- image: gcr.io/knative-samples/helloworld-go
env:
- name: TARGET
value: "Go Sample v1"
----
In this example, the YAML file is named `hello-service.yaml`.
.Procedure
. Navigate to the directory where the `hello-service.yaml` file is contained.
. Deploy the application by applying the YAML file.
+
----
$ oc apply --filename hello-service.yaml
----
After the service has been created and the application has been deployed, Knative will create a new immutable revision for this version of the application.
Knative will also perform network programming to create a route, ingress, service, and load balancer for your application, and will automatically scale your pods up and down based on traffic, including inactive Pods.

View File

@@ -1,22 +0,0 @@
// Module included in the following assemblies:
//
// * serverless/getting-started-knative-services.adoc
[id="deploying-serverless-apps_{context}"]
= Deploying a serverless application
To deploy a serverless application, you must apply the `service.yaml` file.
.Procedure
. Navigate to the directory where the `service.yaml` file is contained.
. Deploy the application by applying the `service.yaml` file.
+
----
$ oc apply --filename service.yaml
----
Now that service has been created and the application has been deployed, Knative will create a new immutable revision for this version of the application.
// TODO: Add docs about revisions
Knative will also perform network programming to create a route, ingress, service, and load balancer for your application, and will automatically scale your pods up and down based on traffic, including inactive pods.

View File

@@ -1,19 +0,0 @@
// Module included in the following assemblies:
//
// * serverless/getting-started-knative-services.adoc
[id="knative-services-connectivity_{context}"]
= Connecting Knative Services to existing Kubernetes deployments
Knative Services can call a Kubernetes deployment in any namespace, provided that there are no existing additional network barriers.
A Kubernetes deployment can call a Knative Service if:
* The Kubernetes deployment is in the same namespace as the target Knative Service.
* The Kubernetes deployment is in a namespace that was manually added to the ServiceMeshMemberRoll in `knative-serving-ingress`.
* The Kubernetes deployment uses the target Knative Service's public URL.
+
[NOTE]
====
Knative Services are accessed using a public URL by default. The target Knative Service must not be configured as a private, `cluster-local` visibility service if you want to connect it to your existing Kubernetes deploying using a public URL.
====

View File

@@ -1,7 +1,6 @@
// Module included in the following assemblies:
//
// applications/application_life_cycle_management/odc-creating-applications-using-developer-perspective.adoc
//serverless/creating-serverless-applications.adoc
[id="odc-importing-codebase-from-git-to-create-application_{context}"]
= Importing a codebase from Git to create an application

View File

@@ -0,0 +1,39 @@
// Module is included in the following assemblies:
//
// serverless/knative_serving/serverless-knative-serving.adoc
// serverless/serving-creating-managing-apps.adoc
[id="serverless-about-services_{context}"]
= Serverless applications using Knative services
To deploy a serverless application using {ServerlessProductName}, you must create a _Knative service_.
Knative services are Kubernetes services, defined by a route and a configuration, and contained in a YAML file.
.Example Knative service YAML
[source,yaml]
----
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go <1>
namespace: default <2>
spec:
template:
spec:
containers:
- image: gcr.io/knative-samples/helloworld-go <3>
env:
- name: TARGET <4>
value: "Go Sample v1"
----
<1> The name of the application.
<2> The namespace the application will use.
<3> The image of the application.
<4> The environment variable printed out by the sample application.
You can create a serverless application by using one of the following methods:
* Create a Knative service from the {product-title} web console.
* Create a Knative service using the `kn` CLI.
* Create and apply a YAML file.

View File

@@ -1,20 +0,0 @@
[id="creating-serverless-applications"]
= Creating serverless applications
include::modules/common-attributes.adoc[]
include::modules/serverless-document-attributes.adoc[]
:context: creating-serverless-applications
// To Do: modules/serverless-creating-serverless-applications-using-cli.adoc[leveloffset=+1]
You can create serverless applications by using the *Developer* perspective in the {product-title} web console.
.Prerequisites
To create serverless applications using the *Developer* perspective ensure that:
* You have xref:../../web_console/web-console.adoc#web-console[logged in to the web console].
* You are in the xref:../../web_console/odc-about-developer-perspective.adoc#odc-about-developer-perspective[*Developer* perspective].
* You have the appropriate xref:../../authentication/using-rbac.adoc#default-roles_using-rbac[roles and permissions] in a project to create applications and other workloads in {product-title}.
* You have xref:../installing_serverless/installing-openshift-serverless.adoc#installing-openshift-serverless[installed the Openshift Serverless Operator].
* You have xref:../installing_serverless/installing-knative-serving.adoc#installing-knative-serving[created a knative-serving namespace and a KnativeServing resource in the knative-serving namespace].
include::modules/odc-importing-codebase-from-git-to-create-application.adoc[leveloffset=+1]

View File

@@ -1,13 +0,0 @@
[id="getting-started-knative-services"]
= Getting started with Knative services
include::modules/common-attributes.adoc[]
include::modules/serverless-document-attributes.adoc[]
:context: getting-started-knative-services
toc::[]
Knative services are Kubernetes services that a user creates to deploy a serverless application. Each Knative service is defined by a route and a configuration, contained in a `.yaml` file.
include::modules/creating-knative-services.adoc[leveloffset=+1]
include::modules/deploying-serverless-apps.adoc[leveloffset=+1]
include::modules/knative-services-connectivity.adoc[leveloffset=+1]

View File

@@ -17,3 +17,7 @@ These CRDs are building blocks to address complex use cases, for example:
* Viewing point-in-time snapshots of deployed code and configurations.
include::modules/serverless-serving-resources.adoc[leveloffset=+1]
include::modules/serverless-apps-intro.adoc[leveloffset=+1]
== Next steps
* Create a serverless application. For more information, see the documentation on xref:../../serverless/serving-creating-managing-apps.adoc#serving-creating-managing-apps[Creating and managing serverless applications].

View File

@@ -0,0 +1,22 @@
include::modules/serverless-document-attributes.adoc[]
[id="serving-creating-managing-apps"]
= Creating and managing serverless applications
include::modules/common-attributes.adoc[]
:context: serving-creating-managing-apps
toc::[]
include::modules/serverless-apps-intro.adoc[leveloffset=+1]
== Creating serverless applications using the {product-title} web console
You can create a serverless application using either the *Developer* or *Administrator* perspective in the {product-title} web console.
include::modules/creating-serverless-apps-admin-console.adoc[leveloffset=+2]
=== Creating serverless applications using the Developer perspective
For more information about creating applications using the *Developer* perspective in {product-title}, see the documentation on xref:../applications/application_life_cycle_management/odc-creating-applications-using-developer-perspective.adoc#odc-creating-applications-using-developer-perspective[Creating applications using the Developer perspective].
include::modules/creating-serverless-apps-kn.adoc[leveloffset=+1]
include::modules/creating-serverless-apps-yaml.adoc[leveloffset=+1]