Knative サービスのデプロイ¶
このチュートリアルでは、環境変数 TARGET
を受け取り、Hello ${TARGET}!
と出力する「Hello world」Knative サービスをデプロイします。
次のコマンドを実行してサービスをデプロイします
kn service create hello \
--image ghcr.io/knative/helloworld-go:latest \
--port 8080 \
--env TARGET=World
期待される出力
Service hello created to latest revision 'hello-0001' is available at URL:
http://hello.default.${LOADBALANCER_IP}.sslip.io
${LOADBALANCER_IP}
の値は、クラスターの種類によって異なります。kind
の場合は 127.0.0.1
、minikube
の場合はローカルトンネルに依存します。
-
次の YAML を
hello.yaml
という名前のファイルにコピーしますapiVersion: serving.knative.dev/v1 kind: Service metadata: name: hello spec: template: spec: containers: - image: ghcr.io/knative/helloworld-go:latest ports: - containerPort: 8080 env: - name: TARGET value: "World"
-
次のコマンドを実行して Knative サービスをデプロイします
kubectl apply -f hello.yaml
期待される出力
service.serving.knative.dev/hello created