How tencentblueking/bkpaas-python-sdk works
Project Type and Purpose
• This is a monorepo of multiple related Python SDKs (blue-krill, bkstorages, bkapi-client-core, bkapi-component-open, apigw-manager, bkpaas-auth, paas-service), packaged and released together to support BlueKing PaaS/SaaS development.
• Each SDK provides reusable building blocks: utility functions, storage backends, API clients, authentication modules, gateway management, and an enhanced service framework.
File-Structure Analysis
• Top-level: CI configurations (.ci/, .github/workflows/), documentation (docs/), monorepo pyproject.toml, readme.md, license.
• sdks/: seven independent Python packages, each with its own tests, demos, build files.
• blue-krill: core utilities (async, auth, monitoring, storage, web helpers)
• bkstorages: Django storage backends for BlueKing repo & S3
• bkapi-client-core: generic BlueKing Cloud API & ESB client
• bkapi-component-open: client for “component open” APIs
• apigw-manager: CLI/Django management commands to sync API Gateway
• bkpaas-auth: PaaS-internal auth (token, middleware, plugins)
• paas-service: PaaS enhancement framework (models, views, tasks)
• Build/Ops: Poetry/pyproject, Makefiles, Dockerfiles (for apigw-manager), GitHub Actions workflows for each SDK.
Key Insights from README
• Purpose: eliminate repeated designs, provide best practices for common PaaS development scenarios.
• Audience: PaaS/SaaS developers integrating with BlueKing ecosystem.
• Tech stack: Python ≥3.6, Django integrations, Kubernetes (Helm charts in examples), S3/Ceph storage, Prometheus for monitoring, JWT for auth.
• Developer Environment – local code, pip installs SDKs
• Monorepo & CI/CD – GitHub repo, CI pipelines, PyPI/Artifacts registry
• SDK Packages – each of the seven sdks/* as separate modules
• BlueKing PaaS Control Plane – API Gateway, ESB, CMDB, Token Service
• External Services – S3/Ceph storage, Kubernetes API Server, Prometheus
• Client Apps – Django apps or CLI tools that consume the SDKs
• Developer → Monorepo: commits, PRs trigger CI/CD
• CI/CD → Package Registry: build & publish each SDK
• Client Apps → SDKs: import & call functions
• SDKs → BlueKing PaaS APIs: REST calls via bkapi-client-core, bkapi-component-open, apigw-manager
• bkpaas-auth → Token Service/DB: user authentication & token validation
• bkstorages → S3/Ceph: upload/download files
• blue-krill/monitoring → Prometheus: metrics/probes
• apigw-manager → Kubernetes API: deploy Helm charts, sync Gateway resources
c. Architectural Patterns & Principles
• Modular monorepo: independent, loosely coupled packages
• Reusable library pattern: common “blue-krill” core, layered dependencies
• CI/CD as code: per-SDK GitHub Actions pipelines, shared templates
• Test-driven & demo apps: each SDK has tests and example/demo integrations
d. Technologies & Frameworks
• Python 3.6+, Poetry/pyproject for packaging
• Django for web integrations (apigw-manager, paas-service, bkstorages)
• Helm/Kubernetes for Gateway sync
• REST & HTTP clients for BlueKing APIs, ESB
• Prometheus client libraries for monitoring