From c2e00f6d96fdc51bd5d655ca0e5a12c4f6750d40 Mon Sep 17 00:00:00 2001 From: Jason Madigan Date: Mon, 25 Mar 2024 11:43:27 +0000 Subject: [PATCH] Podman fixes --- hack/.binEnv | 2 +- hack/.cleanupUtils | 2 +- hack/.kindUtils | 3 ++- hack/.quickstartEnv | 23 ++++++++++++++++++++--- hack/quickstart-metrics.sh | 2 +- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/hack/.binEnv b/hack/.binEnv index 6a49866d4..23faa9204 100644 --- a/hack/.binEnv +++ b/hack/.binEnv @@ -9,4 +9,4 @@ export HELM_BIN="${BIN_DIR}helm" export YQ_BIN="${BIN_DIR}yq" export OPERATOR_SDK_BIN="${BIN_DIR}operator-sdk" export CLUSTERADM_BIN="${BIN_DIR}clusteradm" -export KFILT="docker run --rm -i ryane/kfilt" \ No newline at end of file +export KFILT="$CONTAINER_RUNTIME_BIN run --rm -i ryane/kfilt" \ No newline at end of file diff --git a/hack/.cleanupUtils b/hack/.cleanupUtils index 26ad73e31..b6de4a7ed 100644 --- a/hack/.cleanupUtils +++ b/hack/.cleanupUtils @@ -12,7 +12,7 @@ cleanClusters() { cleanNetwork() { # Delete the network echo "Deleting mgc network" - docker network rm mgc || true + $CONTAINER_RUNTIME_BIN network rm mgc || true } cleanupKind() { diff --git a/hack/.kindUtils b/hack/.kindUtils index 65a1b10eb..23bc1fb90 100644 --- a/hack/.kindUtils +++ b/hack/.kindUtils @@ -58,7 +58,8 @@ kindSetupMGCClusters() { local dataPlaneClusterCount=$5 # Create network for the clusters - docker network create -d bridge --subnet 172.31.0.0/16 ${KIND_CLUSTER_DOCKER_NETWORK} --gateway 172.31.0.1 \ + # TODO: podman equivs of these options? + $CONTAINER_RUNTIME_BIN network create -d bridge --subnet 172.31.0.0/16 ${KIND_CLUSTER_DOCKER_NETWORK} --gateway 172.31.0.1 \ -o "com.docker.network.bridge.enable_ip_masquerade"="true" \ -o "com.docker.network.driver.mtu"="1500" diff --git a/hack/.quickstartEnv b/hack/.quickstartEnv index 3892c44c2..aea64831d 100644 --- a/hack/.quickstartEnv +++ b/hack/.quickstartEnv @@ -1,14 +1,31 @@ # shellcheck shell=bash export TOOLS_IMAGE=quay.io/kuadrant/mgc-tools:latest -export TMP_DIR=/tmp/mgc +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +export TMP_DIR=$SCRIPT_DIR/tmp/mgc + +containerRuntime() { + local container_runtime="" + if command -v podman &> /dev/null; then + container_runtime="podman" + elif command -v docker &> /dev/null; then + container_runtime="docker" + else + echo "Neither Docker nor Podman is installed. Exiting..." + exit 1 + fi + echo "$container_runtime" +} + +export CONTAINER_RUNTIME_BIN=$(containerRuntime) dockerBinCmd() { local network="" - if [ ! -z ${KIND_CLUSTER_DOCKER_NETWORK} ]; then + if [ ! -z "${KIND_CLUSTER_DOCKER_NETWORK}" ]; then network=" --network ${KIND_CLUSTER_DOCKER_NETWORK}" fi - echo "docker run --rm -u $UID -v ${TMP_DIR}:/tmp/mgc:z${network} -e KUBECONFIG=/tmp/mgc/kubeconfig --entrypoint=$1 $TOOLS_IMAGE" + + echo "$CONTAINER_RUNTIME_BIN run --rm -u $UID -v ${TMP_DIR}:${TMP_DIR}${network} -e KUBECONFIG=${TMP_DIR}/kubeconfig --entrypoint=$1 $TOOLS_IMAGE" } export KIND_BIN=kind diff --git a/hack/quickstart-metrics.sh b/hack/quickstart-metrics.sh index e8b6ea02f..4656d33f2 100755 --- a/hack/quickstart-metrics.sh +++ b/hack/quickstart-metrics.sh @@ -16,7 +16,7 @@ # limitations under the License. # -export KFILT="docker run --rm -i ryane/kfilt" +export KFILT="$CONTAINER_RUNTIME_BIN run --rm -i ryane/kfilt" METRICS_FEDERATION=true