基于Kubernetes部署free5gc核心网

2024-04-27 17:12

本文主要是介绍基于Kubernetes部署free5gc核心网,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

说明:
本文仅适合个人对5gc核心网感兴趣测、研究使用。

操作系统版本:

# uname -r
5.4.0-177-generic
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:        20.04
Codename:       focal

修改网卡名称为eth0:

原始网卡信息:

# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope hostvalid_lft forever preferred_lft forever
2: ens5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000link/ether 00:22:4f:60:78:54 brd ff:ff:ff:ff:ff:ffinet 10.121.218.48/24 brd 10.121.218.255 scope global dynamic ens5valid_lft 100654441sec preferred_lft 100654441secinet6 fe80::222:4fff:fe60:7854/64 scope linkvalid_lft forever preferred_lft forever

修改网卡操作:

# vim /etc/default/grub
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
修改GRUB_CMDLINE_LINUX为  -->  GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
# update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-177-generic
Found initrd image: /boot/initrd.img-5.4.0-177-generic
done
# reboot
# vim /etc/netplan/00-installer-config.yaml
network:ethernets:eth0: #修改为eth0dhcp4: trueversion: 2
# netplan apply
如果网卡没有启动使用如下命令:
ip link set eth0 up

查看修改后网卡信息:

# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope hostvalid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000link/ether 00:22:4f:60:78:54 brd ff:ff:ff:ff:ff:ffinet 10.121.218.48/24 brd 10.121.218.255 scope global dynamic eth0valid_lft 100663242sec preferred_lft 100663242secinet6 fe80::222:4fff:fe60:7854/64 scope linkvalid_lft forever preferred_lft forever

安装依赖安装包:

# apt update -y
# apt upgrade -y
# apt install -y curl wget apt-transport-https

安装gpt5g

# apt install gcc -y
# apt install make -y
# apt install git -y
# git clone -b v0.8.1 https://github.com/free5gc/gtp5g.git
# cd gtp5g/
# make
make -C /lib/modules/5.4.0-177-generic/build M=/root/gtp5g modules
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-177-generic'CC [M]  /root/gtp5g/src/gtp5g.oCC [M]  /root/gtp5g/src/log.oCC [M]  /root/gtp5g/src/util.oCC [M]  /root/gtp5g/src/gtpu/dev.oCC [M]  /root/gtp5g/src/gtpu/encap.oCC [M]  /root/gtp5g/src/gtpu/hash.oCC [M]  /root/gtp5g/src/gtpu/link.oCC [M]  /root/gtp5g/src/gtpu/net.oCC [M]  /root/gtp5g/src/gtpu/pktinfo.oCC [M]  /root/gtp5g/src/genl/genl.oCC [M]  /root/gtp5g/src/genl/genl_version.oCC [M]  /root/gtp5g/src/genl/genl_pdr.oCC [M]  /root/gtp5g/src/genl/genl_far.oCC [M]  /root/gtp5g/src/genl/genl_qer.oCC [M]  /root/gtp5g/src/genl/genl_urr.oCC [M]  /root/gtp5g/src/genl/genl_report.oCC [M]  /root/gtp5g/src/genl/genl_bar.oCC [M]  /root/gtp5g/src/pfcp/api_version.oCC [M]  /root/gtp5g/src/pfcp/pdr.oCC [M]  /root/gtp5g/src/pfcp/far.oCC [M]  /root/gtp5g/src/pfcp/qer.oCC [M]  /root/gtp5g/src/pfcp/urr.oCC [M]  /root/gtp5g/src/pfcp/bar.oCC [M]  /root/gtp5g/src/pfcp/seid.oCC [M]  /root/gtp5g/src/proc.oLD [M]  /root/gtp5g/gtp5g.oBuilding modules, stage 2.MODPOST 1 modulesCC [M]  /root/gtp5g/gtp5g.mod.oLD [M]  /root/gtp5g/gtp5g.ko
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-177-generic'
# make install
cp gtp5g.ko /lib/modules/5.4.0-177-generic/kernel/drivers/net
modprobe udp_tunnel
/sbin/depmod -a
modprobe gtp5g
echo "gtp5g" >> /etc/modules

安装docker

# apt update
# apt install apt-transport-https ca-certificates curl software-properties-common -y
# 添加Docker的官方GPG密钥
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK
# 添加Docker软件库
# add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# 再次更新软件库索引
# apt update
# 安装Docker CE
# apt install docker-ce -y
# 启动Docker并设置开机启动
# systemctl start docker
# systemctl enable docker
# 验证Docker安装
# docker --version
Docker version 26.1.0, build 9714adc

