mirror of https://github.com/knative/docs.git
Format markdown (#914)
Produced via: `prettier --write --prose-wrap=always $(find -name '*.md' | grep -v vendor | grep -v .github)`
This commit is contained in:
parent
133f43ede9
commit
1ed88cadd7
|
@ -16,15 +16,15 @@ commands will need to be adjusted for use in a Windows environment.
|
||||||
|
|
||||||
## Installing Glooctl
|
## Installing Glooctl
|
||||||
|
|
||||||
This installation method for Knative depends on Gloo. Run the following
|
This installation method for Knative depends on Gloo. Run the following to
|
||||||
to install `glooctl`, the Gloo command line.
|
install `glooctl`, the Gloo command line.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
curl -sL https://run.solo.io/gloo/install | sh
|
curl -sL https://run.solo.io/gloo/install | sh
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternatively, you can download the Gloo CLI directly via
|
Alternatively, you can download the Gloo CLI directly via
|
||||||
[the github releases](https://github.com/solo-io/gloo/releases) page.
|
[the github releases](https://github.com/solo-io/gloo/releases) page.
|
||||||
|
|
||||||
Next, add `glooctl` to your path with:
|
Next, add `glooctl` to your path with:
|
||||||
|
|
||||||
|
@ -46,10 +46,9 @@ Finally, install Gloo and Knative in a single command with `glooctl`:
|
||||||
glooctl install knative
|
glooctl install knative
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note: To see the content of the kubernetes manifest glooctl installs, run
|
> Note: To see the content of the kubernetes manifest glooctl installs, run
|
||||||
> `glooctl install knative --dry-run`.
|
> `glooctl install knative --dry-run`. Monitor the Gloo components until all of
|
||||||
Monitor the Gloo components until all of the components show a `STATUS` of
|
> the components show a `STATUS` of `Running` or `Completed`:
|
||||||
`Running` or `Completed`:
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get pods --namespace gloo-system
|
kubectl get pods --namespace gloo-system
|
||||||
|
@ -74,10 +73,10 @@ To deploy your first app with Knative, follow the step-by-step
|
||||||
[Getting Started with Knative App Deployment](getting-started-knative-app.md)
|
[Getting Started with Knative App Deployment](getting-started-knative-app.md)
|
||||||
guide.
|
guide.
|
||||||
|
|
||||||
Note that when you've finished deploying the app, you'll need to connect to the Gloo
|
Note that when you've finished deploying the app, you'll need to connect to the
|
||||||
Gateway rather than the Istio Gateway.
|
Gloo Gateway rather than the Istio Gateway.
|
||||||
|
|
||||||
To get the URL of the Gloo Gateway, run
|
To get the URL of the Gloo Gateway, run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export GATEWAY_URL=$(glooctl proxy url --name clusteringress-proxy)
|
export GATEWAY_URL=$(glooctl proxy url --name clusteringress-proxy)
|
||||||
|
@ -94,13 +93,14 @@ export GATEWAY_URL=$(glooctl proxy url --name clusteringress-proxy)
|
||||||
curl -H "Host: helloworld-go.myproject.example.com" $GATEWAY_URL
|
curl -H "Host: helloworld-go.myproject.example.com" $GATEWAY_URL
|
||||||
```
|
```
|
||||||
|
|
||||||
The full instructions for the [Go Hello-World Sample](../serving/samples/helloworld-go) with
|
The full instructions for the
|
||||||
this substitution are published bellow:
|
[Go Hello-World Sample](../serving/samples/helloworld-go) with this substitution
|
||||||
|
are published bellow:
|
||||||
|
|
||||||
### Deploy the Hello-World Go App:
|
### Deploy the Hello-World Go App:
|
||||||
|
|
||||||
Create a new file named `helloworld.go` and paste the following code. This code creates a basic web server which listens on port 8080:
|
Create a new file named `helloworld.go` and paste the following code. This code
|
||||||
|
creates a basic web server which listens on port 8080:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package main
|
package main
|
||||||
|
@ -133,8 +133,8 @@ func main() {
|
||||||
|
|
||||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
In your project directory, create a file named `Dockerfile` and copy the code
|
In your project directory, create a file named `Dockerfile` and copy the code
|
||||||
block below into it. For detailed instructions on dockerizing a Go app, see
|
block below into it. For detailed instructions on dockerizing a Go app, see
|
||||||
[Deploying Go servers with Docker](https://blog.golang.org/docker).
|
[Deploying Go servers with Docker](https://blog.golang.org/docker).
|
||||||
|
@ -167,11 +167,10 @@ ENV PORT 8080
|
||||||
|
|
||||||
# Run the web service on container startup.
|
# Run the web service on container startup.
|
||||||
CMD ["/helloworld"]
|
CMD ["/helloworld"]
|
||||||
```
|
```
|
||||||
|
|
||||||
Create a new file, `service.yaml` and copy the following service definition
|
Create a new file, `service.yaml` and copy the following service definition into
|
||||||
into the file. Make sure to replace `{username}` with your Docker Hub
|
the file. Make sure to replace `{username}` with your Docker Hub username.
|
||||||
username.
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: serving.knative.dev/v1alpha1
|
apiVersion: serving.knative.dev/v1alpha1
|
||||||
|
@ -189,7 +188,7 @@ spec:
|
||||||
env:
|
env:
|
||||||
- name: TARGET
|
- name: TARGET
|
||||||
value: "Go Sample v1"
|
value: "Go Sample v1"
|
||||||
```
|
```
|
||||||
|
|
||||||
Once the sample code has been created, we'll build and deploy it
|
Once the sample code has been created, we'll build and deploy it
|
||||||
|
|
||||||
|
@ -203,26 +202,27 @@ docker build -t {username}/helloworld-go .
|
||||||
|
|
||||||
# Push the container to docker registry
|
# Push the container to docker registry
|
||||||
docker push {username}/helloworld-go
|
docker push {username}/helloworld-go
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
After the build has completed and the container is pushed to docker hub, you
|
After the build has completed and the container is pushed to docker hub, you can
|
||||||
can deploy the app into your cluster. Ensure that the container image value
|
deploy the app into your cluster. Ensure that the container image value in
|
||||||
in `service.yaml` matches the container you built in the previous step. Apply
|
`service.yaml` matches the container you built in the previous step. Apply the
|
||||||
the configuration using `kubectl`:
|
configuration using `kubectl`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl apply --filename service.yaml
|
kubectl apply --filename service.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
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 load balance
|
- Create a new immutable revision for this version of the app.
|
||||||
for your app.
|
- Network programming to create a route, ingress, service, and load balance for
|
||||||
- Automatically scale your pods up and down (including to zero active pods).
|
your app.
|
||||||
|
- Automatically scale your pods up and down (including to zero active pods).
|
||||||
- Run the following command to find the external IP address for the Gloo cluster ingress.
|
|
||||||
|
- Run the following command to find the external IP address for the Gloo cluster
|
||||||
|
ingress.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
CLUSTERINGRESS_URL=$(glooctl proxy url --name clusteringress-proxy)
|
CLUSTERINGRESS_URL=$(glooctl proxy url --name clusteringress-proxy)
|
||||||
echo $CLUSTERINGRESS_URL
|
echo $CLUSTERINGRESS_URL
|
||||||
|
@ -233,7 +233,7 @@ Run the following command to find the domain URL for your service:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl get ksvc helloworld-go -n default --output=custom-columns=NAME:.metadata.name,DOMAIN:.status.domain
|
kubectl get ksvc helloworld-go -n default --output=custom-columns=NAME:.metadata.name,DOMAIN:.status.domain
|
||||||
````
|
```
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -242,22 +242,23 @@ NAME DOMAIN
|
||||||
helloworld-go helloworld-go.default.example.com
|
helloworld-go helloworld-go.default.example.com
|
||||||
```
|
```
|
||||||
|
|
||||||
Test your app by sending it a request. Use the following `curl` command with
|
Test your app by sending it a request. Use the following `curl` command with the
|
||||||
the domain URL `helloworld-go.default.example.com` and `EXTERNAL-IP` address
|
domain URL `helloworld-go.default.example.com` and `EXTERNAL-IP` address that
|
||||||
that you retrieved in the previous steps:
|
you retrieved in the previous steps:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -H "Host: helloworld-go.default.example.com" ${CLUSTERINGRESS_URL}
|
curl -H "Host: helloworld-go.default.example.com" ${CLUSTERINGRESS_URL}
|
||||||
Hello Go Sample v1!
|
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 the sample app deployment
|
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:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl delete --filename service.yaml
|
kubectl delete --filename service.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
Great! our Knative ingress is up and running. See https://github.com/knative/docs for more information on using Knative.
|
Great! our Knative ingress is up and running. See
|
||||||
|
https://github.com/knative/docs for more information on using Knative.
|
||||||
|
|
|
@ -20,20 +20,26 @@ clusters.
|
||||||
|
|
||||||
## Installing Knative
|
## Installing Knative
|
||||||
|
|
||||||
Knative depends on an Ingress/Gateway which is capable of routing requests to Knative Services.
|
Knative depends on an Ingress/Gateway which is capable of routing requests to
|
||||||
|
Knative Services.
|
||||||
|
|
||||||
Currently, two options exist which provide this functionality:
|
Currently, two options exist which provide this functionality:
|
||||||
[Istio](https://istio.io/), the Envoy-based Service Mesh, and [Gloo](https://gloo.solo.io/), the Envoy-based API Gateway.
|
[Istio](https://istio.io/), the Envoy-based Service Mesh, and
|
||||||
|
[Gloo](https://gloo.solo.io/), the Envoy-based API Gateway.
|
||||||
|
|
||||||
## Installing Knative with Gloo
|
## Installing Knative with Gloo
|
||||||
|
|
||||||
[Install with Gloo](Knative-with-Gloo.md): Gloo functions as a lightweight gateway for Knative. Choose this option if you don't require service mesh in your cluster and want a lighter-weight alternative to Istio. Note that *the Knative Eventing component*
|
[Install with Gloo](Knative-with-Gloo.md): Gloo functions as a lightweight
|
||||||
is not supported by Gloo at this time.
|
gateway for Knative. Choose this option if you don't require service mesh in
|
||||||
|
your cluster and want a lighter-weight alternative to Istio. Note that _the
|
||||||
|
Knative Eventing component_ is not supported by Gloo at this time.
|
||||||
|
|
||||||
## Installing Knative with Istio
|
## Installing Knative with Istio
|
||||||
|
|
||||||
Istio is a popular service mesh that includes a Knative-compatiblle
|
Istio is a popular service mesh that includes a Knative-compatiblle ingress.
|
||||||
ingress. Choose this option if you wish to use Istio service mesh features. You will also need to choose this installation option if you wish to use the Knative Eventing component, which currently depends on Istio.
|
Choose this option if you wish to use Istio service mesh features. You will also
|
||||||
|
need to choose this installation option if you wish to use the Knative Eventing
|
||||||
|
component, which currently depends on Istio.
|
||||||
|
|
||||||
There are several options when installing Knative:
|
There are several options when installing Knative:
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,8 @@ export SERVICE_HOST=`kubectl get route grpc-ping --output jsonpath="{.status.dom
|
||||||
export SERVICE_IP=`kubectl get svc istio-ingressgateway --namespace istio-system --output jsonpath="{.status.loadBalancer.ingress[*].ip}"`
|
export SERVICE_IP=`kubectl get svc istio-ingressgateway --namespace istio-system --output jsonpath="{.status.loadBalancer.ingress[*].ip}"`
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Use the client to send message streams to the gRPC server (replacing `{username}`)
|
1. Use the client to send message streams to the gRPC server (replacing
|
||||||
|
`{username}`)
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker run -ti --entrypoint=/client docker.io/{username}/grpc-ping-go \
|
docker run -ti --entrypoint=/client docker.io/{username}/grpc-ping-go \
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# Knative Secrets - Go sample
|
# Knative Secrets - Go sample
|
||||||
|
|
||||||
A simple web app written in Go that you can use for testing. It demonstrates
|
A simple web app written in Go that you can use for testing. It demonstrates how
|
||||||
how to use a Kubernetes secret as a Volume with Knative. We will create a new
|
to use a Kubernetes secret as a Volume with Knative. We will create a new Google
|
||||||
Google Service Account and place it into a Kubernetes secret, then we will
|
Service Account and place it into a Kubernetes secret, then we will mount it
|
||||||
mount it into a container as a Volume.
|
into a container as a Volume.
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
|
@ -13,13 +13,12 @@ mount it into a container as a Volume.
|
||||||
- [Docker](https://www.docker.com) installed and running on your local machine,
|
- [Docker](https://www.docker.com) installed and running on your local machine,
|
||||||
and a Docker Hub account configured (we'll use it for a container registry).
|
and a Docker Hub account configured (we'll use it for a container registry).
|
||||||
- Create a
|
- Create a
|
||||||
[Google Cloud project](https://cloud.google.com/resource-manager/docs/creating-managing-projects)
|
[Google Cloud project](https://cloud.google.com/resource-manager/docs/creating-managing-projects)
|
||||||
and install the `gcloud` CLI and run `gcloud auth login`. This sample will
|
and install the `gcloud` CLI and run `gcloud auth login`. This sample will use
|
||||||
use a mix of `gcloud` and `kubectl` commands. The rest of the sample assumes
|
a mix of `gcloud` and `kubectl` commands. The rest of the sample assumes that
|
||||||
that you've set the `$PROJECT_ID` environment variable to your Google Cloud
|
you've set the `$PROJECT_ID` environment variable to your Google Cloud project
|
||||||
project id, and also set your project ID as default using
|
id, and also set your project ID as default using
|
||||||
`gcloud config set project $PROJECT_ID`.
|
`gcloud config set project $PROJECT_ID`.
|
||||||
|
|
||||||
|
|
||||||
## Recreating the sample code
|
## Recreating the sample code
|
||||||
|
|
||||||
|
@ -27,8 +26,8 @@ While you can clone all of the code from this directory, simple apps are
|
||||||
generally more useful if you build them step-by-step. The following instructions
|
generally more useful if you build them step-by-step. The following instructions
|
||||||
recreate the source files from this folder.
|
recreate the source files from this folder.
|
||||||
|
|
||||||
1. Create a new file named `secrets.go` and paste the following code. This
|
1. Create a new file named `secrets.go` and paste the following code. This code
|
||||||
code creates a basic web server which listens on port 8080:
|
creates a basic web server which listens on port 8080:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package main
|
package main
|
||||||
|
@ -39,13 +38,13 @@ recreate the source files from this folder.
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"cloud.google.com/go/storage"
|
"cloud.google.com/go/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.Print("Secrets sample started.")
|
log.Print("Secrets sample started.")
|
||||||
|
|
||||||
// This sets up the standard GCS storage client, which will pull
|
// This sets up the standard GCS storage client, which will pull
|
||||||
// credentials from GOOGLE_APPLICATION_DEFAULT if specified.
|
// credentials from GOOGLE_APPLICATION_DEFAULT if specified.
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
@ -53,13 +52,13 @@ recreate the source files from this folder.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Unable to initialize storage client: %v", err)
|
log.Fatalf("Unable to initialize storage client: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
// This GCS bucket has been configured so that any authenticated
|
// This GCS bucket has been configured so that any authenticated
|
||||||
// user can access it (Read Only), so any Service Account can
|
// user can access it (Read Only), so any Service Account can
|
||||||
// run this sample.
|
// run this sample.
|
||||||
bkt := client.Bucket("knative-secrets-sample")
|
bkt := client.Bucket("knative-secrets-sample")
|
||||||
|
|
||||||
// Access the attributes of this GCS bucket, and write it back to the
|
// Access the attributes of this GCS bucket, and write it back to the
|
||||||
// user. On failure, return a 500 and the error message.
|
// user. On failure, return a 500 and the error message.
|
||||||
attrs, err := bkt.Attrs(ctx)
|
attrs, err := bkt.Attrs(ctx)
|
||||||
|
@ -70,14 +69,14 @@ recreate the source files from this folder.
|
||||||
fmt.Fprintln(w,
|
fmt.Fprintln(w,
|
||||||
fmt.Sprintf("bucket %s, created at %s, is located in %s with storage class %s\n",
|
fmt.Sprintf("bucket %s, created at %s, is located in %s with storage class %s\n",
|
||||||
attrs.Name, attrs.Created, attrs.Location, attrs.StorageClass))
|
attrs.Name, attrs.Created, attrs.Location, attrs.StorageClass))
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
port := os.Getenv("PORT")
|
port := os.Getenv("PORT")
|
||||||
if port == "" {
|
if port == "" {
|
||||||
port = "8080"
|
port = "8080"
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -124,10 +123,9 @@ recreate the source files from this folder.
|
||||||
CMD ["/hellosecrets"]
|
CMD ["/hellosecrets"]
|
||||||
```
|
```
|
||||||
|
|
||||||
1. [Create a new Google Service Account](
|
1. [Create a new Google Service Account](https://cloud.google.com/iam/docs/creating-managing-service-accounts).
|
||||||
https://cloud.google.com/iam/docs/creating-managing-service-accounts). This Service
|
This Service Account doesn't need any privileges, the GCS bucket has been
|
||||||
Account doesn't need any privileges, the GCS bucket has been configured so that any
|
configured so that any authenticated identity may read it.
|
||||||
authenticated identity may read it.
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
gcloud iam service-accounts create knative-secrets
|
gcloud iam service-accounts create knative-secrets
|
||||||
|
@ -170,29 +168,29 @@ authenticated identity may read it.
|
||||||
image: docker.io/{username}/secrets-go
|
image: docker.io/{username}/secrets-go
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# This directs the Google Cloud SDK to use the identity and project
|
# This directs the Google Cloud SDK to use the identity and project
|
||||||
# defined by the Service Account (aka robot) in the JSON file at
|
# defined by the Service Account (aka robot) in the JSON file at
|
||||||
# this path.
|
# this path.
|
||||||
# - `/var/secret` is determined by the `volumeMounts[0].mountPath`
|
# - `/var/secret` is determined by the `volumeMounts[0].mountPath`
|
||||||
# below. This can be changed if both places are changed.
|
# below. This can be changed if both places are changed.
|
||||||
# - `robot.json` is determined by the "key" that is used to hold the
|
# - `robot.json` is determined by the "key" that is used to hold the
|
||||||
# secret content in the Kubernetes secret. This can be changed
|
# secret content in the Kubernetes secret. This can be changed
|
||||||
# if both places are changed.
|
# if both places are changed.
|
||||||
- name: GOOGLE_APPLICATION_DEFAULT
|
- name: GOOGLE_APPLICATION_DEFAULT
|
||||||
value: /var/secret/robot.json
|
value: /var/secret/robot.json
|
||||||
|
|
||||||
# This section specified where in the container we want the
|
# This section specified where in the container we want the
|
||||||
# volume containing our secret to be mounted.
|
# volume containing our secret to be mounted.
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: robot-secret
|
- name: robot-secret
|
||||||
mountPath: /var/secret
|
mountPath: /var/secret
|
||||||
|
|
||||||
# This section attaches the secret "google-robot-secret" to
|
# This section attaches the secret "google-robot-secret" to
|
||||||
# the Pod holding the user container.
|
# the Pod holding the user container.
|
||||||
volumes:
|
volumes:
|
||||||
- name: robot-secret
|
- name: robot-secret
|
||||||
secret:
|
secret:
|
||||||
secretName: google-robot-secret
|
secretName: google-robot-secret
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building and deploying the sample
|
## Building and deploying the sample
|
||||||
|
@ -222,10 +220,11 @@ folder) you're ready to build and deploy the sample app.
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Now that your service is created, Knative will perform the following steps:
|
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 load balance
|
- Create a new immutable revision for this version of the app.
|
||||||
for your app.
|
- Network programming to create a route, ingress, service, and load balance
|
||||||
- Automatically scale your pods up and down (including to zero active pods).
|
for your app.
|
||||||
|
- Automatically scale your pods up and down (including to zero active pods).
|
||||||
|
|
||||||
1. Run the following command to find the external IP address for your service.
|
1. Run the following command to find the external IP address for your service.
|
||||||
The ingress IP for your cluster is returned. If you just created your
|
The ingress IP for your cluster is returned. If you just created your
|
||||||
|
|
Loading…
Reference in New Issue