Make kubelet directory configurable via an environment variable
@@ -44,6 +44,9 @@ const (
// UserRootless is the user which runs the operator.
UserRootless = 65535
+ // DefaultKubeletPath specifies the default kubelet path.
+ DefaultKubeletPath = "/var/lib/kubelet"
+
// KubeletSeccompRootPath specifies the path where all kubelet seccomp
// profiles are stored.
KubeletSeccompRootPath = "/var/lib/kubelet/seccomp"
@@ -84,6 +87,9 @@ const (
// profiling port.
ProfilingPortEnvKey = "SPO_PROFILING_PORT"
+ // KubeletDirEnvKey is the environment variable key for custom kubelet directory.
+ KubeletDirEnvKey = "KUBELET_DIR"
+
// DefaultProfilingPort is the start port where the profiling endpoint runs.
DefaultProfilingPort = 6060
@@ -155,3 +161,13 @@ func TryToGetOperatorNamespace() (string, error) {
}
return operatorNS, nil
}
+
+// KubeletDir returns the kubelet directory either form an environment variable
+// when is set or the default Kubernetes path.
+func KubeletDir() string {
+ kubeletDir := env.Default(KubeletDirEnvKey, "")
+ if kubeletDir == "" {
+ return DefaultKubeletPath
+ }
+ return kubeletDir
+}
\ No newline at end of file