安装minikube

# wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
# cp minikube-linux-amd64 /usr/local/bin/minikube
# chmod +x /usr/local/bin/minikube

启动minikube

使用普通账号操作:

$ sudo usermod -aG docker $USER && newgrp docker
$ minikube start --driver=docker --cpus=4 --memory=16g --disk-size=100g --cni=flannel
* minikube v1.33.0 on Ubuntu 20.04 (kvm/amd64)
* Using the docker driver based on user configuration
* Using Docker driver with root privileges
* Starting "minikube" primary control-plane node in "minikube" cluster
* Pulling base image v0.0.43 ...
* Downloading Kubernetes v1.30.0 preload ...> preloaded-images-k8s-v18-v1...:  342.90 MiB / 342.90 MiB  100.00% 16.34 M> index.docker.io/kicbase/sta...:  480.29 MiB / 480.29 MiB  100.00% 1.13 Mi
! minikube was unable to download gcr.io/k8s-minikube/kicbase:v0.0.43, but successfully downloaded docker.io/kicbase/stable:v0.0.43 as a fallback image
* Creating docker container (CPUs=4, Memory=16384MB) ...
* Preparing Kubernetes v1.30.0 on Docker 26.0.1 ...- Generating certificates and keys ...- Booting up control plane ...- Configuring RBAC rules ...
* Configuring Flannel (Container Networking Interface) ...
* Verifying Kubernetes components...- Using image gcr.io/k8s-minikube/storage-provisioner:v5
* Enabled addons: default-storageclass, storage-provisioner
* kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

安装kubectl

# curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
# chmod +x kubectl
# mv kubectl /usr/local/bin/

安装helm

# curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
# chmod 700 get_helm.sh
# ./get_helm.sh
Downloading https://get.helm.sh/helm-v3.14.4-linux-amd64.tar.gz
Verifying checksum... Done.
Preparing to install helm into /usr/local/bin
helm installed into /usr/local/bin/helm

安装multus-cni

使用普通账户执行:

$ git clone https://github.com/k8snetworkplumbingwg/multus-cni.git
$ sudo cat /home/yan/multus-cni/deployments/multus-daemonset.yml | kubectl apply  -f -
[sudo] password for yan:
Sorry, try again.
[sudo] password for yan:
customresourcedefinition.apiextensions.k8s.io/network-attachment-definitions.k8s.cni.cncf.io created
clusterrole.rbac.authorization.k8s.io/multus created
clusterrolebinding.rbac.authorization.k8s.io/multus created
serviceaccount/multus created
configmap/multus-cni-config created
daemonset.apps/kube-multus-ds created

安装5GC

使用普通账户执行:

$ kubectl create ns free5gc
$ git clone https://github.com/Orange-OpenSource/towards5gs-helm.git
$ helm -n free5gc install free5gc-v1 /home/yan/towards5gs-helm/charts/free5gc --set global.n2network.masterIf=eth0,global.n4network.masterIf=eth0,global.n6network.masterIf=eth0,global.n9network.masterIf=eth0,global.n6network.subnetIP=10.244.0.0,global.n6network.gatewayIP=10.244.0.2,free5gc-upf.upf.n6if.ipAddress=10.244.0.20
NAME: free5gc-v1
LAST DEPLOYED: Fri Apr 26 09:15:45 2024
NAMESPACE: free5gc
STATUS: deployed
REVISION: 1
NOTES:
#
# Software Name : towards5gs-helm
# SPDX-FileCopyrightText: Copyright (c) 2021 Orange
# SPDX-License-Identifier: Apache-2.0
#
# This software is distributed under the Apache License 2.0,
# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE
# or see the "LICENSE" file for more details.
#
# Author: Abderaouf KHICHANE, Ilhem FAJJARI
# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes
#
#
# Visit the project at https://github.com/Orange-OpenSource/towards5gs-helm
#1. Get the list of created Pods by running:kubectl get pods --namespace free5gc -l "project="Release notes (What's changed in this version):
- Fix TLS configuration for SBI communications
注意:此次的eth0为本机的网卡名。

安装UERANSIM

