blob: a5f9d205aa285e7459a9e7a61e93bfad732240cd [file] [log] [blame]
Wei-Yu Chen450a98a2019-01-15 16:56:30 -08001---
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16---
17kind: ConfigMap
18apiVersion: v1
19metadata:
Wei-Yu Chenb92af452019-01-31 12:08:19 -080020 name: multus-scripts
Wei-Yu Chen450a98a2019-01-15 16:56:30 -080021 namespace: kube-system
22data:
23 install-certs.sh: |
24 # Copied from Calico
25 # https://github.com/projectcalico/cni-plugin/blob/master/k8s-install/scripts/install-cni.sh
26 touch /host/etc/cni/net.d/multus-kubeconfig
27 chmod 600 /host/etc/cni/net.d/multus-kubeconfig
28 SERVICE_ACCOUNT_PATH=/var/run/secrets/kubernetes.io/serviceaccount
29 KUBE_CA_FILE=$SERVICE_ACCOUNT_PATH/ca.crt
30 TLS_CFG="certificate-authority-data: $(cat $KUBE_CA_FILE | base64 | tr -d '\n')"
31 SERVICEACCOUNT_TOKEN=$(cat $SERVICE_ACCOUNT_PATH/token)
Wei-Yu Chenb92af452019-01-31 12:08:19 -080032 cat > /host/etc/cni/net.d/multus-kubeconfig <<EOF
Wei-Yu Chen450a98a2019-01-15 16:56:30 -080033 # Kubeconfig file for Multus CNI plugin.
34 apiVersion: v1
35 kind: Config
36 clusters:
37 - name: local
38 cluster:
39 server: https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}
40 $TLS_CFG
41 users:
42 - name: multus
43 user:
44 token: "${SERVICEACCOUNT_TOKEN}"
45 contexts:
46 - name: multus-context
47 context:
48 cluster: local
49 user: multus
50 current-context: multus-context
51 EOF
Wei-Yu Chenb92af452019-01-31 12:08:19 -080052 install-multus-conf.sh: |
Wei-Yu Chen4b811c82019-02-07 14:25:28 -080053 # If multus config is already exist on nodes (e.g. from kubespray installation)
54 # Then we don't need to create one by the script.
55 if [ -f /host/etc/cni/net.d/00-multus.conf ]; then
56 exit 0;
Wei-Yu Chenbc53a242019-02-05 14:05:34 -080057 fi
58
59 # Select the mainly CNI plugin's configuration and insert into multus's config
60 MASTER_PLUGIN="$(ls /host/etc/cni/net.d | grep -E '\.conf(list)?$' | grep -v 'multus' | head -1)"
Wei-Yu Chenb92af452019-01-31 12:08:19 -080061 MASTER_PLUGIN_JSON="$(cat /host/etc/cni/net.d/$MASTER_PLUGIN)"
62 cat > /host/etc/cni/net.d/00-multus.conf <<EOF
63 {
64 "name": "multus-cni-network",
65 "type": "multus",
66 "logFile": "/var/log/multus.log",
67 "logLevel": "debug",
68 "kubeconfig": "/etc/cni/net.d/multus-kubeconfig",
69 "delegates": [
70 $MASTER_PLUGIN_JSON
71 ]
72 }
73 EOF
Wei-Yu Chen450a98a2019-01-15 16:56:30 -080074---
75kind: ConfigMap
76apiVersion: v1
77metadata:
78 name: sriov-config
79 namespace: kube-system
80data:
81 config.json: |
82 {
83 "resourceList":
84 [
85 {
86 "resourceName": "sriov",
87 "rootDevices": ["04:00.0"],
88 "sriovMode": true,
89 "deviceType": "netdevice"
90 }
91 ]
92 }