Skip to content

Commit af34e66

Browse files
mhamwalaknative-prow-robot
authored andcommitted
Serving samples: add instructions to clone code (#1203)
* Serving Samples: add instructions to clone code * added intro sentence, added space * add specific branch for clone and fix codeblocks * -b branchname and codeblocks * point to branch + codeblocks * -b branch + spacing * branch and space * branch and spaces * forgot the -spring * branch and spaces * branch and spaces * branch and spaces * branch and spaces * branch and spaces * use a branch * typo * branch and space * branch and spaces * branch and spaces * typo * typo * typo * typo * typo * typo * typo * typo * typo * fix failing test * try to fix error * remove typo to fix build error
1 parent 1c0a2f2 commit af34e66

File tree

15 files changed

+1225
-1145
lines changed

15 files changed

+1225
-1145
lines changed

docs/serving/samples/build-private-repo-go/README.md

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ This sample demonstrates:
88
## Before you begin
99

1010
- [Install Knative Serving](../../../install/README.md)
11-
- Create a local folder for this sample and download the files in this directory
12-
into it.
11+
- Download a copy of the code:
12+
13+
```shell
14+
git clone -b "release-0.6" https://github.com/knative/docs knative-docs
15+
cd knative-docs/serving/samples/build-private-repo-go
16+
```
1317

1418
## Setup
1519

@@ -36,32 +40,32 @@ We are going to add to this an image pull Secret.
3640
1. Create your image pull Secret with the following command, replacing values as
3741
necessary:
3842

39-
```shell
40-
kubectl create secret docker-registry dockerhub-pull-secret \
41-
--docker-server=https://index.docker.io/v1/ [email protected] \
42-
--docker-username=<your-name> --docker-password=<your-pword>
43-
```
43+
```shell
44+
kubectl create secret docker-registry dockerhub-pull-secret \
45+
--docker-server=https://index.docker.io/v1/ [email protected] \
46+
--docker-username=<your-name> --docker-password=<your-pword>
47+
```
4448

4549
To learn more about Kubernetes pull Secrets, see
4650
[Creating a Secret in the cluster that holds your authorization token](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-in-the-cluster-that-holds-your-authorization-token).
4751

4852
2. Add the newly created `imagePullSecret` to your default service account by
4953
entering:
5054

51-
```shell
52-
kubectl edit serviceaccount default
53-
```
55+
```shell
56+
kubectl edit serviceaccount default
57+
```
5458

55-
This will open the resource in your default text editor. Under `secrets:`,
56-
add:
59+
This will open the resource in your default text editor. Under `secrets:`,
60+
add:
5761

58-
```yaml
59-
secrets:
60-
- name: default-token-zd84v
61-
# This is the secret we just created:
62-
imagePullSecrets:
63-
- name: dockerhub-pull-secret
64-
```
62+
```yaml
63+
secrets:
64+
- name: default-token-zd84v
65+
# This is the secret we just created:
66+
imagePullSecrets:
67+
- name: dockerhub-pull-secret
68+
```
6569

6670
### 2. Configuring the build
6771

@@ -147,9 +151,9 @@ kubectl create --filename build-bot.yaml
147151
[Kaniko build template](https://github.com/knative/build-templates/blob/master/kaniko/kaniko.yaml)
148152
by entering the following command:
149153
150-
```shell
151-
kubectl apply --filename https://raw.githubusercontent.com/knative/build-templates/master/kaniko/kaniko.yaml
152-
```
154+
```shell
155+
kubectl apply --filename https://raw.githubusercontent.com/knative/build-templates/master/kaniko/kaniko.yaml
156+
```
153157
154158
1. Open `manifest.yaml` and substitute your private DockerHub repository name
155159
for `REPLACE_ME`.
@@ -211,41 +215,41 @@ The sample code is in a private Github repository consisting of two files.
211215

212216
1. `Dockerfile`
213217

214-
```Dockerfile
215-
# Use golang:alpine to optimize the image size.
216-
# See https://hub.docker.com/_/golang/ for more information
217-
# about the difference between golang and golang:alpine.
218-
FROM golang:alpine
218+
```Dockerfile
219+
# Use golang:alpine to optimize the image size.
220+
# See https://hub.docker.com/_/golang/ for more information
221+
# about the difference between golang and golang:alpine.
222+
FROM golang:alpine
219223
220-
ENV GOPATH /go
224+
ENV GOPATH /go
221225
222-
ADD . /go/src/github.com/dewitt/knative-build
226+
ADD . /go/src/github.com/dewitt/knative-build
223227
224-
RUN CGO_ENABLED=0 go build github.com/dewitt/knative-build
228+
RUN CGO_ENABLED=0 go build github.com/dewitt/knative-build
225229
226-
ENTRYPOINT ["knative-build"]
227-
```
230+
ENTRYPOINT ["knative-build"]
231+
```
228232

229233
1. `main.go`
230234

231-
```go
232-
package main
235+
```go
236+
package main
233237
234-
import (
235-
"
236-
"
237-
)
238+
import (
239+
"
240+
"
241+
)
238242
239-
const (
243+
const (
240244
port = ":8080"
241-
)
245+
)
242246
243-
func helloWorld(w http.ResponseWriter, r *http.Request) {
244-
)
245-
}
247+
func helloWorld(w http.ResponseWriter, r *http.Request) {
248+
)
249+
}
246250
247-
func main() {
248-
)
249-
)
250-
}
251-
```
251+
func main() {
252+
)
253+
)
254+
}
255+
```

