Skip to content

Instantly share code, notes, and snippets.

@varesa
Created January 31, 2023 17:45
Show Gist options
  • Save varesa/402a9930fdbac902fc3b7e702b6aaa1e to your computer and use it in GitHub Desktop.
Save varesa/402a9930fdbac902fc3b7e702b6aaa1e to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
if podman pod inspect gitlab 1>/dev/null 2>&1; then
echo "Deleting old pod"
podman pod rm --force gitlab
fi
echo "Creating new pod"
podman pod create --name gitlab
podman pod start gitlab
echo "Getting container ID"
infra_cid="$(sudo podman pod inspect gitlab | jq -r '.State.infraContainerID')"
echo "CID: $infra_cid"
echo "Getting container PID"
infra_pid="$(sudo podman container top "$infra_cid" hpid | tail -n 1)"
echo "PID: $infra_pid"
echo "Deleting pre-existing eth0"
nsenter -t "$infra_pid" -n ip link delete eth0
echo "Move a new interface into namespace"
ip link set eth1 netns "$infra_pid" state up
echo "Add an address"
nsenter -t "$infra_pid" -n ip link set dev eth1 up
nsenter -t "$infra_pid" -n ip addr add 95.216.xx.yy/28 dev eth1
nsenter -t "$infra_pid" -n ip route add default via 95.216.xx.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment