The Open5GS Kubernetes Operator is a custom Kubernetes operator designed to automate the deployment, configuration, and lifecycle management of Open5GS and its subscribers in a declarative way. It uses two CRDs (Custom Resource Definitions): one for managing Open5GS deployments and another for managing Open5GS users, allowing efficient and automated core and subscriber management.
The operator automates the deployment and reconfiguration of Open5GS instances in a Kubernetes cluster. It allows you to define the desired state of an Open5GS deployment in a declarative way, and the operator will ensure that the actual state of the deployment matches the desired state. This includes enabling/disabling components, configuring network slices, and defining the parameters of the Open5GS deployment. Any drift between the actual and desired state will be detected and corrected automatically by the operator. Note that the operator will restart the neccesary pods to apply the changes and that may cause a service interruption.
The operator handles multiple Open5GS deployments across different Kubernetes namespaces, ensuring resource isolation. It can also manage several Open5GS deployments within the same namespace, allowing independent management of each Open5GS instance.
The operator provides full management of Open5GS subscribers, including configuration of network slices and the target Open5GS deployment to which they should be assigned. It distinguishes between Managed Users and Unmanaged Users:
-
Managed Users: These are users whose IMSI is defined in a CR (Custom Resource). The operator controls their configuration, and any discrepancy between the actual state and the desired state in the CR will be detected as drift and corrected automatically, ensuring the configuration always aligns with the declarative source of truth.
-
Unmanaged Users: These users are not controlled by the operator and are created externally (e.g., via scripts that directly modify the database or the Open5GS WebUI). Unmanaged users will not be altered by the operator, allowing compatibility with external tools and temporary deployments that don't need strict management by the operator.
- Operator SDK: OperatorSDK 1.37.0 version
- Go: go 1.23.3 version
To install by using Helm, you can use the Helm chart provided in the charts directory or the open5gs-operator-x.x.x.tgz file. The chart is also available in the Gradiant Charts repository.
helm install open5gs-operator oci://registry-1.docker.io/gradiantcharts/open5gs-operatorTo uninstall the operator, run:
helm uninstall open5gs-operatorFor the other installation options, you can follow this guide.
-
Create a deployment configuration file for Open5GS. Here’s a basic example (the configuration missing will be set to default values):
apiVersion: net.gradiant.org/v1 kind: Open5GS metadata: name: open5gs-sample namespace: default spec: configuration: slices: - sst: "1" sd: "0x111111"
-
Apply the deployment file:
kubectl apply -f open5gs-deployment.yaml
-
Create a configuration file for the users you want to add. Here’s an example:
apiVersion: net.gradiant.org/v1 kind: Open5GSUser metadata: name: open5gsuser-sample namespace: default spec: imsi: "999700000000001" key: "465B5CE8B199B49FAA5F0A2EE238A6BC" opc: "E8ED289DEBA952E4283B54E88E6183CA" sd: "111111" sst: "1" apn: "internet" open5gs: name: "open5gs-sample" namespace: "default"
- The
apn,sst, andsdfields are optional. If they are not provided in the configuration, default values will be used by the system. - The
open5gsfield must contain thenameandnamespaceof the Open5GS deployment to which the user will be assigned.
- The
-
Apply the user configuration:
kubectl apply -f open5gsuser-1.yaml
For more information on how to use the operator and more advanced configurations, please refer to the Documentation.
A complete demo with UERANSIM is available at this link.
- The operator will restart the necessary pods to apply the changes and that may cause a service interruption. For example, if the
amf.metricsparameter is changed, the operator will update the AMF deployment to apply the changes, resulting in a service interruption. - By default, all core components are enabled (except for the WebUI). To disable a component, set the
enabledfield tofalsein the CR. - By default, service accounts are not created. To create a service account, set the
serviceAccountfield totruein the CR for the desired component. - By default, components with metrics support have metrics enabled (AMF, PCF, UPF). To disable metrics, set the
metricsfield tofalsein the CR for the desired component. - By default, components use the
ClusterIPservice type. To change the service type, set theserviceTypefield toLoadBalancerorNodePortin the CR for the desired component. This option is currently available for theamf-ngap,smf-pfcp,upf-pfcp, andupf-gtpuservices. - The
open5gsImagefield in the CR specifies the version of the Open5GS images. If not specified, the operator defaults to versiondocker.io/gradiant/open5gs:2.8.0. - The
webuiImagefield in the CR specifies the version of the Open5GS WebUI image. If not specified, the operator defaults to versiondocker.io/gradiant/open5gs-webui:2.8.0. - The
mongoDBVersionfield in the CR specifies the version of the MongoDB image. If not specified, new installations usedocker.io/library/mongo:8.0.34. See MongoDB migration before changing an existing installation. - Components with metric support can generate a
ServiceMonitorCR to expose metrics to Prometheus. However, ensure that theServiceMonitorCRD is installed in the cluster; otherwise, the operator will encounter an error and fail to create the resource. To create a ServiceMonitor, set theserviceMonitorfield totruein the CR for the desired component. - UPF Deployment Annotations. Use
upf.deploymentAnnotationsto add or remove annotations on the Pod template. The operator tracks the annotations specified in this field and preserves annotations added independently. - UPF GTP-U Interface: The GTP-U network interface used by the UPF is set via the
upf.gtpuDevfield in the CR (e.g.,gtpuDev: "eth0"). By default, the UPF uses theeth0interface. - Unprivileged UPF Mode (Opt-In): Set
spec.upf.unprivilegedtotrueto run UPF withoutprivileged: trueand with a non-root main container (UID 1001); this field is only applied to UPF and is ignored by other components, it requires cluster support for/dev/net/tunandnet.ipv4.ip_forward(including kubeletallowed-unsafe-sysctlsand, on OpenShift, a compatible SCC), and its default value isfalse, so existing deployments keep the current behavior. - WebUI bootstrap. For a new database, create a Secret in the same namespace with keys
usernameandpassword(at least 12 characters) and setspec.webuiAdminSecretto its name. WebUI waits for a configured administrator before starting. Restart the WebUI Deployment after changing bootstrap inputs. Existing accounts are preserved. Rotate any account still using the previous default password through WebUI. - Workload permissions and sizing. Each component uses a dedicated ServiceAccount by default. Set
spec.<component>.serviceAccount: falseto use the namespace default account. Workload Pods do not mount API tokens in either case. Setspec.<component>.resourcesto override the default CPU and memory requests and limits for its main container.
Before upgrading an existing Bitnami installation, pin an available image tag for the legacy deployment and keep it available for rollback. When mongoDBVersion is omitted, the operator keeps the image and claim of an existing Bitnami deployment. The official image uses /data/db and a separate PVC.
- Schedule a maintenance window and stop writes from the core, WebUI and subscriber controller. Back up the
open5gsdatabase withmongodump --db open5gs --archive. Store the archive securely because it contains subscriber keys and account hashes. - Provision a separate PVC and attach it to a temporary MongoDB instance using the desired official image with UID/GID 999 and mount path
/data/db. Restore withmongorestore --archive --nsInclude='open5gs.*'. Check collection counts, representative subscribers and accounts, and confirm the temporary instance can restart and still read its data. - Stop the temporary MongoDB instance so it releases the volume. Set
spec.mongoDBVolumeClaimto the restored PVC andspec.mongoDBVersionto the tested official image. Wait for MongoDB and the dependent workloads. Validate a known WebUI account and a subscriber session before resuming normal writes. - Keep the old volume and archive until cutover is accepted. To roll back, set the original Bitnami image explicitly and clear
spec.mongoDBVolumeClaim. Plan how to preserve writes accepted since cutover before rolling back.
To publish a new version of the operator, follow these steps:
- Make the necessary changes in the code.
- Run the version script:
This will update the version in all relevant files (Makefile, kustomization.yaml, Chart.yaml, and values.yaml).
./set-version.sh <new_version>
- Commit the changes and create the corresponding Pull Request (PR).
This ensures that the published version is consistent with the code and manifests.