### Setup Development Tools Source: https://github.com/tencentblueking/blueking-paas/blob/main/operator/README.md Commands to install necessary build, lint, and testing tools for the project. ```bash $ make controller-gen $ make kustomize ``` ```bash $ make ginkgo ``` ```bash $ make golines $ make gofumpt $ make golangci-lint ``` -------------------------------- ### Start the Project Server Source: https://github.com/tencentblueking/blueking-paas/blob/main/svc-bkrepo/README.md Run the Django development server to start the svc-bkrepo service. ```shell python manage.py runserver 8005 ``` -------------------------------- ### Start Services Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/README.md Commands to start the web server and celery background tasks. ```shell ❯ make server ``` ```shell ❯ make celery ``` -------------------------------- ### Initialize and Start Dependency Services Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/README.md Use docker-compose to initialize the environment and start required services like MySQL, Redis, and Minio. ```shell # 假设你当前在 apiserver 项目的根目录下 ❯ cd dev_utils/bundle # 参考 dev_utils/bundle/README.md,完成 .env 文件的初始化 ❯ echo "..." > .env # 利用 docker 启动依赖环境 ❯ ./start.sh ``` -------------------------------- ### Deployment Information Response Examples Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/en/module_env_released_state.md Examples of successful and error responses returned by the API. ```json { "is_offlined": false, "deployment": { "id": "114392d8-9e77-4011-83a9-41f1737e2466", "status": "successful", "operator": { "id": "0335cce79c92", "username": "admin", "provider_type": 3, "avatar": "" }, "created": "2024-08-16 10:07:33", "start_time": "2024-08-16 10:07:33", "complete_time": "2024-08-16 10:08:07", "finished_status": "release", "build_int_requested_at": null, "release_int_requested_at": null, "has_requested_int": false, "bkapp_revision_id": 247, "deployment_id": "114392d8-9e77-4011-83a9-41f1737e2466", "environment": "prod", "repo": { "source_type": null, "type": "tag", "name": "1.5.5", "url": "docker.example.com/bkpaas/docker/example/default:1.5.5", "revision": "1.5.5", "comment": "" } }, "offline": null, "exposed_link": { "url": "http://apps.example.com/" }, "default_access_entrance": { "url": "http://apps.example.com/" } } ``` ```json { "code": "APP_NOT_RELEASED", "detail": "The application has not been released in this environment" } ``` -------------------------------- ### Start Development Server Source: https://github.com/tencentblueking/blueking-paas/blob/main/webfe/README.md Run this command to start the development server. Replace '${版本代号}' with 'te' for Tencent internal versions or 'ee' for external versions. For 'te' versions, ensure webfe-settings is present in the package_vue directory. ```shell # 版本代号: te 代表腾讯内部版本、ee 代表外部版本 # 如果运行 te 版本,需要在 package_vue 目录下添加 webfe-settings npm run dev:${版本代号} ``` -------------------------------- ### Install Poetry and Project Dependencies Source: https://github.com/tencentblueking/blueking-paas/blob/main/svc-redis/README.md Install the poetry dependency manager and then install project dependencies. This is required before running project commands. ```shell ❯ pip install poetry==2.1.1 ❯ poetry install ``` -------------------------------- ### Initialize Node.js Dependencies Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/README.md Install frontend dependencies using npm. ```shell ❯ make init-node-dep ``` -------------------------------- ### Local Configuration Templates Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/README.md Example configuration snippets for local database and general resources. ```yaml DATABASE_HOST: '' DATABASE_NAME: bk_paas_ng DATABASE_PASSWORD: '' DATABASE_PORT: 3306 DATABASE_USER: root ``` ```text BKKRILL_ENCRYPT_SECRET_KEY: '' LOGIN_FULL: '' BKAUTH_USER_INFO_APIGW_URL: '' ``` -------------------------------- ### Initialize Python Dependencies Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/README.md Install project dependencies using poetry. ```shell ❯ make init-py-dep ``` -------------------------------- ### Install Project Dependencies with Poetry Source: https://github.com/tencentblueking/blueking-paas/blob/main/svc-bkrepo/README.md Initialize project dependencies using the make command, which leverages poetry. ```shell make init-py-dep ``` -------------------------------- ### Get Deployment Step Instance Request Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/zh/get_deploy_phases_instance.md Use this cURL command to make a GET request to retrieve deployment step instance details. Ensure you replace placeholders like *** with your actual credentials and app information. ```bash curl -X GET -H 'X-BKAPI-AUTHORIZATION: {"bk_app_code": "***", "bk_app_secret": "***", "access_token": "***"}' http://bkapi.example.com/api/bkpaas3/prod/bkapps/applications/{app_code}/modules/{module}/envs/{env}/get_deploy_phases/{deployment_id}/ ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/tencentblueking/blueking-paas/blob/main/docs/DEVELOP_GUIDE.md Install pre-commit hooks to ensure code quality on every commit. Assumes you are in the project root directory. ```bash # 假设你当前在 blueking-paas 项目的根目录下 ❯ pre-commit install ``` -------------------------------- ### Response Result Example (JSON) Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/en/batch_create_access_control_strategy.md This is an example of the JSON response received after attempting to add IP whitelists. It indicates which IPs were successfully added and which were ignored. ```json { "added": ["your", "ip", "list"], "ignored": [] } ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/tencentblueking/blueking-paas/blob/main/webfe/README.md Run this command in the webfe/package_vue directory to install project dependencies. If webpack version errors occur, remove node_modules and reinstall. ```shell npm install ``` -------------------------------- ### Initialize Database Source: https://github.com/tencentblueking/blueking-paas/blob/main/svc-otel/README.md Run migrations and load initial data fixtures. ```bash python manage.py migrate # 初始化数据放在 /data/fixtures 目录下 # 注意这里是社区版本的初始化数据,如果是其他版本,需要修改 plans.json 中 region 的值 python manage.py loaddata data/fixtures/plans.json data/fixtures/service.json ``` -------------------------------- ### Get Application Logs with Custom Time Range Source: https://context7.com/tencentblueking/blueking-paas/llms.txt Use this API to retrieve application logs within a specified custom time range. Requires authentication headers and a JSON payload with start and end times. ```bash curl -X POST \ -H 'X-Bkapi-Authorization: {"bk_app_code": "apigw-api-test", "bk_app_secret": "***"}' \ -d '{ "time_range": "customized", "start_time": "2024-01-15T00:00:00Z", "end_time": "2024-01-15T23:59:59Z" }' \ 'https://bkapi.example.com/api/bkpaas3/prod/bkapps/applications/my-app/modules/default/log/standard_output/list/' ``` -------------------------------- ### Install Python 3.11 via pyenv Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/README.md Install the required Python version using pyenv. ```shell ❯ pyenv install 3.11.10 ``` -------------------------------- ### Install Python 3.11 with pyenv Source: https://github.com/tencentblueking/blueking-paas/blob/main/svc-bkrepo/README.md Use pyenv to manage Python versions and install Python 3.11.10. ```shell pyenv install 3.11.10 ``` -------------------------------- ### Initialize Database Source: https://github.com/tencentblueking/blueking-paas/blob/main/svc-bkrepo/README.md Run Django's migrate command to initialize the database schema. ```python python manage.py migrate ``` -------------------------------- ### Install Node.js via nvm Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/README.md Install Node.js version 14 using nvm for Admin42 development. ```shell ❯ nvm install 14 ``` -------------------------------- ### API Response Examples Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/zh/upload_source_package_via_link.md Examples of successful and error responses returned by the upload source package API. ```json { "id": 1347, "version": "0.0.5", "package_name": "package_name:0.0.5", "package_size": "1415656", "sha256_signature": "a0c5e14c38eeaf3681bd5b429338e4e95ea8af3f30c05348a1479cfcf1cdf4d1", "is_deleted": false, "updated": "2024-08-20 19:37:00", "created": "2024-08-20 19:37:00", "operator": "operator name" } ``` ```json { "code": "UNSUPPORTED_SOURCE_ORIGIN", "detail": "未支持的源码来源" } ``` -------------------------------- ### Exception Response Examples Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/en/search_standard_log_with_post.md Examples of error responses returned when a query fails or validation errors occur. ```json { "code": "QUERY_LOG_FAILED", "detail": "Query log failed: ..." } ``` ```json { "code": "VALIDATION_ERROR", "detail": "...", "fields_detail": { "time_range": [ "this field can't be empty。" ] } } ``` -------------------------------- ### Initialize Configuration File Source: https://github.com/tencentblueking/blueking-paas/blob/main/bkpaas-cli/README.md Creates the default configuration file at ${HOME}/.blueking-paas/config.yaml. Ensure the API URLs and username are updated to match your environment. ```shell >>> mkdir ${HOME}/.blueking-paas && cat > ${HOME}/.blueking-paas/config.yaml << EOF # PaaS 平台及用户认证相关的 API 地址 paasApigwUrl: http://bkapi.example.com/api/bkpaas3 paasUrl: https://bkpaas3.example.com checkTokenUrl: http://apigw.example.com/auth/check_token/ # 用户名 username: admin accessToken: "" EOF ``` -------------------------------- ### API Response Example Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/zh/fetch_app_access_token.md This is an example of a successful API response when requesting an AccessToken. It includes the access_token, refresh_token, and their expiration time. ```json { "message": "", "code": "0", "data": { "access_token": "--", "refresh_token": "--", "expires_in": 604784 }, "result": true } ``` -------------------------------- ### Create Cloud-Native Application Source: https://context7.com/tencentblueking/blueking-paas/llms.txt Initialize a Kubernetes-based application using buildpack or Dockerfile build methods. ```bash curl -X POST \ -H 'Content-Type: application/json' \ -H 'X-Bkapi-Authorization: {"bk_app_code": "apigw-api-test", "bk_app_secret": "***", "bk_token": "***"}' \ -d '{ "code": "my-cnative-app", "name": "我的云原生应用", "source_config": { "source_init_template": "dj2_with_auth", "source_control_type": "bare_git", "source_repo_url": "https://github.com/example/my-app.git", "source_origin": 1, "source_dir": ".", "source_repo_auth_info": { "username": "git_user", "password": "git_token" } }, "bkapp_spec": { "build_config": { "build_method": "buildpack" } } }' \ 'https://bkapi.example.com/api/bkpaas3/stag/bkapps/cloud-native/' ``` -------------------------------- ### List All Applications with bkpaas-cli Source: https://context7.com/tencentblueking/blueking-paas/llms.txt Use the bkpaas-cli tool to list all applications managed by the Blueking PaaS platform. ```bash # 列出所有应用 bkpaas-cli app list ``` -------------------------------- ### Makefile Help for Development Commands Source: https://github.com/tencentblueking/blueking-paas/blob/main/bkpaas-cli/README.md Execute `make help` to display a list of available make targets for building, formatting, testing, and managing dependencies. ```shell >>> make help Usage: make help 展示可用 make 命令及说明 开发/构建命令 build 构建 bkpaas-cli 可执行文件 fmt 执行 golines,gofumpt ... vet 执行 go vet ./... tidy 执行 go mod tidy test 执行 ginkgo 单元测试 lint 执行 golangci-lint run 开发工具安装命令 install-ginkgo 下载 ginkgo 二进制 install-golines 下载 golines 二进制 install-gofumpt 下载 gofumpt 二进制 install-golangci-lint 下载 golangci-lint 二进制 ``` -------------------------------- ### API Response Example Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/zh/request_apps_access_permission.md This is an example of the JSON response structure when applying for multi-app access. The status field indicates the processing state of the application. ```python ret = res.json() ret == [{ "application": null, "status": "processing", "contacts": "蓝鲸助手", "reason": "平台权限需人工审核" }, { "application": { "id": "--", "code": "--", "name": "--" }, "status": "pass", "contacts": "rtx", "reason": "提单人具有应用的操作权限,单据自动通过" }, { "application": { "id": "--", "code": "--", "name": "--" }, "status": "processing", "contacts": "rtx", "reason": "提单人不具有该应用的操作权限, 需联系该应用的开发者进行审核" }, { "application": null, "status": "reject", "contacts": "rtx", "reason": "应用不存在" }] ``` -------------------------------- ### Deploy Regular App with Module Specification Source: https://github.com/tencentblueking/blueking-paas/blob/main/bkpaas-cli/README.md Deploy a regular application, specifying the app code, environment, and optionally a module name if it's not the default. This command also shows example build logs. ```shell >>> bkpaas-cli app deploy --bk-app-code=demo-app --env=stag --branch master Application demo-app deploying... Waiting for deploy finished... Waiting for deploy finished... Waiting for deploy finished... Logs: Preparing to build bkapp-demo-app-stag Starting build app: bkapp-demo-app-stag ... Generated build id: ec09dff9-a8a6-a990-6648-4489dff8866 building process finished. Deploy successful. ↗ Open developer center for more details: https://bkpaas3.example.com/developer-center/apps/demo-app/default/deploy/stag ``` -------------------------------- ### Exception Response Example for Manifest Update Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/en/import_manifest.md In case of validation errors or other issues during the manifest update, an exception response is returned. This example shows a 'VALIDATION_ERROR' with details. ```json { "code": "VALIDATION_ERROR", "detail": "apiVersion ... is not valid, ...", "fields_detail": [ "apiVersion ... is not valid, ..." ] } ``` -------------------------------- ### Build Frontend Project Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/README.md Build the frontend assets. ```shell ❯ make npm-build ``` -------------------------------- ### Response Result Example Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/en/analysis_total.md This is an example of the JSON response you can expect when querying application access volume. It includes metrics like page views (pv) and unique visitors (uv). ```json { "site": { "type": "app", "name": "--", "id": 38 }, "result": { "results": { "pv": 100, "uv": 12 }, "source_type": "tracked_pv_by_site", "display_name": "Total site access volume" } } ``` -------------------------------- ### Initialize Service Plans and Clusters Source: https://github.com/tencentblueking/blueking-paas/blob/main/svc-redis/README.md Use the Django shell to create a new Service, a Cluster, and a Plan for PaaS-Redis. This involves defining configuration parameters for the Redis instance. ```python python manage.py shell import json from paas_service.models import Service from paas_service.models import Plan from svc_redis.cluster.models import Cluster # category 为增强服务分类,apiserver 侧也需要参考 apiserver/paasng/fixtures/services.yaml 初始化增强服务分类 svc = Service.objects.create(name="paas_redis", display_name_zh_cn="PaaS-Redis", display_name_en="PaaS-Redis", category=1, logo="http://example.com", available_languages="python,golang,nodejs") # 创建集群 cluster = Cluster.objects.create( name="redis-cluster", type="normal", description="测试集群", ca_data="", cert_data="", key_data="", ) config = { # Redis 部署架构类型 # - "Redis": 单节点模式,适用于开发测试环境 # - "RedisReplication": 主从复制模式,提供基础高可用,适合生产环境 "type": "RedisReplication", # Redis 版本号 "redis_version": "v7.0.15", # Kubernetes 集群名称 "cluster_name": "redis-cluster", # 每个 Redis 实例的内存限制 "memory_size": "2Gi", # 服务暴露方式 (必填) # - "ClusterDNS": 通过集群内 DNS 访问服务 # - "TencentCLB": 通过腾讯云负载均衡器暴露服务 "service_export_type": "TencentCLB", # 是否启用持久化存储 # True 时会自动创建 PVC,需要集群已配置 StorageClass "persistent_storage": False, # 是否启用监控 # 依赖条件: # - 集群已安装 Prometheus Operator "monitor": False # 当前未启用监控 } Plan.objects.create(name="default-redis", description="redis 实例", is_active=True, service_id=svc.uuid, properties={}, config=json.dumps(config)) ``` -------------------------------- ### Response Example for Cluster and Namespace Info Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/en/list_cluster_namespaces_by_code.md This is an example of the JSON response you will receive when querying for application cluster and namespace information. It lists the BCS cluster ID and the corresponding namespace for each entry. ```json [ { "bcs_cluster_id": "BCS-K8S-40104", "namespace": "bkapp-appid1-stag" }, { "bcs_cluster_id": "BCS-K8S-40104", "namespace": "bkapp-appid1-prod" }, ] ``` -------------------------------- ### Initialize Service and Plan Data Source: https://github.com/tencentblueking/blueking-paas/blob/main/svc-rabbitmq/README.md Use the Django shell to create initial Service and Plan entries for RabbitMQ, including configuration details. Ensure the 'category' matches apiserver's configuration. ```python import json from paas_service.models import Service from paas_service.models import Plan # category 为增强服务分类,apiserver 侧也需要参考 apiserver/paasng/fixtures/services.yaml 初始化增强服务分类 svc = Service.objects.create(name="rabbitmq", display_name_zh_cn="RabbitMQ", display_name_en="RabbitMQ", category=1, logo="http://example.com", available_languages="python,golang,nodejs") config = { "host": "127.0.0.1", # RabbitMQ 服务的主机地址 "port": 5672, # RabbitMQ 服务的端口号 "management_api": "http://127.0.0.1:15672", # RabbitMQ 管理 API 的地址 "admin": "admin", # RabbitMQ 的管理员用户名 "password": "password", # RabbitMQ 的管理员密码 "version": "4.0.2", # RabbitMQ 的版本号 } Plan.objects.create(name="default", description="rabbitmq 实例", is_active=True, service_id=svc.uuid, properties={ "region":"default"}, config=json.dumps(config)) ``` -------------------------------- ### Create Kind Kubernetes Cluster Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/tests/paas_wl/e2e/ingress/README.md Create a Kubernetes cluster using kind with a specified image version and configuration file. This command initiates the cluster setup process. ```bash kind create cluster --image kindest/node:v1.20.15@sha256:6f2d011dffe182bad80b85f6c00e8ca9d86b5b8922cdf433d53575c4c5212248 --config=./kind.yaml ``` -------------------------------- ### Get Light Application Info Request Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/zh/get_light_applications.md Use this `curl` command to make a GET request to retrieve light application details. Ensure you have the correct `X-Bkapi-Authorization` header with your `bk_app_code` and `bk_app_secret`. ```bash curl -X GET -H 'X-Bkapi-Authorization: {"bk_app_code": "apigw-api-test", "bk_app_secret": "***"}' --insecure https://bkapi.example.com/api/bkpaas3/prod/system/light-applications?light_app_code=demo_code ``` -------------------------------- ### Configure bkpaas-cli with YAML Source: https://context7.com/tencentblueking/blueking-paas/llms.txt Create a configuration file for the bkpaas-cli tool to connect to the Blueking platform. This involves setting the API gateway URL, PaaS URL, and authentication endpoints. ```bash # 创建配置文件 mkdir -p ${HOME}/.blueking-paas cat > ${HOME}/.blueking-paas/config.yaml << EOF paasApigwUrl: http://bkapi.example.com/api/bkpaas3 paasUrl: https://bkpaas3.example.com checkTokenUrl: http://apigw.example.com/auth/check_token/ username: your_username accessToken: "" EOF ``` -------------------------------- ### Get App Details using cURL Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/zh/get_detailed_app_list.md Use this cURL command to make a GET request to the Blueking PaaS API to retrieve a detailed list of applications. Ensure you replace 'your access_token' with a valid token. ```bash curl -X GET -H 'Accept: */*' -H 'X-BKAPI-AUTHORIZATION: {"access_token": "your access_token"}' http://bkapi.example.com/api/bkpaas3/bkapps/applications/lists/detailed ``` -------------------------------- ### Deploy a Cloud-Native Application with Manifest File using bkpaas-cli Source: https://context7.com/tencentblueking/blueking-paas/llms.txt Deploy a cloud-native application to a specified environment using a local manifest file. ```bash # 部署云原生应用(通过 manifest 文件) bkpaas-cli app deploy --bk-app-code=cnative-app --env=stag -f ./bkapp.yaml ``` -------------------------------- ### 执行代码格式化与检查 Source: https://github.com/tencentblueking/blueking-paas/blob/main/sandbox/daemon/README.md 使用 Makefile 工具链进行代码格式化和静态检查。 ```bash $ make fmt $ make lint ``` -------------------------------- ### Initialize Vue Instance for Process Management Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/paasng/plat_admin/admin42/templates/admin42/settings/process_spec/process_spec_manage.html Sets up the Vue instance with custom delimiters and mixins to handle application process data and UI interactions. ```javascript new Vue({ el: "#proc-spec-plan-list", delimiters: ['$[', ']'], mixins: [SubmitMixin], data: function () { let prefix = window.location.href let filterKey = undefined let appStatus = undefined if (prefix.indexOf("?") > 0) { let query = querystring.parse(prefix.substr(prefix.indexOf("?") + 1)) filterKey = query[SEARCH_PARAM] appStatus = query["app_status"] || undefined } const processedAppList = app_data_list.map(app => ({ ...app, processesLoading: false, processes: null })); return { app_data_list: processedAppList, pagination, SEARCH_PARAM, filterKey, appStatus, dialog: { type: 'edit', visible: false, loading: true, row: { metadata: {}, plan: { max_replicas: 5 } } }, processSpecPlanList: [], urlForCreatingprocessSpecPlan: '{% url "admin.process_spec_plan.manage" %}', } }, methods: { clearSearch() { this.filterKey = ''; let prefix = window.location.href if (prefix.indexOf("?") > 0) { prefix = prefix.substr(0, prefix.indexOf("?")) } window.location.href = prefix }, searchApp() { let query = { offset: 0 } if (this.filterKey && this.filterKey.trim() !== '') { query[this.SEARCH_PARAM] = this.filterKey } if (this.appStatus) { query['app_status'] = this.appStatus } let prefix = window.location.href if (prefix.indexOf("?") > 0) { prefix = prefix.substr(0, prefix.indexOf("?")) } window.location.href = `${prefix}?${querystring.stringify(query)}` }, async handleExpandChange(row, expandedRows) { const isExpanding = expandedRows.includes(row); if (expandedRows.includes(row) && !row.processes) { this.$set(row, 'processesLoading', true); try { await this.fetchAppProcesses(row); this.$nextTick(() => { if (this.$refs.appTable) { this.$refs.appTable.toggleRowExpansion(row, true); } }); } catch (error) { console.error('获取应用进程信息失败:', error); this.$bkMessage({ theme: 'error', message: '获取应用进程信息失败,请稍后重试' }); } finally { this.$set(row, 'processesLoading', false); } } }, async fetchAppProcesses(appRow) { try { const response = await this.$http.get(URLRouter.list_processes.replace("${app_code}", appRow.code)); this.$set(appRow, 'processes', response.processes || []); this.$set(appRow, 'processCount', response.processCount || 0); return response; } catch (error) { this.$set(appRow, 'processes', []); throw error; } }, scale: function (row) { this.dialog.row = row this.dialog.form.process_spec_plan_id = undefined this.dialog.form.target_replicas = row.desired_replicas this.dialog.form.type = "实例数" this.dialog.visible = true }, editProcessSpecPlan: function (row) { this.dialog.row = row this.dialog.form.process_spec_plan_id = row.plan.id this.dialog.form.target_replicas = undefined this.dialog.form.type = "资源方案" this.dialog.loading = true this.fetchprocessSpecPlanList(row).then( data => { this.dialog.visible = true this.dialog.loading = false } ) }, fillUrlTemplate: function (url_template, {form, row}) { if (form.type === '实例数' ) { url_template = URLRouter['scale'] } else if (form.type === '资源方案') { url_template = URLRouter['switch_process_plan'] } return url_template.replace("${engine_app_name}", row.engine_app) .replace("${process_type}", row.type) }, submitCallback: function () { if (this.dialog.form.process_spec_plan_id !== undefined) { let selected_plan = this.processSpecPlanList.filter(item => item.id == this.dialog.form.process_spec_plan_id)[0] if (selected_plan === undefined) { window.location.reload() } else { this.dialog.row.plan = selected_plan } } if (this.dialog.form.target_replicas !== undefined) { this.dialog.row.plan.target_replicas = this.dialog.form.target_replicas this.dialog.row.desired_replicas = this.dialog.form.target_replicas } }, gotoCreateProcessSpecPlan: function () { let row = this.dialog.row let url = this.urlForCreatingprocessSpecPlan ``` -------------------------------- ### 查询蓝鲸插件列表请求示例 Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/zh/list_bk_plugins.md 使用 cURL 发送 GET 请求获取插件列表,需在请求头中提供有效的 API 授权信息。 ```bash curl -X GET -H 'X-Bkapi-Authorization: {"bk_app_code": "bk_apigw_test", "bk_app_secret": "***"}' --insecure https://bkapi.example.com/api/bkpaas3/prod/system/bk_plugins/ ``` -------------------------------- ### Create a module via cURL Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/en/create_module.md Use this request to initialize a new module. Ensure the X-Bkapi-Authorization header is correctly populated with valid credentials. ```bash curl -X POST -H 'Content-Type: application/json' -H 'X-Bkapi-Authorization: {"bk_app_code": "apigw-api-test", "bk_app_secret": "***", "bk_ticket": "***"}' -d '{ "name": "dd1", "source_config": { "source_init_template": "dj2_with_auth", "source_origin": 2 }, "bkapp_spec": { "build_config": { "build_method": "buildpack" } } }' --insecure https://bkapi.example.com/api/bkpaas3/prod/bkapps/applications/{app_code}/modules/ ``` -------------------------------- ### GET /api/bkpaas3/prod/system/uni_applications/query/by_id/ Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/zh/uni_apps_query_by_id.md Retrieves basic information for a list of applications based on their IDs. ```APIDOC ## GET /api/bkpaas3/prod/system/uni_applications/query/by_id/ ### Description Queries basic application information by application ID. This endpoint is intended for internal system use only. ### Method GET ### Endpoint https://bkapi.example.com/api/bkpaas3/prod/system/uni_applications/query/by_id/ ### Parameters #### Query Parameters - **id** (List[string]) - Required - Comma-separated list of application IDs (bk_app_code). - **include_inactive_apps** (boolean) - Optional - Whether to include inactive applications. Default is False. - **include_developers_info** (boolean) - Optional - Whether to include developer information. Default is True. ### Request Example curl -X GET -H 'X-Bkapi-Authorization: {"bk_app_code": "apigw-api-test", "bk_app_secret": "***"}' --insecure 'https://bkapi.example.com/api/bkpaas3/prod/system/uni_applications/query/by_id/?id={bk_app_code}' ### Response #### Success Response (200) - **source** (int) - Application source platform (1: v3, 2: old version) - **name** (string) - Application name - **code** (string) - Application code - **region** (string) - Application region - **logo_url** (string) - Application Logo URL - **developers** (List[string]) - List of application developers - **creator** (string) - Application creator - **created** (string) - Application creation time - **contact_info** (dict) - Contact information object #### Response Example [ { "source": 1, "name": "蝙蝠侠", "code": "batman", "region": "default", "logo_url": "http://example.com/app-logo/blueking_app_default.png", "developers": ["username"], "creator": "username", "created": "2019-08-13 19:15:38", "contact_info": { "latest_operator": "username", "recent_deployment_operators": ["username"] } } ] ``` -------------------------------- ### 获取部署历史请求示例 Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/zh/get_deployments_list.md 使用 cURL 发送 GET 请求获取部署历史,需在 Header 中携带 access_token。 ```bash curl -X GET -H 'X-BKAPI-AUTHORIZATION: {"access_token": "your access_token"}' http://bkapi.example.com/api/bkpaas3/prod/bkapps/applications/{appcode}/modules/{module_name}/deployments/lists/ ``` -------------------------------- ### Create Cloud-Native Application Manifest Source: https://github.com/tencentblueking/blueking-paas/blob/main/bkpaas-cli/README.md Generates a sample BkApp manifest file for cloud-native application deployment. ```shell # 云原生应用有两种部署方式,一种是通过导入 BkApp 的 manifest,一种是通过指定代码分支或者镜像标签 # 方式一:首先你需要准备一份 BkApp 的 manifest,可以在 云原生应用 -> 模块配置 -> 查看 YAML >>> cat > ./bkapp.yaml << EOF apiVersion: paas.bk.tencent.com/v1alpha1 kind: BkApp metadata: name: cnative-demo spec: processes: - image: strm/helloworld-http imagePullPolicy: IfNotPresent cpu: 250m memory: 256Mi name: web replicas: 2 targetPort: 80 EOF ``` -------------------------------- ### 获取部署历史请求示例 Source: https://github.com/tencentblueking/blueking-paas/blob/main/apiserver/paasng/support-files/apigw/api_doc/zh/get_deployments_history.md 使用 cURL 发送 GET 请求以获取部署历史列表,需在 Header 中提供有效的 X-BKAPI-AUTHORIZATION。 ```bash curl -X GET -H 'X-BKAPI-AUTHORIZATION: {"access_token": "your access_token"}' http://bkapi.example.com/api/bkpaas3/prod/bkapps/applications/{appcode}/deployments/lists ``` -------------------------------- ### View Configuration Content Source: https://github.com/tencentblueking/blueking-paas/blob/main/bkpaas-cli/README.md Execute `bkpaas-cli config view` to display the currently loaded configuration file path and its contents. ```shell >>> bkpaas-cli config view configFilePath: /root/.blueking-paas/config.yaml paasApigwUrl: http://bkapi.example.com/api/bkpaas3 paasUrl: https://bkpaas3.example.com checkTokenUrl: http://apigw.example.com/auth/check_token/ username: admin accessToken: [REDACTED] ```