Menguasai Operasi KCC dengan Google Antigravity

1. Pengantar

Dalam codelab ini, Anda akan mempelajari Google Antigravity (disebut sebagai Antigravity di seluruh dokumen ini), platform pengembangan agentic, yang mengubah IDE menjadi era berbasis agen.

Tidak seperti asisten coding standar yang hanya melengkapi baris secara otomatis, Antigravity menyediakan "Mission Control" untuk mengelola agen otonom yang dapat merencanakan, membuat kode, dan bahkan menjelajahi web untuk membantu Anda membangun.

Antigravity didesain sebagai platform yang mengutamakan agen. Hal ini mengasumsikan bahwa AI bukan hanya alat untuk menulis kode, tetapi juga aktor otonom yang mampu merencanakan, menjalankan, memvalidasi, dan melakukan iterasi pada tugas engineering yang kompleks dengan intervensi manusia yang minimal.

Yang akan Anda pelajari

  • Menginstal dan mengonfigurasi Antigravity.
  • Menjelajahi konsep utama Antigravity seperti Agent Manager, Editor, Browser, dan lainnya.
  • Membangun Keterampilan Operasi KCC tingkat produksi dari awal untuk mengelola resource Google Cloud dengan keamanan dan kepatuhan.

Yang Anda butuhkan

Saat ini, Antigravity tersedia sebagai pratinjau untuk akun Gmail pribadi. API ini dilengkapi dengan kuota gratis untuk menggunakan model premier.

Antigravity harus diinstal secara lokal di sistem Anda. Produk ini tersedia di Mac, Windows, dan distribusi Linux tertentu. Selain komputer Anda sendiri, Anda akan memerlukan hal berikut:

  • Akun Gmail (Akun Gmail pribadi).
  • Akun Google Cloud dan Project Google Cloud
  • Browser web seperti Chrome yang mendukung Konsol Google Cloud dan Cloud Shell

2. Penyiapan dan Persyaratan

Penyiapan project

Buat Project Google Cloud

  1. Di Konsol Google Cloud, di halaman pemilih project, pilih atau buat project Google Cloud.
  2. Pastikan penagihan diaktifkan untuk project Cloud Anda. Pelajari cara memeriksa apakah penagihan telah diaktifkan pada suatu project.

Codelab ini dirancang untuk pengguna dan developer dari semua tingkat keahlian (termasuk pemula).

3. Penginstalan

Jika Anda belum menginstal Antigravity, mari kita mulai dengan menginstal Antigravity. Saat ini, produk ini tersedia untuk pratinjau dan Anda dapat menggunakan akun Gmail pribadi Anda untuk mulai menggunakannya.

Buka halaman download dan klik versi sistem operasi yang sesuai dengan kasus Anda. Luncurkan penginstal aplikasi dan instal aplikasi yang sama di komputer Anda. Setelah Anda menyelesaikan penginstalan, luncurkan aplikasi Antigravity.

Langkah-langkah utama selama penyiapan:

  • Pilih alur penyiapan: Sebaiknya mulai dari awal untuk codelab ini.
  • Pengembangan berbasis ulasan (direkomendasikan): Pilih opsi ini. Hal ini memungkinkan agen membuat keputusan dan kembali kepada pengguna untuk mendapatkan persetujuan, yang sangat penting untuk operasi infrastruktur.

Selanjutnya, Konfigurasi Editor Anda dan Login ke Google. Terakhir, setujui Persyaratan Penggunaan.

4. Penyiapan Infrastruktur: GKE & Config Connector

Sebelum dapat membuat skill, Anda memerlukan lingkungan Google Cloud dengan Config Connector (KCC) yang diinstal secara manual dan dikonfigurasi dalam Mode Ruang Nama. Hal ini memungkinkan Anda mengelola resource GCP sebagai objek Kubernetes.

Langkah 0: Siapkan Lingkungan Anda

1. Prasyarat Cluster

Buat cluster GKE baru dengan fitur yang diperlukan diaktifkan:

