Skip to content

Commit

Permalink
Run sriov-cni containers in config daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
zshi-redhat committed Jun 30, 2021
1 parent 271d952 commit 2023207
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 90 deletions.
25 changes: 25 additions & 0 deletions bindata/manifests/daemon/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ spec:
serviceAccountName: sriov-network-config-daemon
priorityClassName: "system-node-critical"
containers:
- name: sriov-cni
image: {{.SRIOVCNIImage}}
securityContext:
privileged: true
resources:
requests:
cpu: 10m
memory: 10Mi
volumeMounts:
- name: cnibin
mountPath: /host/opt/cni/bin
- name: sriov-infiniband-cni
image: {{.SRIOVInfiniBandCNIImage}}
securityContext:
privileged: true
resources:
requests:
cpu: 10m
memory: 10Mi
volumeMounts:
- name: cnibin
mountPath: /host/opt/cni/bin
- name: sriov-network-config-daemon
image: {{.Image}}
command:
Expand Down Expand Up @@ -67,3 +89,6 @@ spec:
- name: host
hostPath:
path: /
- name: cnibin
hostPath:
path: {{.CNIBinPath}}
20 changes: 0 additions & 20 deletions bindata/manifests/plugins/002-rbac.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: sriov-cni
namespace: {{.Namespace}}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: sriov-device-plugin
namespace: {{.Namespace}}
Expand All @@ -28,20 +22,6 @@ rules:
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: sriov-cni
namespace: {{.Namespace}}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: sriov-plugin
subjects:
- kind: ServiceAccount
name: sriov-cni
namespace: {{.Namespace}}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: sriov-device-plugin
namespace: {{.Namespace}}
Expand Down
60 changes: 0 additions & 60 deletions bindata/manifests/plugins/sriov-cni.yaml

This file was deleted.

11 changes: 1 addition & 10 deletions controllers/sriovnetworknodepolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,21 +315,12 @@ func (r *SriovNetworkNodePolicyReconciler) syncPluginDaemonObjs(dp *sriovnetwork
logger := r.Log.WithName("syncPluginDaemonObjs")
logger.Info("Start to sync sriov daemons objects")

// render RawCNIConfig manifests
// render plugin manifests
data := render.MakeRenderData()
data.Data["Namespace"] = namespace
data.Data["SRIOVCNIImage"] = os.Getenv("SRIOV_CNI_IMAGE")
data.Data["SRIOVInfiniBandCNIImage"] = os.Getenv("SRIOV_INFINIBAND_CNI_IMAGE")
data.Data["SRIOVDevicePluginImage"] = os.Getenv("SRIOV_DEVICE_PLUGIN_IMAGE")
data.Data["ReleaseVersion"] = os.Getenv("RELEASEVERSION")
data.Data["ResourcePrefix"] = os.Getenv("RESOURCE_PREFIX")
envCniBinPath := os.Getenv("SRIOV_CNI_BIN_PATH")
if envCniBinPath == "" {
data.Data["CNIBinPath"] = "/var/lib/cni/bin"
} else {
logger.Info("New cni bin found", "CNIBinPath", envCniBinPath)
data.Data["CNIBinPath"] = envCniBinPath
}

objs, err := renderDsForCR(PLUGIN_PATH, &data)
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions controllers/sriovoperatorconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,17 @@ func (r *SriovOperatorConfigReconciler) syncConfigDaemonSet(dc *sriovnetworkv1.S
data := render.MakeRenderData()
data.Data["Image"] = os.Getenv("SRIOV_NETWORK_CONFIG_DAEMON_IMAGE")
data.Data["Namespace"] = namespace
data.Data["SRIOVCNIImage"] = os.Getenv("SRIOV_CNI_IMAGE")
data.Data["SRIOVInfiniBandCNIImage"] = os.Getenv("SRIOV_INFINIBAND_CNI_IMAGE")
data.Data["ReleaseVersion"] = os.Getenv("RELEASEVERSION")
data.Data["ClusterType"] = utils.ClusterType
envCniBinPath := os.Getenv("SRIOV_CNI_BIN_PATH")
if envCniBinPath == "" {
data.Data["CNIBinPath"] = "/var/lib/cni/bin"
} else {
logger.Info("New cni bin found", "CNIBinPath", envCniBinPath)
data.Data["CNIBinPath"] = envCniBinPath
}
objs, err := render.RenderDir(CONFIG_DAEMON_PATH, &data)
if err != nil {
logger.Error(err, "Fail to render config daemon manifests")
Expand Down

0 comments on commit 2023207

Please sign in to comment.