1apiVersion: pubsub.cnrm.cloud.google.com/v1beta1
2kind: PubSubTopic
3metadata:
4 name: ctlfish-pubsub
5---
6apiVersion: bigquery.cnrm.cloud.google.com/v1beta1
7kind: BigQueryDataset
8metadata:
9 name: ctlfishpubsub
10spec:
11 defaultPartitionExpirationMs: 43200000
12---
13apiVersion: bigquery.cnrm.cloud.google.com/v1beta1
14kind: BigQueryTable
15metadata:
16 name: latest
17spec:
18 datasetRef:
19 name: ctlfishpubsub
20 description: "a materialized view for edge resources"
21 materializedView:
22 enableRefresh: true
23 query: |
24 SELECT
25 t.project_id AS project_id,
26 t.cluster_name AS cluster_name,
27 t.cluster_edge_id AS cluster_edge_id,
28 t.kind AS kind,
29 t.group AS k8s_group,
30 t.version AS version,
31 t.name AS name,
32 t.namespace AS namespace,
33 MAX(t.timestamp) AS timestamp,
34 ARRAY_AGG(t.resource IGNORE NULLS
35 ORDER BY
36 t.timestamp DESC
37 LIMIT
38 1) AS resource,
39 ARRAY_AGG(t.operation IGNORE NULLS
40 ORDER BY
41 t.timestamp DESC
42 LIMIT
43 1) AS operation
44 FROM
45 ${gcp_project_id}.ctlfishpubsub.ctlfishpubsub AS t
46 GROUP BY
47 t.project_id,
48 t.cluster_name,
49 t.cluster_edge_id,
50 t.kind,
51 t.group,
52 t.version,
53 t.name,
54 t.namespace
55 refreshIntervalMs: 1800000
56---
57apiVersion: bigquery.cnrm.cloud.google.com/v1beta1
58kind: BigQueryTable
59metadata:
60 name: ctlfishpubsub-resources
61spec:
62 datasetRef:
63 name: ctlfishpubsub
64 description: "a view for latest resources"
65 friendlyName: resources
66 resourceID: resources
67 view:
68 query: |
69 SELECT
70 timestamp,
71 project_id,
72 cluster_name,
73 cluster_edge_id,
74 kind,
75 k8s_group,
76 version,
77 name,
78 namespace,
79 CAST(operation [safe_OFFSET(0)] AS string) AS operation,
80 CAST(resource [safe_OFFSET(0)] AS string) AS resource
81 FROM
82 ${gcp_project_id}.ctlfishpubsub.latest
83 useLegacySql: false
84---
85apiVersion: bigquery.cnrm.cloud.google.com/v1beta1
86kind: BigQueryTable
87metadata:
88 name: ctlfishpubsub
89spec:
90 datasetRef:
91 name: ctlfishpubsub
92 description: "pubsub table for bq"
93 schema: |
94 [
95 {
96 "description":"timestamp",
97 "mode":"REQUIRED",
98 "name":"timestamp",
99 "type":"TIMESTAMP"
100 },
101 {
102 "description":"cluster_name",
103 "mode":"REQUIRED",
104 "name":"cluster_name",
105 "type":"STRING"
106 },
107 {
108 "description":"project_id",
109 "mode":"REQUIRED",
110 "name":"project_id",
111 "type":"STRING"
112 },
113 {
114 "description":"group",
115 "mode":"REQUIRED",
116 "name":"group",
117 "type":"STRING"
118 },
119 {
120 "description":"version",
121 "mode":"REQUIRED",
122 "name":"version",
123 "type":"STRING"
124 },
125 {
126 "description":"kind",
127 "mode":"REQUIRED",
128 "name":"kind",
129 "type":"STRING"
130 },
131 {
132 "description":"name",
133 "mode":"REQUIRED",
134 "name":"name",
135 "type":"STRING"
136 },
137 {
138 "description":"namespace",
139 "mode":"REQUIRED",
140 "name":"namespace",
141 "type":"STRING"
142 },
143 {
144 "description":"operation",
145 "mode":"REQUIRED",
146 "name":"operation",
147 "type":"STRING"
148 },
149 {
150 "description":"cluster_id",
151 "mode":"NULLABLE",
152 "name":"cluster_id",
153 "type":"STRING"
154 },
155 {
156 "description":"cluster_edge_id",
157 "mode":"REQUIRED",
158 "name":"cluster_edge_id",
159 "type":"STRING"
160 },
161 {
162 "description":"resource",
163 "mode":"REQUIRED",
164 "name":"resource",
165 "type":"STRING"
166 }
167 ]
168 timePartitioning:
169 type: DAY
170 field: timestamp
171---
172apiVersion: v1
173kind: Namespace
174metadata:
175 name: ctlfish-infra
View as plain text