Skip to content

Commit

Permalink
Add files for Rogers demo Nov 23
Browse files Browse the repository at this point in the history
  • Loading branch information
niloysh committed Oct 14, 2023
0 parents commit 3edb6e3
Show file tree
Hide file tree
Showing 67 changed files with 2,149 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# free5gc-k8s

22 changes: 22 additions & 0 deletions free5gc-monitor/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../free5gc

patchesStrategicMerge:
- slices/slice1/upf-deployment-patch.yaml
- slices/slice1/smf-deployment-patch.yaml
- slices/slice2/upf-deployment-patch.yaml
- slices/slice2/smf-deployment-patch.yaml

# configMapGenerator:
# - name: smf-fluent-bit-config
# files:
# - slices/slice1/fluent-bit.conf
# - slices/slice1/parsers.conf
# - slices/slice1/filter.lua

images:
- name: ghcr.io/niloysh/free5gc-upf
newTag: latest
6 changes: 6 additions & 0 deletions free5gc-monitor/slices/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- slice1
- slice2
14 changes: 14 additions & 0 deletions free5gc-monitor/slices/slice1/filter.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function add_new_keys(tag, timestamp, record)
if record["slice-session-info"] ~= nil then
-- Add S-NSSAI key
local sst = tostring(record["slice-session-info"]["Snssai"]["SST"])
local sd = tostring(record["slice-session-info"]["Snssai"]["SD"])
record["S-NSSAI"] = sst .. "@" .. sd

-- Add F-SEID key
local remote_seid = tostring(record["slice-session-info"]["PFCPSession"]["Fseid"]["RemoteSEID"])
local ip_address = record["slice-session-info"]["PFCPSession"]["Fseid"]["IPAddress"]
record["F-SEID"] = remote_seid .. "@" .. ip_address
end
return 1, timestamp, record
end
26 changes: 26 additions & 0 deletions free5gc-monitor/slices/slice1/fluent-bit.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[SERVICE]
Flush 1
Log_Level debug
Parsers_File parsers.conf

[INPUT]
Name tail
Parser simple-parser
Path /var/log/smf-slice-info.log
DB /var/log/tail.db

[FILTER]
Name modify
Match *
Add user n6saha

[FILTER]
Name lua
Match *
script filter.lua
call add_new_keys


[OUTPUT]
Name stdout
Match *
6 changes: 6 additions & 0 deletions free5gc-monitor/slices/slice1/parsers.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[PARSER]
Name simple-parser
Format json
Time_Key time
Time_Format %Y-%m-%dT%H:%M:%SZ
Time_Keep On
52 changes: 52 additions & 0 deletions free5gc-monitor/slices/slice1/smf-deployment-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: free5gc-smf
spec:
template:
spec:
containers:
- name: smf
volumeMounts:
- name: varlog
mountPath: /var/log/

- image: busybox
name: smf-logs
args: [/bin/sh, -c, 'while ! tail -f /var/log/smf-slice-info.log 2>/dev/null; do sleep 1 ; done']
volumeMounts:
- mountPath: /var/log/
name: varlog

# - image: fluent/fluent-bit:1.9
# name: smf-stats
# imagePullPolicy: Always
# env:
# - name: FLUENT_UID
# value: "0"
# volumeMounts:
# - name: config-volume
# mountPath: /fluent-bit/etc/
# - name: varlog
# mountPath: /var/log/

resources:
requests:
memory: "256Mi"
cpu: "200m"
limits:
memory: "512Mi"
cpu: "500m"
volumes:
# - name: config-volume
# configMap:
# name: smf-fluent-bit-config
# items:
# - key: fluent-bit.conf
# path: fluent-bit.conf
# - key: parsers.conf
# path: parsers.conf
# - key: filter.lua
# path: filter.lua
- name: varlog
emptyDir: {}
42 changes: 42 additions & 0 deletions free5gc-monitor/slices/slice1/upf-deployment-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: free5gc-upf
spec:
template:
spec:
shareProcessNamespace: true
containers:
- name: upf-stats
image: ghcr.io/niloysh/upf-exporter:v3.0.1
imagePullPolicy: Always
command: [ "/bin/bash", "-c", "--" ]
args:
- |
if [ "$DEBUG_MODE" = "true" ]; then
while true; do sleep 30; done;
else
/app/upf-exporter.py
fi
env:
- name: SLEEP_INTERVAL
value: "5"
- name: SERVER_PORT
value: "9000"
- name: GTP_IFNAME
value: "upf1gtp"
- name: DEBUG_MODE
value: "false"
securityContext:
capabilities:
add: ["NET_ADMIN"]
ports:
- name: metrics
containerPort: 9000
resources:
requests:
memory: "256Mi"
cpu: "200m"
limits:
memory: "512Mi"
cpu: "500m"
30 changes: 30 additions & 0 deletions free5gc-monitor/slices/slice2/smf-deployment-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: free5gc-smf2
spec:
template:
spec:
containers:
- name: smf
volumeMounts:
- name: varlog
mountPath: /var/log/

