Last active
November 11, 2023 09:07
-
-
Save KunalSin9h/1c707d9b4bc6dc7cb61478394d599124 to your computer and use it in GitHub Desktop.
Install and setup containerd on Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
TMPROOT=$(mktemp -d) | |
cd /$TMPROOT | |
SUDO='' | |
if (( $EUID != 0 )); then | |
SUDO='sudo' | |
fi | |
echo "INSTALLING CONTAINERD" | |
echo "" | |
CONTAINERD_VERSION="1.7.7" | |
wget https://github.com/containerd/containerd/releases/download/v$CONTAINERD_VERSION/containerd-$CONTAINERD_VERSION-linux-amd64.tar.gz | |
wget https://github.com/containerd/containerd/releases/download/v$CONTAINERD_VERSION/containerd-$CONTAINERD_VERSION-linux-amd64.tar.gz.sha256sum | |
CONTAINERD_CHECKSUM=$(containerd-$CONTAINERD_VERSION-linux-amd64.tar.gz) | |
GIVEN_SHA256=$(cat containerd-$CONTAINERD_VERSION-linux-amd64.tar.gz.sha256sum) | |
if [[ $CONTAINERD_CHECKSUM -ne $GIVEN_SHA256 ]]; then | |
echo "Failed: Verify containerd checksum" | |
exit 1 | |
fi | |
sudo tar Cxzvf /usr/local containerd-$CONTAINERD_VERSION-linux-amd64.tar.gz | |
echo "" | |
echo "DONE" | |
echo "" | |
echo "SETTING UP CONTAINERD SERVICE" | |
echo "" | |
sudo mkdir -p /usr/local/lib/systemd/system/ | |
sudo curl -o /usr/local/lib/systemd/system/containerd.service https://raw.githubusercontent.com/containerd/containerd/main/containerd.service | |
sudo systemctl daemon-reload | |
sudo systemctl enable --now containerd | |
echo "" | |
echo "INSTALLING RUNC" | |
echo "" | |
RUNC_VERSION="1.1.9" | |
wget https://github.com/opencontainers/runc/releases/download/v$RUNC_VERSION/runc.amd64 | |
sudo install -m 755 runc.amd64 /usr/local/sbin/runc | |
echo "" | |
echo "DONE" | |
echo "" | |
echo "INSTALLING CNI Plugins" | |
echo "" | |
CRI_VERSION="1.3.0" | |
wget https://github.com/containernetworking/plugins/releases/download/v$CRI_VERSION/cni-plugins-linux-amd64-v$CRI_VERSION.tgz | |
wget https://github.com/containernetworking/plugins/releases/download/v$CRI_VERSION/cni-plugins-linux-amd64-v$CRI_VERSION.tgz.sha256 | |
CNI_CHECKSUM=$(cni-plugins-linux-amd64-v$CRI_VERSION.tgz) | |
GIVEN_CNI_SHA256=$(cat cni-plugins-linux-amd64-v$CRI_VERSION.tgz.sha256) | |
if [[ $CNI_CHECKSUM -ne $GIVEN_CNI_SHA256 ]]; then | |
echo "Failed: Verify CNI Plugins checksum" | |
exit 1 | |
fi | |
sudo mkdir -p /opt/cni/bin | |
sudo tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v$CRI_VERSION.tgz | |
echo "" | |
echo "DONE" | |
echo "" | |
echo "Confering CONTAINERD" | |
echo "" | |
sudo mkdir -p /etc/containerd | |
sudo containerd config default | sudo tee /etc/containerd/config.toml | |
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml | |
echo "" | |
echo "DONE" | |
CNI_CONFIG_DIR=${DESTDIR}/etc/cni/net.d | |
$SUDO mkdir -p $CNI_CONFIG_DIR | |
$SUDO cat << EOF | $SUDO tee $CNI_CONFIG_DIR/10-containerd-net.conflist | |
{ | |
"cniVersion": "1.0.0", | |
"name": "containerd-net", | |
"plugins": [ | |
{ | |
"type": "bridge", | |
"bridge": "cni0", | |
"isGateway": true, | |
"ipMasq": true, | |
"promiscMode": true, | |
"ipam": { | |
"type": "host-local", | |
"ranges": [ | |
[{ | |
"subnet": "10.88.0.0/16" | |
}], | |
[{ | |
"subnet": "2001:4860:4860::/64" | |
}] | |
], | |
"routes": [ | |
{ "dst": "0.0.0.0/0" }, | |
{ "dst": "::/0" } | |
] | |
} | |
}, | |
{ | |
"type": "portmap", | |
"capabilities": {"portMappings": true} | |
} | |
] | |
} | |
EOF | |
sudo systemctl restart containerd | |
cd | |
rm -rf $TMPROOT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if still con't able to read
/etc/cni/net.d
then just give read permission to this dirlike