一键导入
azure-aks
Generate AKS cluster configs, node pools, and Kubernetes manifests. Use when the user wants to set up or configure Kubernetes on Azure AKS.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate AKS cluster configs, node pools, and Kubernetes manifests. Use when the user wants to set up or configure Kubernetes on Azure AKS.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Generate Cloudflare AI configs with Workers AI, Vectorize, and AI Gateway. Use when the user wants to run AI inference at the edge, build RAG pipelines, or proxy AI providers through Cloudflare.
Generate D1 SQLite database schemas, queries, and edge-native patterns. Use when the user wants to create, query, or manage Cloudflare D1 databases with Workers or Pages.
Generate Workers KV configs for global key-value storage at the edge. Use when the user wants to store and retrieve data globally with low-latency reads from Cloudflare's edge network.
Generate Cloudflare Pages configs with SSR, functions, and edge deployment. Use when the user wants to deploy full-stack web applications with static assets, server-side rendering, or API functions on Cloudflare Pages.
Generate Cloudflare Queues for reliable message processing at the edge. Use when the user wants to implement task queues, background processing, fan-out patterns, or event-driven architectures on Cloudflare.
Generate R2 storage configs with S3 compatibility, lifecycle, and public access. Use when the user wants to store, serve, or manage objects with zero egress fees on Cloudflare R2.
| name | azure-aks |
| description | Generate AKS cluster configs, node pools, and Kubernetes manifests. Use when the user wants to set up or configure Kubernetes on Azure AKS. |
| argument-hint | [cluster-name] [node-count] [description] |
| disable-model-invocation | true |
| allowed-tools | Read, Write, Edit, Glob, Grep, Bash(az *), Bash(kubectl *), Bash(helm *), Bash(kubelogin *) |
| user-invocable | true |
You are an Azure Kubernetes Service (AKS) expert. Generate production-ready AKS cluster configurations and Kubernetes manifests.
Determine from user input or $ARGUMENTS:
Bicep template:
param location string = resourceGroup().location
param clusterName string
param nodeCount int = 3
param vmSize string = 'Standard_D4s_v5'
resource aks 'Microsoft.ContainerService/managedClusters@2024-01-01' = {
name: clusterName
location: location
identity: { type: 'SystemAssigned' }
sku: {
name: 'Base'
tier: 'Standard' // Use 'Standard' for production (SLA), 'Free' for dev
}
properties: {
kubernetesVersion: '1.29'
dnsPrefix: clusterName
enableRBAC: true
aadProfile: {
managed: true
enableAzureRBAC: true
adminGroupObjectIDs: ['<aad-admin-group-id>']
}
agentPoolProfiles: [
{
name: 'system'
count: 3
vmSize: 'Standard_D2s_v5'
osType: 'Linux'
osSKU: 'AzureLinux'
mode: 'System'
availabilityZones: ['1', '2', '3']
enableAutoScaling: true
minCount: 2
maxCount: 5
maxPods: 110
vnetSubnetID: aksSubnet.id
nodeTaints: ['CriticalAddonsOnly=true:NoSchedule']
upgradeSettings: { maxSurge: '33%' }
}
]
networkProfile: {
networkPlugin: 'azure'
networkPluginMode: 'overlay'
networkPolicy: 'cilium'
networkDataplane: 'cilium'
serviceCidr: '10.0.0.0/16'
dnsServiceIP: '10.0.0.10'
loadBalancerSku: 'standard'
outboundType: 'loadBalancer'
}
autoUpgradeProfile: {
upgradeChannel: 'stable'
nodeOSUpgradeChannel: 'NodeImage'
}
securityProfile: {
defender: {
securityMonitoring: { enabled: true }
logAnalyticsWorkspaceResourceId: logAnalytics.id
}
imageCleaner: {
enabled: true
intervalHours: 48
}
workloadIdentity: { enabled: true }
}
oidcIssuerProfile: { enabled: true }
addonProfiles: {
omsagent: {
enabled: true
config: {
logAnalyticsWorkspaceResourceID: logAnalytics.id
}
}
azureKeyvaultSecretsProvider: {
enabled: true
config: {
enableSecretRotation: 'true'
rotationPollInterval: '2m'
}
}
azurepolicy: { enabled: true }
}
apiServerAccessProfile: {
enablePrivateCluster: false // true for production
authorizedIPRanges: ['203.0.113.0/24'] // restrict API access
}
storageProfile: {
diskCSIDriver: { enabled: true }
fileCSIDriver: { enabled: true }
blobCSIDriver: { enabled: true }
snapshotController: { enabled: true }
}
}
}
General-purpose node pool:
resource userNodePool 'Microsoft.ContainerService/managedClusters/agentPools@2024-01-01' = {
parent: aks
name: 'workload'
properties: {
vmSize: vmSize
count: nodeCount
osType: 'Linux'
osSKU: 'AzureLinux'
mode: 'User'
availabilityZones: ['1', '2', '3']
enableAutoScaling: true
minCount: 2
maxCount: 20
maxPods: 110
vnetSubnetID: aksSubnet.id
nodeLabels: {
'workload-type': 'general'
}
upgradeSettings: { maxSurge: '33%' }
}
}
Spot node pool for cost savings:
resource spotNodePool 'Microsoft.ContainerService/managedClusters/agentPools@2024-01-01' = {
parent: aks
name: 'spot'
properties: {
vmSize: 'Standard_D4s_v5'
count: 0
osType: 'Linux'
osSKU: 'AzureLinux'
mode: 'User'
availabilityZones: ['1', '2', '3']
enableAutoScaling: true
minCount: 0
maxCount: 10
scaleSetPriority: 'Spot'
scaleSetEvictionPolicy: 'Delete'
spotMaxPrice: json('-1')
nodeTaints: ['kubernetes.azure.com/scalesetpriority=spot:NoSchedule']
nodeLabels: {
'kubernetes.azure.com/scalesetpriority': 'spot'
}
}
}
GPU node pool:
resource gpuNodePool 'Microsoft.ContainerService/managedClusters/agentPools@2024-01-01' = {
parent: aks
name: 'gpu'
properties: {
vmSize: 'Standard_NC6s_v3'
count: 0
osType: 'Linux'
mode: 'User'
enableAutoScaling: true
minCount: 0
maxCount: 4
nodeTaints: ['sku=gpu:NoSchedule']
nodeLabels: { 'hardware': 'gpu' }
}
}
Create federated identity for a Kubernetes service account:
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
name: '${clusterName}-workload-id'
location: location
}
resource federatedCredential 'Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials@2023-01-31' = {
parent: managedIdentity
name: 'kubernetes-federated'
properties: {
issuer: aks.properties.oidcIssuerProfile.issuerURL
subject: 'system:serviceaccount:my-namespace:my-service-account'
audiences: ['api://AzureADTokenExchange']
}
}
Kubernetes ServiceAccount manifest:
apiVersion: v1
kind: ServiceAccount
metadata:
name: my-service-account
namespace: my-namespace
annotations:
azure.workload.identity/client-id: "<managed-identity-client-id>"
labels:
azure.workload.identity/use: "true"
Deployment with best practices:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
namespace: my-namespace
labels:
app: my-app
version: v1
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 0
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
version: v1
azure.workload.identity/use: "true"
spec:
serviceAccountName: my-service-account
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: my-app
containers:
- name: my-app
image: myacr.azurecr.io/my-app:v1.0.0
ports:
- containerPort: 8080
protocol: TCP
resources:
requests:
cpu: "250m"
memory: "256Mi"
limits:
cpu: "500m"
memory: "512Mi"
livenessProbe:
httpGet:
path: /health/live
port: 8080
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet:
path: /health/ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
startupProbe:
httpGet:
path: /health/startup
port: 8080
failureThreshold: 30
periodSeconds: 5
env:
- name: AZURE_CLIENT_ID
valueFrom:
secretKeyRef:
name: app-secrets
key: client-id
volumeMounts:
- name: secrets-store
mountPath: "/mnt/secrets-store"
readOnly: true
volumes:
- name: secrets-store
csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: azure-kv-secrets
---
apiVersion: v1
kind: Service
metadata:
name: my-app
namespace: my-namespace
spec:
selector:
app: my-app
ports:
- port: 80
targetPort: 8080
protocol: TCP
type: ClusterIP
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: my-app
namespace: my-namespace
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: my-app
minReplicas: 3
maxReplicas: 20
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80
behavior:
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 10
periodSeconds: 60
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Percent
value: 100
periodSeconds: 15
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: my-app
namespace: my-namespace
spec:
minAvailable: 2
selector:
matchLabels:
app: my-app
SecretProviderClass:
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
name: azure-kv-secrets
namespace: my-namespace
spec:
provider: azure
parameters:
usePodIdentity: "false"
clientID: "<managed-identity-client-id>"
keyvaultName: "my-keyvault"
objects: |
array:
- |
objectName: db-connection-string
objectType: secret
- |
objectName: api-key
objectType: secret
tenantId: "<tenant-id>"
secretObjects:
- secretName: app-secrets
type: Opaque
data:
- objectName: db-connection-string
key: database-url
- objectName: api-key
key: api-key
Application Gateway Ingress Controller (AGIC):
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-app-ingress
namespace: my-namespace
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/ssl-redirect: "true"
appgw.ingress.kubernetes.io/backend-protocol: "http"
appgw.ingress.kubernetes.io/health-probe-path: "/health"
appgw.ingress.kubernetes.io/waf-policy-for-path: "/subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/my-waf"
spec:
tls:
- hosts:
- api.myapp.com
secretName: tls-secret
rules:
- host: api.myapp.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-app
port:
number: 80
NGINX Ingress Controller (managed):
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-app-ingress
namespace: my-namespace
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/proxy-body-size: "10m"
nginx.ingress.kubernetes.io/rate-limit-rps: "100"
spec:
ingressClassName: webapprouting.kubernetes.azure.com
tls:
- hosts:
- api.myapp.com
secretName: tls-secret
rules:
- host: api.myapp.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-app
port:
number: 80
resource fluxConfig 'Microsoft.KubernetesConfiguration/fluxConfigurations@2023-05-01' = {
name: 'cluster-config'
scope: aks
properties: {
scope: 'cluster'
namespace: 'flux-system'
sourceKind: 'GitRepository'
gitRepository: {
url: 'https://github.com/myorg/k8s-manifests'
repositoryRef: { branch: 'main' }
syncIntervalInSeconds: 120
}
kustomizations: {
infrastructure: {
path: './infrastructure'
prune: true
syncIntervalInSeconds: 120
}
apps: {
path: './apps/production'
prune: true
dependsOn: ['infrastructure']
syncIntervalInSeconds: 120
}
}
}
}
resource "azurerm_kubernetes_cluster" "main" {
name = var.cluster_name
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
dns_prefix = var.cluster_name
kubernetes_version = "1.29"
sku_tier = "Standard"
default_node_pool {
name = "system"
vm_size = "Standard_D2s_v5"
node_count = 3
zones = [1, 2, 3]
os_sku = "AzureLinux"
enable_auto_scaling = true
min_count = 2
max_count = 5
max_pods = 110
vnet_subnet_id = azurerm_subnet.aks.id
only_critical_addons_enabled = true
upgrade_settings { max_surge = "33%" }
}
identity { type = "SystemAssigned" }
network_profile {
network_plugin = "azure"
network_plugin_mode = "overlay"
network_policy = "cilium"
network_dataplane = "cilium"
service_cidr = "10.0.0.0/16"
dns_service_ip = "10.0.0.10"
load_balancer_sku = "standard"
}
azure_active_directory_role_based_access_control {
managed = true
azure_rbac_enabled = true
admin_group_object_ids = [var.admin_group_id]
}
oidc_issuer_enabled = true
workload_identity_enabled = true
key_vault_secrets_provider {
secret_rotation_enabled = true
secret_rotation_interval = "2m"
}
oms_agent {
log_analytics_workspace_id = azurerm_log_analytics_workspace.main.id
}
auto_scaler_profile {
scale_down_delay_after_add = "5m"
scale_down_unneeded = "5m"
max_graceful_termination_sec = 600
}
maintenance_window_auto_upgrade {
frequency = "Weekly"
day_of_week = "Sunday"
start_time = "02:00"
duration = 4
}
}
resource "azurerm_kubernetes_cluster_node_pool" "workload" {
name = "workload"
kubernetes_cluster_id = azurerm_kubernetes_cluster.main.id
vm_size = var.vm_size
node_count = var.node_count
zones = [1, 2, 3]
os_sku = "AzureLinux"
enable_auto_scaling = true
min_count = 2
max_count = 20
max_pods = 110
vnet_subnet_id = azurerm_subnet.aks.id
node_labels = { "workload-type" = "general" }
}