docs/serving/samples/gitwebhook-go/README.md

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
A handler written in Go that demonstrates interacting with GitHub through a
22
webhook.
33

4-
## Prerequisites
4+
## Before you begin
55

66
- A Kubernetes cluster with Knative installed. Follow the
77
[installation instructions](../../../install/README.md) if you need to create
@@ -13,18 +13,25 @@ webhook.
1313

1414
## Build the sample code
1515

16+
1. Download a copy of the code:
17+
18+
```shell
19+
git clone -b "release-0.6" https://github.com/knative/docs knative-docs
20+
cd knative-docs/serving/samples/gitwebhook-go
21+
```
22+
1623
1. Use Docker to build a container image for this service. Replace `username`
1724
with your Docker Hub username in the following commands.
1825

19-
```shell
20-
export DOCKER_HUB_USERNAME=username
26+
```shell
27+
export DOCKER_HUB_USERNAME=username
2128
22-
# Build the container, run from the project folder
23-
docker build -t ${DOCKER_HUB_USERNAME}/gitwebhook-go .
29+
# Build the container, run from the project folder
30+
docker build -t ${DOCKER_HUB_USERNAME}/gitwebhook-go .
2431
25-
# Push the container to the registry
26-
docker push ${DOCKER_HUB_USERNAME}/gitwebhook-go
27-
```
32+
# Push the container to the registry
33+
docker push ${DOCKER_HUB_USERNAME}/gitwebhook-go
34+
```
2835

2936
1. Create a secret that holds two values from GitHub, a personal access token
3037
used to make API requests to GitHub, and a webhook secret, used to validate
@@ -36,38 +43,36 @@ docker push ${DOCKER_HUB_USERNAME}/gitwebhook-go
3643
personal access token.
3744
1. Base64 encode the access token:
3845

39-
```shell
40-
$ echo -n "45d382d4a9a93c453fb7c8adc109121e7c29fa3ca" | base64
41-
NDVkMzgyZDRhOWE5M2M0NTNmYjdjOGFkYzEwOTEyMWU3YzI5ZmEzY2E=
42-
```
46+
```shell
47+
$ echo -n "45d382d4a9a93c453fb7c8adc109121e7c29fa3ca" | base64
48+
NDVkMzgyZDRhOWE5M2M0NTNmYjdjOGFkYzEwOTEyMWU3YzI5ZmEzY2E=
49+
```
4350

4451
1. Copy the encoded access token into `github-secret.yaml` next to
4552
`personalAccessToken:`.
4653
1. Create a webhook secert value unique to this sample, base64 encode it, and
4754
copy it into `github-secret.yaml` next to `webhookSecret:`:
4855

49-
```shell
50-
$ echo -n "mygithubwebhooksecret" | base64
51-
bXlnaXRodWJ3ZWJob29rc2VjcmV0
52-
```
56+
```shell
57+
$ echo -n "mygithubwebhooksecret" | base64
58+
bXlnaXRodWJ3ZWJob29rc2VjcmV0
59+
```
5360

5461
1. Apply the secret to your cluster:
5562

56-
```shell
57-
kubectl apply --filename github-secret.yaml
58-
```
63+
```shell
64+
kubectl apply --filename github-secret.yaml
65+
```
5966

6067
1. Next, update the `service.yaml` file in the project to reference the tagged
6168
image from step 1.
6269