# Set your variables
export PROJECT_ID=$(gcloud config get-value project)
export CLUSTER_NAME="kcc-ops-cluster"
export REGION="us-central1"

# Create the cluster
gcloud container clusters create ${CLUSTER_NAME} \
    --region ${REGION} \
    --release-channel "regular" \
    --workload-pool=${PROJECT_ID}.svc.id.goog \
    --logging=SYSTEM \
    --monitoring=SYSTEM

# Get cluster credentials
gcloud container clusters get-credentials ${CLUSTER_NAME} --region ${REGION}

2. Instal Operator Config Connector

Operator akan terus mengupdate penginstalan Anda.

# Download the latest Config Connector operator
gcloud storage cp gs://configconnector-operator/latest/release-bundle.tar.gz release-bundle.tar.gz

# Extract the bundle
tar zxvf release-bundle.tar.gz

# Install the operator (Standard Cluster)
kubectl apply -f operator-system/configconnector-operator.yaml

3. Mengonfigurasi Mode Namespace

Buat resource ConfigConnector untuk menentukan mode operasi.

# configconnector.yaml
apiVersion: core.cnrm.cloud.google.com/v1beta1
kind: ConfigConnector
metadata:
  name: configconnector.core.cnrm.cloud.google.com
spec:
  mode: namespaced
  stateIntoSpec: Absent
kubectl apply -f configconnector.yaml

4. Membuat Identitas dan Namespace

Untuk lab ini, kita akan menggunakan namespace default dan Akun Layanan Google (GSA) khusus.

# Set your variables
export PROJECT_ID=$(gcloud config get-value project)
export NAMESPACE="default"

# Create the Google Service Account
gcloud iam service-accounts create kcc-identity --project ${PROJECT_ID}

# Grant permissions on the project
gcloud projects add-iam-policy-binding ${PROJECT_ID} \
    --member="serviceAccount:kcc-identity@${PROJECT_ID}.iam.gserviceaccount.com" \
    --role="roles/owner"

# Grant Metric Writer permissions
gcloud projects add-iam-policy-binding ${PROJECT_ID} \
    --member="serviceAccount:kcc-identity@${PROJECT_ID}.iam.gserviceaccount.com" \
    --role="roles/monitoring.metricWriter"

# Bind GSA to KSA via Workload Identity
gcloud iam service-accounts add-iam-policy-binding \
    kcc-identity@${PROJECT_ID}.iam.gserviceaccount.com \
    --member="serviceAccount:${PROJECT_ID}.svc.id.goog[cnrm-system/cnrm-controller-manager-${NAMESPACE}]" \
    --role="roles/iam.workloadIdentityUser"

5. Mengonfigurasi Namespace

Buat ConfigConnectorContext untuk memantau namespace.

# configconnectorcontext.yaml
apiVersion: core.cnrm.cloud.google.com/v1beta1
kind: ConfigConnectorContext
metadata:
  name: configconnectorcontext.core.cnrm.cloud.google.com
  namespace: default
spec:
  googleServiceAccount: "kcc-identity@${PROJECT_ID}.iam.gserviceaccount.com"
  stateIntoSpec: Absent
kubectl apply -f configconnectorcontext.yaml

6. Verifikasi Penginstalan

Tunggu hingga pengontrol siap untuk namespace default.

kubectl wait -n cnrm-system \
    --for=condition=Ready pod \
    -l cnrm.cloud.google.com/component=cnrm-controller-manager \
    -l cnrm.cloud.google.com/scoped-namespace=default

5. Agent Manager: Kontrol Misi

Antigravity membuat fork dari fondasi Visual Studio Code (VS Code) open source, tetapi mengubah pengalaman pengguna secara radikal untuk memprioritaskan pengelolaan agen daripada pengeditan teks. Antarmuka dibagi menjadi dua jendela utama yang berbeda: Editor dan Agent Manager.

Pengelola Agen

