Skip to content

Commit 9d15c57

Browse files
authored
Merge pull request #609 from gefyrahq/probe-command-missing
Probe command missing
2 parents 063e51c + 79e3919 commit 9d15c57

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

README.md

-3
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@ are actually able to reach cluster-based resources, such as databases, other (mi
158158
[*Nginx*](https://www.nginx.com/) is used for all kinds of proxying and reverse-proxying traffic, including the interceptions of already running containers
159159
in the cluster.
160160

161-
### Rsync
162-
[*Rsync*](https://rsync.samba.org/) is used to synchronize directories from containers running in the cluster to local
163-
instances. This is particularly important for Kubernetes service account tokens during a bridge operation.
164161

165162
<p align="right">(<a href="#top">back to top</a>)</p>
166163

carrier/setprobe.sh

+7
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ set -e
66
DEFAULT_CONF_FILE="/tmp/nginx.conf"
77

88

9+
if [ -f /tmp/probesset_$1 ]; then
10+
echo "Probe already set to $1"
11+
exit 0
12+
fi
13+
914
echo "Setting listening port to $1 for probe"
1015
block="server {listen $1 default; location / {return 200;}}\n#HTTPMARKER"
1116
sed -i "s~#HTTPMARKER~$block~g" $DEFAULT_CONF_FILE
1217

18+
touch /tmp/probesset_$1
19+
1320
nginx -s reload -c $DEFAULT_CONF_FILE

operator/gefyra/bridge/carrier/__init__.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
BUSYBOX_COMMAND = "/bin/busybox"
1414
CARRIER_CONFIGURE_COMMAND_BASE = [BUSYBOX_COMMAND, "sh", "setroute.sh"]
1515
CARRIER_CONFIGURE_PROBE_COMMAND_BASE = [BUSYBOX_COMMAND, "sh", "setprobe.sh"]
16-
CARRIER_RSYNC_COMMAND_BASE = [BUSYBOX_COMMAND, "sh", "syncdirs.sh"]
1716
CARRIER_ORIGINAL_CONFIGMAP = "gefyra-carrier-restore-configmap"
1817

1918

@@ -36,6 +35,21 @@ def install(self, parameters: Optional[Dict[Any, Any]] = None):
3635
parameters = parameters or {}
3736
self._patch_pod_with_carrier(handle_probes=parameters.get("handleProbes", True))
3837

38+
def _ensure_probes(self, container: k8s.client.V1Container) -> bool:
39+
probes = self._get_all_probes(container)
40+
for probe in probes:
41+
try:
42+
command = CARRIER_CONFIGURE_PROBE_COMMAND_BASE + [
43+
probe.http_get.port,
44+
]
45+
exec_command_pod(
46+
core_v1_api, self.pod, self.namespace, self.container, command
47+
)
48+
except Exception as e:
49+
self.logger.error(e)
50+
return False
51+
return True
52+
3953
def installed(self) -> bool:
4054
pod = core_v1_api.read_namespaced_pod(name=self.pod, namespace=self.namespace)
4155
for container in pod.spec.containers:
@@ -44,7 +58,8 @@ def installed(self) -> bool:
4458
and container.image
4559
== f"{self.configuration.CARRIER_IMAGE}:{self.configuration.CARRIER_IMAGE_TAG}"
4660
):
47-
return True
61+
# we always handle probes, flag is currently ignored
62+
return self._ensure_probes(container=container)
4863
return False
4964

5065
def ready(self) -> bool:

0 commit comments

Comments
 (0)