diff --git a/bin/k8s-log.sh b/bin/k8s-log.sh new file mode 100755 index 0000000..d5b88bf --- /dev/null +++ b/bin/k8s-log.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +if [[ $# -eq 0 ]]; then + echo "Usage: k8s-logs [namespace]" + exit 1 +fi + +keyword=$1 +namespace=$2 + +if [[ -z $namespace ]]; then + echo "Select namespace:" + namespaces=($(kubectl get namespaces -o name | cut -d/ -f2)) + PS3="Namespace: " + select namespace in "${namespaces[@]}"; do + if [[ -n $namespace ]]; then + break + fi + done +fi + +pod=$(kubectl get pods -n "$namespace" | grep "$keyword" | head -1 | awk '{print $1}') +if [[ -z $pod ]]; then + echo "No pods found for keyword: $keyword" + exit 1 +fi + +containers=($(kubectl get pods "$pod" -n "$namespace" -o jsonpath='{.spec.containers[*].name}')) +if [[ ${#containers[@]} -eq 1 ]]; then + container=${containers[0]} +else + echo "Select container:" + PS3="Container: " + select container in "${containers[@]}"; do + if [[ -n $container ]]; then + break + fi + done +fi + +kubectl logs -f "$pod" -n "$namespace" -c "$container" + diff --git a/bin/k8s-shell.sh b/bin/k8s-shell.sh new file mode 100755 index 0000000..8197e54 --- /dev/null +++ b/bin/k8s-shell.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +# function to print usage message +function usage { + echo "Usage: $0 keyword [namespace]" + echo " keyword: a string that identifies the pod you want to access, e.g. amf, smf, upf" + echo " namespace (optional): the Kubernetes namespace where the pod is running" + echo "If no namespace is specified, a namespace picker will be displayed." +} + +# Function to prompt the user to select a namespace from a list +select_namespace() { + echo "Select a namespace:" + select NAMESPACE in $(kubectl get namespaces -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}') + do + if [ -n "$NAMESPACE" ] + then + break + fi + done +} + +# Function to prompt the user to select a container from a list +select_container() { + echo "Select a container:" + select CONTAINER in $(kubectl get pod $POD -n $NAMESPACE -o jsonpath='{range .spec.containers[*]}{.name}{"\n"}{end}') + do + if [ -n "$CONTAINER" ] + then + break + fi + done +} + +# Display help message if no arguments provided +if [ "$#" -eq 0 ] +then + usage + exit 1 +fi + +POD_KEYWORD=$1 + +# Prompt for namespace if not specified +if [ "$#" -eq 1 ] +then + select_namespace +else + NAMESPACE=$2 +fi + +POD=$(kubectl get pods -n $NAMESPACE | grep "$POD_KEYWORD" | awk '{print $1}') + +if [ -z "$POD" ] +then + echo "No pod found with keyword: $POD_KEYWORD in namespace: $NAMESPACE" + exit 1 +fi + +CONTAINER_COUNT=$(kubectl get pod $POD -n $NAMESPACE -o jsonpath='{range .spec.containers[*]}{.name}{"\n"}{end}' | wc -l) + +if [ "$CONTAINER_COUNT" -eq 1 ] +then + CONTAINER=$(kubectl get pod $POD -n $NAMESPACE -o jsonpath='{.spec.containers[0].name}') +else + select_container +fi + +# Try bash shell, fallback to sh +SHELLS=("bash" "sh") +for SHELL in "${SHELLS[@]}" +do + if kubectl exec $POD -n $NAMESPACE -c $CONTAINER -- $SHELL -c 'exit 0' > /dev/null 2>&1 + then + kubectl exec -it $POD -n $NAMESPACE -c $CONTAINER -- $SHELL + exit 0 + fi +done + +echo "No supported shell found in pod: $POD" +exit 1 + diff --git a/ueransim/ueransim-gnb/config/free5gc-gnb.yaml b/ueransim/ueransim-gnb/config/free5gc-gnb.yaml index 680265f..76eaf9c 100644 --- a/ueransim/ueransim-gnb/config/free5gc-gnb.yaml +++ b/ueransim/ueransim-gnb/config/free5gc-gnb.yaml @@ -5,7 +5,7 @@ nci: '0x000000010' # NR Cell Identity (36-bit) idLength: 32 # NR gNB ID length in bits [22...32] tac: 1 # Tracking Area Code -linkIp: 129.97.168.65 # gNB's local IP address for Radio Link Simulation (Usually same with local IP) +linkIp: 0.0.0.0 # gNB's local IP address for Radio Link Simulation (Usually same with local IP) ngapIp: 10.10.2.22 # gNB's local IP address for N2 Interface (Usually same with local IP) gtpIp: 10.10.3.22 # gNB's local IP address for N3 Interface (Usually same with local IP) diff --git a/ueransim/ueransim-gnb/config/wrapper.sh b/ueransim/ueransim-gnb/config/wrapper.sh new file mode 100644 index 0000000..534843b --- /dev/null +++ b/ueransim/ueransim-gnb/config/wrapper.sh @@ -0,0 +1,2 @@ +#!/bin/bash + /ueransim/nr-gnb --config /ueransim/config/free5gc-gnb.yaml \ No newline at end of file diff --git a/ueransim/ueransim-gnb/gnb-configmap.yaml b/ueransim/ueransim-gnb/gnb-configmap.yaml deleted file mode 100644 index cd6bd64..0000000 --- a/ueransim/ueransim-gnb/gnb-configmap.yaml +++ /dev/null @@ -1,40 +0,0 @@ ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: gnb-configmap - labels: - app: ueransim - component: gnb -data: - gnb-config.yaml: | - mcc: '001' # Mobile Country Code value - mnc: '01' # Mobile Network Code value (2 or 3 digits) - - nci: '0x000000010' # NR Cell Identity (36-bit) - idLength: 32 # NR gNB ID length in bits [22...32] - tac: 1 # Tracking Area Code - - linkIp: 0.0.0.0 # gNB's local IP address for Radio Link Simulation (Usually same with local IP) - ngapIp: 10.10.2.31 # gNB's local IP address for N2 Interface (Usually same with local IP) - gtpIp: 10.10.3.31 # gNB's local IP address for N3 Interface (Usually same with local IP) - - # List of AMF address information - amfConfigs: - - address: 10.10.2.1 - port: 38412 - - # List of supported S-NSSAIs by this gNB - slices: - - sst: 1 - sd: 000001 - - sst: 2 - sd: 000002 - - # Indicates whether or not SCTP stream number errors should be ignored. - ignoreStreamIds: true - - wrapper.sh: | - #!/bin/bash - /ueransim/nr-gnb --config /ueransim/config/gnb-config.yaml - diff --git a/ueransim/ueransim-gnb/gnb-deployment.yaml b/ueransim/ueransim-gnb/gnb-deployment.yaml index 1ad15ee..06a1d20 100644 --- a/ueransim/ueransim-gnb/gnb-deployment.yaml +++ b/ueransim/ueransim-gnb/gnb-deployment.yaml @@ -19,8 +19,8 @@ spec: component: gnb annotations: k8s.v1.cni.cncf.io/networks: '[ - { "name": "n2network", "interface": "n2", "ips": [ "10.10.2.31/24" ] }, - { "name": "n3network", "interface": "n3", "ips": [ "10.10.3.31/24" ] } + { "name": "n2network", "interface": "n2", "ips": [ "10.10.2.22/24" ] }, + { "name": "n3network", "interface": "n3", "ips": [ "10.10.3.22/24" ] } ]' spec: containers: @@ -39,11 +39,11 @@ spec: name: gnb-volume resources: requests: - memory: "1024Mi" - cpu: "1000m" + memory: "256Mi" + cpu: "200m" limits: - memory: "2048Mi" - cpu: "2000m" + memory: "512Mi" + cpu: "500m" dnsPolicy: ClusterFirst restartPolicy: Always volumes: @@ -51,8 +51,8 @@ spec: configMap: name: gnb-configmap items: - - key: gnb-config.yaml - path: gnb-config.yaml + - key: free5gc-gnb.yaml + path: free5gc-gnb.yaml - key: wrapper.sh path: wrapper.sh mode: 0777 diff --git a/ueransim/ueransim-gnb/kustomization.yaml b/ueransim/ueransim-gnb/kustomization.yaml index fb0a7dd..11c3019 100644 --- a/ueransim/ueransim-gnb/kustomization.yaml +++ b/ueransim/ueransim-gnb/kustomization.yaml @@ -2,6 +2,11 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- gnb-configmap.yaml - gnb-deployment.yaml -- gnb-service.yaml \ No newline at end of file +- gnb-service.yaml + +configMapGenerator: + - name: gnb-configmap + files: + - config/free5gc-gnb.yaml + - config/wrapper.sh \ No newline at end of file diff --git a/ueransim/ueransim-ue/config/ue3.yaml b/ueransim/ueransim-ue/config/ue3.yaml deleted file mode 100644 index 089ed98..0000000 --- a/ueransim/ueransim-ue/config/ue3.yaml +++ /dev/null @@ -1,72 +0,0 @@ -# IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits) -supi: 'imsi-001010000000003' -# Mobile Country Code value of HPLMN -mcc: '001' -# Mobile Network Code value of HPLMN (2 or 3 digits) -mnc: '01' - -# Permanent subscription key -key: 'B199B49F465B5CE8E238A6BCAA5F0A2E' -# Operator code (OP or OPC) of the UE -op: '283B54E8E8ED289D8E6183CAEBA952E4' -# This value specifies the OP type and it can be either 'OP' or 'OPC' -opType: 'OPC' -# Authentication Management Field (AMF) value -amf: '8000' -# IMEI number of the device. It is used if no SUPI is provided -imei: '356938035643803' -# IMEISV number of the device. It is used if no SUPI and IMEI is provided -imeiSv: '4370816125816151' - -# List of gNB IP addresses for Radio Link Simulation -gnbSearchList: - - 129.97.168.65 - -# UAC Access Identities Configuration -uacAic: - mps: false - mcs: false - -# UAC Access Control Class -uacAcc: - normalClass: 0 - class11: false - class12: false - class13: false - class14: false - class15: false - -# Initial PDU sessions to be established -sessions: - - type: 'IPv4' - apn: 'internet' - slice: - sst: 1 - sd: 000001 - -# Configured NSSAI for this UE by HPLMN -configured-nssai: - - sst: 1 - sd: 000001 - -# Default Configured NSSAI for this UE -default-nssai: - - sst: 1 - sd: 000001 - -# Supported integrity algorithms by this UE -integrity: - IA1: true - IA2: true - IA3: true - -# Supported encryption algorithms by this UE -ciphering: - EA1: true - EA2: true - EA3: true - -# Integrity protection maximum data rate for user plane -integrityMaxRate: - uplink: 'full' - downlink: 'full' diff --git a/ueransim/ueransim-ue/config/kustomization.yaml b/ueransim/ueransim-ue/kustomization.yaml similarity index 100% rename from ueransim/ueransim-ue/config/kustomization.yaml rename to ueransim/ueransim-ue/kustomization.yaml diff --git a/ueransim/ueransim-ue/ue1/kustomization.yaml b/ueransim/ueransim-ue/ue1/kustomization.yaml index a30a1d3..13fbd93 100644 --- a/ueransim/ueransim-ue/ue1/kustomization.yaml +++ b/ueransim/ueransim-ue/ue1/kustomization.yaml @@ -1,3 +1,8 @@ resources: -- ue-configmap.yaml -- ue-deployment.yaml \ No newline at end of file +- ue-deployment.yaml + +configMapGenerator: + - name: ue1-configmap + files: + - ue1.yaml + - wrapper.sh \ No newline at end of file diff --git a/ueransim/ueransim-ue/ue1/ue-configmap.yaml b/ueransim/ueransim-ue/ue1/ue-configmap.yaml deleted file mode 100644 index 1b6a04c..0000000 --- a/ueransim/ueransim-ue/ue1/ue-configmap.yaml +++ /dev/null @@ -1,98 +0,0 @@ ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: ue1-configmap - labels: - app: ueransim - component: ue - name: ue1 -data: - free5gc-ue.yaml: | - # IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits) - supi: 'imsi-001010000000001' - # Mobile Country Code value of HPLMN - mcc: '001' - # Mobile Network Code value of HPLMN (2 or 3 digits) - mnc: '01' - - # Permanent subscription key - key: '465B5CE8B199B49FAA5F0A2EE238A6BC' - # Operator code (OP or OPC) of the UE - op: 'E8ED289DEBA952E4283B54E88E6183CA' - # This value specifies the OP type and it can be either 'OP' or 'OPC' - opType: 'OPC' - # Authentication Management Field (AMF) value - amf: '8000' - # IMEI number of the device. It is used if no SUPI is provided - imei: '356938035643803' - # IMEISV number of the device. It is used if no SUPI and IMEI is provided - imeiSv: '4370816125816151' - - # List of gNB IP addresses for Radio Link Simulation - gnbSearchList: - - gnb-service - - # UAC Access Identities Configuration - uacAic: - mps: false - mcs: false - - # UAC Access Control Class - uacAcc: - normalClass: 0 - class11: false - class12: false - class13: false - class14: false - class15: false - - # Initial PDU sessions to be established - sessions: - - type: 'IPv4' - apn: 'internet' - slice: - sst: 1 - sd: 000001 - - # Configured NSSAI for this UE by HPLMN - configured-nssai: - - sst: 1 - sd: 000001 - - # Default Configured NSSAI for this UE - default-nssai: - - sst: 1 - sd: 000001 - - # Supported integrity algorithms by this UE - integrity: - IA1: true - IA2: true - IA3: true - - # Supported encryption algorithms by this UE - ciphering: - EA1: true - EA2: true - EA3: true - - # Integrity protection maximum data rate for user plane - integrityMaxRate: - uplink: 'full' - downlink: 'full' - - wrapper.sh: | - #!/bin/bash - - mkdir /dev/net - mknod /dev/net/tun c 10 200 - - /ueransim/nr-ue -c /ueransim/config/free5gc-ue.yaml - - wrapper-debug.sh: | - #!/bin/bash - - mkdir /dev/net - mknod /dev/net/tun c 10 200 - diff --git a/ueransim/ueransim-ue/ue1/ue-deployment.yaml b/ueransim/ueransim-ue/ue1/ue-deployment.yaml index 38f72c7..09f40e4 100644 --- a/ueransim/ueransim-ue/ue1/ue-deployment.yaml +++ b/ueransim/ueransim-ue/ue1/ue-deployment.yaml @@ -44,11 +44,11 @@ spec: name: ue-volume resources: requests: - memory: "1024Mi" - cpu: "1000m" + memory: "256Mi" + cpu: "200m" limits: - memory: "2048Mi" - cpu: "2000m" + memory: "512Mi" + cpu: "500m" dnsPolicy: ClusterFirst restartPolicy: Always volumes: @@ -56,11 +56,8 @@ spec: configMap: name: ue1-configmap items: - - key: free5gc-ue.yaml - path: free5gc-ue.yaml + - key: ue1.yaml + path: ue1.yaml - key: wrapper.sh path: wrapper.sh - mode: 0755 - - key: wrapper-debug.sh - path: wrapper-debug.sh mode: 0755 \ No newline at end of file diff --git a/ueransim/ueransim-ue/config/ue1.yaml b/ueransim/ueransim-ue/ue1/ue1.yaml similarity index 100% rename from ueransim/ueransim-ue/config/ue1.yaml rename to ueransim/ueransim-ue/ue1/ue1.yaml diff --git a/ueransim/ueransim-ue/ue1/wrapper.sh b/ueransim/ueransim-ue/ue1/wrapper.sh new file mode 100644 index 0000000..d32c0fe --- /dev/null +++ b/ueransim/ueransim-ue/ue1/wrapper.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +mkdir /dev/net +mknod /dev/net/tun c 10 200 + +/ueransim/nr-ue -c /ueransim/config/ue1.yaml \ No newline at end of file diff --git a/ueransim/ueransim-ue/ue2/kustomization.yaml b/ueransim/ueransim-ue/ue2/kustomization.yaml index a30a1d3..87a0e8c 100644 --- a/ueransim/ueransim-ue/ue2/kustomization.yaml +++ b/ueransim/ueransim-ue/ue2/kustomization.yaml @@ -1,3 +1,8 @@ resources: -- ue-configmap.yaml -- ue-deployment.yaml \ No newline at end of file +- ue-deployment.yaml + +configMapGenerator: + - name: ue2-configmap + files: + - ue2.yaml + - wrapper.sh \ No newline at end of file diff --git a/ueransim/ueransim-ue/ue2/ue-configmap.yaml b/ueransim/ueransim-ue/ue2/ue-configmap.yaml deleted file mode 100644 index 504f934..0000000 --- a/ueransim/ueransim-ue/ue2/ue-configmap.yaml +++ /dev/null @@ -1,93 +0,0 @@ ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: ue2-configmap - labels: - app: ueransim - component: ue - name: ue2 -data: - free5gc-ue.yaml: | - # IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits) - supi: 'imsi-001010000000002' - # Mobile Country Code value of HPLMN - mcc: '001' - # Mobile Network Code value of HPLMN (2 or 3 digits) - mnc: '01' - - # Permanent subscription key - key: 'B199B49F465B5CE8E238A6BCAA5F0A2E' - # Operator code (OP or OPC) of the UE - op: '283B54E8E8ED289D8E6183CAEBA952E4' - # This value specifies the OP type and it can be either 'OP' or 'OPC' - opType: 'OPC' - # Authentication Management Field (AMF) value - amf: '8000' - # IMEI number of the device. It is used if no SUPI is provided - imei: '356938035643803' - # IMEISV number of the device. It is used if no SUPI and IMEI is provided - imeiSv: '4370816125816151' - - # List of gNB IP addresses for Radio Link Simulation - gnbSearchList: - - gnb-service - - # UAC Access Identities Configuration - uacAic: - mps: false - mcs: false - - # UAC Access Control Class - uacAcc: - normalClass: 0 - class11: false - class12: false - class13: false - class14: false - class15: false - - # Initial PDU sessions to be established - sessions: - - type: 'IPv4' - apn: 'internet' - slice: - sst: 2 - sd: 000002 - - # Configured NSSAI for this UE by HPLMN - configured-nssai: - - sst: 2 - sd: 000002 - - # Default Configured NSSAI for this UE - default-nssai: - - sst: 2 - sd: 000002 - - # Supported integrity algorithms by this UE - integrity: - IA1: true - IA2: true - IA3: true - - # Supported encryption algorithms by this UE - ciphering: - EA1: true - EA2: true - EA3: true - - # Integrity protection maximum data rate for user plane - integrityMaxRate: - uplink: 'full' - downlink: 'full' - - - wrapper.sh: | - #!/bin/bash - - mkdir /dev/net - mknod /dev/net/tun c 10 200 - - /ueransim/nr-ue -c /ueransim/config/free5gc-ue.yaml - \ No newline at end of file diff --git a/ueransim/ueransim-ue/ue2/ue-deployment.yaml b/ueransim/ueransim-ue/ue2/ue-deployment.yaml index 9eed332..0032ab6 100644 --- a/ueransim/ueransim-ue/ue2/ue-deployment.yaml +++ b/ueransim/ueransim-ue/ue2/ue-deployment.yaml @@ -36,11 +36,11 @@ spec: name: ue-volume resources: requests: + memory: "256Mi" + cpu: "200m" + limits: memory: "512Mi" cpu: "500m" - limits: - memory: "1024Mi" - cpu: "1000m" dnsPolicy: ClusterFirst restartPolicy: Always volumes: @@ -48,8 +48,8 @@ spec: configMap: name: ue2-configmap items: - - key: free5gc-ue.yaml - path: free5gc-ue.yaml + - key: ue2.yaml + path: ue2.yaml - key: wrapper.sh path: wrapper.sh mode: 0755 \ No newline at end of file diff --git a/ueransim/ueransim-ue/config/ue2.yaml b/ueransim/ueransim-ue/ue2/ue2.yaml similarity index 100% rename from ueransim/ueransim-ue/config/ue2.yaml rename to ueransim/ueransim-ue/ue2/ue2.yaml diff --git a/ueransim/ueransim-ue/ue2/wrapper.sh b/ueransim/ueransim-ue/ue2/wrapper.sh new file mode 100644 index 0000000..d91a653 --- /dev/null +++ b/ueransim/ueransim-ue/ue2/wrapper.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +mkdir /dev/net +mknod /dev/net/tun c 10 200 + +/ueransim/nr-ue -c /ueransim/config/ue2.yaml \ No newline at end of file