$ helm -n free5gc install ueransim /home/yan/towards5gs-helm/charts/ueransim --set global.n2network.masterIf=eth0,global.n3network.masterIf=eth0
NAME: ueransim
LAST DEPLOYED: Fri Apr 26 09:18:48 2024
NAMESPACE: free5gc
STATUS: deployed
REVISION: 1
NOTES:
#
# Software Name : towards5gs-helm
# SPDX-FileCopyrightText: Copyright (c) 2021 Orange
# SPDX-License-Identifier: Apache-2.0
#
# This software is distributed under the Apache License 2.0,
# the text of which is available at https://github.com/Orange-OpenSource/towards5gs-helm/blob/main/LICENSE
# or see the "LICENSE" file for more details.
#
# Author: Abderaouf KHICHANE, Ilhem FAJJARI
# Software description: An open-source project providing Helm charts to deploy 5G components (Core + RAN) on top of Kubernetes
#
#
# Visit the project at https://github.com/Orange-OpenSource/towards5gs-helm
#1. Run UE connectivity test by running these commands:helm --namespace free5gc test ueransimIf you want to run connectivity tests manually, follow:1. Get the UE Pod name by running:export POD_NAME=$(kubectl get pods --namespace free5gc -l "component=ue" -o jsonpath="{.items[0].metadata.name}")2. Check that uesimtun0 interface has been created by running these commands:kubectl --namespace free5gc logs $POD_NAMEkubectl --namespace free5gc exec -it $POD_NAME -- ip address3. Try to access internet from the UE by running:kubectl --namespace free5gc exec -it $POD_NAME -- ping -I uesimtun0 www.google.comkubectl --namespace free5gc exec -it $POD_NAME -- curl --interface uesimtun0 www.google.comkubectl --namespace free5gc exec -it $POD_NAME -- traceroute -i uesimtun0 www.google.comRelease notes (What's changed in this version):
- add the release notes
- add an initContainer to wait for the AMF to be ready
- enhance the handling of k8s NGAP service and network parameters

查看所有pod:

$ kubectl get pod -A
NAMESPACE      NAME                                                    READY   STATUS    RESTARTS      AGE
free5gc        free5gc-v1-free5gc-amf-amf-7844db6fd-xqs4f              1/1     Running   0             20m
free5gc        free5gc-v1-free5gc-ausf-ausf-7dcf7948f-47shs            1/1     Running   0             20m
free5gc        free5gc-v1-free5gc-dbpython-dbpython-85b5c46c66-5524c   1/1     Running   0             20m
free5gc        free5gc-v1-free5gc-nrf-nrf-75b6dd6d97-dn9bn             1/1     Running   0             20m
free5gc        free5gc-v1-free5gc-nssf-nssf-58b865c889-xf969           1/1     Running   0             20m
free5gc        free5gc-v1-free5gc-pcf-pcf-fd4b45967-pt698              1/1     Running   0             20m
free5gc        free5gc-v1-free5gc-smf-smf-75b66b95f5-vr7fj             1/1     Running   0             20m
free5gc        free5gc-v1-free5gc-udm-udm-75fd9d5ccb-lv7tl             1/1     Running   0             20m
free5gc        free5gc-v1-free5gc-udr-udr-7bff444cb4-w7vz8             1/1     Running   0             20m
free5gc        free5gc-v1-free5gc-upf-upf-9867579cf-xrwz5              1/1     Running   0             20m
free5gc        free5gc-v1-free5gc-webui-webui-6497c44789-bwxxj         1/1     Running   0             20m
free5gc        mongodb-0                                               1/1     Running   0             20m
free5gc        ueransim-gnb-76545d6765-l6tmh                           1/1     Running   0             17m
free5gc        ueransim-ue-7cb978fd78-2dlhd                            1/1     Running   0             17m

启动Web界面

$ kubectl port-forward --namespace free5gc svc/webui-service 5000:5000
Forwarding from 127.0.0.1:5000 -> 5000
Forwarding from [::1]:5000 -> 5000

本地电脑操作:

C:\Users\ailink>ssh -L localhost:5000:localhost:5000 yan@10.121.218.48
The authenticity of host '10.121.218.48 (10.121.218.48)' can't be established.
ECDSA key fingerprint is SHA256:2aiuF/m8XpMHm9sGo/6KBMmM52iWFd4mChfUcXXFvzA.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.121.218.48' (ECDSA) to the list of known hosts.
yan@10.121.218.48's password:
Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.4.0-177-generic x86_64)* Documentation:  https://help.ubuntu.com* Management:     https://landscape.canonical.com* Support:        https://ubuntu.com/proSystem information as of Fri 26 Apr 2024 09:52:03 AM UTCSystem load:                      0.27Usage of /:                       5.6% of 289.30GBMemory usage:                     7%Swap usage:                       0%Processes:                        371Users logged in:                  2IPv4 address for br-542cd42b44c7: 192.168.49.1IPv4 address for docker0:         172.17.0.1IPv4 address for eth0:            10.121.218.48Expanded Security Maintenance for Applications is not enabled.0 updates can be applied immediately.Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro statusNew release '22.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.Last login: Fri Apr 26 08:31:48 2024 from 192.168.10.2

