github.com/demonoid81/containerd@v1.3.4/script/setup/install-cni (about)

     1  #!/usr/bin/env bash
     2  
     3  #   Copyright The containerd Authors.
     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  
    17  #
    18  # Builds and installs cni plugins to /opt/cni/bin,
    19  # and create basic cni config in /etc/cni/net.d.
    20  # The commit defined in vendor.conf
    21  #
    22  set -eu -o pipefail
    23  
    24  CNI_COMMIT=$(grep containernetworking/plugins ${GOPATH}/src/github.com/containerd/containerd/vendor.conf | awk '{print $2}')
    25  CNI_DIR=/opt/cni
    26  CNI_CONFIG_DIR=/etc/cni/net.d
    27  
    28  go get -d github.com/containernetworking/plugins/...
    29  cd $GOPATH/src/github.com/containernetworking/plugins
    30  git checkout $CNI_COMMIT
    31  FASTBUILD=true ./build.sh
    32  mkdir -p $CNI_DIR
    33  cp -r ./bin $CNI_DIR
    34  mkdir -p $CNI_CONFIG_DIR
    35  bash -c 'cat >'$CNI_CONFIG_DIR'/10-containerd-net.conflist <<EOF
    36  {
    37    "cniVersion": "0.3.1",
    38    "name": "containerd-net",
    39    "plugins": [
    40      {
    41        "type": "bridge",
    42        "bridge": "cni0",
    43        "isGateway": true,
    44        "ipMasq": true,
    45        "promiscMode": true,
    46        "ipam": {
    47          "type": "host-local",
    48          "subnet": "10.88.0.0/16",
    49          "routes": [
    50            { "dst": "0.0.0.0/0" }
    51          ]
    52        }
    53      },
    54      {
    55        "type": "portmap",
    56        "capabilities": {"portMappings": true}
    57      }
    58    ]
    59  }
    60  EOF'