apiVersion: pubsub.cnrm.cloud.google.com/v1beta1 kind: PubSubTopic metadata: name: ctlfish-pubsub --- apiVersion: bigquery.cnrm.cloud.google.com/v1beta1 kind: BigQueryDataset metadata: name: ctlfishpubsub spec: defaultPartitionExpirationMs: 43200000 --- apiVersion: bigquery.cnrm.cloud.google.com/v1beta1 kind: BigQueryTable metadata: name: latest spec: datasetRef: name: ctlfishpubsub description: "a materialized view for edge resources" materializedView: enableRefresh: true query: | SELECT t.project_id AS project_id, t.cluster_name AS cluster_name, t.cluster_edge_id AS cluster_edge_id, t.kind AS kind, t.group AS k8s_group, t.version AS version, t.name AS name, t.namespace AS namespace, MAX(t.timestamp) AS timestamp, ARRAY_AGG(t.resource IGNORE NULLS ORDER BY t.timestamp DESC LIMIT 1) AS resource, ARRAY_AGG(t.operation IGNORE NULLS ORDER BY t.timestamp DESC LIMIT 1) AS operation FROM ${gcp_project_id}.ctlfishpubsub.ctlfishpubsub AS t GROUP BY t.project_id, t.cluster_name, t.cluster_edge_id, t.kind, t.group, t.version, t.name, t.namespace refreshIntervalMs: 1800000 --- apiVersion: bigquery.cnrm.cloud.google.com/v1beta1 kind: BigQueryTable metadata: name: ctlfishpubsub-resources spec: datasetRef: name: ctlfishpubsub description: "a view for latest resources" friendlyName: resources resourceID: resources view: query: | SELECT timestamp, project_id, cluster_name, cluster_edge_id, kind, k8s_group, version, name, namespace, CAST(operation [safe_OFFSET(0)] AS string) AS operation, CAST(resource [safe_OFFSET(0)] AS string) AS resource FROM ${gcp_project_id}.ctlfishpubsub.latest useLegacySql: false --- apiVersion: bigquery.cnrm.cloud.google.com/v1beta1 kind: BigQueryTable metadata: name: ctlfishpubsub spec: datasetRef: name: ctlfishpubsub description: "pubsub table for bq" schema: | [ { "description":"timestamp", "mode":"REQUIRED", "name":"timestamp", "type":"TIMESTAMP" }, { "description":"cluster_name", "mode":"REQUIRED", "name":"cluster_name", "type":"STRING" }, { "description":"project_id", "mode":"REQUIRED", "name":"project_id", "type":"STRING" }, { "description":"group", "mode":"REQUIRED", "name":"group", "type":"STRING" }, { "description":"version", "mode":"REQUIRED", "name":"version", "type":"STRING" }, { "description":"kind", "mode":"REQUIRED", "name":"kind", "type":"STRING" }, { "description":"name", "mode":"REQUIRED", "name":"name", "type":"STRING" }, { "description":"namespace", "mode":"REQUIRED", "name":"namespace", "type":"STRING" }, { "description":"operation", "mode":"REQUIRED", "name":"operation", "type":"STRING" }, { "description":"cluster_id", "mode":"NULLABLE", "name":"cluster_id", "type":"STRING" }, { "description":"cluster_edge_id", "mode":"REQUIRED", "name":"cluster_edge_id", "type":"STRING" }, { "description":"resource", "mode":"REQUIRED", "name":"resource", "type":"STRING" } ] timePartitioning: type: DAY field: timestamp --- apiVersion: v1 kind: Namespace metadata: name: ctlfish-infra