Skip to content

Commit 44b22c5

Browse files
authored
Update install docs to handle multiple platforms (tensorflow#28)
* Add readme, move GKE to new file * Fix links
1 parent 21af391 commit 44b22c5

File tree

3 files changed

+185
-182
lines changed

3 files changed

+185
-182
lines changed

install/Knative-with-GKE.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# Knative the easy way (on Google Kubernetes Engine)
2+
3+
This guide walks you through the installation of the latest version of
4+
[Knative serving](https://github.com/knative/serving) using pre-built images on
5+
a Google Kubernetes Engine cluster.
6+
7+
You can find [guides for other platforms here](README.md).
8+
9+
## Prerequisites
10+
11+
### Install gcloud SDK
12+
13+
> If you already have `gcloud` installed, you can skip this section.
14+
15+
1. [Install the Google Cloud SDK](https://cloud.google.com/sdk/).
16+
1. Authorize `gcloud` to use your Google account:
17+
18+
```shell
19+
gcloud auth login
20+
```
21+
22+
### Define environment variables
23+
24+
To simply the command lines for this walkthrough, we need to define a few
25+
environment variables.
26+
27+
If you already have a default project set in `gcloud`, enter:
28+
29+
```shell
30+
export PROJECT_ID=$(gcloud config get-value project)
31+
```
32+
33+
Or, if you don't have an existing GCP project you'd like to use,
34+
replace `my-knative-project` with your desired project ID. This variable will
35+
be used later to create your new GCP project. The project ID must be globally
36+
unique across all GCP projects.
37+
38+
```shell
39+
export PROJECT_ID=my-knative-project
40+
```
41+
42+
Set the following two variables as desired:
43+
44+
```shell
45+
export CLUSTER_NAME=knative
46+
export CLUSTER_ZONE=us-west1-c
47+
```
48+
49+
### Register a Google Cloud Platform Project
50+
51+
If you already have a GCP project configured, make sure your project is set
52+
as your `gcloud` default:
53+
54+
```shell
55+
gcloud config set project $PROJECT_ID
56+
```
57+
58+
If you don't already have a GCP project configured, create a new project:
59+
60+
```shell
61+
gcloud projects create $PROJECT_ID --set-as-default
62+
```
63+
64+
Enable the necessary APIs in this project:
65+
66+
```shell
67+
gcloud services enable \
68+
cloudapis.googleapis.com \
69+
container.googleapis.com \
70+
containerregistry.googleapis.com
71+
```
72+
73+
## Step 1: Create a Kubernetes Cluster
74+
75+
Create a Kubernetes cluster on GKE (large enough to host all the Knative
76+
components). The recommended configuration for a cluster is:
77+
78+
* Kubernetes version 1.10 or later
79+
* 4 vCPU nodes (`n1-standard-4`)
80+
* Node autoscaling, up to 10 nodes
81+
* API scopes for `cloud-platform`, `logging-write`, `monitoring-write`, and
82+
`pubsub` (if those features will be used)
83+
84+
To create a cluster matching these requriements:
85+
86+
```shell
87+
gcloud container clusters create $CLUSTER_NAME \
88+
--zone=$CLUSTER_ZONE \
89+
--cluster-version latest \
90+
--machine-type n1-standard-4 \
91+
--enable-autoscaling --min-nodes=1 --max-nodes=10 \
92+
--scopes=cloud-platform,logging-write,monitoring-write,pubsub \
93+
--num-nodes 3
94+
```
95+
96+
After the cluster is created, grant `cluster-admin` permissions to the current
97+
user. These permissions are required to create the necessary
98+
[RBAC rules for Istio](https://istio.io/docs/concepts/security/rbac/).
99+
100+
```shell
101+
kubectl create clusterrolebinding cluster-admin-binding \
102+
--clusterrole=cluster-admin \
103+
--user=$(gcloud config get-value core/account)
104+
```
105+
106+
## Step 2: Install Istio
107+
108+
Knative depends on Istio, which must be installed first:
109+
110+
```shell
111+
# Install from pre-compiled images
112+
kubectl apply -f https://storage.googleapis.com/knative-releases/latest/istio.yaml
113+
114+
# Label the default namespace with istio-injection=enabled.
115+
kubectl label namespace default istio-injection=enabled
116+
```
117+
118+
Monitor the Istio components, until all of the components report `Running` or
119+
`Completed`:
120+
121+
```shell
122+
kubectl get pods -n istio-system --watch
123+
```
124+
125+
CTRL+C when it's done.
126+
127+
## Step 3: Install Knative Serving
128+
129+
Next, we will install [Knative Serving](https://github.com/knative/serving) and
130+
its dependencies:
131+
132+
```shell
133+
kubectl apply -f https://storage.googleapis.com/knative-releases/latest/release.yaml
134+
```
135+
136+
Monitor the Knative components, until all of the components report `Running`:
137+
138+
```shell
139+
kubectl get pods -n knative-serving --watch
140+
```
141+
142+
CTRL+C when it's done.
143+
144+
You are now ready to deploy apps Now you can deploy your app or function to your
145+
newly created Knative cluster.
146+
147+
## Step 4: Run Hello World
148+
149+
Now that your cluster is running the Knative components, follow the insturctions
150+
for one of the [sample apps](../serving/samples/README.MD) to deploy your first
151+
app.
152+
153+
## Cleanup (optional)
154+
155+
Running a cluster in Kubernetes Engine will cost you money, so if you aren't
156+
using it you may wish to delete the cluster when you're done. Deleting the
157+
cluster will also remove Knative, Istio, and any apps you've deployed.
158+
159+
```shell
160+
gcloud container clusters delete $CLUSTER_NAME --zone $CLUSTER_ZONE
161+
```

install/Knative-with-Minikube.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Knative the easy way with Minikube
1+
# Knative the easy way (with Minikube)
22

33
This how-to will guide you through installation of the latest version of [Knative](https://github.com/knative/serving) using pre-built images and demonstrate deployment of a sample app onto the newly created Knative cluster.
44

@@ -44,7 +44,7 @@ minikube start --memory=8192 --cpus=4 \
4444

4545
Knative depends on Istio. Run the following to install Istio. (We are changing `LoadBalancer` to `NodePort` for the `istio-ingress` service)
4646

47-
```bash
47+
```shell
4848
wget -O - https://storage.googleapis.com/knative-releases/latest/istio.yaml \
4949
| sed 's/LoadBalancer/NodePort/' \
5050
| kubectl apply -f -
@@ -55,51 +55,55 @@ kubectl label namespace default istio-injection=enabled
5555

5656
Wait until each Istio component is running or completed (STATUS column shows 'Running' or 'Completed'):
5757

58-
```bash
58+
```shell
5959
kubectl get pods -n istio-system --watch
6060
```
61+
6162
CTRL+C when it's done.
6263

6364
## Knative
6465

6566
Next, we will install [Knative](https://github.com/knative/serving):
6667

67-
We are using the https://storage.googleapis.com/elafros-releases/latest/release-lite.yaml file which omits some of the monitoring components to reduce the memory used by the Knative components since you do have limited resources available. To use the provided `release-lite.yaml` release run:
68-
```bash
68+
We are using the `https://storage.googleapis.com/elafros-releases/latest/release-lite.yaml` file which omits some of the monitoring components to reduce the memory used by the Knative components since you do have limited resources available. To use the provided `release-lite.yaml` release run:
69+
70+
```shell
6971
kubectl apply -f https://storage.googleapis.com/knative-releases/latest/release-lite.yaml
7072
```
7173

7274
Wait until all Knative components are running (STATUS column shows 'Running'):
7375

74-
```bash
76+
```shell
7577
kubectl get pods -n knative-serving-system --watch
7678
```
79+
7780
CTRL+C when it's done.
78-
81+
7982
Now you can deploy your app/function to your newly created Knative cluster.
8083

8184
## Test App
8285

8386
The following instruction will deploy the `Primer` sample app onto your new Knative cluster.
8487

85-
> Note, you will be deploying using pre-build image so no need to clone the Primer repo or install anything locally. If you want to run the `Primer` app locally see the [Primer Readme](https://github.com/mchmarny/primer) for instructions.
88+
> Note, you will be deploying using pre-build image so no need to clone the Primer repo or install anything locally. If you want to run the `Primer` app locally see the [Primer Readme](https://github.com/mchmarny/primer) for instructions.
8689
87-
```bash
90+
```shell
8891
kubectl apply -f https://storage.googleapis.com/knative-samples/primer.yaml
8992
```
9093

9194
Wait for the ingress to gety created. This may take a few seconds. You can check by running:
9295

93-
```bash
96+
```shell
9497
kubectl get ing --watch
9598
```
99+
96100
CTRL+C when it's done.
97101

98102
Capture the IP and host name by running these commands:
99103

100-
> Note that we changed the `istio-ingress` service to use a `NodePort` since `LoadBalancer` is not supported on Minikube. Here we look up the IP of the Minikube node as well as the actual port used for the ingress.
104+
> Note that we changed the `istio-ingress` service to use a `NodePort` since `LoadBalancer` is not supported on Minikube. Here we look up the IP of the Minikube node as well as the actual port used for the ingress.
101105
102-
```bash
106+
```shell
103107
export SERVICE_IP=$(minikube ip):$(kubectl get svc istio-ingress -n istio-system \
104108
-o 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')
105109

@@ -111,14 +115,14 @@ export SERVICE_HOST=`kubectl get ing primer-ingress \
111115
112116
Run the Primer app. The higher the number, the longer it will run.
113117

114-
```bash
118+
```shell
115119
curl -H "Host: ${SERVICE_HOST}" http://$SERVICE_IP/5000000
116120
```
117121

118122
## Cleanup
119123

120124
Delete the Kubernetes cluster along with Knative, Istio and Primer sample app
121125

122-
```
126+
```shell
123127
minikube delete
124128
```

0 commit comments

Comments
 (0)