func NewLifecycle() (*core.Lifecycle, error) {
	binaryPath, err := os.Executable()
	if err != nil {
		return nil, errors.WithStack(err)
	}
	exePath := filepath.Join(LifecycleVolumeMountDir, filepath.Base(binaryPath))
	lifecycle := &core.Lifecycle{
		PreStop: &core.Handler{
			Exec: &core.ExecAction{
				Command: append([]string{exePath}, "lifecycle", "preStop"),
			},
		},
	}
	return lifecycle, nil
}
NewLifecycle creates a lifecycle structure with preStop handler.
package k8sutil
import (
	"os"
	"path/filepath"
	"github.com/arangodb/kube-arangodb/pkg/util/errors"
	"github.com/arangodb/kube-arangodb/pkg/util/constants"
	core "k8s.io/api/core/v1"
)
const (
	initLifecycleContainerName = "init-lifecycle"
	LifecycleVolumeMountDir    = "/lifecycle/tools"
	lifecycleVolumeName        = "lifecycle"
)
func InitLifecycleContainer(image string, resources *core.ResourceRequirements, securityContext *core.SecurityContext) (core.Container, error) {
	binaryPath, err := os.Executable()
	if err != nil {
		return core.Container{}, errors.WithStack(err)
	}
	c := core.Container{
		Name:    initLifecycleContainerName,
		Image:   image,
		Command: append([]string{binaryPath}, "lifecycle", "copy", "--target", LifecycleVolumeMountDir),
		VolumeMounts: []core.VolumeMount{
			LifecycleVolumeMount(),
		},
		ImagePullPolicy: core.PullIfNotPresent,
		SecurityContext: securityContext,
	}
	if resources != nil {
		c.Resources = ExtractPodResourceRequirement(*resources)
	}
	return c, nil
}