Ibm cloud

From j4flmao/agent-skills · View interactive version

Ibm cloud is an AI agent skill from the GitHub repository j4flmao/agent-skills. Use when the user asks about IBM Cloud, IBM Cloud VPC, IKS or Red Hat OpenShift on IBM Cloud, Code Engine, Cloud Object Storage, Schematics, Satellite, Direct Link, IBM Cloud IAM, or the ibm Terraform provider. Produces IBM Cloud architectures and IaC. Not for AWS (use aws) or Oracle Cloud (use orac

How to use this skill

Skill file

IBM Cloud

Purpose

Manage IBM Cloud resources: VPC infrastructure, IKS (Kubernetes), Object Storage, IAM, networking, and automation with Terraform and Schematics.

Agent Protocol

Trigger

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".

Input Context

Output Artifact

Terraform HCL or IBM Cloud CLI commands for resource provisioning.

Response Format

Terraform HCL or ibmcloud CLI commands. No preamble.

Completion Criteria

Max Response Length

400 lines.

Quick Start

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.

Decision Tree: IBM Cloud Compute Options

| 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 |

Core Workflow

Step 1: VPC Networking

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"
}

Step 2: Security Groups and ACLs

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"
  }
}

Step 3: IKS (IBM Kubernetes Service)

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"
  }
}

Step 4: Object Storage (COS)

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"
}

Step 5: IAM Access Management

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"
  }
}

Step 6: IBM Cloud Databases

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"
}

Step 7: IBM Cloud Satellite (Hybrid)

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"
  }
}

Step 8: Direct Link (Private Connectivity)

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
}

Step 9: IBM Cloud Monitoring and Logging

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
  }
}

Step 10: Event Notifications

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
    }
  }
}

Rules

Production Considerations

Anti-Patterns

References

Handoff

Architecture Decision Trees

IBM Cloud IKS vs OpenShift

| 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 |

Cloud Object Storage vs Block Storage

| 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 |

Implementation Patterns

Terraform: IBM Cloud VPC with IKS Cluster

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"
}

Bash: IBM Cloud CLI Automation

#!/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'
}

Production Considerations

Anti-Patterns

Performance Optimization

Security Considerations

Implementation Patterns

Observer Pattern for Event Handling

`

interface EventObserver<T> {

onEvent(event: T): Promise<void>;

}

class EventBus<T> {

private observers: Set<EventObserver<T>> = new Set();

subscribe(observer: EventObserver<T>): void {

this.observers.add(observer);

}

unsubscribe(observer: EventObserver<T>): void {

this.observers.delete(observer);

}

async emit(event: T): Promise<void> {

const results = Array.from(this.observers).map(o => o.onEvent(event));

await Promise.allSettled(results);

}

}

`

Configuration-Driven Approach

`

config:

defaults:

timeout: 30s

retryCount: 3

overrides:

production:

timeout: 60s

retryCount: 5

development:

timeout: 300s

retryCount: 1

`

Production Considerations

Deployment Checklist

Monitoring and Alerting

| 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-Patterns

| 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 |

Performance Optimization

Caching Strategy

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).

Resource Pooling

Profiling Methodology

  1. Establish baseline with production traffic profile
  2. Profile CPU with sampling profiler (pprof, perf, async-profiler)
  3. Profile memory with heap dumps and allocation tracking
  4. Profile I/O with strace/perf trace for syscall analysis
  5. Profile latency with distributed tracing (OpenTelemetry)
  6. Identify bottleneck, formulate hypothesis, implement fix
  7. Re-profile to verify improvement, repeat

Security Considerations

Threat Modeling (STRIDE)

Supply Chain Security

Secrets Management

Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.