Skip to content
Snippets Groups Projects
Commit 315d67fa authored by Sheng Yang's avatar Sheng Yang
Browse files

Add `--helper-image` parameter (and env) to specify the image for helper pod

parent 3256bdf6
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,9 @@ var (
FlagNamespace = "namespace"
EnvNamespace = "NAMESPACE"
DefaultNamespace = "local-path-storage"
FlagHelperImage = "helper-image"
EnvHelperImage = "HELPER_IMAGE"
DefaultHelperImage = "busybox"
)
func cmdNotFound(c *cli.Context, command string) {
......@@ -66,6 +69,12 @@ func StartCmd() cli.Command {
EnvVar: EnvNamespace,
Value: DefaultNamespace,
},
cli.StringFlag{
Name: FlagHelperImage,
Usage: "Required. The helper image used for create/delete directories on the host",
EnvVar: EnvHelperImage,
Value: DefaultHelperImage,
},
},
Action: func(c *cli.Context) {
if err := startDaemon(c); err != nil {
......@@ -106,8 +115,12 @@ func startDaemon(c *cli.Context) error {
if namespace == "" {
return fmt.Errorf("invalid empty flag %v", FlagNamespace)
}
helperImage := c.String(FlagHelperImage)
if helperImage == "" {
return fmt.Errorf("invalid empty flag %v", FlagHelperImage)
}
provisioner, err := NewProvisioner(stopCh, kubeClient, configFile, namespace)
provisioner, err := NewProvisioner(stopCh, kubeClient, configFile, namespace, helperImage)
if err != nil {
return err
}
......
......@@ -39,9 +39,10 @@ var (
)
type LocalPathProvisioner struct {
stopCh chan struct{}
kubeClient *clientset.Clientset
namespace string
stopCh chan struct{}
kubeClient *clientset.Clientset
namespace string
helperImage string
config *Config
configData *ConfigData
......@@ -66,12 +67,13 @@ type Config struct {
NodePathMap map[string]*NodePathMap
}
func NewProvisioner(stopCh chan struct{}, kubeClient *clientset.Clientset, configFile, namespace string) (*LocalPathProvisioner, error) {
func NewProvisioner(stopCh chan struct{}, kubeClient *clientset.Clientset, configFile, namespace, helperImage string) (*LocalPathProvisioner, error) {
p := &LocalPathProvisioner{
stopCh: stopCh,
kubeClient: kubeClient,
namespace: namespace,
kubeClient: kubeClient,
namespace: namespace,
helperImage: helperImage,
// config will be updated shortly by p.refreshConfig()
config: nil,
......@@ -324,7 +326,7 @@ func (p *LocalPathProvisioner) createHelperPod(action ActionType, cmdsForPath []
Containers: []v1.Container{
{
Name: "local-path-" + string(action),
Image: "busybox",
Image: p.helperImage,
Command: append(cmdsForPath, filepath.Join("/data/", volumeDir)),
VolumeMounts: []v1.VolumeMount{
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment