|
| 1 | +# Cloud Metadata Syncer Configuration |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The Cloud metadata syncer enriches netflow data with cloud provider network information, including: |
| 6 | + |
| 7 | +- VPC and subnet details: CIDR ranges, regions, zones. |
| 8 | +- VPC peering connections and their IP ranges |
| 9 | +- Cloud provider service IP ranges |
| 10 | + |
| 11 | +This metadata enables better network flow analysis and region/zone attribution for network traffic. |
| 12 | +**NOTE**: Zones information is not available via GCP VPC metadata due to the nature of networking in GCP. |
| 13 | + |
| 14 | +## How It Works |
| 15 | + |
| 16 | +1. On startup, kvisor fetches VPC metadata from your cloud provider API |
| 17 | +2. Metadata is cached and refreshed periodically (default: every hour) |
| 18 | +3. Network flow events are enriched with VPC context (region, zone, subnet info) |
| 19 | +4. The syncer runs as a background controller in the kvisor controller pod |
| 20 | + |
| 21 | +## Supported Cloud Providers |
| 22 | + |
| 23 | +Currently supported: |
| 24 | +- GCP - Support with Workload Identity and Service Account authentication |
| 25 | + |
| 26 | +Coming soon: |
| 27 | +- AWS |
| 28 | +- Azure |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## GCP Configuration |
| 33 | + |
| 34 | +### Prerequisites |
| 35 | + |
| 36 | +1. **GCP Project** with the VPC you want to monitor |
| 37 | +2. **GCP Service Account** with the following IAM permissions: |
| 38 | + - `compute.networks.list` |
| 39 | + - `compute.networks.listPeeringRoutes` |
| 40 | + - `compute.subnetworks.list` |
| 41 | + |
| 42 | + **Recommended IAM Role:** `roles/compute.networkViewer` |
| 43 | + |
| 44 | +3. **VPC Network Name** - The name of the VPC network to monitor |
| 45 | + |
| 46 | +### Authentication Methods |
| 47 | + |
| 48 | +Choose one of the following authentication methods: |
| 49 | + |
| 50 | +#### Option 1: Workload Identity (Recommended) |
| 51 | + |
| 52 | +**Step 1: Create GCP Service Account** |
| 53 | + |
| 54 | +```bash |
| 55 | +export PROJECT_ID="your-gcp-project-id" |
| 56 | +export SERVICE_ACCOUNT_NAME="kvisor-vpc-reader" |
| 57 | + |
| 58 | +# Create service account |
| 59 | +gcloud iam service-accounts create ${SERVICE_ACCOUNT_NAME} \ |
| 60 | + --project=${PROJECT_ID} \ |
| 61 | + --display-name="Kvisor VPC Metadata Reader" |
| 62 | + |
| 63 | +# Grant necessary permissions |
| 64 | +gcloud projects add-iam-policy-binding ${PROJECT_ID} \ |
| 65 | + --project=${PROJECT_ID} \ |
| 66 | + --member="serviceAccount:${SERVICE_ACCOUNT_NAME}@${PROJECT_ID}.iam.gserviceaccount.com" \ |
| 67 | + --role="roles/compute.networkViewer" |
| 68 | +``` |
| 69 | + |
| 70 | +**Step 2: Enable Workload Identity Binding** |
| 71 | + |
| 72 | +```bash |
| 73 | +export NAMESPACE="kvisor" |
| 74 | +export KSA_NAME="kvisor" # Kubernetes service account name |
| 75 | + |
| 76 | +# Bind Kubernetes service account to GCP service account |
| 77 | +gcloud iam service-accounts add-iam-policy-binding \ |
| 78 | + ${SERVICE_ACCOUNT_NAME}@${PROJECT_ID}.iam.gserviceaccount.com \ |
| 79 | + --project=${PROJECT_ID} \ |
| 80 | + --role roles/iam.workloadIdentityUser \ |
| 81 | + --member "serviceAccount:${PROJECT_ID}.svc.id.goog[${NAMESPACE}/${KSA_NAME}]" |
| 82 | +``` |
| 83 | + |
| 84 | +**Step 3: Configure Helm Values** |
| 85 | + |
| 86 | +Create or update your `values.yaml`: |
| 87 | + |
| 88 | +```yaml |
| 89 | +agent: |
| 90 | + extraArgs: |
| 91 | + # Right now agent is getting all cluster network ranges upon pod start |
| 92 | + # so in this case we could miss some flows if network ranges change |
| 93 | + # as temporary solution we can disable this check |
| 94 | + netflow-check-cluster-network-ranges: false |
| 95 | + |
| 96 | +controller: |
| 97 | + extraArgs: |
| 98 | + # VPC syncer configuration |
| 99 | + cloud-provider: gcp |
| 100 | + cloud-provider-vpc-sync-enabled: true |
| 101 | + cloud-provider-gcp-project-id: "your-gcp-project-id" |
| 102 | + cloud-provider-vpc-name: "your-vpc-name" |
| 103 | + cloud-provider-vpc-sync-interval: 1h # Optional: refresh interval |
| 104 | + cloud-provider-vpc-name: "your-vpc-name" |
| 105 | + |
| 106 | + nodeSelector: |
| 107 | + iam.gke.io/gke-metadata-server-enabled: "true" |
| 108 | + |
| 109 | + # Service account with Workload Identity annotation |
| 110 | + serviceAccount: |
| 111 | + create: true |
| 112 | + name: kvisor |
| 113 | + annotations: |
| 114 | + iam.gke.io/gcp-service-account: "kvisor-vpc-reader@your-gcp-project-id.iam.gserviceaccount.com" |
| 115 | +``` |
| 116 | +
|
| 117 | +**Step 4: Install/Upgrade kvisor** |
| 118 | +
|
| 119 | +```bash |
| 120 | +helm upgrade --install castai-kvisor castai-helm/castai-kvisor \ |
| 121 | + --namespace kvisor \ |
| 122 | + --create-namespace \ |
| 123 | + --values values.yaml |
| 124 | +``` |
| 125 | + |
| 126 | +--- |
| 127 | + |
| 128 | +#### Option 2: Service Account Key File |
| 129 | + |
| 130 | +**Step 1: Create GCP Service Account and Key** |
| 131 | + |
| 132 | +```bash |
| 133 | +export PROJECT_ID="your-gcp-project-id" |
| 134 | +export SERVICE_ACCOUNT_NAME="kvisor-vpc-reader" |
| 135 | + |
| 136 | +# Create service account |
| 137 | +gcloud iam service-accounts create ${SERVICE_ACCOUNT_NAME} \ |
| 138 | + --project=${PROJECT_ID} \ |
| 139 | + --display-name="Kvisor VPC Metadata Reader" |
| 140 | + |
| 141 | +# Grant necessary permissions |
| 142 | +gcloud projects add-iam-policy-binding ${PROJECT_ID} \ |
| 143 | + --project=${PROJECT_ID} \ |
| 144 | + --member="serviceAccount:${SERVICE_ACCOUNT_NAME}@${PROJECT_ID}.iam.gserviceaccount.com" \ |
| 145 | + --role="roles/compute.networkViewer" |
| 146 | + |
| 147 | +# Create and download key |
| 148 | +gcloud iam service-accounts keys create kvisor-sa-key.json \ |
| 149 | + --project=${PROJECT_ID} \ |
| 150 | + --iam-account=${SERVICE_ACCOUNT_NAME}@${PROJECT_ID}.iam.gserviceaccount.com |
| 151 | +``` |
| 152 | + |
| 153 | +**Step 2: Create Kubernetes Secret** |
| 154 | + |
| 155 | +```bash |
| 156 | +kubectl create namespace kvisor |
| 157 | + |
| 158 | +kubectl create secret generic gcp-credentials \ |
| 159 | + --from-file=credentials.json=kvisor-sa-key.json \ |
| 160 | + --namespace kvisor |
| 161 | + |
| 162 | +# Delete the local key file |
| 163 | +rm kvisor-sa-key.json |
| 164 | +``` |
| 165 | + |
| 166 | +**Step 3: Configure Helm Values** |
| 167 | + |
| 168 | +Create or update your `values.yaml`: |
| 169 | + |
| 170 | +```yaml |
| 171 | +controller: |
| 172 | + # VPC syncer configuration |
| 173 | + extraArgs: |
| 174 | + cloud-provider: gcp |
| 175 | + cloud-provider-vpc-sync-enabled: true |
| 176 | + cloud-provider-gcp-project-id: "your-gcp-project-id" |
| 177 | + cloud-provider-vpc-name: "your-vpc-name" |
| 178 | + cloud-provider-vpc-sync-interval: 1h # Optional: refresh interval |
| 179 | + |
| 180 | + # Mount credentials as environment variable |
| 181 | + env: |
| 182 | + - name: GCP_CREDENTIALS_FILE |
| 183 | + value: /var/secrets/gcp/credentials.json |
| 184 | + |
| 185 | + # Mount secret as volume |
| 186 | + volumeMounts: |
| 187 | + - name: gcp-credentials |
| 188 | + mountPath: /var/secrets/gcp |
| 189 | + readOnly: true |
| 190 | + |
| 191 | + volumes: |
| 192 | + - name: gcp-credentials |
| 193 | + secret: |
| 194 | + secretName: gcp-credentials |
| 195 | +``` |
| 196 | +
|
| 197 | +**Step 4: Install/Upgrade kvisor** |
| 198 | +
|
| 199 | +```bash |
| 200 | +helm upgrade --install castai-kvisor castai-helm/castai-kvisor \ |
| 201 | + --namespace kvisor \ |
| 202 | + --create-namespace \ |
| 203 | + --values values.yaml |
| 204 | +``` |
| 205 | + |
| 206 | +--- |
0 commit comments