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
|
||||
|
||||
This installation method for Knative depends on Gloo. Run the following
|
||||
to install `glooctl`, the Gloo command line.
|
||||
This installation method for Knative depends on Gloo. Run the following to
|
||||
install `glooctl`, the Gloo command line.
|
||||
|
||||
```shell
|
||||
curl -sL https://run.solo.io/gloo/install | sh
|
||||
```
|
||||
|
||||
Alternatively, you can download the Gloo CLI directly via
|
||||
[the github releases](https://github.com/solo-io/gloo/releases) page.
|
||||
Alternatively, you can download the Gloo CLI directly via
|
||||
[the github releases](https://github.com/solo-io/gloo/releases) page.
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
> Note: To see the content of the kubernetes manifest glooctl installs, run
|
||||
> `glooctl install knative --dry-run`.
|
||||
Monitor the Gloo components until all of the components show a `STATUS` of
|
||||
`Running` or `Completed`:
|
||||
> Note: To see the content of the kubernetes manifest glooctl installs, run
|
||||
> `glooctl install knative --dry-run`. Monitor the Gloo components until all of
|
||||
> the components show a `STATUS` of `Running` or `Completed`:
|
||||
|
||||
```shell
|
||||
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)
|
||||
guide.
|
||||
|
||||
Note that when you've finished deploying the app, you'll need to connect to the Gloo
|
||||
Gateway rather than the Istio Gateway.
|
||||
Note that when you've finished deploying the app, you'll need to connect to the
|
||||
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
|
||||
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
|
||||
```
|
||||
|
||||
The full instructions for the [Go Hello-World Sample](../serving/samples/helloworld-go) with
|
||||
this substitution are published bellow:
|
||||
|
||||
The full instructions for the
|
||||
[Go Hello-World Sample](../serving/samples/helloworld-go) with this substitution
|
||||
are published bellow:
|
||||
|
||||
### 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
|
||||
package main
|
||||
|
@ -133,8 +133,8 @@ func main() {
|
|||
|
||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
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
|
||||
[Deploying Go servers with Docker](https://blog.golang.org/docker).
|
||||
|
@ -167,11 +167,10 @@ ENV PORT 8080
|
|||
|
||||
# Run the web service on container startup.
|
||||
CMD ["/helloworld"]
|
||||
```
|
||||
```
|
||||
|
||||
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.
|
||||
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/v1alpha1
|
||||
|
@ -189,7 +188,7 @@ spec:
|
|||
env:
|
||||
- name: TARGET
|
||||
value: "Go Sample v1"
|
||||
```
|
||||
```
|
||||
|
||||
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
|
||||
docker push {username}/helloworld-go
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
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`:
|
||||
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
|
||||
```
|
||||
```
|
||||
|
||||
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
|
||||
for 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.
|
||||
|
||||
|
||||
- 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).
|
||||
|
||||
- Run the following command to find the external IP address for the Gloo cluster
|
||||
ingress.
|
||||
|
||||
```bash
|
||||
CLUSTERINGRESS_URL=$(glooctl proxy url --name clusteringress-proxy)
|
||||
echo $CLUSTERINGRESS_URL
|
||||
|
@ -233,7 +233,7 @@ Run the following command to find the domain URL for your service:
|
|||
|
||||
```bash
|
||||
kubectl get ksvc helloworld-go -n default --output=custom-columns=NAME:.metadata.name,DOMAIN:.status.domain
|
||||
````
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
|
@ -242,22 +242,23 @@ NAME DOMAIN
|
|||
helloworld-go helloworld-go.default.example.com
|
||||
```
|
||||
|
||||
Test your app by sending it a request. Use the following `curl` command with
|
||||
the domain URL `helloworld-go.default.example.com` and `EXTERNAL-IP` address
|
||||
that you retrieved in the previous steps:
|
||||
Test your app by sending it a request. Use the following `curl` command with the
|
||||
domain URL `helloworld-go.default.example.com` and `EXTERNAL-IP` address that
|
||||
you retrieved in the previous steps:
|
||||
|
||||
```bash
|
||||
curl -H "Host: helloworld-go.default.example.com" ${CLUSTERINGRESS_URL}
|
||||
Hello Go Sample v1!
|
||||
````
|
||||
```
|
||||
|
||||
> 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:
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
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:
|
||||
[Istio](https://istio.io/), the Envoy-based Service Mesh, and [Gloo](https://gloo.solo.io/), the Envoy-based API Gateway.
|
||||
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.
|
||||
|
||||
## 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*
|
||||
is not supported by Gloo at this time.
|
||||
[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_ is not supported by Gloo at this time.
|
||||
|
||||
## Installing Knative with Istio
|
||||
|
||||
Istio is a popular service mesh that includes a Knative-compatiblle
|
||||
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.
|
||||
Istio is a popular service mesh that includes a Knative-compatiblle 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.
|
||||
|
||||
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}"`
|
||||
```
|
||||
|
||||
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
|
||||
docker run -ti --entrypoint=/client docker.io/{username}/grpc-ping-go \
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# Knative Secrets - Go sample
|
||||
|
||||
A simple web app written in Go that you can use for testing. It demonstrates
|
||||
how to use a Kubernetes secret as a Volume with Knative. We will create a new
|
||||
Google Service Account and place it into a Kubernetes secret, then we will
|
||||
mount it into a container as a Volume.
|
||||
A simple web app written in Go that you can use for testing. It demonstrates how
|
||||
to use a Kubernetes secret as a Volume with Knative. We will create a new Google
|
||||
Service Account and place it into a Kubernetes secret, then we will mount it
|
||||
into a container as a Volume.
|
||||
|
||||
## 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,
|
||||
and a Docker Hub account configured (we'll use it for a container registry).
|
||||
- Create a
|
||||
[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
|
||||
use a mix of `gcloud` and `kubectl` commands. The rest of the sample assumes
|
||||
that you've set the `$PROJECT_ID` environment variable to your Google Cloud
|
||||
project id, and also set your project ID as default using
|
||||
`gcloud config set project $PROJECT_ID`.
|
||||
|
||||
[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 use
|
||||
a mix of `gcloud` and `kubectl` commands. The rest of the sample assumes that
|
||||
you've set the `$PROJECT_ID` environment variable to your Google Cloud project
|
||||
id, and also set your project ID as default using
|
||||
`gcloud config set project $PROJECT_ID`.
|
||||
|
||||
## 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
|
||||
recreate the source files from this folder.
|
||||
|
||||
1. Create a new file named `secrets.go` and paste the following code. This
|
||||
code creates a basic web server which listens on port 8080:
|
||||
1. Create a new file named `secrets.go` and paste the following code. This code
|
||||
creates a basic web server which listens on port 8080:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
@ -39,13 +38,13 @@ recreate the source files from this folder.
|
|||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
|
||||
"cloud.google.com/go/storage"
|
||||
)
|
||||
|
||||
|
||||
func main() {
|
||||
log.Print("Secrets sample started.")
|
||||
|
||||
|
||||
// This sets up the standard GCS storage client, which will pull
|
||||
// credentials from GOOGLE_APPLICATION_DEFAULT if specified.
|
||||
ctx := context.Background()
|
||||
|
@ -53,13 +52,13 @@ recreate the source files from this folder.
|
|||
if err != nil {
|
||||
log.Fatalf("Unable to initialize storage client: %v", err)
|
||||
}
|
||||
|
||||
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
// This GCS bucket has been configured so that any authenticated
|
||||
// user can access it (Read Only), so any Service Account can
|
||||
// run this sample.
|
||||
bkt := client.Bucket("knative-secrets-sample")
|
||||
|
||||
|
||||
// Access the attributes of this GCS bucket, and write it back to the
|
||||
// user. On failure, return a 500 and the error message.
|
||||
attrs, err := bkt.Attrs(ctx)
|
||||
|
@ -70,14 +69,14 @@ recreate the source files from this folder.
|
|||
fmt.Fprintln(w,
|
||||
fmt.Sprintf("bucket %s, created at %s, is located in %s with storage class %s\n",
|
||||
attrs.Name, attrs.Created, attrs.Location, attrs.StorageClass))
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = "8080"
|
||||
}
|
||||
|
||||
|
||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
|
||||
}
|
||||
```
|
||||
|
@ -124,10 +123,9 @@ recreate the source files from this folder.
|
|||
CMD ["/hellosecrets"]
|
||||
```
|
||||
|
||||
1. [Create a new Google Service Account](
|
||||
https://cloud.google.com/iam/docs/creating-managing-service-accounts). This Service
|
||||
Account doesn't need any privileges, the GCS bucket has been configured so that any
|
||||
authenticated identity may read it.
|
||||
1. [Create a new Google Service Account](https://cloud.google.com/iam/docs/creating-managing-service-accounts).
|
||||
This Service Account doesn't need any privileges, the GCS bucket has been
|
||||
configured so that any authenticated identity may read it.
|
||||
|
||||
```shell
|
||||
gcloud iam service-accounts create knative-secrets
|
||||
|
@ -170,29 +168,29 @@ authenticated identity may read it.
|
|||
image: docker.io/{username}/secrets-go
|
||||
|
||||
env:
|
||||
# This directs the Google Cloud SDK to use the identity and project
|
||||
# defined by the Service Account (aka robot) in the JSON file at
|
||||
# this path.
|
||||
# - `/var/secret` is determined by the `volumeMounts[0].mountPath`
|
||||
# below. This can be changed if both places are changed.
|
||||
# - `robot.json` is determined by the "key" that is used to hold the
|
||||
# secret content in the Kubernetes secret. This can be changed
|
||||
# if both places are changed.
|
||||
- name: GOOGLE_APPLICATION_DEFAULT
|
||||
value: /var/secret/robot.json
|
||||
# This directs the Google Cloud SDK to use the identity and project
|
||||
# defined by the Service Account (aka robot) in the JSON file at
|
||||
# this path.
|
||||
# - `/var/secret` is determined by the `volumeMounts[0].mountPath`
|
||||
# below. This can be changed if both places are changed.
|
||||
# - `robot.json` is determined by the "key" that is used to hold the
|
||||
# secret content in the Kubernetes secret. This can be changed
|
||||
# if both places are changed.
|
||||
- name: GOOGLE_APPLICATION_DEFAULT
|
||||
value: /var/secret/robot.json
|
||||
|
||||
# This section specified where in the container we want the
|
||||
# volume containing our secret to be mounted.
|
||||
volumeMounts:
|
||||
- name: robot-secret
|
||||
mountPath: /var/secret
|
||||
- name: robot-secret
|
||||
mountPath: /var/secret
|
||||
|
||||
# This section attaches the secret "google-robot-secret" to
|
||||
# the Pod holding the user container.
|
||||
volumes:
|
||||
- name: robot-secret
|
||||
secret:
|
||||
secretName: google-robot-secret
|
||||
- name: robot-secret
|
||||
secret:
|
||||
secretName: google-robot-secret
|
||||
```
|
||||
|
||||
## 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:
|
||||
- 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 external IP address for your service.
|
||||
The ingress IP for your cluster is returned. If you just created your
|
||||
|
|
Loading…
Reference in New Issue