feat(example): add factorio image example
Build and Push Docker Image / Build image (push) Successful in 1m45s

This commit is contained in:
2026-06-28 19:24:51 +03:00
parent 04ad3616c9
commit 9dd5cbf4c5
3 changed files with 61 additions and 11 deletions
+24
View File
@@ -0,0 +1,24 @@
apiVersion: server-manager.acooldomain.co/v1alpha1
kind: Image
metadata:
labels:
app.kubernetes.io/name: kubernetes-operator
app.kubernetes.io/managed-by: kustomize
name: minecraft-paper-1-21-5
spec:
location: git.acooldomain.co/server-manager/minecraft:paper-1.21.5
name: minecraft
tag: paper-1.21.5
working_dir: /opt/server
ports:
- port: 25565
protocol: TCP
init_script:
image: alpine:latest
command:
- /bin/sh
args:
- /bin/sh
- "-c"
- "echo eula=true >> /data/eula.txt"
+16 -2
View File
@@ -1,7 +1,7 @@
package controller package controller
type SourceConfig struct { type SourceConfig struct {
DefaultEnabled bool `yaml:"DefaultEnabled"` DefaultEnabled bool `yaml:"defaultEnabled"`
} }
type SourceDefinition struct { type SourceDefinition struct {
@@ -15,9 +15,22 @@ type ServerConfig struct {
Sources []SourceDefinition `yaml:"sources"` Sources []SourceDefinition `yaml:"sources"`
} }
type UserDefaultPermissionConfig struct {
Modify bool `yaml:"modify"`
Share bool `yaml:"share"`
Realtime bool `yaml:"realtime"`
Create bool `yaml:"create"`
Delete bool `yaml:"delete"`
Api bool `yaml:"api"`
}
type UserDefaultsConfig struct {
Permissions UserDefaultPermissionConfig `yaml:"permissions"`
}
type AuthPasswordMethodConfig struct { type AuthPasswordMethodConfig struct {
Enabled bool `yaml:"enabled"` Enabled bool `yaml:"enabled"`
MinLength bool `yaml:"minLength"` MinLength int `yaml:"minLength"`
} }
type AuthProxyMethodConfig struct { type AuthProxyMethodConfig struct {
@@ -43,4 +56,5 @@ type FileBrowserConfig struct {
Server ServerConfig `yaml:"server"` Server ServerConfig `yaml:"server"`
Auth AuthConfig `yaml:"auth"` Auth AuthConfig `yaml:"auth"`
Frontend FrontendConfig `yaml:"frontend"` Frontend FrontendConfig `yaml:"frontend"`
UserDefaults UserDefaultsConfig `yaml:"userDefaults"`
} }
@@ -302,13 +302,16 @@ func (r *ServerManagerReconciler) Reconcile(ctx context.Context, req ctrl.Reques
if err != nil { if err != nil {
return ctrl.Result{}, err return ctrl.Result{}, err
} }
var foundBrowserConfigMap *corev1.ConfigMap logging.Info("created browser configmap")
var foundBrowserConfigMap corev1.ConfigMap
err = r.Get(ctx, client.ObjectKeyFromObject(browserConfigMap), foundBrowserConfigMap) err = r.Get(ctx, client.ObjectKeyFromObject(browserConfigMap), &foundBrowserConfigMap)
if err != nil { if err != nil {
logging.Info("Failed getting browser configmap", "err", err)
err = r.Create(ctx, browserConfigMap) err = r.Create(ctx, browserConfigMap)
return ctrl.Result{Requeue: true}, err return ctrl.Result{Requeue: true}, err
} }
logging.Info("verified browser config map")
browserPod := r.BrowserPod(s, pvc, browserPvc, browserConfigMap) browserPod := r.BrowserPod(s, pvc, browserPvc, browserConfigMap)
foundBrowser := &corev1.Pod{} foundBrowser := &corev1.Pod{}
@@ -535,6 +538,7 @@ func (r *ServerManagerReconciler) BrowserService(s *servermanagerv1alpha1.Server
func (r *ServerManagerReconciler) BrowserConfigMap(s *servermanagerv1alpha1.ServerManager) (*corev1.ConfigMap, error) { func (r *ServerManagerReconciler) BrowserConfigMap(s *servermanagerv1alpha1.ServerManager) (*corev1.ConfigMap, error) {
serializedConfig, err := yaml.Marshal(FileBrowserConfig{ serializedConfig, err := yaml.Marshal(FileBrowserConfig{
Server: ServerConfig{ Server: ServerConfig{
Port: 80,
BaseUrl: r.GenerateBrowserSubPath(s), BaseUrl: r.GenerateBrowserSubPath(s),
Sources: []SourceDefinition{ Sources: []SourceDefinition{
{ {
@@ -551,28 +555,36 @@ func (r *ServerManagerReconciler) BrowserConfigMap(s *servermanagerv1alpha1.Serv
}, },
Proxy: AuthProxyMethodConfig{ Proxy: AuthProxyMethodConfig{
Enabled: true, Enabled: true,
Header: "X-Forwarded-User", Header: r.Config.Browser.AuthHeader,
}, },
}, },
}, },
Frontend: FrontendConfig{ Frontend: FrontendConfig{
Name: "ACoolFileBrowser", Name: "ACoolFileBrowser",
}, },
UserDefaults: UserDefaultsConfig{
Permissions: UserDefaultPermissionConfig{
Modify: true,
Create: true,
Delete: true,
Api: true,
Share: true,
Realtime: true,
},
},
}) })
if err != nil { if err != nil {
return nil, err return nil, err
} }
var configMapData map[string]string
configMapData["config.yaml"] = string(serializedConfig)
return &corev1.ConfigMap{ return &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-browser-config", s.Name), Name: fmt.Sprintf("%s-browser-config", s.Name),
Namespace: s.Namespace, Namespace: s.Namespace,
Labels: map[string]string{"browser": s.Name}, Labels: map[string]string{"browser": s.Name},
}, },
Data: configMapData, Data: map[string]string{"config.yaml": string(serializedConfig)},
}, nil }, nil
} }