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 ( ...@@ -25,6 +25,9 @@ var (
FlagNamespace = "namespace" FlagNamespace = "namespace"
EnvNamespace = "NAMESPACE" EnvNamespace = "NAMESPACE"
DefaultNamespace = "local-path-storage" DefaultNamespace = "local-path-storage"
FlagHelperImage = "helper-image"
EnvHelperImage = "HELPER_IMAGE"
DefaultHelperImage = "busybox"
) )
func cmdNotFound(c *cli.Context, command string) { func cmdNotFound(c *cli.Context, command string) {
...@@ -66,6 +69,12 @@ func StartCmd() cli.Command { ...@@ -66,6 +69,12 @@ func StartCmd() cli.Command {
EnvVar: EnvNamespace, EnvVar: EnvNamespace,
Value: DefaultNamespace, 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) { Action: func(c *cli.Context) {
if err := startDaemon(c); err != nil { if err := startDaemon(c); err != nil {
...@@ -106,8 +115,12 @@ func startDaemon(c *cli.Context) error { ...@@ -106,8 +115,12 @@ func startDaemon(c *cli.Context) error {
if namespace == "" { if namespace == "" {
return fmt.Errorf("invalid empty flag %v", FlagNamespace) 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 { if err != nil {
return err return err
} }
......
...@@ -42,6 +42,7 @@ type LocalPathProvisioner struct { ...@@ -42,6 +42,7 @@ type LocalPathProvisioner struct {
stopCh chan struct{} stopCh chan struct{}
kubeClient *clientset.Clientset kubeClient *clientset.Clientset
namespace string namespace string
helperImage string
config *Config config *Config
configData *ConfigData configData *ConfigData
...@@ -66,12 +67,13 @@ type Config struct { ...@@ -66,12 +67,13 @@ type Config struct {
NodePathMap map[string]*NodePathMap 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{ p := &LocalPathProvisioner{
stopCh: stopCh, stopCh: stopCh,
kubeClient: kubeClient, kubeClient: kubeClient,
namespace: namespace, namespace: namespace,
helperImage: helperImage,
// config will be updated shortly by p.refreshConfig() // config will be updated shortly by p.refreshConfig()
config: nil, config: nil,
...@@ -324,7 +326,7 @@ func (p *LocalPathProvisioner) createHelperPod(action ActionType, cmdsForPath [] ...@@ -324,7 +326,7 @@ func (p *LocalPathProvisioner) createHelperPod(action ActionType, cmdsForPath []
Containers: []v1.Container{ Containers: []v1.Container{
{ {
Name: "local-path-" + string(action), Name: "local-path-" + string(action),
Image: "busybox", Image: p.helperImage,
Command: append(cmdsForPath, filepath.Join("/data/", volumeDir)), Command: append(cmdsForPath, filepath.Join("/data/", volumeDir)),
VolumeMounts: []v1.VolumeMount{ VolumeMounts: []v1.VolumeMount{
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment