建立專案
在 專構件的集合,用來定義及管理資源和「基礎架構即程式碼」部署。 案中,您可以從目錄中新增可部署的架構,並編輯其設定。 從專案部署設定時,系統會根據您部署的設定來分組資源。
開始之前
系統會在專案帳戶中為使用者建立資源。 您必須擁有在帳戶內建立專案的權限,以及建立專案工具資源的權限。 確保您擁有下列存取權限:
- IBM Cloud 專案服務上的編輯角色。
- IBM Cloud® Schematics 服務中的編輯與管理員角色
- 專案資源群組上的檢視者角色
有關存取權限的詳細資訊,請參閱《 指派使用者存取專案的權限 》。
新增使用者至專案
專案存取權限由 IBM CloudIdentity and Access Management (IAM)進行管控。 您可透過在專案實例中授予讀取者角色或更高權限,將使用者新增至專案。 有關指派專案存取權限的詳細資訊,請參閱 《指派使用者專案存取權限》。
使用主控台建立專案
您可以透過前往 圖示 導航選單 並選擇 專案 或從 中的可部署 目錄 架構來建立專案。 專 案亦可透過專案 API 進行建立。
透過控制台為專案新增可部署架構
您添加至專案的可部署架構,在專案使用者介面中以配置形式呈現。 在專案中新增可部署架構後,您可在部署前編輯其設定。 有幾種方法可為您的專案添加可部署架構。
若要從專案儀表板為您的專案新增可部署架構,請完成以下步驟:
- 從專案儀表板中,選擇「設定」標籤頁。
- 按一下建立。
- 從目錄中選擇可部署的架構。
- 按一下組態和部署。
您亦可直接從目錄將可部署架構新增至專案:
- 前往 IBM Cloud 目錄。
- 選擇可部署架構。
- 從目錄清單中,您可以建立新專案或新增至現有專案。
- 按一下組態和部署。
在您的專案中自訂可部署架構
根據可部署架構的不同,您可能在從目錄將其新增至專案時進行自訂。 您可能有以下選項:
- 添加可選的部署架構,以擴展特定使用案例的解決方案。
- 將一種架構替換為另一種架構。 例如,若提供多個資料庫選項,您可選擇欲使用的資料庫。
- 從專案中選取現有的架構設定,以便與您正在新增的架構重複使用。 透過此方式,您可降低成本並重複使用相同的部署方案於多種架構。
在目錄清單的「擴展此架構」區段中,點擊「自訂」以在配置和部署前優化您的架構。 若在可部署架構的目錄清單中未提供 「自訂」 選項,您仍 可透過在專案中疊加其他可部署架構來 配置並自訂該架構。
在您完成選項設定並將可部署架構加入專案後,可透過點選「設定」標籤頁中的 自訂架構 圖示 選項 > 進一步進行自訂。 從此處出發,您可添加其他相容的可部署架構,進一步客製化解決方案。
若要在 IBM Cloud 專案服務之外備份專案資訊,您可以匯出專案。 如需詳細資訊,請前往 專案 JSON。
當您準備好從專案中的 可部署架構 部署資源時,請參閱如何配置和部署可部署架構的步驟。
使用 CLI 建立專案
若要使用命令列介面建立專案,請執行以下 ibmcloud project create 指令:
ibmcloud project create [--definition DEFINITION | --definition-name DEFINITION-NAME --definition-destroy-on-delete=DEFINITION-DESTROY-ON-DELETE --definition-description DEFINITION-DESCRIPTION --definition-auto-deploy=DEFINITION-AUTO-DEPLOY --definition-monitoring-enabled=DEFINITION-MONITORING-ENABLED] --location LOCATION --resource-group RESOURCE-GROUP [--configs CONFIGS] [--environments ENVIRONMENTS]
請參閱 ibmcloud project create 以查看範例指令及更多關於指令參數的資訊。
透過命令列介面將可部署架構新增至專案
若要透過命令列介面為專案新增可部署架構,請執行以下 ibmcloud project config-create 指令:
ibmcloud project config-create --project-id PROJECT-ID [--definition DEFINITION | --definition-compliance-profile DEFINITION-COMPLIANCE-PROFILE --definition-locator-id DEFINITION-LOCATOR-ID --definition-description DEFINITION-DESCRIPTION --definition-name DEFINITION-NAME --definition-environment-id DEFINITION-ENVIRONMENT-ID --definition-authorizations DEFINITION-AUTHORIZATIONS --definition-inputs DEFINITION-INPUTS --definition-settings DEFINITION-SETTINGS --definition-members DEFINITION-MEMBERS --definition-resource-crns DEFINITION-RESOURCE-CRNS] [--schematics SCHEMATICS | --schematics-workspace-crn SCHEMATICS-WORKSPACE-CRN]
請參閱 ibmcloud project config-create 以查看範例指令及更多關於指令參數的資訊。
若要在 IBM Cloud 專案服務之外備份專案資訊,您可以匯出專案。 如需詳細資訊,請前往 專案 JSON。
使用 API 建立專案
您可以 透過程式化方式呼叫專案 API 來建立專案,如下列範例請求所示:
curl -X POST --location --header "Authorization: Bearer {iam_token}" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '{ "definition": { "name": "acme-microservice", "description": "A microservice to deploy on top of ACME infrastructure.", "authorizations": { "method": "trusted_profile", "trusted_profile_id": "Profile-9ac10c5c-195c-41ef-b465-68a6b6dg5f12" } }, "configs": [ { "definition": { "name": "account-stage", "description": "The stage account configuration.", "locator_id": "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" } }, { "definition": { "name": "env-stage", "description": "The stage environment configuration that includes services common to all the environment regions.", "locator_id": "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global", "inputs": { "account_id": "ref:/configs/account-stage/inputs/account_id", "resource_group": "stage", "access_tags": [ "env:stage" ], "logdna_name": "The name of the LogDNA stage service instance.", "sysdig_name": "The name of the SysDig stage service instance." } } }, { "definition": { "name": "region-us-south-stage", "description": "The stage us-south configuration.", "locator_id": "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global" } }, { "definition": { "name": "region-eu-de-stage", "description": "The stage eu-de configuration.", "locator_id": "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global", "inputs": { "account_id": "ref:/configs/account-stage/inputs/account_id", "resource_group": "ref:/configs/env-stage/outputs/resource_group_id", "logdna_id": "ref:/configs/env-stage/outputs/logdna_id", "sysdig_id": "ref:/configs/env-stage/outputs/sysdig_id", "access_tags": [ "region:eu-de" ] } } } ], "location": "us-south", "resource_group": "Default" }' \
"{base_url}/v1/projects"
透過 API 為專案新增可部署架構
您可以透過程式化方式將可部署架構新增至現有專案,方法是呼叫 Projects API 並自訂設定,如下列範例請求所示:
curl -X POST --location --header "Authorization: Bearer {iam_token}" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '{ "definition": { "name": "env-stage", "description": "The stage environment configuration.", "locator_id": "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global", "inputs": { "account_id": "account_id", "resource_group": "stage", "access_tags": [ "env:stage" ], "logdna_name": "LogDNA_stage_service", "sysdig_name": "SysDig_stage_service" } } }' \
"{base_url}/v1/projects/{project_id}/configs"
若要在 IBM Cloud 專案服務之外備份專案資訊,您可以匯出專案。 如需詳細資訊,請前往 專案 JSON。