クラウドでシークレットと設定を管理する
実行時に認証情報を安全に注入します。
「クラウドでシークレットと設定を管理する」はCoddyKit上の無料MLOps Academyレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはMLOps Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 MLOps Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Keep Secrets Out of Images
A database password baked into an image leaks to anyone who pulls it. Inject secrets at runtime instead, never at build time. 🔐
Config vs Secrets
Plain settings like a model path are config. Sensitive values like API keys are secrets. Both stay outside the image, handled differently.
Env Vars for Plain Config
Non-sensitive settings ride in as environment variables at deploy time. The same image then behaves differently in staging and production.
gcloud run deploy model-api --set-env-vars MODEL_STAGE=ProductionRead Them in Code
Your app reads those values with os.environ. Provide a sensible default so the code still runs locally without every variable set.
stage = os.environ.get("MODEL_STAGE", "Staging")Use a Secret Manager
Real secrets belong in a secret manager like AWS Secrets Manager or Google Secret Manager. It encrypts, versions, and audits access.
Reference, Do Not Embed
You attach a secret by reference, and the platform mounts the value at runtime. The secret never appears in your deploy command.
gcloud run deploy model-api --set-secrets API_KEY=api-key:latestMount as Env or File
A secret can land as an environment variable or a mounted file. Certificates and long keys are often cleaner read from a file path.
Grant Least Privilege
Give the service account only the secrets it truly needs. This least privilege rule shrinks the blast radius if a token ever leaks.
Rotate Without Redeploying
Pin secrets to a version like latest, then rotate by adding a new version. New instances pick it up with no image rebuild needed.
Never Log a Secret
Logs are stored and widely readable, so a printed key is as good as public. Scrub secrets from output and from error traces alike.
One Image, Many Environments
With config and secrets external, a single image runs everywhere. You change behavior by swapping variables, not by rebuilding.
Quick Check
Let us check the safe way to handle an API key.
Recap
You split config from secrets, injected both at runtime, used a secret manager, and rotated safely. One image now runs anywhere. 🔑
よくある質問
「クラウドでシークレットと設定を管理する」レッスンは無料ですか?
はい。「クラウドでシークレットと設定を管理する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、MLOps Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 MLOps Academyコースには全4レッスンが含まれています。
「クラウドでシークレットと設定を管理する」で何を学びますか?
実行時に認証情報を安全に注入します。 ブラウザで直接実行するハンズオンコードでMLOps Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
MLOps Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのMLOps Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「クラウドでシークレットと設定を管理する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このMLOps Academyレッスンでコードを書いて実行できますか?
はい。すべてのMLOps Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- イメージをレジストリにプッシュする
- サーバーレスコンテナランタイムにデプロイする
- オートスケーリングと同時実行数を設定する
- クラウドでシークレットと設定を管理する