登陆5GCWeb界面,http://localhost:5000,用户名和秘密为admin/free5gc
在这里插入图片描述
在这里插入图片描述
本次安装到这里完毕,后续章节会补充UE和GNB接入操作。
参考网址:
链接: free5GC
链接: free5gc Helm chart

这篇关于基于Kubernetes部署free5gc核心网的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/941070

相关文章

Kubernetes常用命令大全近期总结

《Kubernetes常用命令大全近期总结》Kubernetes是用于大规模部署和管理这些容器的开源软件-在希腊语中,这个词还有“舵手”或“飞行员”的意思,使用Kubernetes(有时被称为“... 目录前言Kubernetes 的工作原理为什么要使用 Kubernetes?Kubernetes常用命令总

python管理工具之conda安装部署及使用详解

《python管理工具之conda安装部署及使用详解》这篇文章详细介绍了如何安装和使用conda来管理Python环境,它涵盖了从安装部署、镜像源配置到具体的conda使用方法,包括创建、激活、安装包... 目录pytpshheraerUhon管理工具:conda部署+使用一、安装部署1、 下载2、 安装3

k8s部署MongDB全过程

《k8s部署MongDB全过程》文章介绍了如何在Kubernetes集群中部署MongoDB,包括环境准备、创建Secret、创建服务和Deployment,并通过Robo3T工具测试连接... 目录一、环境准备1.1 环境说明1.2 创建 namespace1.3 创建mongdb账号/密码二、创建Sec

Java中的Opencv简介与开发环境部署方法

《Java中的Opencv简介与开发环境部署方法》OpenCV是一个开源的计算机视觉和图像处理库,提供了丰富的图像处理算法和工具,它支持多种图像处理和计算机视觉算法,可以用于物体识别与跟踪、图像分割与... 目录1.Opencv简介Opencv的应用2.Java使用OpenCV进行图像操作opencv安装j

将Python应用部署到生产环境的小技巧分享

《将Python应用部署到生产环境的小技巧分享》文章主要讲述了在将Python应用程序部署到生产环境之前,需要进行的准备工作和最佳实践,包括心态调整、代码审查、测试覆盖率提升、配置文件优化、日志记录完... 目录部署前夜:从开发到生产的心理准备与检查清单环境搭建:打造稳固的应用运行平台自动化流水线:让部署像

Python项目打包部署到服务器的实现

《Python项目打包部署到服务器的实现》本文主要介绍了PyCharm和Ubuntu服务器部署Python项目,包括打包、上传、安装和设置自启动服务的步骤,具有一定的参考价值,感兴趣的可以了解一下... 目录一、准备工作二、项目打包三、部署到服务器四、设置服务自启动一、准备工作开发环境:本文以PyChar

centos7基于keepalived+nginx部署k8s1.26.0高可用集群

《centos7基于keepalived+nginx部署k8s1.26.0高可用集群》Kubernetes是一个开源的容器编排平台,用于自动化地部署、扩展和管理容器化应用程序,在生产环境中,为了确保集... 目录一、初始化(所有节点都执行)二、安装containerd(所有节点都执行)三、安装docker-

在Ubuntu上部署SpringBoot应用的操作步骤

《在Ubuntu上部署SpringBoot应用的操作步骤》随着云计算和容器化技术的普及,Linux服务器已成为部署Web应用程序的主流平台之一,Java作为一种跨平台的编程语言,具有广泛的应用场景,本... 目录一、部署准备二、安装 Java 环境1. 安装 JDK2. 验证 Java 安装三、安装 mys

Jenkins中自动化部署Spring Boot项目的全过程

《Jenkins中自动化部署SpringBoot项目的全过程》:本文主要介绍如何使用Jenkins从Git仓库拉取SpringBoot项目并进行自动化部署,通过配置Jenkins任务,实现项目的... 目录准备工作启动 Jenkins配置 Jenkins创建及配置任务源码管理构建触发器构建构建后操作构建任务

若依部署Nginx和Tomcat全过程

《若依部署Nginx和Tomcat全过程》文章总结了两种部署方法:Nginx部署和Tomcat部署,Nginx部署包括打包、将dist文件拉到指定目录、配置nginx.conf等步骤,Tomcat部署... 目录Nginx部署后端部署Tomcat部署出现问题:点击刷新404总结Nginx部署第一步:打包