Google Cloud Platform へのデプロイ
On This Page
Google Cloud Platform にデプロイする前に、Google Cloud SDK を承認して、デフォルトの設定を行う必要があります。 詳細は、 Google Cloud SDK の承認 に関するドキュメントを参照してください。
Google Cloud Orb の使用
CircleCI Orb レジストリ にある複数の Google Cloud Orb を使ってデプロイを簡易化することができます。 たとえば、 Google Kubernetes Engine (GKE) Orb に含まれるビルド済みのジョブは、Docker イメージをビルドおよびパブリッシュし、イメージを GKE クラスタに以下のようにロールアウトします。
version: 2.1
orbs:
gke: circleci/gcp-gke@x.y.z # Use the GCP GKE orb in your config
workflows:
main:
jobs:
- gke/publish-and-rollout-image:
cluster: <your-GKE-cluster> # name of GKE cluster to be created
container: <your-K8-container-name> # name of your Kubernetes container
deployment: <your-K8-deployment-name> # name of your Kubernetes deployment
image: <your-image> # name of your Docker image
tag: $CIRCLE_SHA1 # Docker image tag - optional
2.0 の設定を使用した GKE へのデプロイ
以下の例では、build-job
が終了し、現在のブランチが main
の場合に、CircleCI はデプロイジョブを実行します。
version: 2
jobs:
# build job ommitted for brevity
deploy-job:
docker:
- image: <docker-image-name-tag>
auth:
username: mydockerhub-user
password: $DOCKERHUB_PASSWORD # context / project UI env-var reference
working_directory: /tmp/my-project
steps:
- run:
name: Deploy Main to GKE
command: |
# Push Docker image to registry, update K8s deployment to use new image - `gcloud` command handles authentication and push all at once
sudo /opt/google-cloud-sdk/bin/gcloud docker push us.gcr.io/${PROJECT_NAME}/hello
# The new image is now available in GCR for the GCP infrastructure to access, next, change permissions:
sudo chown -R ubuntu:ubuntu /home/ubuntu/.kube
# Use `kubectl` to find the line that specifies the image to use for our container, replace with image tag of the new image.
# The K8s deployment intelligently upgrades the cluster by shutting down old containers and starting up-to-date ones.
kubectl patch deployment docker-hello-google -p '{"spec":{"template":{"spec":{"containers":[{"name":"docker-hello-google","image":"us.gcr.io/circle-ctl-test/hello:'"$CIRCLE_SHA1"'"}]}}}}'
workflows:
version: 2
build-deploy:
jobs:
- build-job
- deploy-job:
requires:
- build-job # Only deploy once the build job has completed
filters:
branches:
only: main # Only deploy on the main branch
他の例は、 CircleCI Google Cloud デプロイサンプルプロジェクト を参照してください。
ドキュメントの改善にご協力ください
このガイドは、CircleCI の他のドキュメントと同様にオープンソースであり、 GitHub でご利用いただけます。 ご協力いただき、ありがとうございます。
- このページの編集をご提案ください (最初に「コントリビューションガイド」をご覧ください)。
- ドキュメントの問題点を報告する、またはフィードバックやコメントを送信するには、GitHub で issue を作成してください。
- CircleCI は、ユーザーの皆様の弊社プラットフォームにおけるエクスペリエンスを向上させる方法を常に模索しています。 フィードバックをお寄せいただける場合は、リサーチコミュニティにご参加ください。
サポートが必要ですか
CircleCI のサポートエンジニアによる、サービスに関する問題、請求およびアカウントについての質問への対応、設定の構築に関する問題解決のサポートを行っています。 サポートチケットを送信して、CircleCI のサポートエンジニアにお問い合わせください。日本語でお問い合わせいただけます。
または、 サポートサイト から、サポート記事やコミュニティフォーラム、トレーニングリソースをご覧いただけます。
CircleCI Documentation by CircleCI is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.