1. परिचय
इस कोडलैब में, आपको Google Antigravity (जिसे इस दस्तावेज़ में Antigravity कहा गया है) के बारे में जानकारी मिलेगी. यह एक एजेंटिक डेवलपमेंट प्लैटफ़ॉर्म है, जो आईडीई को एजेंट-फ़र्स्ट युग में बदल रहा है.
सामान्य कोडिंग असिस्टेंट सिर्फ़ लाइनों को पूरा करते हैं. वहीं, Antigravity, ऑटोनॉमस एजेंट को मैनेज करने के लिए "मिशन कंट्रोल" की सुविधा देता है. ये एजेंट, आपके लिए प्लान बना सकते हैं, कोडिंग कर सकते हैं, और यहां तक कि वेब ब्राउज़ भी कर सकते हैं.
Antigravity को एजेंट-फ़र्स्ट प्लैटफ़ॉर्म के तौर पर डिज़ाइन किया गया है. इससे यह माना जाता है कि एआई सिर्फ़ कोड लिखने का टूल नहीं है. यह एक ऑटोनॉमस ऐक्टर है, जो कम से कम मानवीय हस्तक्षेप के साथ, इंजीनियरिंग से जुड़े मुश्किल टास्क को प्लान कर सकता है, उन्हें पूरा कर सकता है, उनकी पुष्टि कर सकता है, और उनमें बदलाव कर सकता है.
आपको क्या सीखने को मिलेगा
- Antigravity को इंस्टॉल और कॉन्फ़िगर करना.
- Antigravity के मुख्य कॉन्सेप्ट के बारे में जानना. जैसे, एजेंट मैनेजर, एडिटर, ब्राउज़र वगैरह.
- सुरक्षा और अनुपालन के साथ Google Cloud के संसाधनों को मैनेज करने के लिए, शुरुआत से लेकर प्रोडक्शन-ग्रेड KCC Ops Skill बनाना.
आपको किन चीज़ों की ज़रूरत होगी
फ़िलहाल, Antigravity निजी Gmail खातों के लिए, प्रीव्यू के तौर पर उपलब्ध है. इसमें, प्रीमियर मॉडल इस्तेमाल करने के लिए, मुफ़्त कोटा मिलता है.
Antigravity को आपके सिस्टम पर स्थानीय तौर पर इंस्टॉल करना होगा. यह प्रॉडक्ट Mac, Windows, और Linux के कुछ डिस्ट्रिब्यूशन पर उपलब्ध है. अपने डिवाइस के अलावा, आपको इनकी ज़रूरत होगी:
- एक Gmail खाता (निजी Gmail खाता).
- एक Google Cloud खाता और Google Cloud प्रोजेक्ट
- कोई वेब ब्राउज़र, जैसे कि Chrome, जो Google Cloud Console और Cloud Shell के साथ काम करता हो
2. सेटअप और ज़रूरी शर्तें
प्रोजेक्ट का सेटअप
Google Cloud प्रोजेक्ट बनाना
- Google Cloud Console में, प्रोजेक्ट चुनने वाले पेज पर जाकर, कोई Google Cloud प्रोजेक्ट चुनें या बनाएं.
- पक्का करें कि आपके Cloud प्रोजेक्ट के लिए बिलिंग चालू हो. यह देखने का तरीका जानें कि किसी प्रोजेक्ट के लिए बिलिंग चालू है या नहीं.
यह कोडलैब, सभी लेवल के उपयोगकर्ताओं और डेवलपर (शुरुआती लोगों के लिए भी) के लिए बनाया गया है.
3. इंस्टॉलेशन
अगर आपने Antigravity को पहले से इंस्टॉल नहीं किया है, तो आइए Antigravity को इंस्टॉल करने से शुरुआत करते हैं. फ़िलहाल, यह प्रॉडक्ट प्रीव्यू के तौर पर उपलब्ध है. इसका इस्तेमाल शुरू करने के लिए, अपने निजी Gmail खाते का इस्तेमाल किया जा सकता है.
डाउनलोड पेज पर जाएं और अपने ऑपरेटिंग सिस्टम के लिए सही वर्शन पर क्लिक करें. ऐप्लिकेशन इंस्टॉलर लॉन्च करें और उसे अपने डिवाइस पर इंस्टॉल करें. इंस्टॉल करने के बाद, Antigravity ऐप्लिकेशन लॉन्च करें.
सेटअप के दौरान ज़रूरी चरण:
- सेटअप का तरीका चुनें: हमारा सुझाव है कि इस कोडलैब के लिए, नए सिरे से शुरुआत करें.
- समीक्षा के आधार पर डेवलपमेंट (सुझाया गया है): यह विकल्प चुनें. इससे एजेंट को फ़ैसला लेने और मंज़ूरी के लिए उपयोगकर्ता के पास वापस आने की अनुमति मिलती है. यह इंफ़्रास्ट्रक्चर के ऑपरेशन के लिए ज़रूरी है.
इसके बाद, अपना एडिटर कॉन्फ़िगर करें और Google में साइन इन करें. आखिर में, इस्तेमाल की शर्तें स्वीकार करें.
4. इंफ़्रास्ट्रक्चर का सेटअप: GKE और Config Connector
स्किल बनाने से पहले, आपको Google Cloud का ऐसा एनवायरमेंट चाहिए जिसमें Config Connector (KCC) मैन्युअल तरीके से इंस्टॉल किया गया हो और नेमस्पेस वाले मोड में कॉन्फ़िगर किया गया हो. इससे, GCP के संसाधनों को Kubernetes ऑब्जेक्ट के तौर पर मैनेज किया जा सकता है.
पहला चरण: अपना एनवायरमेंट तैयार करना
1. क्लस्टर की ज़रूरी शर्तें
ज़रूरी सुविधाएं चालू करके, नया GKE क्लस्टर बनाएं:
# 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. Config Connector ऑपरेटर इंस्टॉल करना
ऑपरेटर, आपके इंस्टॉलेशन को अप-टू-डेट रखता है.
# 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. नेमस्पेस वाले मोड को कॉन्फ़िगर करना
ऑपरेटिंग मोड तय करने के लिए, ConfigConnector संसाधन बनाएं.
# 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. पहचान और नेमस्पेस बनाना
इस लैब के लिए, हम default नेमस्पेस और Google का खास सर्विस खाता (जीएसए) इस्तेमाल करेंगे.
# 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. नेमस्पेस को कॉन्फ़िगर करना
नेमस्पेस पर नज़र रखने के लिए, ConfigConnectorContext बनाएं.
# 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. इंस्टॉलेशन की पुष्टि करना
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. एजेंट मैनेजर: मिशन कंट्रोल
Antigravity, ओपन-सोर्स Visual Studio Code (VS Code) के फ़ाउंडेशन पर आधारित है. हालांकि, यह टेक्स्ट में बदलाव करने के बजाय, एजेंट मैनेजमेंट को प्राथमिकता देने के लिए, उपयोगकर्ता अनुभव में पूरी तरह से बदलाव करता है. इंटरफ़ेस को दो अलग-अलग प्राइमरी विंडो में बांटा गया है: Editor और Agent Manager.
एजेंट मैनेजर
Antigravity लॉन्च करने पर, आम तौर पर उपयोगकर्ता को एजेंट मैनेजर दिखता है. यह इंटरफ़ेस, मिशन कंट्रोल डैशबोर्ड के तौर पर काम करता है. इसे हाई-लेवल ऑर्केस्ट्रेशन के लिए डिज़ाइन किया गया है. इससे डेवलपर, अलग-अलग वर्कस्पेस या टास्क में एसिंक्रोनस तरीके से काम करने वाले कई एजेंट को स्पॉन कर सकते हैं, उनकी निगरानी कर सकते हैं, और उनसे इंटरैक्ट कर सकते हैं.
इस व्यू में, डेवलपर एक आर्किटेक्ट के तौर पर काम करता है. वे हाई-लेवल के लक्ष्य तय करते हैं. इनमें से हर अनुरोध के लिए, एक खास एजेंट इंस्टेंस स्पॉन होता है. यूज़र इंटरफ़ेस (यूआई) में, काम की इन पैरलल स्ट्रीम को विज़ुअलाइज़ किया जाता है. इसमें हर एजेंट का स्टेटस, उनके बनाए गए आर्टफ़ैक्ट (प्लान, नतीजे, अंतर), और मानवीय मंज़ूरी के लिए बाकी बचे अनुरोध दिखाए जाते हैं.
6. Antigravity ब्राउज़र और आर्टफ़ैक्ट
Antigravity, प्लान बनाने और काम पूरा करने के दौरान आर्टफ़ैक्ट बनाता है. ये रिच मार्कडाउन फ़ाइलें, आर्किटेक्चर डायग्राम, इमेज, ब्राउज़र रिकॉर्डिंग, और कोड में अंतर होते हैं.
आर्टफ़ैक्ट, "भरोसे की कमी" की समस्या को हल करते हैं
जब कोई एजेंट दावा करता है कि "मैंने बग ठीक कर दिया है", तो पहले डेवलपर को पुष्टि करने के लिए कोड पढ़ना पड़ता था. Antigravity में, एजेंट इसे साबित करने के लिए एक आर्टफ़ैक्ट बनाता है.
आर्टफ़ैक्ट
Antigravity से बनाए गए मुख्य आर्टफ़ैक्ट ये हैं:
Task Lists: कोड लिखने से पहले जनरेट किया गया, स्ट्रक्चर्ड प्लान.Implementation Plan: तकनीकी जानकारी के साथ, आर्किटेक्ट किए गए बदलाव.Walkthrough: बदलावों की खास जानकारी और उन्हें टेस्ट करने का तरीका.Browser Recordings: यूज़र इंटरफ़ेस (यूआई) की पुष्टि के लिए, ब्राउज़र सेशन की वीडियो रिकॉर्डिंग.
Antigravity ब्राउज़र
जब एजेंट को वेब से इंटरैक्ट करना होता है, तो वह ब्राउज़र सब-एजेंट को शुरू करता है. यह सब-एजेंट, क्लिक कर सकता है, स्क्रोल कर सकता है, टाइप कर सकता है, और कंसोल लॉग पढ़ सकता है. यह Antigravity से मैनेज किए जाने वाले ब्राउज़र में खुले पेजों पर काम करने के लिए, खास मॉडल का इस्तेमाल करता है.
7. एडिटर का अनुभव
एडिटर, VS Code की तरह ही काम करता है. इसमें स्टैंडर्ड फ़ाइल एक्सप्लोरर, सिंटैक्स हाइलाइटिंग, और एक्सटेंशन ईकोसिस्टम शामिल है.
एडिटर की मुख्य सुविधाएं:
- ऑटो-कंप्लीट: Tab दबाने पर, स्मार्ट सुझाव स्वीकार किए जाते हैं.
- Tab to import: इसमें, ज़रूरी डिपेंडेंसी जोड़ने का सुझाव दिया जाता है.
- कमांड (
Cmd + I): सामान्य भाषा का इस्तेमाल करके, इनलाइन कंप्लीशन ट्रिगर करना. - एजेंट साइड पैनल (
Cmd + L): सवाल पूछने या@का इस्तेमाल करके फ़ाइलों को रेफ़र करने के लिए, एजेंट पैनल को टॉगल करना.
8. सुझाव/राय देना या शिकायत करना
Antigravity की सबसे बड़ी खासियत यह है कि यह आसानी से आपका फ़ीडबैक इकट्ठा कर सकता है. इन आर्टफ़ैक्ट की मदद से, Google Docs में टिप्पणियों के स्टाइल में, एजेंट को फ़ीडबैक दिया जा सकता है.
किसी प्लान या टास्क में टिप्पणी जोड़ने पर, पक्का करें कि आपने टिप्पणी सबमिट की हो. इससे एजेंट, आपकी पसंद के मुताबिक काम करता है.
9. KCC Ops Skill बनाना
अब जब आपको प्लैटफ़ॉर्म के बारे में पता चल गया है, तो आइए KCC Ops Skill बनाते हैं.
Kubernetes Config Connector (KCC) की मदद से, GCP के संसाधनों को K8s ऑब्जेक्ट के तौर पर मैनेज किया जा सकता है. हालांकि, इसके लिए सुरक्षा से जुड़े नियमों की ज़रूरत होती है, ताकि कॉन्फ़िगरेशन में बदलाव न हो, अनुपालन से जुड़े नियमों का उल्लंघन न हो, और गलती से संसाधन फिर से न बन जाएं.
पहला चरण: स्किल का स्ट्रक्चर बनाना
अपने वर्कस्पेस के रूट में, अपनी स्किल के लिए डायरेक्ट्री स्ट्रक्चर बनाएं:
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
दूसरा चरण: SKILL.md (मुख्य जानकारी) बनाना
SKILL.md में, एजेंट के लिए मेटाडेटा और मुख्य "गोल्डन रूल" तय किया जाता है. .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
```
तीसरा चरण: इन्वेंट्री टूल लागू करना
KCC के संसाधनों का पता लगाने के लिए, .agents/skills/kcc-ops/scripts/inventory.sh बनाएं:
#!/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
चौथा चरण: नीति की जांच करने की लॉजिक जोड़ना
.agents/skills/kcc-ops/scripts/vet-policy.sh बनाएं. यह स्क्रिप्ट, OPA की नीतियों के हिसाब से मेनिफ़ेस्ट की जांच करने के लिए, gator का इस्तेमाल करेगी:
#!/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
पांचवा चरण: इम्यूटेबल फ़ील्ड की सुरक्षा लागू करना
यह सुरक्षा से जुड़ा एक अहम नियम है. .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"
छठा चरण: इमरजेंसी रिकवरी (ज़बरदस्ती मिटाना)
.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
सातवां चरण: संसाधन फ़ाइनल करना
सभी स्क्रिप्ट को एक्ज़ीक्यूटेबल बनाएं:
chmod +x .agents/skills/kcc-ops/scripts/*.sh
10. अपनी नई स्किल की जांच करना
अब, नई बातचीत शुरू करें और अपनी स्किल की जांच करें:
- डिस्कवरी:
@kcc-ops Show me all KCC resources in my cluster. - अनुपालन: StorageBucket के साथ, फ़ाइल
bucket.yamlबनाएं. पूछें:@kcc-ops Vet my bucket.yaml manifest. - सुरक्षा: मौजूद किसी मौजूदा बकेट की
locationकोbucket.yamlमें अपडेट करने की कोशिश करें. पूछें:@kcc-ops Verify my bucket.yaml for immutable changes.
ध्यान दें कि एजेंट, आपकी SKILL.md से सही स्क्रिप्ट को समझदारी से कैसे चुनता है और "गोल्डन रूल" का पालन कैसे करता है.
11. एजेंट को सुरक्षित करना
एआई एजेंट को अपने टर्मिनल का ऐक्सेस देना एक अहम सुविधा है. हालांकि, इसके लिए कंट्रोल की ज़रूरत होती है.
Antigravity - सेटिंग - टर्मिनल पर जाएं और अनुमति वाली सूची और मनाही वाली सूची देखें.
- अनुमति वाली सूची: यहां
ls,kubectl get, और अपनी स्किल की स्क्रिप्ट जोड़ें. - मनाही वाली सूची: यहां
sudo,rm -rfया अन्य डिस्ट्रक्टिव कमांड जोड़ें, ताकि एजेंट हमेशा अनुमति मांगे.
12. नतीजा
बधाई हो! आपने Antigravity को इंस्टॉल करने से लेकर, KCC Operations Skill बनाने तक का सफ़र तय कर लिया है.
आपने यह सीखा है:
- कस्टम बैश टूल की मदद से, एजेंट को कैसे बढ़ाया जाए.
- ऑपरेशनल "गोल्डन रूल" को
SKILL.mdमें कैसे एनकोड किया जाए. - मुश्किल इंफ़्रास्ट्रक्चर मैनेजमेंट के लिए, सुरक्षा से जुड़े नियम कैसे तय किए जाएं.
कौनसी नई सुविधाएं आने वाली हैं?
resources/policies फ़ोल्डर में, OPA की ज़्यादा पाबंदियां जोड़ें. इसके अलावा, क्लस्टर की तैयारी की जांच को ऑटोमेट करने के लिए, check-health.sh स्क्रिप्ट जोड़ें!