Skip to content

Commit 1a894bd

Browse files
committed
recreate
1 parent 05dce51 commit 1a894bd

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

.github/workflows/infra-setup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Terraplan apply
3636
run: |
3737
cd terraform
38-
terraform destroy --auto-approve
38+
terraform apply tfplan
3939
4040
ansible:
4141
name: Deploy build

terraform/modules/k8s-cluster/setup/common.sh

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ else
3131
echo "Containerd already installed, skipping..."
3232
fi
3333

34-
# Install containerd service file from the correct version
35-
wget https://raw.githubusercontent.com/containerd/containerd/v${CONTAINERD_VERSION}/containerd.service
36-
mkdir -p /usr/local/lib/systemd/system
37-
mv containerd.service /usr/local/lib/systemd/system/containerd.service
38-
systemctl daemon-reload
34+
SERVICE_FILE="/usr/local/lib/systemd/system/containerd.service"
35+
if [ ! -f "$SERVICE_FILE" ]; then
36+
wget -q -O containerd.service "https://raw.githubusercontent.com/containerd/containerd/v${CONTAINERD_VERSION}/containerd.service"
37+
mkdir -p /usr/local/lib/systemd/system
38+
mv containerd.service "$SERVICE_FILE"
39+
40+
# Reload systemd only if a new file was added
41+
systemctl daemon-reload
42+
echo "Containerd service file updated and systemd reloaded."
43+
else
44+
echo "Containerd service file already exists. Skipping download."
45+
fi
3946

4047
mkdir -p /etc/containerd
4148
containerd config default | sudo tee /etc/containerd/config.toml > /dev/null
@@ -44,10 +51,17 @@ sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.to
4451
systemctl enable --now containerd
4552
systemctl restart containerd
4653

47-
# Install runc
48-
wget https://github.com/opencontainers/runc/releases/download/v1.2.3/runc.amd64
49-
install -m 755 runc.amd64 /usr/local/sbin/runc
50-
rm -f runc.amd64
54+
RUNC_VERSION="1.2.3" # Set desired runc version
55+
RUNC_BIN="/usr/local/sbin/runc"
56+
if [ -x "$RUNC_BIN" ] && [ "$($RUNC_BIN --version | awk 'NR==1 {print $3}')" = "$RUNC_VERSION" ]; then
57+
echo "runc v$RUNC_VERSION is already installed. Skipping."
58+
else
59+
echo "Installing runc v$RUNC_VERSION..."
60+
wget -q "https://github.com/opencontainers/runc/releases/download/v${RUNC_VERSION}/runc.amd64"
61+
install -m 755 runc.amd64 "$RUNC_BIN"
62+
rm -f runc.amd64
63+
echo "runc v$RUNC_VERSION installed successfully."
64+
fi
5165

5266
echo "-------------Installing CNI Plugins-------------"
5367

@@ -57,20 +71,22 @@ CNI_TARBALL="cni-plugins-linux-amd64-v${CNI_VERSION}.tgz"
5771
CNI_DIR="/opt/cni/bin"
5872

5973
mkdir -p ${CNI_DIR}
60-
echo "Downloading CNI plugins..."
61-
curl -O -L https://github.com/containernetworking/plugins/releases/download/v${CNI_VERSION}/${CNI_TARBALL}
62-
tar Cxzvf ${CNI_DIR} ${CNI_TARBALL}
63-
rm -f ${CNI_TARBALL}
64-
echo "CNI plugins installed successfully!"
74+
if [ ! -f "${CNI_DIR}/bridge" ]; then
75+
echo "Downloading CNI plugins..."
76+
curl -O -L https://github.com/containernetworking/plugins/releases/download/v${CNI_VERSION}/${CNI_TARBALL}
77+
tar Cxzvf ${CNI_DIR} ${CNI_TARBALL}
78+
rm -f ${CNI_TARBALL}
79+
echo "CNI plugins installed successfully!"
80+
else
81+
echo "CNI plugins already installed."
82+
fi
6583

6684
modprobe br_netfilter
6785
echo "br_netfilter" | sudo tee -a /etc/modules-load.d/modules.conf
6886
echo "net.bridge.bridge-nf-call-iptables = 1" | sudo tee -a /etc/sysctl.conf
6987
sudo sysctl -p
7088

71-
# Create the directory with proper permissions (if not already exists)
7289
sudo mkdir -p -m 755 /etc/apt/keyrings
73-
7490
# Check if the key file already exists
7591
if [ ! -f /etc/apt/keyrings/kubernetes-apt-keyring.gpg ]; then
7692
# Download the key if it doesn't exist

0 commit comments

Comments
 (0)