mirror of https://github.com/knative/docs.git
* fix tab formatting * change from bold to heading 3
This commit is contained in:
parent
897bf8903a
commit
04eb1ecf81
|
@ -33,8 +33,7 @@ cd knative-docs/code-samples/serving/cloudevents/cloudevents-go
|
|||
|
||||
## The sample code.
|
||||
|
||||
1. If you look in `cloudevents.go`, you will see two key functions for the
|
||||
different modes of operation:
|
||||
1. If you look in `cloudevents.go`, you will see two key functions for the different modes of operation:
|
||||
|
||||
```go
|
||||
func (recv *Receiver) ReceiveAndSend(ctx context.Context, event cloudevents.Event) cloudevents.Result {
|
||||
|
@ -48,79 +47,51 @@ cd knative-docs/code-samples/serving/cloudevents/cloudevents-go
|
|||
}
|
||||
```
|
||||
|
||||
1. Choose how you would like to build the application:
|
||||
2. Choose how you would like to build the application:
|
||||
|
||||
### Dockerfile
|
||||
|
||||
=== "Dockerfile"
|
||||
|
||||
If you look in `Dockerfile`, you will see a method for pulling in the
|
||||
dependencies and building a small Go container based on Alpine. You can build
|
||||
and push this to your registry of choice via:
|
||||
|
||||
* If you look in `Dockerfile`, you will see a method for pulling in the dependencies and building a small Go container based on Alpine. You can build and push this to your registry of choice via:
|
||||
```bash
|
||||
docker build -t <image> .
|
||||
docker push <image>
|
||||
```
|
||||
|
||||
### ko
|
||||
|
||||
=== "ko"
|
||||
|
||||
You can use [`ko`](https://github.com/google/ko) to build and push just the image with:
|
||||
|
||||
* You can use [`ko`](https://github.com/google/ko) to build and push just the image with:
|
||||
```bash
|
||||
ko publish github.com/knative/docs/code-samples/serving/cloudevents/cloudevents-go
|
||||
```
|
||||
|
||||
However, if you use `ko` for the next step, this is not necessary.
|
||||
|
||||
|
||||
3. Choose how you would like to deploy the application:
|
||||
|
||||
|
||||
|
||||
1. Choose how you would like to deploy the application:
|
||||
|
||||
|
||||
=== "yaml (with Dockerfile)"
|
||||
|
||||
If you look in `service.yaml`, take the `<image>` name you used earlier and insert it
|
||||
into the `image:` field, then run:
|
||||
|
||||
### yaml (with Dockerfile)
|
||||
* If you look in `service.yaml`, take the `<image>` name you used earlier and insert it into the `image:` field, then run:
|
||||
```bash
|
||||
kubectl apply -f service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "yaml (with ko)"
|
||||
|
||||
If using `ko` to build and push:
|
||||
|
||||
### yaml (with ko)
|
||||
* If using `ko` to build and push:
|
||||
```bash
|
||||
ko apply -f service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "kn (with Dockerfile)"
|
||||
|
||||
If using `kn` to deploy:
|
||||
|
||||
### kn (with Dockerfile)
|
||||
* If using `kn` to deploy:
|
||||
```bash
|
||||
kn service create cloudevents-go --image=<IMAGE>
|
||||
```
|
||||
|
||||
|
||||
=== "kn (with ko)"
|
||||
|
||||
You can compose `kn` and `ko` to build and deploy with a single step using:
|
||||
|
||||
### kn (with ko)
|
||||
* You can compose `kn` and `ko` to build and deploy with a single step using:
|
||||
```bash
|
||||
kn service create cloudevents-go --image=$(ko publish github.com/knative/docs/code-samples/serving/cloudevents/cloudevents-go)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Testing the sample
|
||||
|
||||
Get the URL for your Service with:
|
||||
|
|
|
@ -58,16 +58,15 @@ In the `Dockerfile`, you can see how the dependencies are installed using npm.
|
|||
docker push <image>
|
||||
```
|
||||
|
||||
=== "yaml"
|
||||
### yaml
|
||||
|
||||
To deploy the Knative service, edit the `service.yaml` file and replace
|
||||
`<registry/repository/image:tag>` with the image you have just created.
|
||||
To deploy the Knative service, edit the `service.yaml` file and replace `<registry/repository/image:tag>` with the image you have just created.
|
||||
|
||||
```bash
|
||||
kubectl apply -f service.yaml
|
||||
```
|
||||
|
||||
=== "kn"
|
||||
### kn
|
||||
|
||||
To deploy using the `kn` CLI:
|
||||
|
||||
|
@ -75,9 +74,6 @@ In the `Dockerfile`, you can see how the dependencies are installed using npm.
|
|||
kn service create cloudevents-nodejs --image=<image>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
## Testing the sample
|
||||
|
||||
Get the URL for your Service with:
|
||||
|
@ -111,17 +107,13 @@ You will get back:
|
|||
|
||||
To remove the sample app from your cluster, delete the service.
|
||||
|
||||
=== "yaml"
|
||||
|
||||
Run:
|
||||
### yaml
|
||||
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
=== "kn"
|
||||
|
||||
Run:
|
||||
### kn
|
||||
|
||||
```bash
|
||||
kn service delete cloudevents-nodejs
|
||||
|
|
|
@ -49,9 +49,7 @@ This will build a statically linked binary, in order to create an image from scr
|
|||
```bash
|
||||
docker build -t <image> .
|
||||
```
|
||||
|
||||
|
||||
=== "yaml"
|
||||
### yaml
|
||||
|
||||
To deploy the Knative Service, look in the `service.yaml` and replace `<image>` with the deployed image name. Then run:
|
||||
|
||||
|
@ -60,7 +58,7 @@ docker build -t <image> .
|
|||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
### kn
|
||||
|
||||
If using `kn` to deploy:
|
||||
|
||||
|
@ -68,10 +66,6 @@ docker build -t <image> .
|
|||
kn service create cloudevents-rust --image=<image>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Testing the sample
|
||||
|
||||
Get the URL for your Service with:
|
||||
|
@ -139,21 +133,15 @@ You'll get as result:
|
|||
|
||||
## Removing the sample app deployment
|
||||
|
||||
To remove the sample app from your cluster, delete the service.
|
||||
To remove the sample app from your cluster, delete the service:
|
||||
|
||||
|
||||
=== "yaml"
|
||||
|
||||
Run:
|
||||
### yaml
|
||||
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
|
||||
Run:
|
||||
### kn
|
||||
|
||||
```bash
|
||||
kn service delete cloudevents-rust
|
||||
|
|
|
@ -125,19 +125,14 @@ kubectl delete --filename service.yaml
|
|||
|
||||
To remove the sample app from your cluster, delete the service:
|
||||
|
||||
|
||||
=== "yaml"
|
||||
|
||||
Run:
|
||||
### yaml
|
||||
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
|
||||
Run:
|
||||
### kn
|
||||
|
||||
```bash
|
||||
kn service delete cloudevents-spring
|
||||
|
|
|
@ -35,34 +35,24 @@ cd knative-docs/code-samples/serving/cloudevents/cloudevents-vertx
|
|||
|
||||
## Build and deploy the sample
|
||||
|
||||
To build the image, run:
|
||||
|
||||
1. To build the image, run:
|
||||
```bash
|
||||
mvn compile jib:build -Dimage=<image_name>
|
||||
```
|
||||
2. Choose one of the following methods to deploy the sample:
|
||||
|
||||
|
||||
=== "yaml"
|
||||
|
||||
To deploy the Knative Service, look in the `service.yaml` and replace `<image>` with the deployed image name. Then run:
|
||||
|
||||
### yaml
|
||||
* To deploy the Knative Service, look in the `service.yaml` and replace `<image>` with the deployed image name. Then run:
|
||||
```bash
|
||||
kubectl apply -f service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
|
||||
If using `kn` to deploy:
|
||||
|
||||
### kn
|
||||
* If using `kn` to deploy:
|
||||
```bash
|
||||
kn service create cloudevents-vertx --image=<image>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Testing the sample
|
||||
|
||||
Get the URL for your Service with:
|
||||
|
@ -132,19 +122,13 @@ You'll see on the console:
|
|||
|
||||
To remove the sample app from your cluster, delete the service:
|
||||
|
||||
|
||||
=== "yaml"
|
||||
|
||||
Run:
|
||||
### yaml
|
||||
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
|
||||
Run:
|
||||
### kn
|
||||
|
||||
```bash
|
||||
kn service delete cloudevents-vertx
|
||||
|
|
|
@ -118,9 +118,9 @@ docker push {username}/helloworld-go
|
|||
### Deploying to knative
|
||||
After the build has completed and the container is pushed to docker hub, you can deploy the app into your cluster. Choose one of the following methods:
|
||||
|
||||
#### `yaml`
|
||||
### yaml
|
||||
|
||||
Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub username.
|
||||
1. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub username.
|
||||
|
||||
```yaml
|
||||
apiVersion: serving.knative.dev/v1
|
||||
|
@ -138,22 +138,19 @@ spec:
|
|||
value: "Go Sample v1"
|
||||
```
|
||||
|
||||
Check that the container image value in the `service.yaml` file matches the container you built in the previous step.
|
||||
1. Check that the container image value in the `service.yaml` file matches the container you built in the previous step.
|
||||
|
||||
Apply the configuration using `kubectl`:
|
||||
1. Apply the configuration using `kubectl`:
|
||||
|
||||
```bash
|
||||
kubectl apply --filename service.yaml
|
||||
```
|
||||
|
||||
After your service is created, Knative will perform the following steps:
|
||||
|
||||
- Create a new immutable revision for this version of the app.
|
||||
- Network programming to create a route, ingress, service, and load balance
|
||||
for your app.
|
||||
- Network programming to create a route, ingress, service, and load balance for your app.
|
||||
- Automatically scale your pods up and down (including to zero active pods).
|
||||
|
||||
Run the following command to find the domain URL for your service:
|
||||
1. Run the following command to find the domain URL for your service:
|
||||
```bash
|
||||
kubectl get ksvc helloworld-go --output=custom-columns=NAME:.metadata.name,URL:.status.url
|
||||
```
|
||||
|
@ -165,9 +162,9 @@ helloworld-go http://helloworld-go.default.1.2.3.4.xip.io
|
|||
```
|
||||
|
||||
|
||||
#### `kn`
|
||||
### kn
|
||||
|
||||
Use `kn` to deploy the service:
|
||||
1. Use `kn` to deploy the service:
|
||||
|
||||
```bash
|
||||
kn service create helloworld-go --image=docker.io/{username}/helloworld-go --env TARGET="Go Sample v1"
|
||||
|
@ -176,7 +173,6 @@ kn service create helloworld-go --image=docker.io/{username}/helloworld-go --env
|
|||
You should see output like this:
|
||||
```bash
|
||||
Creating service 'helloworld-go' in namespace 'default':
|
||||
|
||||
0.031s The Configuration is still working to reflect the latest desired specification.
|
||||
0.051s The Route is still working to reflect the latest desired specification.
|
||||
0.076s Configuration "helloworld-go" is waiting for a Revision to become ready.
|
||||
|
@ -186,15 +182,14 @@ Creating service 'helloworld-go' in namespace 'default':
|
|||
16.066s Waiting for load balancer to be ready
|
||||
16.237s Ready to serve.
|
||||
|
||||
Service 'helloworld-go' created to latest revision 'helloworld-go-jjzgd-1' is available at URL:
|
||||
http://helloworld-go.default.1.2.3.4.xip.io
|
||||
Service 'helloworld-go' created to latest revision 'helloworld-go-jjzgd-1' is available at URL: http://helloworld-go.default.1.2.3.4.xip.io
|
||||
```
|
||||
|
||||
You can then access your service through the resulting URL.
|
||||
1. You can then access your service through the resulting URL.
|
||||
|
||||
|
||||
|
||||
## Verifying
|
||||
## Verification
|
||||
|
||||
Now you can make a request to your app and see the result. Replace the following URL with the URL returned in the previous command.
|
||||
|
||||
|
@ -209,12 +204,12 @@ Hello Go Sample v1!
|
|||
|
||||
To remove the sample app from your cluster, delete the service record:
|
||||
|
||||
#### `kubectl`
|
||||
### kubectl
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
#### `kn`
|
||||
### kn
|
||||
```bash
|
||||
kn service delete helloworld-go
|
||||
```
|
||||
|
|
|
@ -73,13 +73,11 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-java
|
|||
|
||||
## Deploy
|
||||
|
||||
1. After the build has completed and the container is pushed to Docker Hub, you
|
||||
can deploy the app into your cluster. Choose one of the following methods:
|
||||
After the build has completed and the container is pushed to Docker Hub, you can deploy the app into your cluster. Choose one of the following methods:
|
||||
|
||||
### kn
|
||||
|
||||
=== "kn"
|
||||
|
||||
Use `kn` to deploy the service, make sure to replace `{username}` with your Docker Hub username:
|
||||
1. Use `kn` to deploy the service, make sure to replace `{username}` with your Docker Hub username:
|
||||
|
||||
```bash
|
||||
kn service create helloworld-java --image=docker.io/{username}/helloworld-java --env TARGET="SparkJava Sample v1"
|
||||
|
@ -88,11 +86,9 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-java
|
|||
This will wait until your service is deployed and ready, and ultimately it will print the URL through which you can access the service.
|
||||
|
||||
|
||||
=== "kubectl"
|
||||
### kubectl
|
||||
|
||||
1. Create a new file, `service.yaml` and copy the following service definition
|
||||
into the file. Make sure to replace `{username}` with your Docker Hub
|
||||
username.
|
||||
1. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub username.
|
||||
|
||||
```yaml
|
||||
apiVersion: serving.knative.dev/v1
|
||||
|
@ -116,10 +112,6 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-java
|
|||
kubectl apply --filename service.yaml
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
After your service is created, Knative will perform the following steps:
|
||||
|
||||
- Create a new immutable revision for this version of the app.
|
||||
|
@ -131,8 +123,7 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-java
|
|||
|
||||
1. Run one of the followings commands to find the domain URL for your service.
|
||||
|
||||
|
||||
=== "kn"
|
||||
### kn
|
||||
|
||||
```bash
|
||||
kn service describe helloworld-java -o url
|
||||
|
@ -144,7 +135,7 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-java
|
|||
http://helloworld-java.default.1.2.3.4.xip.io
|
||||
```
|
||||
|
||||
=== "kubectl"
|
||||
### kubectl
|
||||
```bash
|
||||
kubectl get ksvc helloworld-java --output=custom-columns=NAME:.metadata.name,URL:.status.url
|
||||
```
|
||||
|
@ -156,11 +147,7 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-java
|
|||
helloworld-java http://helloworld-java.default.1.2.3.4.xip.io
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1. Now you can make a request to your app and see the result. Replace
|
||||
2. Now you can make a request to your app and see the result. Replace
|
||||
the following URL with the URL returned in the previous command.
|
||||
|
||||
Example:
|
||||
|
@ -176,15 +163,14 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-java
|
|||
|
||||
## Delete
|
||||
|
||||
To remove the sample app from your cluster, delete the service record.
|
||||
To remove the sample app from your cluster, delete the service record:
|
||||
|
||||
|
||||
=== "kn"
|
||||
### kn
|
||||
```bash
|
||||
kn service delete helloworld-java
|
||||
```
|
||||
|
||||
=== "kubectl"
|
||||
### kubectl
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
|
|
@ -132,9 +132,9 @@ During the creation of a Service, Knative performs the following steps:
|
|||
- Network programming to create a Route, ingress, Service, and load balancer for your app.
|
||||
- Automatically scale your pods up and down, including scaling down to zero active pods.
|
||||
|
||||
To deploy the app:
|
||||
Choose one of the following methods to deploy the app:
|
||||
|
||||
### YAML
|
||||
### yaml
|
||||
|
||||
1. Create a new file named `service.yaml` and copy the following service definition
|
||||
into the file:
|
||||
|
@ -166,7 +166,7 @@ To deploy the app:
|
|||
|
||||
### kn
|
||||
|
||||
With `kn` you can deploy the service with
|
||||
1. With `kn` you can deploy the service with
|
||||
|
||||
```bash
|
||||
kn service create helloworld-java-spring --image=docker.io/{username}/helloworld-java-spring --env TARGET="Spring Boot Sample v1"
|
||||
|
@ -220,7 +220,7 @@ This will wait until your service is deployed and ready, and ultimately it will
|
|||
|
||||
## Deleting the app
|
||||
|
||||
To remove the sample app from your cluster, delete the service.
|
||||
To remove the sample app from your cluster, delete the service:
|
||||
|
||||
### kubectl
|
||||
```bash
|
||||
|
|
|
@ -88,15 +88,12 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-php
|
|||
|
||||
## Building and deploying the sample
|
||||
|
||||
Once you have recreated the sample code files (or used the files in the sample
|
||||
folder) you're ready to build and deploy the sample app.
|
||||
Once you have recreated the sample code files (or used the files in the sample folder) you're ready to build and deploy the sample app.
|
||||
|
||||
Choose one of the following methods:
|
||||
|
||||
=== "yaml"
|
||||
|
||||
1. Use Docker to build the sample code into a container. To build and push with
|
||||
Docker Hub, run these commands replacing `{username}` with your Docker Hub
|
||||
username:
|
||||
### yaml
|
||||
1. Use Docker to build the sample code into a container. To build and push with Docker Hub, run these commands replacing `{username}` with your Docker Hub username:
|
||||
|
||||
```bash
|
||||
# Build the container on your local machine
|
||||
|
@ -106,19 +103,14 @@ folder) you're ready to build and deploy the sample app.
|
|||
docker push {username}/helloworld-php
|
||||
```
|
||||
|
||||
1. After the build has completed and the container is pushed to docker hub, you
|
||||
can deploy the app into your cluster. Ensure that the container image value
|
||||
in `service.yaml` matches the container you built in the previous step. Apply
|
||||
the configuration using `kubectl`:
|
||||
1. After the build has completed and the container is pushed to docker hub, you can deploy the app into your cluster. Ensure that the container image value in `service.yaml` matches the container you built in the previous step. Apply the configuration using `kubectl`:
|
||||
|
||||
```bash
|
||||
kubectl apply --filename service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
|
||||
With `kn` you can deploy the service with
|
||||
### kn
|
||||
1. With `kn` you can deploy the service with
|
||||
|
||||
```bash
|
||||
kn service create helloworld-php --image=docker.io/{username}/helloworld-php --env TARGET="Ruby Sample v1"
|
||||
|
@ -127,10 +119,8 @@ folder) you're ready to build and deploy the sample app.
|
|||
This will wait until your service is deployed and ready, and ultimately it will print the URL through which you can access the service.
|
||||
|
||||
The output will look like:
|
||||
|
||||
```
|
||||
Creating service 'helloworld-php' in namespace 'default':
|
||||
|
||||
0.035s The Configuration is still working to reflect the latest desired specification.
|
||||
0.139s The Route is still working to reflect the latest desired specification.
|
||||
0.250s Configuration "helloworld-php" is waiting for a Revision to become ready.
|
||||
|
@ -138,49 +128,32 @@ folder) you're ready to build and deploy the sample app.
|
|||
8.136s Ingress has not yet been reconciled.
|
||||
8.277s unsuccessfully observed a new generation
|
||||
8.398s Ready to serve.
|
||||
|
||||
Service 'helloworld-php' created to latest revision 'helloworld-php-akhft-1' is available at URL:
|
||||
http://helloworld-php.default.1.2.3.4.xip.io
|
||||
Service 'helloworld-php' created to latest revision 'helloworld-php-akhft-1' is available at URL: http://helloworld-php.default.1.2.3.4.xip.io
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1. Now that your service is created, Knative will perform the following steps:
|
||||
Now that your service is created, Knative will perform the following steps:
|
||||
|
||||
- Create a new immutable revision for this version of the app.
|
||||
- Network programming to create a route, ingress, service, and a load balancer
|
||||
for your app.
|
||||
- Network programming to create a route, ingress, service, and a load balancer for your app.
|
||||
- Automatically scale your pods up and down (including to zero active pods).
|
||||
|
||||
1. To find the URL for your service, use
|
||||
|
||||
|
||||
=== "kubectl"
|
||||
|
||||
### kubectl
|
||||
```
|
||||
kubectl get ksvc helloworld-php --output=custom-columns=NAME:.metadata.name,URL:.status.url
|
||||
kubectl get ksvc helloworld-php --output=custom columns=NAME:.metadata.name,URL:.status.url
|
||||
NAME URL
|
||||
helloworld-php http://helloworld-php.default.1.2.3.4.xip.io
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
|
||||
### kn
|
||||
```bash
|
||||
kn service describe helloworld-php -o url
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
http://helloworld-php.default.1.2.3.4.xip.io
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
1. Now you can make a request to your app and see the result. Replace
|
||||
the following URL with the URL returned in the previous command.
|
||||
|
||||
|
@ -191,15 +164,14 @@ folder) you're ready to build and deploy the sample app.
|
|||
|
||||
## Removing the sample app deployment
|
||||
|
||||
To remove the sample app from your cluster, delete the service record.
|
||||
To remove the sample app from your cluster, delete the service record:
|
||||
|
||||
|
||||
=== "kubectl"
|
||||
### kubectl
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
=== "kn"
|
||||
### kn
|
||||
|
||||
```bash
|
||||
kn service delete helloworld-php
|
||||
|
|
|
@ -110,8 +110,9 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-python
|
|||
|
||||
## Deploying the app
|
||||
|
||||
After the build has completed and the container is pushed to Docker Hub, you
|
||||
can deploy the app into your cluster.
|
||||
After the build has completed and the container is pushed to Docker Hub, you can deploy the app into your cluster.
|
||||
|
||||
Choose one of the following methods to deploy the app:
|
||||
|
||||
### yaml
|
||||
|
||||
|
@ -135,7 +136,7 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-python
|
|||
value: "Python Sample v1"
|
||||
```
|
||||
|
||||
2. Ensure that the container image value in `service.yaml` matches the container
|
||||
1. Ensure that the container image value in `service.yaml` matches the container
|
||||
you built in the previous step. Apply the configuration using `kubectl`:
|
||||
|
||||
```bash
|
||||
|
@ -177,7 +178,6 @@ kubectl get ksvc helloworld-python --output=custom-columns=NAME:.metadata.name,
|
|||
```
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
NAME URL
|
||||
helloworld-python http://helloworld-python.default.1.2.3.4.sslip.io
|
||||
|
@ -190,15 +190,11 @@ kubectl get ksvc helloworld-python --output=custom-columns=NAME:.metadata.name,
|
|||
```
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
http://helloworld-python.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Now you can make a request to your app and see the result. Replace the following URL
|
||||
1. Now you can make a request to your app and see the result. Replace the following URL
|
||||
with the URL returned in the previous command.
|
||||
|
||||
Example:
|
||||
|
@ -215,7 +211,7 @@ curl $(kn service describe helloworld-python -o url)
|
|||
|
||||
## Removing
|
||||
|
||||
To remove the sample app from your cluster, delete the service record.
|
||||
To remove the sample app from your cluster, delete the service record:
|
||||
|
||||
### kubectl
|
||||
|
||||
|
|
|
@ -81,9 +81,7 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-ruby
|
|||
bundle install
|
||||
```
|
||||
|
||||
1. Create a new file, `service.yaml` and copy the following service definition
|
||||
into the file. Make sure to replace `{username}` with your Docker Hub
|
||||
username.
|
||||
1. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub username.
|
||||
|
||||
```yaml
|
||||
apiVersion: serving.knative.dev/v1
|
||||
|
@ -103,16 +101,13 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-ruby
|
|||
|
||||
## Deploying
|
||||
|
||||
1. After the build has completed and the container is pushed to Docker Hub, you
|
||||
can deploy the app into your cluster.
|
||||
After the build has completed and the container is pushed to Docker Hub, you can deploy the app into your cluster.
|
||||
|
||||
Choose one of the following methods to deploy the app:
|
||||
|
||||
=== "yaml"
|
||||
|
||||
1. Create a new file, `service.yaml` and copy the following service definition
|
||||
into the file. Make sure to replace `{username}` with your Docker Hub
|
||||
username.
|
||||
### yaml
|
||||
|
||||
* Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub username.
|
||||
```yaml
|
||||
apiVersion: serving.knative.dev/v1
|
||||
kind: Service
|
||||
|
@ -128,28 +123,19 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-ruby
|
|||
- name: TARGET
|
||||
value: "Ruby Sample v1"
|
||||
```
|
||||
|
||||
Ensure that the container image value
|
||||
in `service.yaml` matches the container you built in the previous step. Apply
|
||||
the configuration using `kubectl`:
|
||||
|
||||
Ensure that the container image value in `service.yaml` matches the container you built in the previous step.
|
||||
Apply the configuration using `kubectl`:
|
||||
```bash
|
||||
kubectl apply --filename service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
|
||||
With `kn` you can deploy the service with
|
||||
|
||||
### kn
|
||||
* With `kn` you can deploy the service with:
|
||||
```bash
|
||||
kn service create helloworld-ruby --image=docker.io/{username}/helloworld-ruby --env TARGET="Ruby Sample v1"
|
||||
```
|
||||
|
||||
This will wait until your service is deployed and ready, and ultimately it will print the URL through which you can access the service.
|
||||
|
||||
The output will look like:
|
||||
|
||||
```
|
||||
Creating service 'helloworld-ruby' in namespace 'default':
|
||||
|
||||
|
@ -165,10 +151,6 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-ruby
|
|||
http://helloworld-ruby.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
During the creation of your service, Knative performs the following steps:
|
||||
|
||||
- Create a new immutable revision for this version of the app.
|
||||
|
@ -180,37 +162,28 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-ruby
|
|||
|
||||
1. Run one of the followings commands to find the domain URL for your service.
|
||||
|
||||
|
||||
=== "kubectl"
|
||||
### kubectl
|
||||
```bash
|
||||
kubectl get ksvc helloworld-ruby --output=custom-columns=NAME:.metadata.name,URL:.status.url
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
NAME URL
|
||||
helloworld-ruby http://helloworld-ruby.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
|
||||
### kn
|
||||
```bash
|
||||
kn service describe helloworld-ruby -o url
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
http://helloworld-ruby.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
1. Now you can make a request to your app and see the result. Replace
|
||||
the following URL with the URL returned in the previous command.
|
||||
2. Now you can make a request to your app and see the result.
|
||||
Replace the following URL with the URL returned in the previous command.
|
||||
|
||||
Example:
|
||||
|
||||
|
@ -226,17 +199,14 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-ruby
|
|||
|
||||
## Removing
|
||||
|
||||
To remove the sample app from your cluster, delete the service record.
|
||||
|
||||
|
||||
=== "kubectl"
|
||||
To remove the sample app from your cluster, delete the service record:
|
||||
|
||||
### kubectl
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
=== "kn"
|
||||
|
||||
### kn
|
||||
```bash
|
||||
kn service delete helloworld-ruby
|
||||
```
|
||||
|
|
|
@ -102,7 +102,7 @@ local Docker Repository.
|
|||
## Deploying to Knative Serving
|
||||
|
||||
|
||||
=== "yaml"
|
||||
### yaml
|
||||
|
||||
Apply the [Service yaml definition](service.yaml):
|
||||
|
||||
|
@ -110,7 +110,7 @@ local Docker Repository.
|
|||
kubectl apply -f service.yaml
|
||||
```
|
||||
|
||||
=== "kn"
|
||||
### kn
|
||||
|
||||
With `kn` you can deploy the service with
|
||||
|
||||
|
@ -124,7 +124,6 @@ local Docker Repository.
|
|||
|
||||
```
|
||||
Creating service 'helloworld-scala' in namespace 'default':
|
||||
|
||||
0.035s The Configuration is still working to reflect the latest desired specification.
|
||||
0.139s The Route is still working to reflect the latest desired specification.
|
||||
0.250s Configuration "helloworld-scala" is waiting for a Revision to become ready.
|
||||
|
@ -137,28 +136,26 @@ local Docker Repository.
|
|||
http://helloworld-scala.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
=== "kubectl"
|
||||
|
||||
Then find the service host:
|
||||
### kubectl
|
||||
|
||||
1. Find the service host:
|
||||
```bash
|
||||
kubectl get ksvc helloworld-scala \
|
||||
--output=custom-columns=NAME:.metadata.name,URL:.status.url
|
||||
|
||||
# It will print something like this, the URL is what you're looking for.
|
||||
# NAME URL
|
||||
# helloworld-scala http://helloworld-scala.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
Finally, to try your service, use the obtained URL:
|
||||
2. Finally, to try your service, use the obtained URL:
|
||||
|
||||
```bash
|
||||
curl -v http://helloworld-scala.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
|
||||
### kn
|
||||
1. Find the service host:
|
||||
```bash
|
||||
kn service describe helloworld-scala -o url
|
||||
```
|
||||
|
@ -169,7 +166,7 @@ local Docker Repository.
|
|||
http://helloworld-scala.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
Finally, to try your service, use the obtained URL:
|
||||
2. Finally, to try your service, use the obtained URL:
|
||||
|
||||
```bash
|
||||
curl -v http://helloworld-scala.default.1.2.3.4.sslip.io
|
||||
|
@ -177,13 +174,13 @@ local Docker Repository.
|
|||
|
||||
## Cleanup
|
||||
|
||||
=== "kubectl"
|
||||
### kubectl
|
||||
|
||||
```bash
|
||||
kubectl delete -f service.yaml
|
||||
```
|
||||
|
||||
=== "kn"
|
||||
### kn
|
||||
|
||||
```bash
|
||||
kn service delete helloworld-scala
|
||||
|
|
|
@ -80,16 +80,12 @@ folder) you're ready to build and deploy the sample app.
|
|||
|
||||
## Deploying
|
||||
|
||||
1. After the build has completed and the container is pushed to Docker Hub, you
|
||||
can deploy the app into your cluster.
|
||||
After the build has completed and the container is pushed to Docker Hub, you can deploy the app into your cluster.
|
||||
|
||||
Choose one of the following methods to deploy the app:
|
||||
|
||||
=== "yaml"
|
||||
|
||||
1. Create a new file, `service.yaml` and copy the following service definition
|
||||
into the file. Make sure to replace `{username}` with your Docker Hub
|
||||
username.
|
||||
|
||||
### yaml
|
||||
1. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub username.
|
||||
```yaml
|
||||
apiVersion: serving.knative.dev/v1
|
||||
kind: Service
|
||||
|
@ -105,31 +101,22 @@ folder) you're ready to build and deploy the sample app.
|
|||
- name: TARGET
|
||||
value: "Shell Sample v1"
|
||||
```
|
||||
|
||||
Ensure that the container image value
|
||||
in `service.yaml` matches the container you built in the previous step. Apply
|
||||
the configuration using `kubectl`:
|
||||
|
||||
Ensure that the container image value in `service.yaml` matches the container you built in the previous step.
|
||||
1. Apply the configuration using `kubectl`:
|
||||
```bash
|
||||
kubectl apply --filename service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
|
||||
With `kn` you can deploy the service with
|
||||
|
||||
### kn
|
||||
1. With `kn` you can deploy the service with
|
||||
```bash
|
||||
kn service create helloworld-shell --image=docker.io/{username}/helloworld-shell --env TARGET="Shell Sample v1"
|
||||
```
|
||||
|
||||
This will wait until your service is deployed and ready, and ultimately it will print the URL through which you can access the service.
|
||||
|
||||
The output will look like:
|
||||
|
||||
```
|
||||
Creating service 'helloworld-shell' in namespace 'default':
|
||||
|
||||
0.035s The Configuration is still working to reflect the latest desired specification.
|
||||
0.139s The Route is still working to reflect the latest desired specification.
|
||||
0.250s Configuration "helloworld-shell" is waiting for a Revision to become ready.
|
||||
|
@ -142,10 +129,6 @@ folder) you're ready to build and deploy the sample app.
|
|||
http://helloworld-shell.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
During the creation of your service, Knative performs the following steps:
|
||||
|
||||
- Creates of a new immutable revision for this version of the app.
|
||||
|
@ -155,37 +138,27 @@ folder) you're ready to build and deploy the sample app.
|
|||
|
||||
## Verification
|
||||
|
||||
1. Run one of the followings commands to find the domain URL for your service.
|
||||
1. Run one of the followings commands to find the domain URL for your service:
|
||||
|
||||
|
||||
=== "kubectl"
|
||||
### kubectl
|
||||
```bash
|
||||
kubectl get ksvc helloworld-shell --output=custom-columns=NAME:.metadata.name,URL:.status.url
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
NAME URL
|
||||
helloworld-shell http://helloworld-shell.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
|
||||
### kn
|
||||
```bash
|
||||
kn service describe helloworld-shell -o url
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
http://helloworld-shell.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
1. Now you can make a request to your app and see the result. Replace
|
||||
the following URL with the URL returned in the previous command.
|
||||
|
||||
|
@ -203,15 +176,16 @@ folder) you're ready to build and deploy the sample app.
|
|||
|
||||
## Removing
|
||||
|
||||
To remove the sample app from your cluster, delete the service record.
|
||||
To remove the sample app from your cluster, delete the service record:
|
||||
|
||||
### kubectl
|
||||
|
||||
=== "kubectl"
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
=== "kn"
|
||||
### kn
|
||||
|
||||
```bash
|
||||
kn service delete helloworld-shell
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue