blob: 135e7694a1add586e8cb24fbb5da41a6f7796e8d [file] [log] [blame]
Wei-Yu Chen0f12b9c2019-04-18 11:12:59 -07001---
2# Copyright 2018-present Open Networking Foundation
3# Copyright 2018 Intel Corporation
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16---
17apiVersion: apiextensions.k8s.io/v1beta1
18kind: CustomResourceDefinition
19metadata:
20 # name must match the spec fields below, and be in the form: <plural>.<group>
21 name: network-attachment-definitions.k8s.cni.cncf.io
22 annotations:
23 "helm.sh/hook": "crd-install"
24 "helm.sh/hook-delete-policy": "before-hook-creation"
25spec:
26 # group name to use for REST API: /apis/<group>/<version>
27 group: k8s.cni.cncf.io
28 # version name to use for REST API: /apis/<group>/<version>
29 version: v1
30 # either Namespaced or Cluster
31 scope: Namespaced
32 names:
33 # plural name to be used in the URL: /apis/<group>/<version>/<plural>
34 plural: network-attachment-definitions
35 # singular name to be used as an alias on the CLI and for display
36 singular: network-attachment-definition
37 # kind is normally the CamelCased singular type. Your resource manifests use this.
38 kind: NetworkAttachmentDefinition
39 # shortNames allow shorter string to match your resource on the CLI
40 shortNames:
41 - net-attach-def
42---
43apiVersion: v1
44kind: ServiceAccount
45metadata:
46 name: multus-sa
47 namespace: kube-system
48 annotations:
49 "helm.sh/hook": "pre-install"
50 "helm.sh/hook-delete-policy": "before-hook-creation"
51---
52apiVersion: v1
53kind: Secret
54metadata:
55 name: multus-sa-secret
56 namespace: kube-system
57 annotations:
58 kubernetes.io/service-account.name: multus-sa
59type: kubernetes.io/service-account-token
60---
61kind: ClusterRole
62apiVersion: rbac.authorization.k8s.io/v1
63metadata:
64 name: multus-pod-networks-lister
65rules:
66- apiGroups: [""]
67 resources: ["pods"]
68 verbs: ["get"]
69- apiGroups: [""]
70 resources: ["pods/status"]
71 verbs: ["update"]
72- apiGroups: ["k8s.cni.cncf.io"]
73 resources: ["*"]
74 verbs: ["get"]
75---
76kind: ConfigMap
77apiVersion: v1
78metadata:
79 name: multus-scripts
80 namespace: kube-system
81data:
82 install-certs.sh: |
83 # Copied from Calico
84 # https://github.com/projectcalico/cni-plugin/blob/master/k8s-install/scripts/install-cni.sh
85 touch /host/etc/cni/net.d/multus-kubeconfig
86 chmod 600 /host/etc/cni/net.d/multus-kubeconfig
87 SERVICE_ACCOUNT_PATH=/var/run/secrets/multus/serviceaccount
88 KUBE_CA_FILE=$SERVICE_ACCOUNT_PATH/ca.crt
89 TLS_CFG="certificate-authority-data: $(cat $KUBE_CA_FILE | base64 | tr -d '\n')"
90 SERVICEACCOUNT_TOKEN=$(cat $SERVICE_ACCOUNT_PATH/token)
91 cat > /host/etc/cni/net.d/multus-kubeconfig <<EOF
92 # Kubeconfig file for Multus CNI plugin.
93 apiVersion: v1
94 kind: Config
95 clusters:
96 - name: local
97 cluster:
98 server: https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}
99 $TLS_CFG
100 users:
101 - name: multus
102 user:
103 token: "${SERVICEACCOUNT_TOKEN}"
104 contexts:
105 - name: multus-context
106 context:
107 cluster: local
108 user: multus
109 current-context: multus-context
110 EOF
111 install-multus-conf.sh: |
112 # copied from https://github.com/intel/multus-cni/blob/master/images/entrypoint.sh
113 rm -f /host/etc/cni/net.d/00-multus.conf
114 MASTER_PLUGIN="$(ls /host/etc/cni/net.d | grep -E '\.conf(list)?$' | head -1)"
115 MASTER_PLUGIN_JSON="$(cat /host/etc/cni/net.d/$MASTER_PLUGIN)"
116 cat > /host/etc/cni/net.d/00-multus.conf <<EOF
117 {
118 "name": "multus-cni-network",
119 "type": "multus",
120 "logFile": "/var/log/multus.log",
121 "logLevel": "debug",
122 "kubeconfig": "/etc/cni/net.d/multus-kubeconfig",
123 "delegates": [
124 $MASTER_PLUGIN_JSON
125 ]
126 }
127 EOF
128---
129kind: ClusterRoleBinding
130apiVersion: rbac.authorization.k8s.io/v1
131metadata:
132 name: multus-rb
133roleRef:
134 apiGroup: rbac.authorization.k8s.io
135 kind: ClusterRole
136 name: multus-pod-networks-lister
137subjects:
138- kind: ServiceAccount
139 name: multus-sa
140 namespace: kube-system
141---
142apiVersion: apps/v1
143kind: DaemonSet
144metadata:
145 name: sriov-device-plugin
146 namespace: kube-system
147spec:
148 selector:
149 matchLabels:
150 name: sriov-device-plugin
151 template:
152 metadata:
153 labels:
154 name: sriov-device-plugin
155 spec:
156 initContainers:
157 - name: init-sriovds
158 image: {{ .Values.sriovds.initimage }}
159 command: [ "bash", "-c" ]
160 args:
161 - cp /tmp/cni/bin/{multus,sriov,vfioveth,centralip,jq} /host/opt/cni/bin/;
162 /tmp/multus/install-multus-conf.sh;
163 /tmp/multus/install-certs.sh;
164 systemctl stop kubelet;
165 echo "Restarting crio/containerd, kubelet";
166 systemctl restart containerd;
167 systemctl restart crio;
168 systemctl restart kubelet;
169 volumeMounts:
170 - name: usr-bin
171 mountPath: /host/usr/bin
172 - name: cni-bin
173 mountPath: /host/opt/cni/bin
174 - name: multus-sa
175 mountPath: /var/run/secrets/multus/serviceaccount
176 - name: multus-scripts
177 mountPath: /tmp/multus
178 - name: cni-conf
179 mountPath: /host/etc/cni/net.d
180 - name: dbus
181 mountPath: /var/run/dbus
182 - name: systemd
183 mountPath: /run/systemd
184 containers:
185 - name: sriovds
186 image: {{ .Values.sriovds.image }}
187 command: [ "sh", "-c" ]
188 args:
189 - /usr/bin/sriovdp --logtostderr -v 10;
190 sleep infinity;
191 volumeMounts:
192 - name: net
193 mountPath: /sys/class/net
194 readOnly: true
195 - name: dp-sock
196 mountPath: /var/lib/kubelet/device-plugins/
197 readOnly: false
198 - mountPath: /etc/pcidp
199 name: sriov-config
200 readOnly: false
201 volumes:
202 - name: sriov-config
203 configMap:
204 name: sriov-config
205 - name: usr-bin
206 hostPath:
207 path: /usr/bin
208 - name: cni-bin
209 hostPath:
210 path: /opt/cni/bin
211 - name: multus-sa
212 secret:
213 secretName: multus-sa-secret
214 - name: multus-scripts
215 configMap:
216 defaultMode: 511
217 name: multus-scripts
218 - name: cni-conf
219 hostPath:
220 path: /etc/cni/net.d
221 - name: dbus
222 hostPath:
223 path: /var/run/dbus
224 - name: systemd
225 hostPath:
226 path: /run/systemd
227 - name: net
228 hostPath:
229 path: /sys/class/net
230 - name: dp-sock
231 hostPath:
232 path: /var/lib/kubelet/device-plugins/
233 hostNetwork: true
234 hostPID: true