Skip to content

Commit 98d4312

Browse files
mbaldessaridarkdoc
andcommitted
Fix pki bind mount when using podman machine
Currently we test for the existance of local TLS folder and bind mount them in containers. This does not work correctly when using podman machine, because a the test is running on the host and so we might bind mount the wrong folder. For example: On Mac OSX /etc/pki does not exist on the folder and so we bind mount /etc/ssl even though /etc/pki does exist in the podman machine VM Co-Authored-By: Ákos Erős <aeros@redhat.com>
1 parent 1f08dfe commit 98d4312

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

scripts/pattern-util.sh

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,20 @@ if [ -n "$KUBECONFIG" ]; then
4949
fi
5050
fi
5151

52-
# Use /etc/pki by default and try a couple of fallbacks if it does not exist
53-
if [ -d /etc/pki ]; then
54-
PKI_HOST_MOUNT="/etc/pki"
55-
elif [ -d /etc/ssl ]; then
56-
PKI_HOST_MOUNT="/etc/ssl"
52+
# Detect if we use podman machine. If we do not then we bind mount local host ssl folders
53+
# if we are using podman machine then we do not bind mount anything (for now!)
54+
REMOTE_PODMAN=$(podman system connection list -q | wc -l)
55+
if [ $REMOTE_PODMAN -eq 0 ]; then # If we are not using podman machine we check the hosts folders
56+
# Use /etc/pki by default and try a couple of fallbacks if it does not exist
57+
if [ -d /etc/pki ]; then
58+
PKI_HOST_MOUNT_ARGS="-v /etc/pki:/etc/pki:ro"
59+
elif [ -d /etc/ssl ]; then
60+
PKI_HOST_MOUNT_ARGS="-v /etc/ssl:/etc/ssl:ro"
61+
else
62+
PKI_HOST_MOUNT_ARGS="-v /usr/share/ca-certificates:/usr/share/ca-certificates:ro"
63+
fi
5764
else
58-
PKI_HOST_MOUNT="/usr/share/ca-certificates"
65+
PKI_HOST_MOUNT_ARGS=""
5966
fi
6067

6168
# Copy Kubeconfig from current environment. The utilities will pick up ~/.kube/config if set so it's not mandatory
@@ -67,13 +74,7 @@ podman run -it --rm --pull=newer \
6774
-e EXTRA_HELM_OPTS \
6875
-e EXTRA_PLAYBOOK_OPTS \
6976
-e KUBECONFIG \
70-
-e K8S_AUTH_HOST \
71-
-e K8S_AUTH_VERIFY_SSL \
72-
-e K8S_AUTH_SSL_CA_CERT \
73-
-e K8S_AUTH_USERNAME \
74-
-e K8S_AUTH_PASSWORD \
75-
-e K8S_AUTH_TOKEN \
76-
-v "${PKI_HOST_MOUNT}":/etc/pki:ro \
77+
${PKI_HOST_MOUNT_ARGS} \
7778
-v "${HOME}":"${HOME}" \
7879
-v "${HOME}":/pattern-home \
7980
${PODMAN_ARGS} \

0 commit comments

Comments
 (0)