chore(filebrowser): migrate from filebrowser to filebrowser quantum
Build and Push Docker Image / Build image (push) Successful in 9m10s
Build and Push Docker Image / Build image (push) Successful in 9m10s
This commit is contained in:
@@ -0,0 +1,46 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
type SourceConfig struct {
|
||||||
|
DefaultEnabled bool `yaml:"DefaultEnabled"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SourceDefinition struct {
|
||||||
|
Path string `yaml:"path"`
|
||||||
|
Config SourceConfig `yaml:"config"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServerConfig struct {
|
||||||
|
Port int `yaml:"port"`
|
||||||
|
BaseUrl string `yaml:"baseURL"`
|
||||||
|
Sources []SourceDefinition `yaml:"sources"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuthPasswordMethodConfig struct {
|
||||||
|
Enabled bool `yaml:"enabled"`
|
||||||
|
MinLength bool `yaml:"minLength"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuthProxyMethodConfig struct {
|
||||||
|
Enabled bool `yaml:"enabled"`
|
||||||
|
Header string `yaml:"header"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuthMethodsConfig struct {
|
||||||
|
Password AuthPasswordMethodConfig `yaml:"password"`
|
||||||
|
Proxy AuthProxyMethodConfig `yaml:"proxy"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuthConfig struct {
|
||||||
|
AdminUsername string `yaml:"adminUsername"`
|
||||||
|
Methods AuthMethodsConfig `yaml:"methods"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type FrontendConfig struct {
|
||||||
|
Name string `yaml:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type FileBrowserConfig struct {
|
||||||
|
Server ServerConfig `yaml:"server"`
|
||||||
|
Auth AuthConfig `yaml:"auth"`
|
||||||
|
Frontend FrontendConfig `yaml:"frontend"`
|
||||||
|
}
|
||||||
@@ -23,6 +23,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
traefikv3 "github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd/traefikio/v1alpha1"
|
traefikv3 "github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd/traefikio/v1alpha1"
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
@@ -297,7 +298,19 @@ func (r *ServerManagerReconciler) Reconcile(ctx context.Context, req ctrl.Reques
|
|||||||
}
|
}
|
||||||
logging.Info("verified server service")
|
logging.Info("verified server service")
|
||||||
|
|
||||||
browserPod := r.BrowserPod(s, pvc, browserPvc)
|
browserConfigMap, err := r.BrowserConfigMap(s)
|
||||||
|
if err != nil {
|
||||||
|
return ctrl.Result{}, err
|
||||||
|
}
|
||||||
|
var foundBrowserConfigMap *corev1.ConfigMap
|
||||||
|
|
||||||
|
err = r.Get(ctx, client.ObjectKeyFromObject(browserConfigMap), foundBrowserConfigMap)
|
||||||
|
if err != nil {
|
||||||
|
err = r.Create(ctx, browserConfigMap)
|
||||||
|
return ctrl.Result{Requeue: true}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
browserPod := r.BrowserPod(s, pvc, browserPvc, browserConfigMap)
|
||||||
foundBrowser := &corev1.Pod{}
|
foundBrowser := &corev1.Pod{}
|
||||||
err = r.Get(ctx, client.ObjectKeyFromObject(browserPod), foundBrowser)
|
err = r.Get(ctx, client.ObjectKeyFromObject(browserPod), foundBrowser)
|
||||||
if err == nil && !s.Spec.Browser.On {
|
if err == nil && !s.Spec.Browser.On {
|
||||||
@@ -519,15 +532,51 @@ func (r *ServerManagerReconciler) BrowserService(s *servermanagerv1alpha1.Server
|
|||||||
return service
|
return service
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ServerManagerReconciler) BrowserPod(s *servermanagerv1alpha1.ServerManager, pvc *corev1.PersistentVolumeClaim, browserPvc *corev1.PersistentVolumeClaim) *corev1.Pod {
|
func (r *ServerManagerReconciler) BrowserConfigMap(s *servermanagerv1alpha1.ServerManager) (*corev1.ConfigMap, error) {
|
||||||
ports := make([]corev1.ContainerPort, len(s.Spec.Server.Ports))
|
serializedConfig, err := yaml.Marshal(FileBrowserConfig{
|
||||||
|
Server: ServerConfig{
|
||||||
|
BaseUrl: r.GenerateBrowserSubPath(s),
|
||||||
|
Sources: []SourceDefinition{
|
||||||
|
{
|
||||||
|
Path: "/tmp/data",
|
||||||
|
Config: SourceConfig{DefaultEnabled: true},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Auth: AuthConfig{
|
||||||
|
AdminUsername: "admin",
|
||||||
|
Methods: AuthMethodsConfig{
|
||||||
|
Password: AuthPasswordMethodConfig{
|
||||||
|
Enabled: false,
|
||||||
|
},
|
||||||
|
Proxy: AuthProxyMethodConfig{
|
||||||
|
Enabled: true,
|
||||||
|
Header: "X-Forwarded-User",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Frontend: FrontendConfig{
|
||||||
|
Name: "ACoolFileBrowser",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
for i, port := range s.Spec.Server.Ports {
|
if err != nil {
|
||||||
ports[i] = corev1.ContainerPort{
|
return nil, err
|
||||||
ContainerPort: port.Port,
|
|
||||||
Protocol: port.Protocol,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var configMapData map[string]string
|
||||||
|
configMapData["config.yaml"] = string(serializedConfig)
|
||||||
|
return &corev1.ConfigMap{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: fmt.Sprintf("%s-browser-config", s.Name),
|
||||||
|
Namespace: s.Namespace,
|
||||||
|
Labels: map[string]string{"browser": s.Name},
|
||||||
|
},
|
||||||
|
Data: configMapData,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *ServerManagerReconciler) BrowserPod(s *servermanagerv1alpha1.ServerManager, pvc *corev1.PersistentVolumeClaim, browserPvc *corev1.PersistentVolumeClaim, browserConfigMap *corev1.ConfigMap) *corev1.Pod {
|
||||||
var fsGroupValue int64 = 2000
|
var fsGroupValue int64 = 2000
|
||||||
var runAsUserValue int64 = 1000
|
var runAsUserValue int64 = 1000
|
||||||
policy := corev1.FSGroupChangeOnRootMismatch // Optimizes startup speed
|
policy := corev1.FSGroupChangeOnRootMismatch // Optimizes startup speed
|
||||||
@@ -562,19 +611,12 @@ func (r *ServerManagerReconciler) BrowserPod(s *servermanagerv1alpha1.ServerMana
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{Name: "config-volume",
|
||||||
|
VolumeSource: corev1.VolumeSource{
|
||||||
|
ConfigMap: &corev1.ConfigMapVolumeSource{
|
||||||
|
LocalObjectReference: corev1.LocalObjectReference{
|
||||||
|
Name: browserConfigMap.Name,
|
||||||
},
|
},
|
||||||
InitContainers: []corev1.Container{
|
|
||||||
{
|
|
||||||
Name: "proxy-setter",
|
|
||||||
Image: "filebrowser/filebrowser",
|
|
||||||
ImagePullPolicy: corev1.PullIfNotPresent,
|
|
||||||
Ports: ports,
|
|
||||||
Command: []string{"/bin/sh"},
|
|
||||||
Args: []string{"-c", fmt.Sprintf("rm /tmp/database/filebrowser.db; filebrowser config init -d /tmp/database/filebrowser.db && filebrowser config set --auth.method=noauth --auth.header=%s -d /tmp/database/filebrowser.db", r.Config.Browser.AuthHeader)},
|
|
||||||
VolumeMounts: []corev1.VolumeMount{
|
|
||||||
{
|
|
||||||
Name: "browser-volume",
|
|
||||||
MountPath: "/tmp/database",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -582,10 +624,9 @@ func (r *ServerManagerReconciler) BrowserPod(s *servermanagerv1alpha1.ServerMana
|
|||||||
Containers: []corev1.Container{
|
Containers: []corev1.Container{
|
||||||
{
|
{
|
||||||
Name: "browser",
|
Name: "browser",
|
||||||
Image: "filebrowser/filebrowser",
|
Image: "ghcr.io/gtsteffaniak/filebrowser",
|
||||||
ImagePullPolicy: corev1.PullIfNotPresent,
|
ImagePullPolicy: corev1.PullIfNotPresent,
|
||||||
Ports: ports,
|
Args: []string{"-c", "/tmp/config/config.yaml"},
|
||||||
Args: []string{"-d", "/tmp/database/filebrowser.db", "-r", "/tmp/data", "-b", r.GenerateBrowserSubPath(s)},
|
|
||||||
VolumeMounts: []corev1.VolumeMount{
|
VolumeMounts: []corev1.VolumeMount{
|
||||||
{
|
{
|
||||||
Name: "volume",
|
Name: "volume",
|
||||||
@@ -595,6 +636,10 @@ func (r *ServerManagerReconciler) BrowserPod(s *servermanagerv1alpha1.ServerMana
|
|||||||
Name: "browser-volume",
|
Name: "browser-volume",
|
||||||
MountPath: "/tmp/database",
|
MountPath: "/tmp/database",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "config-volume",
|
||||||
|
MountPath: "/tmp/config",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user