63-
```yaml
64-
apiVersion: serving.knative.dev/v1alpha1
65-
kind: Service
66-
metadata:
67-
name: gitwebhook
68-
namespace: default
69-
spec:
70-
template:
70+
```yaml
71+
apiVersion: serving.knative.dev/v1alpha1
72+
kind: Service
73+
metadata:
74+
name: gitwebhook
75+
namespace: default
7176
spec:
7277
- containers:
7378
# Replace {DOCKER_HUB_USERNAME} with your actual docker hub username
@@ -83,14 +88,14 @@ spec:
8388
secretKeyRef:
8489
name: githubsecret
8590
key: accessToken
86-
```
91+
```
8792

8893
1. Use `kubectl` to apply the `service.yaml` file.
8994

90-
```shell
91-
$ kubectl apply --filename service.yaml
92-
service "gitwebhook" created
93-
```
95+
```shell
96+
$ kubectl apply --filename service.yaml
97+
service "gitwebhook" created
98+
```
9499

95100
1. Finally, once the service is running, create the webhook from your GitHub
96101
repo to the URL for this service. For this to work properly you will need to
@@ -99,12 +104,12 @@ service "gitwebhook" created
99104

100105
1. Retrieve the hostname for this service, using the following command:
101106

102-
```shell
103-
$ kubectl get ksvc gitwebhook \
104-
--output=custom-columns=NAME:.metadata.name,DOMAIN:.status.domain
105-
NAME DOMAIN
106-
gitwebhook gitwebhook.default.example.com
107-
```
107+
```shell
108+
$ kubectl get ksvc gitwebhook \
109+
--output=custom-columns=NAME:.metadata.name,DOMAIN:.status.domain
110+
NAME DOMAIN
111+
gitwebhook gitwebhook.default.example.com
112+
```
108113

109114
1. Browse on GitHub to the repository where you want to create a webhook.
110115
1. Click **Settings**, then **Webhooks**, then **Add webhook**.

docs/serving/samples/grpc-ping-go/README.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
A simple gRPC server written in Go that you can use for testing.
22

3-
This sample requires knative/serving 0.4 or later.
4-
53
## Prerequisites
64

7-
1. [Install Knative](../../../install/README.md).
5+
- [Install the Knative Serving version 0.4 or later](../../../install/README.md).
6+
7+
- Install [docker](https://www.docker.com/).
88

9-
1. Install [docker](https://www.docker.com/).
9+
- Download a copy of the code:
10+
11+
```shell
12+
git clone -b "release-0.6" https://github.com/knative/docs knative-docs
13+
cd knative-docs/serving/samples/grpc-ping-go
14+
```
1015

1116
## Build and run the gRPC server
1217

@@ -31,20 +36,20 @@ kubectl apply --filename docs/serving/samples/grpc-ping-go/sample.yaml
3136

3237
1. Fetch the created ingress hostname and IP.
3338

34-
```shell
35-
# Put the Host name into an environment variable.
36-
export SERVICE_HOST=`kubectl get route grpc-ping --output jsonpath="{.status.domain}"`
39+
```shell
40+
# Put the Host name into an environment variable.
41+
export SERVICE_HOST=`kubectl get route grpc-ping --output jsonpath="{.status.domain}"`
3742

38-
# Put the ingress IP into an environment variable.
39-
export SERVICE_IP=`kubectl get svc istio-ingressgateway --namespace istio-system --output jsonpath="{.status.loadBalancer.ingress[*].ip}"`
40-
```
43+
# Put the ingress IP into an environment variable.
44+
export SERVICE_IP=`kubectl get svc istio-ingressgateway --namespace istio-system --output jsonpath="{.status.loadBalancer.ingress[*].ip}"`
45+
```
4146

4247
1. Use the client to send message streams to the gRPC server (replacing
4348
`{username}`)
4449

45-
```shell
46-
docker run -ti --entrypoint=/client docker.io/{username}/grpc-ping-go \
47-
-server_addr="${SERVICE_IP}:80" \
48-
-server_host_override="${SERVICE_HOST}" \
49-
-insecure
50-
```
50+
```shell
51+
docker run -ti --entrypoint=/client docker.io/{username}/grpc-ping-go \
52+
-server_addr="${SERVICE_IP}:80" \
53+
-server_host_override="${SERVICE_HOST}" \
54+
-insecure
55+
```

0 commit comments

Comments
 (0)