- image: busybox
name: smf-logs
args: [/bin/sh, -c, 'while ! tail -f /var/log/smf-slice-info.log 2>/dev/null; do sleep 1 ; done']
volumeMounts:
- mountPath: /var/log/
name: varlog

resources:
requests:
memory: "256Mi"
cpu: "200m"
limits:
memory: "512Mi"
cpu: "500m"
volumes:
- name: varlog
emptyDir: {}
42 changes: 42 additions & 0 deletions free5gc-monitor/slices/slice2/upf-deployment-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: free5gc-upf2
spec:
template:
spec:
shareProcessNamespace: true
containers:
- name: upf-stats
image: ghcr.io/niloysh/upf-exporter:v3.0.1
imagePullPolicy: Always
command: [ "/bin/bash", "-c", "--" ]
args:
- |
if [ "$DEBUG_MODE" = "true" ]; then
while true; do sleep 30; done;
else
/app/upf-exporter.py
fi
env:
- name: SLEEP_INTERVAL
value: "5"
- name: SERVER_PORT
value: "9000"
- name: GTP_IFNAME
value: "upf2gtp"
- name: DEBUG_MODE
value: "false"
securityContext:
capabilities:
add: ["NET_ADMIN"]
ports:
- name: metrics
containerPort: 9000
resources:
requests:
memory: "256Mi"
cpu: "200m"
limits:
memory: "512Mi"
cpu: "500m"
4 changes: 4 additions & 0 deletions free5gc-webui/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resources:
- webui-configmap.yaml
- webui-deployment.yaml
- webui-service.yaml
24 changes: 24 additions & 0 deletions free5gc-webui/webui-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: webui-configmap
labels:
app: free5gc
data:
webuicfg.yaml: |
info:
version: 1.0.0
description: Docker-WebUI initial local configuration
configuration:
mongodb:
name: free5gc
url: mongodb://mongodb:27017
# the kind of log output
# debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic
# ReportCaller: enable the caller report or not, value: true or false
logger:
WEBUI:
debugLevel: info
ReportCaller: false
67 changes: 67 additions & 0 deletions free5gc-webui/webui-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: free5gc-webui
labels:
app: free5gc
spec:
selector:
matchLabels:
app: free5gc
replicas: 1
template:
metadata:
labels:
app: free5gc
spec:
initContainers:
- name: wait-mongo
image: busybox:1.32.0
env:
- name: DEPENDENCIES
value: mongodb:27017
command: ["sh", "-c", "until nc -z $DEPENDENCIES; do echo waiting for the MongoDB; sleep 2; done;"]
containers:
- image: ghcr.io/niloysh/free5gc-aio:v3.2.0
name: webui
ports:
- containerPort: 5000
command: ["./webui"]
args: ["--config", "config/webuicfg.yaml"]
env:
- name: GIN_MODE
value: release
volumeMounts:
- mountPath: /free5gc/config/
name: webui-volume
readinessProbe:
initialDelaySeconds: 0
periodSeconds: 1
timeoutSeconds: 1
failureThreshold: 40
successThreshold: 1
httpGet:
port: 5000
livenessProbe:
initialDelaySeconds: 120
periodSeconds: 10
timeoutSeconds: 10
failureThreshold: 3
successThreshold: 1
httpGet:
port: 5000
resources:
requests:
memory: "512Mi"
cpu: "500m"
limits:
memory: "1024Mi"
cpu: "1000m"
dnsPolicy: ClusterFirst
restartPolicy: Always
volumes:
- name: webui-volume
projected:
sources:
- configMap:
name: webui-configmap
13 changes: 13 additions & 0 deletions free5gc-webui/webui-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: webui-service
labels:
app: free5gc
spec:
type: NodePort
ports:
- port: 5000
nodePort: 30505
selector:
app: free5gc
Loading

0 comments on commit 3edb6e3

Please sign in to comment.