Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial packages for OAI #3

Merged
merged 10 commits into from
Dec 1, 2023
10 changes: 9 additions & 1 deletion workloads/oai/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# workloads/oai
# OAI Packages

Packages for deploying the following are stored here

- OAI RAN custom controller
- OAI CU-CP
- OAI CU-UP
- OAI DU
- OAI UE SIM
10 changes: 10 additions & 0 deletions workloads/oai/oai-ran-operator/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kpt.dev/v1
kind: Kptfile

metadata:
name: oai-ran-operator
annotations:
config.kubernetes.io/local-config: "true"

info:
description: oai ran operator package

Large diffs are not rendered by default.

102 changes: 102 additions & 0 deletions workloads/oai/oai-ran-operator/operator/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole

metadata:
name: oai-ran-operator-cluster-role
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- configmaps
- services
- serviceaccounts
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- list
- watch
- apiGroups:
- apps
resources:
- deployments
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- deployments/status
verbs:
- get
- apiGroups:
- k8s.cni.cncf.io
resources:
- network-attachment-definitions
verbs:
- get
- list
- watch
- create
- apiGroups:
- workload.nephio.org
resources:
- nfdeployments
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- workload.nephio.org
resources:
- nfdeployments/status
verbs:
- get
- patch
- update
- apiGroups:
- ref.nephio.org
resources:
- configs
verbs:
- get
- list
- watch
13 changes: 13 additions & 0 deletions workloads/oai/oai-ran-operator/operator/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: oai-ran-operator-rolebinding-cluster
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: oai-ran-operator-cluster-role
subjects:
- kind: ServiceAccount
name: oai-ran-operator
namespace: oai-ran-operators

34 changes: 34 additions & 0 deletions workloads/oai/oai-ran-operator/operator/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: oai-ran-operators
name: oai-ran-operator
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: oai-ran-operator
app.kubernetes.io/component: controller
template:
metadata:
name: oai-ran-operator
labels:
app.kubernetes.io/name: oai-ran-operator
app.kubernetes.io/component: controller
spec:
serviceAccountName: oai-ran-operator
containers:
- name: operator
image: 10.0.0.12:5001/oai-ran-operator:latest
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 10m
memory: 64Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
4 changes: 4 additions & 0 deletions workloads/oai/oai-ran-operator/operator/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: oai-ran-operators
5 changes: 5 additions & 0 deletions workloads/oai/oai-ran-operator/operator/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
namespace: oai-ran-operators
name: oai-ran-operator
10 changes: 10 additions & 0 deletions workloads/oai/oai-ran-operator/package-context.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap

metadata:
name: kptfile.kpt.dev
annotations:
config.kubernetes.io/local-config: "true"

data:
name: example
24 changes: 24 additions & 0 deletions workloads/oai/pkg-example-cucp-bp/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
name: pkg-cucp
annotations:
config.kubernetes.io/local-config: "true"
info:
description: example cucp blueprint package

pipeline:
mutators:
- image: gcr.io/kpt-fn/apply-replacements:v0.1.1
configPath: apply-replacements-owner.yaml
- image: gcr.io/kpt-fn/apply-replacements:v0.1.1
configPath: apply-replacements-namespace.yaml
- image: gcr.io/kpt-fn/set-namespace:v0.4.1
configPath: package-context.yaml
- image: nephio/nfdeploy-fn:1729579664202010624
- image: docker.io/nephio/interface-fn:v1.0.1
- image: docker.io/nephio/nad-fn:v1.0.1
- image: docker.io/nephio/interface-fn:v1.0.1
- image: nephio/nfdeploy-fn:1729579664202010624
- image: gcr.io/kpt-fn/starlark:v0.4
configPath: append-fn.yaml
72 changes: 72 additions & 0 deletions workloads/oai/pkg-example-cucp-bp/append-fn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
apiVersion: fn.kpt.dev/v1alpha1
kind: StarlarkRun
metadata: # kpt-merge: /set-annotation
name: set-configuration
annotations:
config.kubernetes.io/local-config: "true"
internal.kpt.dev/upstream-identifier: fn.kpt.dev|StarlarkRun|default|set-configuration
source: |-
nad_flag = False
append_flag = False
for resource in ctx.resource_list["items"]:
if resource.get("kind") == "Kptfile" and resource.get("status") != None:
for status in resource["status"]["conditions"]:
if "NFDeployment" in status["type"] and status["status"] == "True":
append_flag = True
if resource["metadata"]["name"] == "cucp-edge01-n2":
nad_flag = True

if append_flag == True:
for resource in ctx.resource_list["items"]:
if resource.get("kind") == "NFDeployment" and resource.get("spec") != None:
if resource["spec"].get("parametersRefs") != None:

resource["spec"]["parametersRefs"].append({"name": "amf-regional-gnb-edge01",
"apiVersion": "ref.nephio.org/v1alpha1",
"kind": "Config"
})

else:
resource["spec"]["parametersRefs"] = [{"name": "amf-regional-gnb-edge01",
"apiVersion": "ref.nephio.org/v1alpha1",
"kind": "Config"
}]



if resource["spec"].get("interfaces") != None:
resource["spec"]["interfaces"].append(
{
"name": "n2",
"ipv4": {
"address": "172.21.6.98/22",
"gateway": "172.21.6.98"
},
"vlanID": 4
}
)
else:
resource["spec"]["interfaces"] = [{
"name": "n2",
"ipv4": {
"address": "172.21.6.98/22",
"gateway": "172.21.6.98"
},
"vlanID": 4
}]


if not nad_flag:
networkdefinitions_json = {
"apiVersion": "k8s.cni.cncf.io/v1",
"kind": "NetworkAttachmentDefinition",
"metadata": {
"name": "cucp-edge01-n2",
"namespace": "oai-cucp"
},
"spec": {
"config": "{ \"cniVersion\": \"0.3.1\", \"plugins\":[{\"capabilities\":{\"ips\":true},\"type\": \"macvlan\", \"master\":\"eth0\", \"mode\": \"bridge\", \"ipam\": { \"type\": \"static\", \"addresses\": [ { \"address\":\"172.21.6.98/22\" } ] } }]}"
}
}

ctx.resource_list["items"].append(networkdefinitions_json)
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: fn.kpt.dev/v1alpha1
kind: ApplyReplacements
metadata:
name: replace-namespace
annotations:
config.kubernetes.io/local-config: "true"
replacements:
- source:
kind: ConfigMap
name: kptfile.kpt.dev
fieldPath: data.name
targets:
- select:
kind: Config
fieldPaths:
- metadata.namespace
- select:
kind: NFConfig
fieldPaths:
- metadata.namespace
- spec.configRefs.0.metadata.namespace
- spec.configRefs.1.metadata.namespace
- select:
kind: NFDeployment
fieldPaths:
- spec.configRefs.[kind=Config].namespace
- select:
kind: Interface
fieldPaths:
- metadata.annotations.[specializer.nephio.org/namespace]
- select:
kind: Capacity
fieldPaths:
- metadata.annotations.[specializer.nephio.org/namespace]
- select:
kind: DataNetwork
fieldPaths:
- metadata.annotations.[specializer.nephio.org/namespace]
- select:
kind: Dependency
fieldPaths:
- metadata.annotations.[specializer.nephio.org/namespace]
47 changes: 47 additions & 0 deletions workloads/oai/pkg-example-cucp-bp/apply-replacements-owner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: fn.kpt.dev/v1alpha1
kind: ApplyReplacements
metadata:
name: propagate-name
annotations:
config.kubernetes.io/local-config: "true"
replacements:
- source:
kind: WorkloadCluster
name: workload-cluster
fieldPath: spec.clusterName
targets:
- select:
kind: NFDeployment
fieldPaths:
- metadata.name
options:
delimiter: '-'
index: 1
- select:
kind: Interface
fieldPaths:
- metadata.annotations.[specializer.nephio.org/owner]
options:
delimiter: '-'
index: 1
- select:
kind: Capacity
fieldPaths:
- metadata.annotations.[specializer.nephio.org/owner]
options:
delimiter: '-'
index: 1
- select:
kind: DataNetwork
fieldPaths:
- metadata.annotations.[specializer.nephio.org/owner]
options:
delimiter: '-'
index: 1
- select:
kind: Dependency
fieldPaths:
- metadata.annotations.[specializer.nephio.org/owner]
options:
delimiter: '-'
index: 1
Loading