Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions deploy/helm/csi-s3/templates/csi-s3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ spec:
- "--nodeid=$(NODE_ID)"
- "--v=4"
env:
- name: MY_POD_HOST_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.hostIP
- name: MINIO_PORT
value: "{{ .Values.minio.port }}"
- name: CSI_ENDPOINT
value: unix:///csi/csi.sock
- name: NODE_ID
Expand Down
5 changes: 5 additions & 0 deletions deploy/helm/csi-s3/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ secret:
endpoint: https://storage.yandexcloud.net
# Region
region: ""
# Minio
minio: disable

tolerations:
all: false
Expand All @@ -48,3 +50,6 @@ tolerations:
nodeSelector: {}

kubeletPath: /var/lib/kubelet

minio:
port: 30080
31 changes: 21 additions & 10 deletions pkg/mounter/geesefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

const (
geesefsCmd = "geesefs"
geesefsCmd = "geesefs"
)

// Implements Mounter
Expand All @@ -24,6 +24,7 @@ type geesefsMounter struct {
region string
accessKeyID string
secretAccessKey string
minio string
}

func newGeeseFSMounter(meta *s3.FSMeta, cfg *s3.Config) (Mounter, error) {
Expand All @@ -33,6 +34,7 @@ func newGeeseFSMounter(meta *s3.FSMeta, cfg *s3.Config) (Mounter, error) {
region: cfg.Region,
accessKeyID: cfg.AccessKeyID,
secretAccessKey: cfg.SecretAccessKey,
minio: cfg.Minio,
}, nil
}

Expand Down Expand Up @@ -70,6 +72,9 @@ func (geesefs *geesefsMounter) CopyBinary(from, to string) error {
}

func (geesefs *geesefsMounter) MountDirect(target string, args []string) error {
if geesefs.minio == "enable" {
geesefs.endpoint = "http://" + os.Getenv("MY_POD_HOST_IP") + ":" + os.Getenv("MINIO_PORT")
}
args = append([]string{
"--endpoint", geesefs.endpoint,
"-o", "allow_other",
Expand Down Expand Up @@ -143,21 +148,27 @@ func (geesefs *geesefsMounter) Mount(target, volumeID string) error {
if pluginDir == "" {
pluginDir = "/var/lib/kubelet/plugins/ru.yandex.s3.csi"
}
args = append([]string{pluginDir+"/geesefs", "-f", "-o", "allow_other", "--endpoint", geesefs.endpoint}, args...)
glog.Info("Starting geesefs using systemd: "+strings.Join(args, " "))
unitName := "geesefs-"+systemd.PathBusEscape(volumeID)+".service"

if geesefs.minio == "enable" {
geesefs.endpoint = "http://" + os.Getenv("MY_POD_HOST_IP") + ":" + os.Getenv("MINIO_PORT")
glog.Info("minio url: ", geesefs.endpoint)
}

args = append([]string{pluginDir + "/geesefs", "-f", "-o", "allow_other", "--endpoint", geesefs.endpoint}, args...)
glog.Info("Starting geesefs using systemd: " + strings.Join(args, " "))
unitName := "geesefs-" + systemd.PathBusEscape(volumeID) + ".service"
newProps := []systemd.Property{
systemd.Property{
Name: "Description",
Value: dbus.MakeVariant("GeeseFS mount for Kubernetes volume "+volumeID),
Name: "Description",
Value: dbus.MakeVariant("GeeseFS mount for Kubernetes volume " + volumeID),
},
systemd.PropExecStart(args, false),
systemd.Property{
Name: "Environment",
Value: dbus.MakeVariant([]string{ "AWS_ACCESS_KEY_ID="+geesefs.accessKeyID, "AWS_SECRET_ACCESS_KEY="+geesefs.secretAccessKey }),
Name: "Environment",
Value: dbus.MakeVariant([]string{"AWS_ACCESS_KEY_ID=" + geesefs.accessKeyID, "AWS_SECRET_ACCESS_KEY=" + geesefs.secretAccessKey}),
},
systemd.Property{
Name: "CollectMode",
Name: "CollectMode",
Value: dbus.MakeVariant("inactive-or-failed"),
},
}
Expand All @@ -178,7 +189,7 @@ func (geesefs *geesefsMounter) Mount(target, volumeID string) error {
// FIXME This may mean that the same bucket&path are used for multiple PVs. Support it somehow
return fmt.Errorf(
"GeeseFS for volume %v is already mounted on host, but"+
" in a different directory. We want %v, but it's in %v",
" in a different directory. We want %v, but it's in %v",
volumeID, target, curPath,
)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/s3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Config struct {
Endpoint string
Mounter string
Insecure bool
Minio string
}

type FSMeta struct {
Expand Down Expand Up @@ -87,6 +88,7 @@ func NewClientFromSecret(secret map[string]string) (*s3Client, error) {
// Mounter is set in the volume preferences, not secrets
Mounter: "",
Insecure: insecure,
Minio: secret["minio"],
})
}

Expand Down