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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ data:
securityContextFsGroup: "1001"
# If provided, will clean up all other volumes on the Velero and Node Agent pods
preserveVolumes: "my-bucket,my-other-bucket"
# use this if you deployed an ingress for the fileserver running on 3000 to access logs from outside the cluster network
# e.g. via ur velero cli. You will need to deploy the service/ingress yourself. See examples/filserverService.yaml
externalDownloadHostname: "www.velero-logs.domain.com"
# using https currently seems not to be supported by the velero client
externalDownloadScheme: "http"
externalDownloadPort: 80
```

## Removing the plugin
Expand Down
20 changes: 20 additions & 0 deletions examples/filserverService.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Service
metadata:
name: fileserver
namespace: velero
spec:
ports:
- name: fileserver
protocol: TCP
port: 3000
targetPort: 3000
selector:
app.kubernetes.io/instance: velero
app.kubernetes.io/name: velero
type: ClusterIP
sessionAffinity: None
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
internalTrafficPolicy: Cluster
6 changes: 6 additions & 0 deletions examples/pluginConfigMap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ data:
fileserverImage: ttl.sh/dans/local-volume-provider:12h
securityContextRunAsUser: "1001"
securityContextFsGroup: "1001"
# use this if you deployed an ingress for the fileserver running on 3000 to access logs from outside the cluster network
# e.g. via ur velero cli. You will need to deploy the service/ingress yourself. See examples/filserverService.yaml
externalDownloadHostname: "www.velero-logs.domain.com"
# using https currently seems not to be supported by the velero client
externalDownloadScheme: "http"
externalDownloadPort: 80
5 changes: 4 additions & 1 deletion pkg/plugin/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ type localVolumeObjectStoreOpts struct {
securityContextRunAsGroup string
securityContextFSGroup string
preserveVolumes map[string]bool
externalDownloadHostname string
externalDownloadPort string
externalDownloadScheme string
}

const (
Expand Down Expand Up @@ -163,7 +166,7 @@ func ensureDeploymentHasVolume(deployment *appsv1.Deployment, volumeSpec *corev1
}
veleroContainer.VolumeMounts = append(veleroContainer.VolumeMounts, *volumeMountSpec)

// Add the POD_IP for servering the signed URLs
// Add the POD_IP for serving the signed URLs
if !containerHasEnvVar(veleroContainer, "POD_IP") {
veleroContainer.Env = append(veleroContainer.Env, corev1.EnvVar{
Name: "POD_IP",
Expand Down
23 changes: 19 additions & 4 deletions pkg/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/url"
"os"
"path/filepath"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -249,14 +250,25 @@ func (o *LocalVolumeObjectStore) CreateSignedURL(bucket, key string, ttl time.Du
})
log.Debug("LocalVolumeObjectStore.CreateSignedURL called")

namespace := os.Getenv("VELERO_NAMESPACE")

downloadHostname := os.Getenv("POD_IP")
if o.opts.externalDownloadHostname != "" {
downloadHostname = o.opts.externalDownloadHostname
}
downloadScheme := "http"
if o.opts.externalDownloadScheme != "" {
downloadScheme = o.opts.externalDownloadScheme
}
downloadPort := 3000
if o.opts.externalDownloadPort != "" {
downloadPort, _ = strconv.Atoi(o.opts.externalDownloadPort)
}
signedUrl := url.URL{
Scheme: "http",
Host: fmt.Sprintf("%s:%d", os.Getenv("POD_IP"), 3000),
Scheme: downloadScheme,
Host: fmt.Sprintf("%s:%d", downloadHostname, downloadPort),
Path: fmt.Sprintf("/%s/%s", bucket, key),
}

namespace := os.Getenv("VELERO_NAMESPACE")
err := SignURL(&signedUrl, namespace, ttl)
if err != nil {
return "", errors.Wrap(err, "failed to create signed url")
Expand Down Expand Up @@ -292,6 +304,9 @@ func (o *LocalVolumeObjectStore) getLocalVolumeStoreOpts() error {
securityContextRunAsGroup: pluginConfigMap.Data["securityContextRunAsGroup"],
securityContextFSGroup: pluginConfigMap.Data["securityContextFsGroup"],
preserveVolumes: preserveVolumes,
externalDownloadHostname: pluginConfigMap.Data["externalDownloadHostname"],
externalDownloadScheme: pluginConfigMap.Data["externalDownloadScheme"],
externalDownloadPort: pluginConfigMap.Data["externalDownloadPort"],
}
}
return nil
Expand Down