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,78 +47,50 @@ 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
|
||||
|
||||
* 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
|
||||
|
||||
* 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.
|
||||
|
||||
|
||||
=== "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:
|
||||
|
||||
```bash
|
||||
docker build -t <image> .
|
||||
docker push <image>
|
||||
```
|
||||
|
||||
|
||||
=== "ko"
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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:
|
||||
|
||||
```bash
|
||||
kubectl apply -f service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "yaml (with ko)"
|
||||
|
||||
If using `ko` to build and push:
|
||||
|
||||
```bash
|
||||
ko apply -f service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "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:
|
||||
|
||||
```bash
|
||||
kn service create cloudevents-go --image=$(ko publish github.com/knative/docs/code-samples/serving/cloudevents/cloudevents-go)
|
||||
```
|
||||
|
||||
3. 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:
|
||||
```bash
|
||||
kubectl apply -f service.yaml
|
||||
```
|
||||
|
||||
### yaml (with ko)
|
||||
* If using `ko` to build and push:
|
||||
```bash
|
||||
ko apply -f service.yaml
|
||||
```
|
||||
|
||||
### 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:
|
||||
```bash
|
||||
kn service create cloudevents-go --image=$(ko publish github.com/knative/docs/code-samples/serving/cloudevents/cloudevents-go)
|
||||
```
|
||||
|
||||
## Testing the sample
|
||||
|
||||
|
|
|
@ -51,32 +51,28 @@ of operation:
|
|||
## Build and Deploy the Application
|
||||
|
||||
In the `Dockerfile`, you can see how the dependencies are installed using npm.
|
||||
You can build and push this to your registry of choice via:
|
||||
You can build and push this to your registry of choice via:
|
||||
|
||||
```bash
|
||||
docker build -t <image> .
|
||||
docker push <image>
|
||||
```
|
||||
```bash
|
||||
docker build -t <image> .
|
||||
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"
|
||||
|
||||
To deploy using the `kn` CLI:
|
||||
|
||||
```bash
|
||||
kn service create cloudevents-nodejs --image=<image>
|
||||
```
|
||||
```bash
|
||||
kubectl apply -f service.yaml
|
||||
```
|
||||
|
||||
### kn
|
||||
|
||||
To deploy using the `kn` CLI:
|
||||
|
||||
```bash
|
||||
kn service create cloudevents-nodejs --image=<image>
|
||||
```
|
||||
|
||||
## Testing the sample
|
||||
|
||||
|
@ -111,18 +107,14 @@ You will get back:
|
|||
|
||||
To remove the sample app from your cluster, delete the service.
|
||||
|
||||
=== "yaml"
|
||||
### yaml
|
||||
|
||||
Run:
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
### kn
|
||||
|
||||
=== "kn"
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
kn service delete cloudevents-nodejs
|
||||
```
|
||||
```bash
|
||||
kn service delete cloudevents-nodejs
|
||||
```
|
||||
|
|
|
@ -49,43 +49,37 @@ This will build a statically linked binary, in order to create an image from scr
|
|||
```bash
|
||||
docker build -t <image> .
|
||||
```
|
||||
### 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
|
||||
```
|
||||
|
||||
|
||||
=== "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:
|
||||
|
||||
```bash
|
||||
kn service create cloudevents-rust --image=<image>
|
||||
```
|
||||
|
||||
|
||||
### kn
|
||||
|
||||
If using `kn` to deploy:
|
||||
|
||||
```bash
|
||||
kn service create cloudevents-rust --image=<image>
|
||||
```
|
||||
|
||||
## Testing the sample
|
||||
|
||||
Get the URL for your Service with:
|
||||
|
||||
```bash
|
||||
$ kubectl get ksvc
|
||||
NAME URL LATESTCREATED LATESTREADY READY REASON
|
||||
cloudevents-rust http://cloudevents-rust.sslip.io cloudevents-rust-vl8fq cloudevents-rust-vl8fq True
|
||||
```
|
||||
```bash
|
||||
$ kubectl get ksvc
|
||||
NAME URL LATESTCREATED LATESTREADY READY REASON
|
||||
cloudevents-rust http://cloudevents-rust.sslip.io cloudevents-rust-vl8fq cloudevents-rust-vl8fq True
|
||||
```
|
||||
|
||||
Then send a CloudEvent to it with:
|
||||
|
||||
```bash
|
||||
$ curl \
|
||||
```bash
|
||||
$ curl \
|
||||
-X POST -v \
|
||||
-H "content-type: application/json" \
|
||||
-H "ce-specversion: 1.0" \
|
||||
|
@ -94,11 +88,11 @@ $ curl \
|
|||
-H "ce-id: 123-abc" \
|
||||
-d '{"name":"Dave"}' \
|
||||
http://cloudevents-rust.sslip.io
|
||||
```
|
||||
```
|
||||
|
||||
You can also send CloudEvents spawning a temporary curl pod in your cluster with:
|
||||
|
||||
```bash
|
||||
```bash
|
||||
$ kubectl run curl \
|
||||
--image=curlimages/curl --rm=true --restart=Never -ti -- \
|
||||
-X POST -v \
|
||||
|
@ -109,11 +103,11 @@ $ kubectl run curl \
|
|||
-H "ce-id: 123-abc" \
|
||||
-d '{"name":"Dave"}' \
|
||||
http://cloudevents-rust.default.svc
|
||||
```
|
||||
```
|
||||
|
||||
You'll get as result:
|
||||
|
||||
```bash
|
||||
```bash
|
||||
> POST / HTTP/1.1
|
||||
> Host: localhost:8080
|
||||
> User-Agent: curl/7.69.1
|
||||
|
@ -135,26 +129,20 @@ You'll get as result:
|
|||
< date: Sat, 23 May 2020 09:00:01 GMT
|
||||
<
|
||||
{"name":"Dave"}
|
||||
```
|
||||
```
|
||||
|
||||
## 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
|
||||
|
||||
=== "yaml"
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
Run:
|
||||
### kn
|
||||
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
kn service delete cloudevents-rust
|
||||
```
|
||||
```bash
|
||||
kn service delete cloudevents-rust
|
||||
```
|
||||
|
|
|
@ -125,20 +125,15 @@ kubectl delete --filename service.yaml
|
|||
|
||||
To remove the sample app from your cluster, delete the service:
|
||||
|
||||
### yaml
|
||||
|
||||
=== "yaml"
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
### kn
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
kn service delete cloudevents-spring
|
||||
```
|
||||
```bash
|
||||
kn service delete cloudevents-spring
|
||||
```
|
||||
|
|
|
@ -35,33 +35,23 @@ 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:
|
||||
```bash
|
||||
kubectl apply -f service.yaml
|
||||
```
|
||||
|
||||
=== "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:
|
||||
|
||||
```bash
|
||||
kn service create cloudevents-vertx --image=<image>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
### kn
|
||||
* If using `kn` to deploy:
|
||||
```bash
|
||||
kn service create cloudevents-vertx --image=<image>
|
||||
```
|
||||
|
||||
## Testing the sample
|
||||
|
||||
|
@ -132,20 +122,14 @@ You'll see on the console:
|
|||
|
||||
To remove the sample app from your cluster, delete the service:
|
||||
|
||||
### yaml
|
||||
|
||||
=== "yaml"
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
Run:
|
||||
### kn
|
||||
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
kn service delete cloudevents-vertx
|
||||
```
|
||||
```bash
|
||||
kn service delete cloudevents-vertx
|
||||
```
|
||||
|
|
|
@ -116,85 +116,80 @@ 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:
|
||||
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
|
||||
kind: Service
|
||||
metadata:
|
||||
name: helloworld-go
|
||||
namespace: default
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/{username}/helloworld-go
|
||||
env:
|
||||
- name: TARGET
|
||||
value: "Go Sample v1"
|
||||
```
|
||||
```yaml
|
||||
apiVersion: serving.knative.dev/v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: helloworld-go
|
||||
namespace: default
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/{username}/helloworld-go
|
||||
env:
|
||||
- name: TARGET
|
||||
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`:
|
||||
|
||||
```bash
|
||||
kubectl apply --filename service.yaml
|
||||
```
|
||||
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.
|
||||
- Automatically scale your pods up and down (including to zero active pods).
|
||||
|
||||
- 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.
|
||||
- Automatically scale your pods up and down (including to zero active pods).
|
||||
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
|
||||
```
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
Example:
|
||||
```bash
|
||||
NAME URL
|
||||
helloworld-go http://helloworld-go.default.1.2.3.4.xip.io
|
||||
```
|
||||
Example:
|
||||
```bash
|
||||
NAME URL
|
||||
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"
|
||||
```
|
||||
|
||||
You should see output like this:
|
||||
```bash
|
||||
Creating service 'helloworld-go' in namespace 'default':
|
||||
```bash
|
||||
kn service create helloworld-go --image=docker.io/{username}/helloworld-go --env TARGET="Go Sample v1"
|
||||
```
|
||||
|
||||
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.
|
||||
15.694s ...
|
||||
15.738s Ingress has not yet been reconciled.
|
||||
15.784s Waiting for Envoys to receive Endpoints data.
|
||||
16.066s Waiting for load balancer to be ready
|
||||
16.237s Ready to serve.
|
||||
15.694s ...
|
||||
15.738s Ingress has not yet been reconciled.
|
||||
15.784s Waiting for Envoys to receive Endpoints data.
|
||||
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.
|
||||
|
||||
|
@ -203,18 +198,18 @@ curl http://helloworld-go.default.1.2.3.4.sslip.io
|
|||
Hello Go Sample v1!
|
||||
```
|
||||
|
||||
> Note: Add `-v` option to get more detail if the `curl` command failed.
|
||||
> Note: Add `-v` option to get more detail if the `curl` command failed.
|
||||
|
||||
## Removing
|
||||
|
||||
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,54 +73,46 @@ 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"
|
||||
1. Use `kn` to deploy the service, make sure to replace `{username}` with your Docker Hub username:
|
||||
|
||||
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"
|
||||
```
|
||||
```bash
|
||||
kn service create helloworld-java --image=docker.io/{username}/helloworld-java --env TARGET="SparkJava 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.
|
||||
|
||||
|
||||
=== "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
|
||||
kind: Service
|
||||
metadata:
|
||||
name: helloworld-java
|
||||
namespace: default
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/{username}/helloworld-java
|
||||
env:
|
||||
- name: TARGET
|
||||
value: "SparkJava Sample v1"
|
||||
```
|
||||
```yaml
|
||||
apiVersion: serving.knative.dev/v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: helloworld-java
|
||||
namespace: default
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/{username}/helloworld-java
|
||||
env:
|
||||
- name: TARGET
|
||||
value: "SparkJava Sample v1"
|
||||
```
|
||||
|
||||
1. Ensure that the container image value in `service.yaml` matches the container you built in the previous step. Apply the configuration using `kubectl`:
|
||||
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
|
||||
kubectl apply --filename service.yaml
|
||||
```
|
||||
```bash
|
||||
kubectl apply --filename service.yaml
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
After your service is created, Knative will perform the following steps:
|
||||
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
|
||||
|
@ -129,62 +121,56 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-java
|
|||
|
||||
## Verify
|
||||
|
||||
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.
|
||||
|
||||
### kn
|
||||
|
||||
=== "kn"
|
||||
```bash
|
||||
kn service describe helloworld-java -o url
|
||||
```
|
||||
|
||||
```bash
|
||||
kn service describe helloworld-java -o url
|
||||
```
|
||||
Example:
|
||||
|
||||
Example:
|
||||
```bash
|
||||
http://helloworld-java.default.1.2.3.4.xip.io
|
||||
```
|
||||
|
||||
```bash
|
||||
http://helloworld-java.default.1.2.3.4.xip.io
|
||||
```
|
||||
### kubectl
|
||||
```bash
|
||||
kubectl get ksvc helloworld-java --output=custom-columns=NAME:.metadata.name,URL:.status.url
|
||||
```
|
||||
|
||||
=== "kubectl"
|
||||
```bash
|
||||
kubectl get ksvc helloworld-java --output=custom-columns=NAME:.metadata.name,URL:.status.url
|
||||
```
|
||||
Example:
|
||||
|
||||
Example:
|
||||
```bash
|
||||
NAME URL
|
||||
helloworld-java http://helloworld-java.default.1.2.3.4.xip.io
|
||||
```
|
||||
|
||||
```bash
|
||||
NAME URL
|
||||
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:
|
||||
Example:
|
||||
|
||||
```bash
|
||||
curl http://helloworld-java.default.1.2.3.4.sslip.io
|
||||
Hello SparkJava Sample v1!
|
||||
# Even easier with kn:
|
||||
curl $(kn service describe helloworld-java -o url)
|
||||
```
|
||||
```bash
|
||||
curl http://helloworld-java.default.1.2.3.4.sslip.io
|
||||
Hello SparkJava Sample v1!
|
||||
# Even easier with kn:
|
||||
curl $(kn service describe helloworld-java -o url)
|
||||
```
|
||||
|
||||
> Note: Add `-v` option to get more detail if the `curl` command failed.
|
||||
|
||||
## 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
|
||||
```bash
|
||||
kn service delete helloworld-java
|
||||
```
|
||||
|
||||
=== "kn"
|
||||
```bash
|
||||
kn service delete helloworld-java
|
||||
```
|
||||
|
||||
=== "kubectl"
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
### 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,13 +166,13 @@ 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"
|
||||
```
|
||||
```bash
|
||||
kn service create helloworld-java-spring --image=docker.io/{username}/helloworld-java-spring --env TARGET="Spring Boot 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.
|
||||
This will wait until your service is deployed and ready, and ultimately it will print the URL through which you can access the service.
|
||||
|
||||
## Verification
|
||||
|
||||
|
@ -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,119 +88,91 @@ 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"
|
||||
### 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:
|
||||
|
||||
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
|
||||
docker build -t {username}/helloworld-php .
|
||||
|
||||
```bash
|
||||
# Build the container on your local machine
|
||||
docker build -t {username}/helloworld-php .
|
||||
# Push the container to docker registry
|
||||
docker push {username}/helloworld-php
|
||||
```
|
||||
|
||||
# Push the container to docker registry
|
||||
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
|
||||
```
|
||||
|
||||
```bash
|
||||
kubectl apply --filename service.yaml
|
||||
```
|
||||
### 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"
|
||||
```
|
||||
|
||||
=== "kn"
|
||||
This will wait until your service is deployed and ready, and ultimately it will print the URL through which you can access the service.
|
||||
|
||||
With `kn` you can deploy the service with
|
||||
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.
|
||||
8.040s ...
|
||||
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
|
||||
```
|
||||
|
||||
```bash
|
||||
kn service create helloworld-php --image=docker.io/{username}/helloworld-php --env TARGET="Ruby Sample v1"
|
||||
```
|
||||
Now that your service is created, Knative will perform the following steps:
|
||||
|
||||
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.
|
||||
8.040s ...
|
||||
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
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1. 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.
|
||||
- Automatically scale your pods up and down (including to zero active pods).
|
||||
- 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.
|
||||
- Automatically scale your pods up and down (including to zero active pods).
|
||||
|
||||
1. To find the URL for your service, use
|
||||
|
||||
### kubectl
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
=== "kubectl"
|
||||
|
||||
```
|
||||
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"
|
||||
|
||||
```bash
|
||||
kn service describe helloworld-php -o url
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
http://helloworld-php.default.1.2.3.4.xip.io
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
```bash
|
||||
curl http://helloworld-php.default.1.2.3.4.sslip.io
|
||||
Hello PHP Sample v1!
|
||||
```
|
||||
```bash
|
||||
curl http://helloworld-php.default.1.2.3.4.sslip.io
|
||||
Hello PHP Sample v1!
|
||||
```
|
||||
|
||||
## 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
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
=== "kubectl"
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
### kn
|
||||
|
||||
=== "kn"
|
||||
|
||||
```bash
|
||||
kn service delete helloworld-php
|
||||
```
|
||||
```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
|
||||
|
@ -166,56 +167,51 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-python
|
|||
|
||||
## 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.
|
||||
> Note: If your URL includes `example.com` then consult the setup instructions for
|
||||
> configuring DNS (e.g. with `sslip.io`), or [using a Custom Domain](https://knative.dev/docs/serving/using-a-custom-domain).
|
||||
|
||||
### kubectl
|
||||
### kubectl
|
||||
|
||||
```bash
|
||||
kubectl get ksvc helloworld-python --output=custom-columns=NAME:.metadata.name,URL:.status.url
|
||||
```
|
||||
|
||||
Example:
|
||||
```bash
|
||||
kubectl get ksvc helloworld-python --output=custom-columns=NAME:.metadata.name,URL:.status.url
|
||||
```
|
||||
|
||||
Example:
|
||||
```bash
|
||||
NAME URL
|
||||
helloworld-python http://helloworld-python.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
### kn
|
||||
### kn
|
||||
|
||||
```bash
|
||||
kn service describe helloworld-python -o url
|
||||
```
|
||||
```bash
|
||||
kn service describe helloworld-python -o url
|
||||
```
|
||||
|
||||
Example:
|
||||
```bash
|
||||
http://helloworld-python.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
```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:
|
||||
|
||||
```bash
|
||||
curl http://helloworld-python.default.1.2.3.4.sslip.io
|
||||
Hello Python Sample v1!
|
||||
```bash
|
||||
curl http://helloworld-python.default.1.2.3.4.sslip.io
|
||||
Hello Python Sample v1!
|
||||
|
||||
# Even easier with kn:
|
||||
curl $(kn service describe helloworld-python -o url)
|
||||
```
|
||||
# Even easier with kn:
|
||||
curl $(kn service describe helloworld-python -o url)
|
||||
```
|
||||
|
||||
> Note: Add `-v` option to get more detail if the `curl` command failed.
|
||||
|
||||
## 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,39 +81,34 @@ 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
|
||||
kind: Service
|
||||
metadata:
|
||||
name: helloworld-ruby
|
||||
namespace: default
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/{username}/helloworld-ruby
|
||||
env:
|
||||
- name: TARGET
|
||||
value: "Ruby Sample v1"
|
||||
```
|
||||
```yaml
|
||||
apiVersion: serving.knative.dev/v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: helloworld-ruby
|
||||
namespace: default
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/{username}/helloworld-ruby
|
||||
env:
|
||||
- name: TARGET
|
||||
value: "Ruby Sample v1"
|
||||
```
|
||||
|
||||
## 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"
|
||||
### 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
|
||||
metadata:
|
||||
|
@ -127,30 +122,21 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-ruby
|
|||
env:
|
||||
- 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`:
|
||||
```bash
|
||||
kubectl apply --filename service.yaml
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
```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:
|
||||
|
||||
```
|
||||
### 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':
|
||||
|
||||
0.035s The Configuration is still working to reflect the latest desired specification.
|
||||
|
@ -163,13 +149,9 @@ cd knative-docs/code-samples/serving/hello-world/helloworld-ruby
|
|||
|
||||
Service 'helloworld-ruby' created to latest revision 'helloworld-ruby-akhft-1' is available at URL:
|
||||
http://helloworld-ruby.default.1.2.3.4.sslip.io
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
During the creation of your service, Knative performs the following steps:
|
||||
During the creation of your service, Knative performs 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
|
||||
|
@ -180,39 +162,30 @@ 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
|
||||
```bash
|
||||
kubectl get ksvc helloworld-ruby --output=custom-columns=NAME:.metadata.name,URL:.status.url
|
||||
```
|
||||
|
||||
=== "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
|
||||
```
|
||||
|
||||
Example:
|
||||
### kn
|
||||
```bash
|
||||
kn service describe helloworld-ruby -o url
|
||||
```
|
||||
Example:
|
||||
```bash
|
||||
http://helloworld-ruby.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
```bash
|
||||
NAME URL
|
||||
helloworld-ruby http://helloworld-ruby.default.1.2.3.4.sslip.io
|
||||
```
|
||||
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.
|
||||
|
||||
|
||||
=== "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.
|
||||
|
||||
Example:
|
||||
Example:
|
||||
|
||||
```bash
|
||||
curl http://helloworld-ruby.default.1.2.3.4.sslip.io
|
||||
|
@ -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.
|
||||
To remove the sample app from your cluster, delete the service record:
|
||||
|
||||
### kubectl
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
=== "kubectl"
|
||||
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
=== "kn"
|
||||
|
||||
```bash
|
||||
kn service delete helloworld-ruby
|
||||
```
|
||||
### kn
|
||||
```bash
|
||||
kn service delete helloworld-ruby
|
||||
```
|
||||
|
|
|
@ -102,89 +102,86 @@ local Docker Repository.
|
|||
## Deploying to Knative Serving
|
||||
|
||||
|
||||
=== "yaml"
|
||||
### yaml
|
||||
|
||||
Apply the [Service yaml definition](service.yaml):
|
||||
Apply the [Service yaml definition](service.yaml):
|
||||
|
||||
```bash
|
||||
kubectl apply -f service.yaml
|
||||
```
|
||||
```bash
|
||||
kubectl apply -f service.yaml
|
||||
```
|
||||
|
||||
=== "kn"
|
||||
### kn
|
||||
|
||||
With `kn` you can deploy the service with
|
||||
With `kn` you can deploy the service with
|
||||
|
||||
```bash
|
||||
kn service create helloworld-scala --image=docker.io/{username}/helloworld-scala --env TARGET="Scala Sample v1"
|
||||
```
|
||||
```bash
|
||||
kn service create helloworld-scala --image=docker.io/{username}/helloworld-scala --env TARGET="Scala 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.
|
||||
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:
|
||||
The output will look like:
|
||||
|
||||
```
|
||||
Creating service 'helloworld-scala' in namespace 'default':
|
||||
```
|
||||
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.
|
||||
8.040s ...
|
||||
8.136s Ingress has not yet been reconciled.
|
||||
8.277s unsuccessfully observed a new generation
|
||||
8.398s Ready to serve.
|
||||
|
||||
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.
|
||||
8.040s ...
|
||||
8.136s Ingress has not yet been reconciled.
|
||||
8.277s unsuccessfully observed a new generation
|
||||
8.398s Ready to serve.
|
||||
Service 'helloworld-scala' created to latest revision 'helloworld-scala-abcd-1' is available at URL:
|
||||
http://helloworld-scala.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
Service 'helloworld-scala' created to latest revision 'helloworld-scala-abcd-1' is available at URL:
|
||||
http://helloworld-scala.default.1.2.3.4.sslip.io
|
||||
```
|
||||
### kubectl
|
||||
|
||||
=== "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
|
||||
```
|
||||
|
||||
Then find the service host:
|
||||
2. Finally, to try your service, use the obtained URL:
|
||||
|
||||
```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:
|
||||
|
||||
```bash
|
||||
curl -v http://helloworld-scala.default.1.2.3.4.sslip.io
|
||||
```
|
||||
```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
|
||||
```
|
||||
|
||||
```bash
|
||||
kn service describe helloworld-scala -o url
|
||||
```
|
||||
Example:
|
||||
|
||||
Example:
|
||||
```bash
|
||||
http://helloworld-scala.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
```bash
|
||||
http://helloworld-scala.default.1.2.3.4.sslip.io
|
||||
```
|
||||
2. Finally, to try your service, use the obtained URL:
|
||||
|
||||
Finally, to try your service, use the obtained URL:
|
||||
|
||||
```bash
|
||||
curl -v http://helloworld-scala.default.1.2.3.4.sslip.io
|
||||
```
|
||||
```bash
|
||||
curl -v http://helloworld-scala.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
## Cleanup
|
||||
|
||||
=== "kubectl"
|
||||
### kubectl
|
||||
|
||||
```bash
|
||||
kubectl delete -f service.yaml
|
||||
```
|
||||
```bash
|
||||
kubectl delete -f service.yaml
|
||||
```
|
||||
|
||||
=== "kn"
|
||||
### kn
|
||||
|
||||
```bash
|
||||
kn service delete helloworld-scala
|
||||
```
|
||||
```bash
|
||||
kn service delete helloworld-scala
|
||||
```
|
||||
|
|
|
@ -80,73 +80,56 @@ 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"
|
||||
### 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
|
||||
metadata:
|
||||
name: helloworld-shell
|
||||
namespace: default
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/{username}/helloworld-shell
|
||||
env:
|
||||
- name: TARGET
|
||||
value: "Shell Sample v1"
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
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.
|
||||
### 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:
|
||||
|
||||
```yaml
|
||||
apiVersion: serving.knative.dev/v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: helloworld-shell
|
||||
namespace: default
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: docker.io/{username}/helloworld-shell
|
||||
env:
|
||||
- name: TARGET
|
||||
value: "Shell Sample v1"
|
||||
```
|
||||
```
|
||||
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.
|
||||
8.040s ...
|
||||
8.136s Ingress has not yet been reconciled.
|
||||
8.277s unsuccessfully observed a new generation
|
||||
8.398s Ready to serve.
|
||||
|
||||
Ensure that the container image value
|
||||
in `service.yaml` matches the container you built in the previous step. Apply
|
||||
the configuration using `kubectl`:
|
||||
Service 'helloworld-shell' created to latest revision 'helloworld-shell-kwdpt-1' is available at URL:
|
||||
http://helloworld-shell.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
```bash
|
||||
kubectl apply --filename service.yaml
|
||||
```
|
||||
|
||||
|
||||
=== "kn"
|
||||
|
||||
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.
|
||||
8.040s ...
|
||||
8.136s Ingress has not yet been reconciled.
|
||||
8.277s unsuccessfully observed a new generation
|
||||
8.398s Ready to serve.
|
||||
|
||||
Service 'helloworld-shell' created to latest revision 'helloworld-shell-kwdpt-1' is available at URL:
|
||||
http://helloworld-shell.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
During the creation of your service, Knative performs the following steps:
|
||||
During the creation of your service, Knative performs the following steps:
|
||||
|
||||
- Creates of a new immutable revision for this version of the app.
|
||||
- Programs the network to create a route, ingress, service, and load balance
|
||||
|
@ -155,36 +138,26 @@ 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.
|
||||
|
||||
|
||||
=== "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"
|
||||
|
||||
```bash
|
||||
kn service describe helloworld-shell -o url
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
http://helloworld-shell.default.1.2.3.4.sslip.io
|
||||
```
|
||||
|
||||
1. Run one of the followings commands to find the domain URL for your service:
|
||||
|
||||
### 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
|
||||
```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
|
||||
```
|
||||
```bash
|
||||
kubectl delete --filename service.yaml
|
||||
```
|
||||
|
||||
=== "kn"
|
||||
```bash
|
||||
kn service delete helloworld-shell
|
||||
```
|
||||
### kn
|
||||
|
||||
```bash
|
||||
kn service delete helloworld-shell
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue