Skip to content

Commit

Permalink
update to v0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
toshi0607 committed Dec 8, 2019
1 parent d7c053a commit 8cc3890
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
16 changes: 8 additions & 8 deletions step0.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ $ kubectl get nodes

```shell
$ kubectl apply --selector knative.dev/crd-install=true \
--filename https://github.com/knative/serving/releases/download/v0.9.0/serving.yaml \
--filename https://github.com/knative/eventing/releases/download/v0.9.0/release.yaml \
--filename https://github.com/knative/serving/releases/download/v0.9.0/monitoring.yaml
--filename https://github.com/knative/serving/releases/download/v0.10.0/serving.yaml \
--filename https://github.com/knative/eventing/releases/download/v0.10.0/release.yaml \
--filename https://github.com/knative/serving/releases/download/v0.10.0/monitoring.yaml

$ kubectl apply --filename https://github.com/knative/serving/releases/download/v0.9.0/serving.yaml \
--filename https://github.com/knative/eventing/releases/download/v0.9.0/release.yaml \
--filename https://github.com/knative/serving/releases/download/v0.9.0/monitoring.yaml
$ kubectl apply --filename https://github.com/knative/serving/releases/download/v0.10.0/serving.yaml \
--filename https://github.com/knative/eventing/releases/download/v0.10.0/release.yaml \
--filename https://github.com/knative/serving/releases/download/v0.10.0/monitoring.yaml
```

つぎのコマンドを実行して確認ステータスを確認してください。すべてのPodのStatusが*Running*になれば設定完了です。
Expand All @@ -152,13 +152,13 @@ $ kubectl get pods --namespace knative-monitoring
EventingでKnativeのServiceをsinkに指定する場合は現状追加でセットアップが必要です。本ワークショップをEventing含めて実施する場合はつぎのコマンドを実行してください。

```
$ kubectl apply -f https://raw.githubusercontent.com/knative/serving/master/third_party/istio-1.2.7/istio-knative-extras.yaml
$ kubectl apply -f https://raw.githubusercontent.com/knative/serving/release-0.10/third_party/istio-1.2.7/istio-knative-extras.yaml
# Istioのバージョン確認
# $ kubectl get pod -n istio-system
# istio-ingressgateway-f659695c4-sssrs
# $ kubectl get pod istio-ingressgateway-f659695c4-sssrs -n istio-system -oyaml | grep image
# image: gke.gcr.io/istio/proxyv2:1.1.13-gke.0
# image: gke.gcr.io/istio/proxyv2:1.1.16-gke.0
# => OK: 1.2.7, NG: 1.3.3
```

Expand Down
16 changes: 8 additions & 8 deletions step1.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ spec:
$ kubectl apply --filename blue-green-route.yaml
```

図のようにRouteが -> Revisonの状態になります。
図のようにRoute -> Revisonの状態になります。

![](./images/revision_blue_100.png)

Expand Down Expand Up @@ -445,7 +445,7 @@ kind: CronJobSource
metadata:
name: cronjob-source
spec:
schedule: "*/1 * * * *"
schedule: "*/2 * * * *"
data: '{"message": "Hello Eventing!"}'
sink:
apiVersion: serving.knative.dev/v1alpha1
Expand All @@ -459,7 +459,7 @@ spec:
$ kubectl apply --filename cronjob-source.yaml
```

`CronJobSource`はspec.scheduleに記述したクロン式に従ってイベントを発行します。この例では1分毎にHello Eventing!というメッセージを発行します。
`CronJobSource`はspec.scheduleに記述したクロン式に従ってイベントを発行します。この例では30秒毎にHello Eventing!というメッセージを発行します。

KnativeのServiceで受信したメッセージはコンテナのログで確認できます。つぎのコマンドを実行してメッセージを確認してください。

Expand All @@ -478,7 +478,7 @@ $ kubectl delete --filename cronjob-source.yaml

* 実行したアプリケーションのソースコード
* [event_display](https://github.com/knative/eventing-contrib/blob/master/cmd/event_display/main.go)
* Eventing v0.9でKnative Servingを利用するにあたりcluster local gatewayを別途セットアップしなければならない件
* Eventing v0.9、0.10でKnative Servingを利用するにあたりcluster local gatewayを別途セットアップしなければならない件
* [Cluster local issue with Knative Eventing v0.9.0](https://medium.com/google-cloud/cluster-local-issue-with-knative-eventing-v0-9-0-a1fee2215cfe)
* https://github.com/knative/eventing/issues/1973

Expand All @@ -494,7 +494,7 @@ https://cloud.google.com/pubsub/docs/overview
まずGCP Cloud Pub/Subをイベントソースとするためにつぎのコマンドを実行してください。

```shell
$ kubectl apply -f https://github.com/google/knative-gcp/releases/download/v0.9.0/cloud-run-events.yaml
$ kubectl apply -f https://github.com/google/knative-gcp/releases/download/v0.10.1/cloud-run-events.yaml
```

利用しているGCPプロジェクトでCloud Pub/Sub APIを有効化してください。
Expand Down Expand Up @@ -552,7 +552,7 @@ $ kubectl apply --filename event-display-service.yaml
つぎのマニフェストを`pullsubscription.yaml`という名前で保存し、適用してください。specにはPubSubのtopic名とイベントの送信先を記述しています。

```yaml
apiVersion: pubsub.cloud.run/v1alpha1
apiVersion: pubsub.cloud.google.com/v1alpha1
kind: PullSubscription
metadata:
name: testing-source-event-display
Expand All @@ -566,8 +566,8 @@ spec:
```shell
$ kubectl apply -f pullsubscription.yaml
# 少し時間がかかるので注意
$ kubectl get pullsubscription -w
# READYがTRUEになるまで少し時間がかかるので注意
$ kubectl get pullsubscription
```

PubSubのトピックにイベントを発行してください。メッセージはなんでも大丈夫です。
Expand Down
20 changes: 17 additions & 3 deletions step4.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $ gcloud config set run/platform managed
$ gcloud config set run/region asia-northeast1

# コンテナイメージをCloud Runにデプロイ
$ gcloud beta run deploy --image gcr.io/knative-samples/helloworld-go
$ gcloud run deploy --image gcr.io/knative-samples/helloworld-go
# プロンプト
## Service Name (helloworld-go): 何も入力せずEnter
## Allow unauthenticated invocations to [helloworld-go]: y
Expand All @@ -41,7 +41,7 @@ Hello World!
環境変数をセットしてリクエストし直してみましょう。

```shell
$ gcloud beta run services update helloworld-go --update-env-vars TARGET="Cloud Run!"
$ gcloud run services update helloworld-go --update-env-vars TARGET="Cloud Run!"
$ curl $HELLO_WORLD_GO_URL
Hello Cloud Run!
```
Expand All @@ -57,7 +57,19 @@ $ hey -z 10s -c 5 $HELLO_WORLD_GO_URL

https://console.cloud.google.com/run/detail/asia-northeast1/helloworld-go/metrics

現状ServingのAPIのすべての機能もサポートしていないベータ段階のサービスですが、順次機能追加されています。コンテナベースのアプリケーションをメインで扱っていなくても、既存のコンテナをサーバーレスなAPIにするなど触れ合う機会は増えていくかもしれません。
step1と同様にトラフィック分割を試してみましょう。

トラフィックを流すRevision名はコンソールから確認してください。

https://console.cloud.google.com/run/detail/asia-northeast1/helloworld-go/revisions

```shell
# Revision名はご自身のものに置き換えてください
$ gcloud alpha run services update-traffic --region=asia-northeast1 --platform=managed --to-revisions=helloworld-go-00002-xob=50,helloworld-go-00001-yul=50
$ curl $HELLO_WORLD_GO_URL
```

Cloud Runは2019年11月にGAされたリリースですが、現状Knative ServingのAPIすべてに互換性があるわけではなく、順次機能追加されています。コンテナベースのアプリケーションをメインで扱っていなくても、既存のコンテナをサーバーレスなAPIにするなど触れ合う機会は増えていくかもしれません。

また、GKEやオンプレミス、マルチクラウド環境などでCloud Runを構築・実行する[Cloud Run for Anthos](https://cloud.google.com/run/docs/gke/setup)もあります。

Expand All @@ -71,5 +83,7 @@ https://cloud.google.com/serverless-options/
* [Cloud Run、Cloud Run for Anthosの機能比較](https://cloud.google.com/run#choose-the-platform-that-fits-you)
* [Cloud Run on GKEに覗くKnative](https://qiita.com/toshi0607/items/eeeabe81b1beac343b6b)
* [Anthos](https://cloud.google.com/anthos/)
* [Mastering Serverless Applications with Google Cloud Run](https://learning.oreilly.com/library/view/mastering-serverless-applications/9781492057086/)
* Early Release段階ですが、Cloud FunctionsやApp Engineとの使い分けや、ServerlessなコンピューティングソリューションをFunctionとServiceに分類するなど視点が面白く感性が期待されます。

[戻る](step3.md) | [次へ](step5.md)

0 comments on commit 8cc3890

Please sign in to comment.