Saat meluncurkan Antigravity, pengguna biasanya disambut oleh Agent Manager. Antarmuka ini berfungsi sebagai dasbor Mission Control. Dirancang untuk orkestrasi tingkat tinggi, sehingga memungkinkan developer membuat, memantau, dan berinteraksi dengan beberapa agen yang beroperasi secara asinkron di berbagai ruang kerja atau tugas.

Dalam tampilan ini, developer bertindak sebagai arsitek. Mereka menentukan tujuan tingkat tinggi. Setiap permintaan ini memunculkan instance agen khusus. UI menyediakan visualisasi aliran kerja paralel ini, yang menampilkan status setiap agen, Artefak yang telah dihasilkan (rencana, hasil, perbedaan), dan permintaan persetujuan manual yang tertunda.

6. Browser & Artefak Antigravitasi

Antigravity membuat Artifacts saat merencanakan dan menyelesaikan pekerjaannya. File markdown lengkap, diagram arsitektur, gambar, rekaman browser, dan perbedaan kode.

Artefak mengatasi "Kesenjangan Kepercayaan"

Saat agen mengklaim, "Saya telah memperbaiki bug", sebelumnya developer harus membaca kode untuk memverifikasi. Dalam Antigravitasi, agen menghasilkan artefak untuk membuktikannya.

Artefak

Berikut adalah artefak utama yang dihasilkan oleh Antigravity:

  • Task Lists: Rencana terstruktur yang dibuat sebelum menulis kode.
  • Implementation Plan: Perubahan yang diarsitek dengan detail teknis.
  • Walkthrough: Ringkasan perubahan dan cara mengujinya.
  • Browser Recordings: Rekaman video sesi browser untuk verifikasi UI.

Browser Antigravity

Saat perlu berinteraksi dengan web, agen akan memanggil subagen browser. Sub-agen ini dapat mengklik, men-scroll, mengetik, dan membaca log konsol. Fitur ini menggunakan model khusus untuk beroperasi di halaman yang terbuka dalam browser yang dikelola Antigravity.

7. Pengalaman editor

Editor mempertahankan keakraban VS Code. Editor ini mencakup penjelajah file standar, penyorotan sintaksis, dan ekosistem ekstensi.

Fitur utama Editor:

  • Pelengkapan otomatis: Saran cerdas diterima dengan menekan Tab.
  • Tab untuk mengimpor: Menyarankan penambahan dependensi yang tidak ada.
  • Perintah (Cmd + I): Memicu penyelesaian inline menggunakan bahasa alami.
  • Panel Samping Agen (Cmd + L): Beralih panel agen untuk mengajukan pertanyaan atau merujuk ke file menggunakan @.

8. Memberikan Masukan

Inti dari Antigravity adalah kemampuannya untuk mengumpulkan masukan Anda dengan mudah. Artefak ini adalah cara bagi Anda untuk memberikan masukan kepada agen dalam komentar gaya Google Dokumen.

Setiap kali Anda menambahkan komentar ke rencana atau tugas, pastikan Anda ingat untuk mengirimkan komentar tersebut. Hal ini mengarahkan agen ke arah yang Anda inginkan.

9. Membangun Keterampilan Operasi KCC

Setelah memahami platform, mari kita buat KCC Ops Skill.

Kubernetes Config Connector (KCC) memungkinkan Anda mengelola resource GCP sebagai objek K8s. Namun, hal ini memerlukan pembatasan keamanan untuk mencegah penyimpangan konfigurasi, pelanggaran kepatuhan, dan pembuatan ulang resource yang tidak disengaja.

Langkah 1: Menyusun Keterampilan

Di root ruang kerja, buat struktur direktori untuk skill Anda:

mkdir -p .agents/skills/kcc-ops/scripts
mkdir -p .agents/skills/kcc-ops/resources/policies/templates
mkdir -p .agents/skills/kcc-ops/resources/policies/constraints

Langkah 2: Buat SKILL.md (Otak)

SKILL.md menentukan metadata dan "Aturan Emas" inti untuk agen. Buat .agents/skills/kcc-ops/SKILL.md:

