Skip to content

Commit

Permalink
service-mesh: test readiness with exec probe
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerdev committed Jan 13, 2025
1 parent 662af0c commit 705e957
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions internal/kuberesource/parts.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ func ServiceMeshProxy() *applycorev1.ContainerApplyConfiguration {
WithInitialDelaySeconds(1).
WithPeriodSeconds(5).
WithFailureThreshold(5).
WithTCPSocket(TCPSocketAction().
WithPort(intstr.FromInt(15006))),
WithExec(ExecAction().
WithCommand("test", "-f", "/ready")),
).
WithArgs(
"-l", "debug",
Expand Down
5 changes: 5 additions & 0 deletions internal/kuberesource/wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ func TCPSocketAction() *applycorev1.TCPSocketActionApplyConfiguration {
return applycorev1.TCPSocketAction()
}

// ExecAction creates a new ExecActionApplyConfiguration.
func ExecAction() *applycorev1.ExecActionApplyConfiguration {
return applycorev1.ExecAction()
}

// RuntimeClassConfig wraps applypodsv1.RuntimeClassApplyConfiguration for a runtime class.
type RuntimeClassConfig struct {
*applynodev1.RuntimeClassApplyConfiguration
Expand Down
3 changes: 2 additions & 1 deletion packages/containers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,14 @@ let
name = "service-mesh-proxy";
tag = "v${pkgs.service-mesh.version}";
copyToRoot = with pkgs; [
busybox
envoy
iptables-legacy
];
config = {
# Use Entrypoint so we can append arguments.
Entrypoint = [ "${pkgs.service-mesh}/bin/service-mesh" ];
Env = [ "PATH=/bin" ]; # This is only here for policy generation.
Env = [ "PATH=/bin" ];
};
};

Expand Down
5 changes: 5 additions & 0 deletions service-mesh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ func run() (retErr error) {
return fmt.Errorf("failed to set up iptables rules: %w", err)
}

// Signal readiness for startup probe.
if err := os.WriteFile("/ready", nil, 0o644); err != nil {
return err
}

// execute the envoy binary
envoyBin, err := exec.LookPath("envoy")
if err != nil {
Expand Down

0 comments on commit 705e957

Please sign in to comment.