Writing Skills
writing-skills
效率与协作技能,来自 obra/superpowers,查看原文获取完整用途和操作说明。
ibm-cloud【部署与运维】Use this skill when the user says 'ibm cloud', 'ibm cloud infrastructure', 'ibm cloud services', 'ibm cloud pak', 'ibm cloud foundry', 'ibm cloud kubernetes', 'iks', 'ibm cloud satellite', 'ibm cloud schematics', 'ibm cloud terraform', 'ibm cloud iam', 'ibm cloud vpc', 'ibm cloud vsi', 'ibm cloud load balancer', 'ibm cloud dns', 'ibm cloud direct lin…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Manage IBM Cloud resources: VPC infrastructure, IKS (Kubernetes), Object Storage, IAM, networking, and automation with Terraform and Schematics.
Exact user phrases: "ibm cloud", "iks", "ibm kubernetes", "ibm vpc", "ibm cloud terraform", "ibm schematics", "ibm satellite", "ibm direct link", "ibm cloud object storage", "ibm cloud databases".
Terraform HCL or IBM Cloud CLI commands for resource provisioning.
Terraform HCL or ibmcloud CLI commands. No preamble.
400 lines.
Create VPC with public/private subnets → Deploy IKS cluster with 3 worker nodes → Provision COS bucket with HMAC → Set up IAM access groups → Configure Direct Link for hybrid connectivity → Enable Monitoring and Logging.
| Option | Use Case | Management |
|---|---|---|
| IKS (IBM Kubernetes Service) | Containerized workloads | Managed control plane |
| Code Engine | Serverless containers, batch jobs | Fully managed, scale-to-zero |
| VSI (Virtual Server Instance) | Traditional apps, legacy | Self-managed OS |
| Bare Metal | High-performance, licensed DBs | Self-managed, dedicated |
| Cloud Foundry | PaaS apps (legacy) | Managed runtime |
| Satellite | Hybrid/edge, consistent services | IBM-managed control plane on customer hardware |
terraform {
required_providers {
ibm = {
source = "IBM-Cloud/ibm"
version = "~> 1.65"
}
}
}
resource "ibm_is_vpc" "main" {
name = "vpc-prod"
resource_group = data.ibm_resource_group.rg.id
address_prefix_management = "manual"
}
resource "ibm_is_vpc_address_prefix" "prefix" {
vpc = ibm_is_vpc.main.id
name = "prefix-zone1"
cidr = "10.0.0.0/16"
}
resource "ibm_is_subnet" "public" {
name = "subnet-public"
vpc = ibm_is_vpc.main.id
zone = "${var.region}-1"
ipv4_cidr_block = "10.0.1.0/24"
public_gateway = ibm_is_public_gateway.main.id
}
resource "ibm_is_subnet" "private" {
name = "subnet-private"
vpc = ibm_is_vpc.main.id
zone = "${var.region}-1"
ipv4_cidr_block = "10.0.2.0/24"
}
resource "ibm_is_security_group" "sg" {
name = "sg-web"
vpc = ibm_is_vpc.main.id
resource_group = data.ibm_resource_group.rg.id
}
resource "ibm_is_security_group_rule" "http" {
group = ibm_is_security_group.sg.id
direction = "inbound"
remote = "0.0.0.0/0"
tcp {
port_min = 80
port_max = 80
}
}
resource "ibm_is_security_group_rule" "https" {
group = ibm_is_security_group.sg.id
direction = "inbound"
remote = "0.0.0.0/0"
tcp {
port_min = 443
port_max = 443
}
}
resource "ibm_is_network_acl" "nacl" {
name = "nacl-public"
vpc = ibm_is_vpc.main.id
rules {
name = "allow-all-outbound"
action = "allow"
direction = "outbound"
source = "0.0.0.0/0"
destination = "0.0.0.0/0"
}
}
resource "ibm_container_vpc_cluster" "cluster" {
name = "iks-prod"
vpc_id = ibm_is_vpc.main.id
worker_count = 3
flavor = "bx2.4x16"
kube_version = "1.28.9"
resource_group_id = data.ibm_resource_group.rg.id
zones {
subnet_id = ibm_is_subnet.private.resource_crn
name = "${var.region}-1"
}
service_subnet = "172.16.0.0/16"
pod_subnet = "172.17.0.0/16"
# ALB ingress controller
public_service_endpoint = true
private_service_endpoint = true
}
resource "ibm_container_worker_pool" "pool" {
cluster = ibm_container_vpc_cluster.cluster.id
worker_pool_name = "pool-gpu"
flavor = "gx2.8x64x1v100"
worker_count = 2
zones {
subnet_id = ibm_is_subnet.private.resource_crn
name = "${var.region}-1"
}
}
resource "ibm_resource_instance" "cos" {
name = "cos-prod"
service = "cloud-object-storage"
plan = "standard"
location = "global"
resource_group_id = data.ibm_resource_group.rg.id
}
resource "ibm_cos_bucket" "bucket" {
bucket_name = "app-data-bucket"
resource_instance_id = ibm_resource_instance.cos.id
region_location = var.region
storage_class = "standard"
force_delete = true
# Lifecycle rules
lifecycle_rule {
enabled = true
id = "archive-90d"
expiration {
days = 90
}
}
}
resource "ibm_cos_bucket" "archive" {
bucket_name = "app-archive-bucket"
resource_instance_id = ibm_resource_instance.cos.id
region_location = var.region
storage_class = "vault"
}
resource "ibm_iam_access_group" "ops" {
name = "DevOpsEngineers"
description = "DevOps engineering team"
}
resource "ibm_iam_access_group_policy" "ops_policy" {
access_group_id = ibm_iam_access_group.ops.id
roles = ["Viewer", "Editor"]
resources {
resource_type = "resource-group"
resource = data.ibm_resource_group.rg.id
}
}
resource "ibm_iam_access_group_policy" "ops_backup" {
access_group_id = ibm_iam_access_group.ops.id
roles = ["Operator"]
resource_attributes {
name = "serviceName"
value = "cloud-object-storage"
operator = "stringEquals"
}
}
# Service ID for automation
resource "ibm_iam_service_id" "ci" {
name = "ci-pipeline"
description = "CI/CD pipeline service ID"
}
resource "ibm_iam_service_policy" "ci_policy" {
iam_service_id = ibm_iam_service_id.ci.id
roles = ["Writer"]
resources {
resource_type = "bucket"
resource = ibm_cos_bucket.bucket.id
service = "cloud-object-storage"
}
}
resource "ibm_resource_instance" "postgres" {
name = "postgres-prod"
service = "databases-for-postgresql"
plan = "standard"
location = var.region
resource_group_id = data.ibm_resource_group.rg.id
parameters = {
members_cpu_allocation_count = 6
members_memory_allocation_mb = 16464
members_disk_allocation_mb = 102400
service_endpoints = "private"
auto_scaling_enabled = true
}
}
resource "ibm_database" "redis" {
resource_group_id = data.ibm_resource_group.rg.id
name = "redis-prod"
plan = "standard"
location = var.region
service = "databases-for-redis"
adminpassword = var.redis_password
members_cpu_count = 2
members_memory_mb = 8192
members_disk_mb = 51200
service_endpoints = "private-only"
}
resource "ibm_satellite_location" "location" {
location = "edge-location-1"
managed_from = var.region
resource_group_id = data.ibm_resource_group.rg.id
zones {
name = "zone-1"
provider = "ibm"
}
}
resource "ibm_satellite_cluster" "cluster" {
name = "satellite-cluster"
location = ibm_satellite_location.location.id
kube_version = "1.28.9"
worker_count = 3
host_labels = {
"env" = "production"
}
}
resource "ibm_dl_gateway" "dl" {
name = "direct-link-primary"
speed_mbps = 1000
customer_asn = 65001
bgp_base_cidr = "10.200.0.0/30"
bgp_ibm_cidr = "10.200.0.1/30"
cross_connect_router = "LAB-xcr01.dal05"
location = "DAL05"
resource_group = data.ibm_resource_group.rg.id
}
resource "ibm_resource_instance" "cloud_monitor" {
name = "monitoring-prod"
service = "sysdig-monitor"
plan = "graduated-tier"
location = var.region
resource_group_id = data.ibm_resource_group.rg.id
parameters = {
default_receiver = true
ingest_key = var.sysdig_ingest_key
}
}
resource "ibm_resource_instance" "logdna" {
name = "logging-prod"
service = "logdna"
plan = "graduated-tier"
location = var.region
resource_group_id = data.ibm_resource_group.rg.id
parameters = {
default_receiver = true
ingest_key = var.logdna_ingest_key
}
}
resource "ibm_resource_instance" "en" {
name = "event-notifications"
service = "event-notifications"
plan = "lite"
location = var.region
resource_group_id = data.ibm_resource_group.rg.id
}
resource "ibm_en_topic" "alerts" {
instance_guid = ibm_resource_instance.en.guid
name = "alerts-topic"
description = "Production alerts"
}
resource "ibm_en_destination" "pagerduty" {
instance_guid = ibm_resource_instance.en.guid
name = "pagerduty-destination"
type = "push_android"
config {
params {
api_key = var.pagerduty_api_key
}
}
}
devops-kubernetes for workload deployment on IKS clusters.devops-terraform for Terraform state and module patterns for IBM Cloud.devops-hybrid-cloud for connectivity between IBM Cloud and on-prem/other clouds.devops-backup-dr for backup strategies using IBM Cloud services.devops-observability for monitoring and logging integration with IBM Cloud.| Decision | IKS (IBM Kubernetes Service) | OpenShift (ROKS) |
|---|---|---|
| Management | IBM-managed control plane | Red Hat managed |
| Container runtime | containerd | CRI-O (OpenShift) |
| Networking | IBM Cloud VLAN + Calico | OpenShift SDN (OVN-K8s) |
| Developer tooling | kubectl, standard K8s | oc, Web Console, Operators |
| Security | IBM Cloud IAM + RBAC | SCC + built-in cert rotation |
| Best for | Standard K8s workloads | Enterprise, compliance-heavy |
| Aspect | COS (Object Storage) | Block Storage |
|---|---|---|
| Access | REST API (HTTP/S) | iSCSI volume mount |
| Throughput | Scales with concurrent requests | Single volume limit |
| Use case | Backup, archival, data lake | Databases, stateful apps |
| Capacity | Effectively unlimited | Up to 2 TB per volume |
| Cost | Low, pay-per-GB-stored | Higher, provisioned IOPS |
resource "ibm_is_vpc" "main" {
name = "production-vpc"
}
resource "ibm_is_subnet" "workers" {
count = 3
name = "workers-${count.index + 1}"
vpc = ibm_is_vpc.main.id
zone = "us-south-${count.index + 1}"
ipv4_cidr_block = cidrsubnet(var.vpc_cidr, 4, count.index)
}
resource "ibm_container_vpc_cluster" "iks" {
name = "production-iks"
vpc_id = ibm_is_vpc.main.id
worker_count = 3
flavor = "bx2.4x16"
kube_version = "1.28"
update_all_workers = true
zones {
subnet_id = ibm_is_subnet.workers[0].id
name = "us-south-1"
}
zones {
subnet_id = ibm_is_subnet.workers[1].id
name = "us-south-2"
}
zones {
subnet_id = ibm_is_subnet.workers[2].id
name = "us-south-3"
}
}
resource "ibm_resource_instance" "cos" {
name = "app-backup-cos"
service = "cloud-object-storage"
plan = "standard"
location = "global"
}
#!/usr/bin/env bash
ibmcloud_login() {
ibmcloud login --apikey "$IBM_CLOUD_API_KEY" -r us-south -g production
}
iks_credentials() {
local cluster=$1
ibmcloud ks cluster config --cluster "$cluster" --admin
export KUBECONFIG="${HOME}/.bluemix/plugins/container-service/clusters/${cluster}/kube-config-prod.yaml"
}
list_all_resources() {
ibmcloud resource service-instances --all-resource-groups \
--output json | jq -r '.[].name'
}
` interface EventObserver { onEvent(event: T): Promise; }
class EventBus { private observers: Set<EventObserver> = new Set(); subscribe(observer: EventObserver): void { this.observers.add(observer); } unsubscribe(observer: EventObserver): void { this.observers.delete(observer); } async emit(event: T): Promise { const results = Array.from(this.observers).map(o => o.onEvent(event)); await Promise.allSettled(results); } } `
config: defaults: timeout: 30s retryCount: 3 overrides: production: timeout: 60s retryCount: 5 development: timeout: 300s retryCount: 1
| Metric | Threshold | Severity | Action |
|---|---|---|---|
| Error rate | > 1% over 5min | Critical | Page on-call |
| p99 latency | > 2s over 5min | Warning | Investigate |
| Throughput drop | > 50% over 1min | Critical | Check upstream |
| Queue depth | > 1000 over 1min | Warning | Scale consumers |
| Disk usage | > 85% | Warning | Clean or expand |
| Memory usage | > 90% heap | Critical | Restart or scale |
| Anti-Pattern | Symptom | Root Cause | Solution |
|---|---|---|---|
| Premature optimization | Complex code for no measured benefit | Guessing instead of profiling | Measure first, optimize based on data |
| Copy-paste reuse | Duplicate code across codebase | Lack of abstraction | Extract shared logic into libraries |
| Gold-plating | Features with no current requirement | Over-engineering | YAGNI — build what's needed now |
| Magical thinking | Assumptions without validation | Skipping error handling | Handle all failure modes explicitly |
Cache hierarchy: L1 (in-memory local) → L2 (distributed Redis/Memcached) → L3 (CDN/Edge). Cache invalidation: TTL-based (simple, stale), event-based (complex, fresh), write-through (consistent, higher write latency), write-behind (fast writes, eventual consistency).