---
name: kcc-ops
description: Assists with Config Connector (KCC) configuration, resource generation, and troubleshooting on Google Cloud.
---

# Config Connector (KCC) Operations Skill

Use this skill to manage Google Cloud resources using Kubernetes-style configuration (Config Connector).

## 🛑 GOLDEN RULE: Separate Generation from Application

**NEVER generate and apply a manifest in a single autonomous step.**

1. **Craft:** Write the generated manifest to a local file.
2. **Analyze:** Present the manifest to the user. Perform Impact Analysis and Dry Runs. Explain the consequences of the change (e.g., "If this topic is deleted, the attached subscription becomes orphaned").
3. **Wait:** Pause execution and explicitly wait for user permission to proceed.
4. **Apply:** Only run `kubectl apply` *after* the user has reviewed the manifest and the impact analysis, and then unequivocally confirmed you should proceed.

## Core Responsibilities

0. **Context Verification**: Verify the execution context (cluster, namespace, GCP project, user account) with the user before performing any operations.
1. **Installation & Health**: Verify KCC is properly installed and healthy on the target cluster.
2. **Resource Inventory**: Query and summarize existing KCC resources within a namespace.
3. **Brownfield Bulk Export (Adoption)**: Export existing GCP project resources into valid KCC YAML manifests.
4. **Manifest Generation**: Generate valid YAML manifests for GCP resources using KCC CRDs.
5. **Impact Analysis**: Identify ancillary services and resources (e.g., Cloud Run, Apps) that depend on a resource being modified.
6. **Change Differentiation**: Generate diff summaries for resource edits to support change control.
7. **Policy Compliance**: Vet KCC manifests against OPA/Gatekeeper policies.
8. **Troubleshooting**: Analyze resource status, and consult the troubleshooting guide to resolve reconciliation issues.

## Guidelines for Operations

### 0. Context Verification

Before performing **any operations or executing commands** (including health checks), you **MUST** verify the current execution context and obtain explicit user confirmation.

1. **Read Context:** Use commands like `kubectl config current-context`, `kubectl config view --minify -o jsonpath='{.contexts[0].context.namespace}'`, `gcloud config get-value project`, and `gcloud config get-value account` to determine the active environment.
2. **Present & Ask:** Show this information to the user clearly (e.g., "I see my context is X, namespace is Y, project is Z, and account is A. Is this correct?").
3. **Wait:** Do not proceed with any other steps or scripts until the user has confirmed or provided corrections.

### 1. Installation & Health Check

Before performing operations, ensure the environment is ready:

- **Automation**: You MUST use `./scripts/check-health.sh` to verify namespaces, controllers, and CRDs. Do not use manual kubectl commands for health checks, as the script enforces standard formatting and context verification.

### 2. Resource Inventory & Discovery

To understand the current state of infrastructure:

- **Automation**: You MUST use `./scripts/inventory.sh` to get a summary table of all KCC resources. Do not use manual kubectl queries, as the script is optimized to securely discover all CRDs with context validation.

### 3. Manifest Structure

- All KCC resources belong to the `cnrm.cloud.google.com` API group.
- Use the `cnrm.cloud.google.com/project-id` annotation for cross-project resource management if not using Namespaced Mode.
- Always include `apiVersion`, `kind`, `metadata`, and `spec`.

### 4. Official Resource Reference (Agent Action)

