crossplane/stack-azureCrossplane Stack for Microsoft Azure 是一个基于 Crossplane 的扩展组件(Stack),旨在通过 Kubernetes API 统一管理 Microsoft Azure 云资源。作为 Crossplane 生态的一部分,该 Stack 提供了与 Azure 云服务的深度集成,允许用户以声明式方式定义、部署和管理 Azure 基础设施资源(如虚拟机、存储账户、网络组件等),实现基础设施即代码(IaC)与 Kubernetes 控制平面的无缝协同。
kubectl、Kubernetes API 或客户端工具(如 Terraform、ArgoCD)进行操作。tenantID、clientID、clientSecret、subscriptionID)。Azure Stack 通过 Crossplane Provider 实现与 Azure API 的交互,需先部署 Provider CRD 和控制器:
bash# 部署 Azure Provider CRD kubectl apply -f [***] kubectl apply -f [***] # 其他 CRDs(根据版本调整) # 部署 Provider 控制器(通过 Crossplane Package) kubectl apply -f - <<EOF apiVersion: pkg.crossplane.io/v1 kind: Provider metadata: name: provider-azure spec: package: xpkg.upbound.io/crossplane-contrib/provider-azure:v0.31.0 EOF
确认 Provider 状态为 HEALTHY:
bashkubectl get providers # 输出示例: # NAME INSTALLED HEALTHY PACKAGE AGE # provider-azure True True xpkg.upbound.io/crossplane-contrib/provider-azure:v0.31.0 5m
将 Azure Service Principal 信息存储为 Kubernetes Secret:
bashkubectl create secret generic azure-creds -n crossplane-system --from-literal=credentials='{ "tenantId": "your-azure-tenant-id", "clientId": "your-azure-client-id", "clientSecret": "your-azure-client-secret", "subscriptionId": "your-azure-subscription-id" }'
创建 ProviderConfig 以关联认证信息,供 Azure 资源管理使用:
yaml# azure-provider-config.yaml apiVersion: azure.crossplane.io/v1beta1 kind: ProviderConfig metadata: name: default spec: credentials: source: Secret secretRef: namespace: crossplane-system name: azure-creds key: credentials subscriptionID: "your-azure-subscription-id" # 可选,若 Secret 中已包含可省略
应用配置:
bashkubectl apply -f azure-provider-config.yaml
通过 Crossplane ManagedResource 定义 Azure 存储账户:
yaml# azure-storage-account.yaml apiVersion: storage.azure.crossplane.io/v1alpha1 kind: Account metadata: name: example-storage spec: forProvider: accountTier: Standard accountReplicationType: LRS location: eastus providerConfigRef: name: default # 关联上文定义的 ProviderConfig writeConnectionSecretToRef: name: storage-conn namespace: default
部署资源:
bashkubectl apply -f azure-storage-account.yaml
检查存储账户是否创建成功:
bashkubectl get accounts.storage.azure.crossplane.io example-storage # 输出示例(状态为 READY 表示成功): # NAME READY SYNCED EXTERNAL-NAME AGE # example-storage True True example-storage 3m
通过 合成资源(Composite Resources) 和 资源类(ResourceClass) 抽象通用 Azure 资源配置,实现标准化复用。例如,定义一个“开发环境存储账户”资源类:
yaml# storage-resource-class.yaml apiVersion: core.crossplane.io/v1alpha1 kind: ResourceClass metadata: name: azure-storage-dev spec: provisioner: account.storage.azure.crossplane.io/v1alpha1 parameters: accountTier: Standard accountReplicationType: LRS location: eastus providerConfigRef: name: default
Azure Stack 相关镜像(Provider 控制器)托管于 Upbound Registry:
bashdocker pull xpkg.upbound.io/crossplane-contrib/provider-azure:v0.31.0
Provider 控制器部署 YAML(由 Crossplane 自动管理,通常无需手动修改):
yamlapiVersion: apps/v1 kind: Deployment metadata: name: crossplane-contrib-provider-azure namespace: crossplane-system spec: replicas: 1 selector: matchLabels: pkg.crossplane.io/provider: provider-azure template: metadata: labels: pkg.crossplane.io/provider: provider-azure spec: containers: - name: provider image: xpkg.upbound.io/crossplane-contrib/provider-azure:v0.31.0 args: - --debug resources: limits: cpu: 1000m memory: 1Gi requests: cpu: 100m memory: 20Mi
| 参数路径 | 描述 | 示例值 | 必需性 |
|---|---|---|---|
spec.credentials.secretRef.name | 存储 Azure 认证信息的 Secret 名称 | azure-creds | 是 |
spec.credentials.secretRef.key | Secret 中认证信息的 Key | credentials | 是 |
spec.subscriptionID | Azure 订阅 ID | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | 是 |
spec.forProvider.location | Azure 资源部署区域 | eastus | 是 |
spec.forProvider.accountTier | 存储账户层级(针对存储资源) | Standard | 是 |
Provider 资源事件:kubectl describe provider provider-azure。kubectl describe account example-storage 或 kubectl logs -n crossplane-system deployment/crossplane-contrib-provider-azure。tenantID/clientID/clientSecret 是否正确。


manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务