Skip to content

Commit 1f56e27

Browse files
committed
dev
1 parent 765ca7c commit 1f56e27

File tree

17 files changed

+429
-150
lines changed

17 files changed

+429
-150
lines changed

config/sample-config.yaml

Lines changed: 213 additions & 100 deletions
Large diffs are not rendered by default.

pkg/handler/resources.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,35 @@ func (h *Handlers) GetClusters(ctx context.Context) func(w http.ResponseWriter,
4444
}
4545
}
4646

47+
func (h *Handlers) GetUDNs(ctx context.Context) func(w http.ResponseWriter, r *http.Request) {
48+
return func(w http.ResponseWriter, r *http.Request) {
49+
params := r.URL.Query()
50+
namespace := params.Get(namespaceKey)
51+
isDev := namespace != ""
52+
53+
clients, err := newClients(h.Cfg, r.Header, false, namespace)
54+
if err != nil {
55+
writeError(w, http.StatusInternalServerError, err.Error())
56+
return
57+
}
58+
var code int
59+
startTime := time.Now()
60+
defer func() {
61+
metrics.ObserveHTTPCall("GetUDNs", code, startTime)
62+
}()
63+
64+
// Fetch and merge values for K8S_ClusterName
65+
values, code, err := h.getLabelValues(ctx, clients, fields.UDN, isDev)
66+
if err != nil {
67+
writeError(w, code, err.Error())
68+
return
69+
}
70+
71+
code = http.StatusOK
72+
writeJSON(w, code, utils.NonEmpty(utils.Dedup(values)))
73+
}
74+
}
75+
4776
func (h *Handlers) GetZones(ctx context.Context) func(w http.ResponseWriter, r *http.Request) {
4877
return func(w http.ResponseWriter, r *http.Request) {
4978
params := r.URL.Query()

pkg/model/fields/fields.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const (
3434
SrcZone = Src + Zone
3535
DstZone = Dst + Zone
3636
Cluster = "K8S_ClusterName"
37+
UDN = "UDN"
3738
Layer = "K8S_FlowLayer"
3839
Packets = "Packets"
3940
Proto = "Proto"

pkg/server/routes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func setupRoutes(ctx context.Context, cfg *config.Config, authChecker auth.Check
5151
// Common endpoints
5252
api.HandleFunc("/flow/metrics", h.GetTopology(ctx))
5353
api.HandleFunc("/resources/clusters", h.GetClusters(ctx))
54+
api.HandleFunc("/resources/udns", h.GetUDNs(ctx))
5455
api.HandleFunc("/resources/zones", h.GetZones(ctx))
5556
api.HandleFunc("/resources/namespaces", h.GetNamespaces(ctx))
5657
api.HandleFunc("/resources/names", h.GetNames(ctx))

scripts/update-config.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ yq eval-all --inplace 'select(fileIndex==0).frontend.columns = select(fileIndex=
99
echo " - filters..."
1010
yq eval-all --inplace 'select(fileIndex==0).frontend.filters = select(fileIndex==1).filters | select(fileIndex==0)' ./config/sample-config.yaml ./tmp/config.yaml
1111

12+
echo " - scopes..."
13+
yq eval-all --inplace 'select(fileIndex==0).frontend.scopes = select(fileIndex==1).scopes | select(fileIndex==0)' ./config/sample-config.yaml ./tmp/config.yaml
14+
1215
echo " - fields..."
1316
yq eval-all --inplace 'select(fileIndex==0).frontend.fields = select(fileIndex==1).fields | select(fileIndex==0)' ./config/sample-config.yaml ./tmp/config.yaml
1417

web/console-extensions.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,40 @@
243243
}
244244
}
245245
},
246+
{
247+
"type": "console.tab/horizontalNav",
248+
"properties": {
249+
"model": {
250+
"version": "v1",
251+
"group": "k8s.ovn.org",
252+
"kind": "ClusterUserDefinedNetwork"
253+
},
254+
"component": {
255+
"$codeRef": "netflowTab.default"
256+
},
257+
"page": {
258+
"name": "%plugin__netobserv-plugin~Network Traffic%",
259+
"href": "netflow"
260+
}
261+
}
262+
},
263+
{
264+
"type": "console.tab/horizontalNav",
265+
"properties": {
266+
"model": {
267+
"version": "v1",
268+
"group": "k8s.ovn.org",
269+
"kind": "UserDefinedNetwork"
270+
},
271+
"component": {
272+
"$codeRef": "netflowTab.default"
273+
},
274+
"page": {
275+
"name": "%plugin__netobserv-plugin~Network Traffic%",
276+
"href": "netflow"
277+
}
278+
}
279+
},
246280
{
247281
"type": "console.tab",
248282
"properties": {

web/locales/en/plugin__netobserv-plugin.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"IP": "IP",
1010
"No information available for this content. Change scope to get more details.": "No information available for this content. Change scope to get more details.",
1111
"Cluster name": "Cluster name",
12+
"UDN": "UDN",
1213
"Source": "Source",
1314
"Destination": "Destination",
1415
"Stats": "Stats",

web/src/api/ipfix.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ export interface Fields {
179179
_IsFirst?: string;
180180
/** In conversation tracking, a counter of flow logs per conversation */
181181
numFlowLogs?: number;
182+
/** User Defined Network identifier */
183+
UdnId?: string;
182184
}
183185

184186
export type Field = keyof Fields | keyof Labels;

web/src/api/loki.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export interface TopologyMetricPeer {
7373
namespace?: string;
7474
host?: string;
7575
cluster?: string;
76+
udn?: string;
7677
}
7778

7879
export type GenericMetric = {

web/src/api/routes.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ export const getClusters = (forcedNamespace?: string): Promise<string[]> => {
7575
});
7676
};
7777

78+
export const getUDNs = (forcedNamespace?: string): Promise<string[]> => {
79+
const params = { namespace: forcedNamespace };
80+
return axios.get(ContextSingleton.getHost() + '/api/resources/udns', { params }).then(r => {
81+
if (r.status >= 400) {
82+
throw new Error(`${r.statusText} [code=${r.status}]`);
83+
}
84+
return r.data;
85+
});
86+
};
87+
7888
export const getZones = (forcedNamespace?: string): Promise<string[]> => {
7989
const params = { namespace: forcedNamespace };
8090
return axios.get(ContextSingleton.getHost() + '/api/resources/zones', { params }).then(r => {

0 commit comments

Comments
 (0)