When generating or troubleshooting manifests, you **must not guess** the API schema. Always consult the [Official Config Connector Reference](https://cloud.google.com/config-connector/docs/reference/overview) for the exact API version, kind, and required fields for the specific resource and cross reference with the official [github repository](https://github.com/GoogleCloudPlatform/k8s-config-connector/tree/master/config/crds/resources).

### 5. Troubleshooting Checklist

When a resource is not reconciling (check `kubectl get <kind> <name> -o yaml`):

- **Ready Condition**: Look for `status.conditions` where `type: Ready` and `status: "False"`.
- **Reason/Message**: Check the `reason` and `message` fields in the status conditions.
- **Consult the Guide**: Immediately check `./resources/troubleshooting-guide.md` for definitions of the error reason (e.g. `DependencyInvalid`, `ManagementConflict`) and follow its resolution steps.
- **Common Issues**:
  - Permissions: The KCC service account lacks IAM roles.
  - Quotas: GCP project quota exceeded.
  - Conflicts: Resource already exists or is managed by another tool.
  - Immutable Fields: Attempting to change a field that requires resource recreation. Look for "Update failed" errors related to immutable fields.
  - Reference Resolution: Check if the resource is waiting for a dependency (e.g., `referenced project not found`).

### 6. Impact Analysis (Ancillary Services)

Before modifying a resource (e.g., GCS Bucket, Pub/Sub Topic), verify whatElse depends on it:

- **Reference Search (Cluster-wide)**: Search for other KCC resources that reference the item.

  ```bash
  # Example: Find resources referencing a bucket named 'my-data-bucket'
  kubectl get-all -n <namespace> -o yaml | grep -C 5 "my-data-bucket"
  ```

- **IAM-based Analysis**: Check for IAM Service Accounts that have roles on the specific resource. A Cloud Run job or GKE Workload Identity might be using those permissions.
- **Common Ancillary Dependencies**:
  - **Storage Buckets**: Look for Cloud Run/GKE mounts (CSI), Cloud Functions triggers, or Dataflow jobs.
  - **Networks**: Check for Firewall rules, Forwarding rules, and GKE cluster assignments.
  - **IAM Policies**: Changing a policy might break access for external applications not managed by KCC.
- **Resource Graph**: Use `gcloud asset search-all-resources` to find resources that might have implicit links.

### 3. Policy Compliance & Best Practices

Evaluate KCC manifests against security and governance policies. The vetting tool supports three source modes:

- **Built-in Mode (Default)**: Uses the skill's high-fidelity `v1beta1` library (300+ Anthos constraints).
  - `Usage: ./scripts/vet-policy.sh <manifest-path>`
- **Remote Mode**: Clones and vets against an external Git repository.
  - `Usage: ./scripts/vet-policy.sh <manifest-path> <repo-url> [git-ref]`
  - ⚠️ **Note**: External libraries like the legacy GCP Policy Library may be out-of-date and cause schema validation errors with modern `gator`.
- **Local Mode**: Vets against a local directory of policies.
  - `Usage: ./scripts/vet-policy.sh <manifest-path> /path/to/local/policies`

**Interaction Model:**

1. Call `./scripts/vet-policy.sh` with the appropriate arguments.
2. Interpret the `=== KCC Best Practices ===` and `=== OPA/Gatekeeper ===` reports.
3. Supplement automated findings with manual review for specific security features not yet covered by OPA (e.g., `publicAccessPrevention: enforced`, `versioning: {enabled: true}`).

  ```bash
  # Run the skill's helper script (repo URL and branch are optional)
  ./scripts/vet-policy.sh manifest.yaml [policy-repo-url] [policy-ref]
  ```

## Skill Assets

This skill includes additional resources to streamline operations:

- **`scripts/`**: Automation scripts (e.g., `vet-policy.sh`, `bulk-export.sh`).
- **`examples/`**: Reference KCC manifests (e.g., `restricted-bucket.yaml`).
- **`resources/`**: Common templates, documentation snippets, and troubleshooting guides (e.g., `troubleshooting-guide.md`).

### 4. Safety Rails for Applying Manifests

Before applying any KCC manifest update to an existing resource, you MUST:

- **Verify Immutable Fields**: Call `./scripts/verify-immutable.sh <manifest-path>` to detect updates to fields (like `location`, `name`, `project-id`) that trigger destructive resource recreation.
- **Explain Impact**: If destructive changes are detected, you MUST warn the user and explain the downtime/data loss implications before requesting approval.

### 5. Emergency Recovery & Troubleshooting

If a resource is stuck in a "Deletion" or "Error" state:

- **Check for Abondon Flag**: Check if the resource has the `cnrm.cloud.google.com/deletion-policy: abandon` annotation. If it does, you will need to remove the annotation and then force delete the resource.
- **Force Delete**: Call `./scripts/force-delete.sh <kind> <name> [namespace]` to bypass Kubernetes finalizers and remove the resource from the cluster.
- **Orphan Warning**: Inform the user that force-deleting a KCC object may leave an orphaned resource in Google Cloud that requires manual cleanup.

### 6. Change Differentiation

When editing an existing resource, always generate a diff to summarize the change for reviewers or Git history:

- **Local Diff**:

  ```bash
  # Diff a local file against the cluster state
  kubectl diff -f modified-resource.yaml
  ```

- **Commit Summary Template**:

  ```text
  [KCC Change] Update <ResourceName> (<Kind>)
  - Field 'spec.foo' changed from 'X' to 'Y'
  - Impact: Ancillary service <ServiceName> will see updated <Config>
  ```

### 9. Best Practices

- **Namespaced Mode**: Prefer namespaced mode for better isolation.
- **Sensitive Data**: Use `spec.credential.secretRef` or similar for sensitive fields.
- **Resource Naming**: Use consistent naming conventions that match your Kubernetes/GCP standards.
- **Annotations**:
  - `cnrm.cloud.google.com/deletion-policy: abandon`: Keep GCP resource on KCC deletion.
  - `cnrm.cloud.google.com/state-into-spec: absent`: Prevents KCC from syncing GCP state back into the Kubernetes object (useful for avoiding reconciliation loops on fields like node counts).

## Common Resource Examples

### Compute Instance

```yaml
apiVersion: compute.cnrm.cloud.google.com/v1beta1
kind: ComputeInstance
metadata:
  name: instance-sample
  annotations:
    cnrm.cloud.google.com/project-id: "my-project-id"
spec:
  machineType: n1-standard-1
  zone: us-central1-a
  bootDisk:
    initializeParams:
      sourceImage: projects/debian-cloud/global/images/family/debian-11
  networkInterface:
    - networkRef:
        name: default
```

### Storage Bucket

```yaml
apiVersion: storage.cnrm.cloud.google.com/v1beta1
kind: StorageBucket
metadata:
  name: bucket-sample
spec:
  location: US
```

### Pub/Sub Topic & Subscription

```yaml
apiVersion: pubsub.cnrm.cloud.google.com/v1beta1
kind: PubSubTopic
metadata:
  name: order-events-topic
---
apiVersion: pubsub.cnrm.cloud.google.com/v1beta1
kind: PubSubSubscription
metadata:
  name: order-processor-sub
spec:
  topicRef:
    name: order-events-topic
  ackDeadlineSeconds: 30
```

Langkah 3: Terapkan Alat Inventaris

Buat .agents/skills/kcc-ops/scripts/inventory.sh untuk menemukan resource KCC:

#!/bin/bash
# List all resources in the cnrm.cloud.google.com group
KCC_KINDS=$(kubectl api-resources --no-headers | awk '/\.cnrm\.cloud\.google\.com/ {print $1}')
KCC_KINDS_CSV=$(echo "$KCC_KINDS" | paste -sd, -)

printf "%-40s %-30s %-10s %s\n" "KIND" "NAME" "READY" "STATUS/MESSAGE"
kubectl get "$KCC_KINDS_CSV" -A -o custom-columns="KIND:.kind,NAME:.metadata.name,READY:.status.conditions[?(@.type=='Ready')].status,MSG:.status.conditions[?(@.type=='Ready')].message" --ignore-not-found --no-headers

Langkah 4: Tambahkan Logika Penyelidikan Kebijakan

Buat .agents/skills/kcc-ops/scripts/vet-policy.sh. Skrip ini akan menggunakan gator untuk memeriksa manifes berdasarkan kebijakan OPA:

#!/bin/bash
MANIFEST=$1
SKILL_ROOT=$(dirname "$(dirname "$0")")
POLICY_SRC="$SKILL_ROOT/resources/policies"

echo "=== OPA/Gatekeeper Policy Vetting ==="
if command -v gator >/dev/null 2>&1; then
    gator test -f "$MANIFEST" -f "$POLICY_SRC/templates" -f "$POLICY_SRC/constraints"
else
    echo "Gator not found. Skipping OPA audit."
fi

Langkah 5: Terapkan Perlindungan Kolom yang Tidak Dapat Diubah

Ini adalah pagar pengaman penting. Buat .agents/skills/kcc-ops/scripts/verify-immutable.sh:

#!/bin/bash
MANIFEST=$1
KIND=$(grep "^kind:" "$MANIFEST" | awk '{print $2}')
NAME=$(grep "name:" "$MANIFEST" | head -n 1 | awk '{print $2}')

# Check for changes in common immutable fields
IMMUTABLE_FIELDS=("location" "project-id" "name" "zone" "region")
TEMP_FILE=$(mktemp)
kubectl get "$KIND" "$NAME" -o yaml > "$TEMP_FILE" 2>/dev/null

for field in "${IMMUTABLE_FIELDS[@]}"; do
    NEW=$(grep "$field:" "$MANIFEST" | awk '{print $2}')
    OLD=$(grep "$field:" "$TEMP_FILE" | awk '{print $2}')
    if [ -n "$NEW" ] && [ -n "$OLD" ] && [ "$NEW" != "$OLD" ]; then
        echo "🚨 WARNING: Immutable field '$field' is changing! Potential resource recreation."
    fi
done
rm "$TEMP_FILE"

Langkah 6: Pemulihan Darurat (Hapus Paksa)

Buat .agents/skills/kcc-ops/scripts/force-delete.sh:

#!/bin/bash
KIND=$1; NAME=$2; NS=${3:-default}
echo "Removing finalizers for $KIND/$NAME in $NS..."
kubectl patch "$KIND" "$NAME" -n "$NS" -p '{"metadata":{"finalizers":null}}' --type=merge
kubectl delete "$KIND" "$NAME" -n "$NS" --wait=false

Langkah 7: Selesaikan Sumber Daya

Jadikan semua skrip dapat dieksekusi:

chmod +x .agents/skills/kcc-ops/scripts/*.sh

10. Menguji Skill baru Anda

Sekarang, mulai percakapan baru dan uji kemampuan Anda:

  1. Penemuan: @kcc-ops Show me all KCC resources in my cluster.
  2. Kepatuhan: Buat file bucket.yaml dengan StorageBucket. Tanya: @kcc-ops Vet my bucket.yaml manifest.
  3. Keamanan: Mencoba memperbarui location bucket yang ada di bucket.yaml. Tanya: @kcc-ops Verify my bucket.yaml for immutable changes.

Perhatikan bagaimana agen secara cerdas memilih skrip yang benar dan mengikuti "Aturan Emas" dari SKILL.md Anda.

11. Mengamankan Agen

Memberi agen AI akses ke terminal Anda sangat berguna, tetapi memerlukan kontrol.

Buka Antigravity - Settings - Terminal, lalu pelajari Allow List dan Deny List.

  • Daftar yang Diizinkan: Tambahkan ls, kubectl get, dan skrip skill Anda di sini.
  • Daftar Penolakan: Tambahkan sudo, rm -rf, atau perintah destruktif lainnya untuk memastikan agen SELALU meminta izin.

12. Kesimpulan

Selamat! Anda telah beralih dari menginstal Antigravity hingga membuat KCC Operations Skill dengan fidelitas tinggi.

Anda telah mempelajari:

  • Cara memperluas agen dengan alat bash kustom.
  • Cara mengenkode "Aturan Emas" operasional ke dalam SKILL.md.
  • Cara menyediakan batas keamanan untuk pengelolaan infrastruktur yang kompleks.

Apa Selanjutnya?

Perluas folder resources/policies Anda dengan lebih banyak batasan OPA, atau tambahkan skrip check-health.sh untuk mengotomatiskan pemeriksaan kesiapan cluster.