Skip to content

Commit

Permalink
Merge pull request #7 from jain-ashish-sam/main
Browse files Browse the repository at this point in the history
Oai-Controller Changes for O1-Telnet
  • Loading branch information
nephio-prow[bot] committed Jun 28, 2024
2 parents e750221 + 5206141 commit 80fa770
Show file tree
Hide file tree
Showing 22 changed files with 981 additions and 607 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.20 as builder
FROM golang:1.20 AS builder
ARG TARGETOS
ARG TARGETARCH

Expand All @@ -16,6 +16,7 @@ COPY cmd/main.go cmd/main.go
COPY internal/controller/ internal/controller/
COPY api api


# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
Expand Down
3 changes: 2 additions & 1 deletion internal/controller/randeployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,17 @@ func (r *RANDeploymentReconciler) GetConfigs(ctx context.Context, ranDeployment
// For more details, check Reconcile and its Result here:
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.15.0/pkg/reconcile
func (r *RANDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {

logger := log.FromContext(ctx).WithValues("RANDeployment", req.NamespacedName)
logger.Info("Reconcile for RANDeployment")

instance := &workloadv1alpha1.NFDeployment{}
err := r.Get(ctx, req.NamespacedName, instance)
if err != nil {
if errors.IsNotFound(err) {
logger.Info("RANDeployment resource not found, ignoring because object must be deleted")
return ctrl.Result{}, nil
}

logger.Error(err, "Failed to get RANDeployment")
return ctrl.Result{}, err
}
Expand Down
6 changes: 3 additions & 3 deletions internal/controller/resources_cucp.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (resource CuCpResources) GetConfigMap(log logr.Logger, ranDeployment *workl

configMap1 := &corev1.ConfigMap{
Data: map[string]string{
"mounted.conf": configuration,
"gnb.conf": configuration,
},
ObjectMeta: metav1.ObjectMeta{
Name: "oai-gnb-cu-cp-configmap",
Expand Down Expand Up @@ -205,8 +205,8 @@ func (resource CuCpResources) GetDeployment(log logr.Logger, ranDeployment *work
corev1.VolumeMount{
Name: "configuration",
ReadOnly: false,
SubPath: "mounted.conf",
MountPath: "/opt/oai-gnb/etc/mounted.conf",
SubPath: "gnb.conf",
MountPath: "/opt/oai-gnb/etc/gnb.conf",
},
},
Env: []corev1.EnvVar{
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/resources_cucp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,8 @@ func TestGetConfigMapCuCp(t *testing.T) {
NSSAI_SD: *tc.paramsPlmn.Spec.PLMNInfo[0].NSSAI[0].SD,
})

if !reflect.DeepEqual(got[0].Data["mounted.conf"], defaultWantConfigurations) {
t.Errorf("GetConfigMap returned %s Wanted %s", got[0].Data["mounted.conf"], defaultWantConfigurations)
if !reflect.DeepEqual(got[0].Data["gnb.conf"], defaultWantConfigurations) {
t.Errorf("GetConfigMap returned %s Wanted %s", got[0].Data["gnb.conf"], defaultWantConfigurations)
}
} else {
if got != nil {
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/resources_cuup.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ func (resource CuUpResources) GetDeployment(log logr.Logger, ranDeployment *work
VolumeMounts: []corev1.VolumeMount{

corev1.VolumeMount{
MountPath: "/opt/oai-gnb/etc/mounted.conf",
MountPath: "/opt/oai-gnb/etc/gnb.conf",
Name: "configuration",
ReadOnly: false,
SubPath: "mounted.conf",
SubPath: "gnb.conf",
},
},
Env: []corev1.EnvVar{
Expand All @@ -111,7 +111,7 @@ func (resource CuUpResources) GetDeployment(log logr.Logger, ranDeployment *work
},
corev1.EnvVar{
Name: "USE_ADDITIONAL_OPTIONS",
Value: "--sa",
Value: "--sa --log_config.global_log_options level,nocolor,time",
},
corev1.EnvVar{
Name: "USE_VOLUMED_CONF",
Expand Down Expand Up @@ -259,7 +259,7 @@ func (resource CuUpResources) GetConfigMap(log logr.Logger, ranDeployment *workl
Kind: "ConfigMap",
},
Data: map[string]string{
"mounted.conf": configuration,
"gnb.conf": configuration,
},
}

Expand Down
4 changes: 2 additions & 2 deletions internal/controller/resources_cuup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ func TestGetConfigMapCuUp(t *testing.T) {
t.Errorf("GetConfigMap CuUp returned %v Wanted nil", got)
}
} else {
if got[0].Data["mounted.conf"] != tc.wantedConfiguration {
t.Errorf("GetConfigMap CuUp returned %v Wanted %v", got[0].Data["mounted.conf"], tc.wantedConfiguration)
if got[0].Data["gnb.conf"] != tc.wantedConfiguration {
t.Errorf("GetConfigMap CuUp returned %v Wanted %v", got[0].Data["gnb.conf"], tc.wantedConfiguration)
}
}

Expand Down
68 changes: 48 additions & 20 deletions internal/controller/resources_du.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
workloadv1alpha1 "github.com/nephio-project/api/workload/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
resourcev1 "k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"
Expand Down Expand Up @@ -98,7 +99,7 @@ func (resource DuResources) GetConfigMap(log logr.Logger, ranDeployment *workloa

configMap1 := &corev1.ConfigMap{
Data: map[string]string{
"mounted.conf": configuration,
"gnb.conf": configuration,
},
ObjectMeta: metav1.ObjectMeta{
Name: "oai-gnb-du-configmap",
Expand All @@ -113,7 +114,6 @@ func (resource DuResources) GetConfigMap(log logr.Logger, ranDeployment *workloa
}

func (resource DuResources) GetDeployment(log logr.Logger, ranDeployment *workloadv1alpha1.NFDeployment, configInfo *ConfigInfo) []*appsv1.Deployment {

spec := ranDeployment.Spec

networkAttachmentDefinitionNetworks, err := resource.createNetworkAttachmentDefinitionNetworks(ranDeployment.Name, &spec)
Expand Down Expand Up @@ -178,22 +178,10 @@ func (resource DuResources) GetDeployment(log logr.Logger, ranDeployment *worklo

corev1.Container{
Env: []corev1.EnvVar{

corev1.EnvVar{
Name: "TZ",
Value: "Europe/Paris",
},
corev1.EnvVar{
Name: "RFSIMULATOR",
Value: "server",
},
corev1.EnvVar{
Name: "USE_ADDITIONAL_OPTIONS",
Value: "--sa --rfsim --log_config.global_log_options level,nocolor,time",
},
corev1.EnvVar{
Name: "USE_VOLUMED_CONF",
Value: "yes",
Name: "USE_ADDITIONAL_OPTIONS",
Value: "--sa --rfsim --log_config.global_log_options level,nocolor,time" +
" --telnetsrv --telnetsrv.shrmod o1 --telnetsrv.listenaddr 192.168.74.2",
},
},
Image: paramsOAI.Spec.Image,
Expand All @@ -210,15 +198,25 @@ func (resource DuResources) GetDeployment(log logr.Logger, ranDeployment *worklo
Protocol: corev1.Protocol("UDP"),
},
},
Resources: corev1.ResourceRequirements{
Limits: corev1.ResourceList{
corev1.ResourceCPU: resourcev1.MustParse("2000m"),
corev1.ResourceMemory: resourcev1.MustParse("2Gi"),
},
Requests: corev1.ResourceList{
corev1.ResourceCPU: resourcev1.MustParse("2000m"),
corev1.ResourceMemory: resourcev1.MustParse("1Gi"),
},
},
Stdin: false,
TTY: false,
VolumeMounts: []corev1.VolumeMount{

corev1.VolumeMount{
Name: "configuration",
ReadOnly: false,
SubPath: "mounted.conf",
MountPath: "/opt/oai-gnb/etc/mounted.conf",
SubPath: "gnb.conf",
MountPath: "/opt/oai-gnb/etc/gnb.conf",
},
},
Name: "gnbdu",
Expand Down Expand Up @@ -309,5 +307,35 @@ func (resource DuResources) GetService() []*corev1.Service {
},
}

return []*corev1.Service{service1}
// O1-Telent Service
service2 := &corev1.Service{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "Service",
},
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"app.kubernetes.io/name": "oai-gnb-du-o1-telnet-lb",
},
Name: "oai-gnb-du-o1-telnet-lb",
},
Spec: corev1.ServiceSpec{
Selector: map[string]string{
"app.kubernetes.io/name": "oai-gnb-du",
},
Type: corev1.ServiceType("LoadBalancer"),
Ports: []corev1.ServicePort{
corev1.ServicePort{
Port: 9090,
Protocol: corev1.Protocol("TCP"),
NodePort: 32500,
TargetPort: intstr.IntOrString{
IntVal: 9090,
},
},
},
},
}

return []*corev1.Service{service1, service2}
}
4 changes: 2 additions & 2 deletions internal/controller/resources_du_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ func TestGetConfigMapDu(t *testing.T) {
NSSAI_SD: *tc.paramsPlmn.Spec.PLMNInfo[0].NSSAI[0].SD,
})

if !reflect.DeepEqual(got[0].Data["mounted.conf"], defaultWantConfigurations) {
t.Errorf("GetConfigMap returned %s Wanted %s", got[0].Data["mounted.conf"], defaultWantConfigurations)
if !reflect.DeepEqual(got[0].Data["gnb.conf"], defaultWantConfigurations) {
t.Errorf("GetConfigMap returned %s Wanted %s", got[0].Data["gnb.conf"], defaultWantConfigurations)
}
} else {
if got != nil {
Expand Down
Loading

0 comments on commit 80fa770

Please sign in to comment.