diff --git a/apps/hydra/glance/configmap.yaml b/apps/hydra/glance/configmap.yaml new file mode 100644 index 0000000..6f25b8f --- /dev/null +++ b/apps/hydra/glance/configmap.yaml @@ -0,0 +1,111 @@ +apiVersion: v1 +data: + glance.yml: | + server: + assets-path: /app/assets + + theme: + # Note: assets are cached by the browser, changes to the CSS file + # will not be reflected until the browser cache is cleared (Ctrl+F5) + custom-css-file: /assets/user.css + + pages: + # It's not necessary to create a new file for each page and include it, you can simply + # put its contents here, though multiple pages are easier to manage when separated + - $include: home.yml + home.yml: | + - name: Home + # Optionally, if you only have a single page you can hide the desktop navigation for a cleaner look + # hide-desktop-navigation: true + columns: + - size: small + widgets: + - type: calendar + first-day-of-week: monday + + - type: rss + limit: 10 + collapse-after: 3 + cache: 12h + feeds: + - url: https://selfh.st/rss/ + title: selfh.st + - url: https://ciechanow.ski/atom.xml + - url: https://www.joshwcomeau.com/rss.xml + title: Josh Comeau + - url: https://samwho.dev/rss.xml + - url: https://ishadeed.com/feed.xml + title: Ahmad Shadeed + + - type: twitch-channels + channels: + - theprimeagen + - j_blow + - giantwaffle + - cohhcarnage + - christitustech + - EJ_SA + + - size: full + widgets: + - type: group + widgets: + - type: hacker-news + - type: lobsters + + - type: videos + channels: + - UCXuqSBlHAE6Xw-yeJA0Tunw # Linus Tech Tips + - UCR-DXc1voovS8nhAvccRZhg # Jeff Geerling + - UCsBjURrPoezykLs9EqgamOA # Fireship + - UCBJycsmduvYEL83R_U4JriQ # Marques Brownlee + - UCHnyfMqiRRG1u-2MsSQLbXA # Veritasium + + - type: group + widgets: + - type: reddit + subreddit: technology + show-thumbnails: true + - type: reddit + subreddit: selfhosted + show-thumbnails: true + + - size: small + widgets: + - type: weather + location: London, United Kingdom + units: metric # alternatively "imperial" + hour-format: 12h # alternatively "24h" + # Optionally hide the location from being displayed in the widget + # hide-location: true + + - type: markets + markets: + - symbol: SPY + name: S&P 500 + - symbol: BTC-USD + name: Bitcoin + - symbol: NVDA + name: NVIDIA + - symbol: AAPL + name: Apple + - symbol: MSFT + name: Microsoft + + - type: releases + cache: 1d + # Without authentication the Github API allows for up to 60 requests per hour. You can create a + # read-only token from your Github account settings and use it here to increase the limit. + # token: ... + repositories: + - glanceapp/glance + - go-gitea/gitea + - immich-app/immich + - syncthing/syncthing + user.css: | + main { + } +kind: ConfigMap +metadata: + name: glance-configmap + namespace: glance diff --git a/apps/hydra/glance/kustomization.yaml b/apps/hydra/glance/kustomization.yaml index a9036ad..f59c08a 100644 --- a/apps/hydra/glance/kustomization.yaml +++ b/apps/hydra/glance/kustomization.yaml @@ -1,5 +1,9 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization -metadata: {} +metadata: + name: glance + namespace: glance resources: +- configmap.yaml - namespace.yaml +- service.yaml diff --git a/apps/hydra/glance/service.yaml b/apps/hydra/glance/service.yaml new file mode 100644 index 0000000..bb17aec --- /dev/null +++ b/apps/hydra/glance/service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: glance + name: glance + namespace: glance +spec: + ports: + - nodePort: 30009 + port: 8080 + targetPort: 0 + selector: + app: glance + type: NodePort +status: + loadBalancer: {} diff --git a/apps/hydra/kustomization.yaml b/apps/hydra/kustomization.yaml index f26ac2b..b2ec6d2 100644 --- a/apps/hydra/kustomization.yaml +++ b/apps/hydra/kustomization.yaml @@ -4,3 +4,4 @@ resources: - secrets/ - linkding/ - immich/ + - glance/ diff --git a/config/glance/assets/user.css b/config/glance/assets/user.css index e69de29..513d5ad 100644 --- a/config/glance/assets/user.css +++ b/config/glance/assets/user.css @@ -0,0 +1,2 @@ +main { +} diff --git a/pkg/glance.go b/pkg/glance.go index c24f138..92fe6d9 100644 --- a/pkg/glance.go +++ b/pkg/glance.go @@ -4,17 +4,61 @@ import ( "danicos.dev/daniel/go-kube/pkg/kube" "danicos.dev/daniel/go-kube/pkg/stack" "danicos.dev/daniel/homelab/pkg/root" + apps "k8s.io/api/apps/v1" + core "k8s.io/api/core/v1" ) -var meta kube.Metadata +var Secret = struct { + Name string + TokenKey string +}{ + Name: root.Glance.Name + "-secret", + TokenKey: "token", +} + var Namespace = kube.Namespace(root.Glance.Name) +var meta kube.Metadata +var srv core.Service +var config_map core.ConfigMap + +func init() { + meta = kube.NewMetadata(root.Glance.Name, Namespace) + srv = meta.Service(root.Glance.Port) + srv.Spec.Type = core.ServiceTypeNodePort + srv.Spec.Ports[0].NodePort = int32(root.Glance.Public.NodePort) + + config_map = kube.ConfigFromFile("glance.yml", "./config/glance/config/glance.yml", meta) + config_map.Data["home.yml"] = string(kube.ReadFileBytes("./config/glance/config/home.yml")) + config_map.Data["user.css"] = string(kube.ReadFileBytes("./config/glance/assets/user.css")) +} func Stack() stack.Stack { kz := kube.NewKuztomizedStack( meta, map[string]any{ "namespace": Namespace, + "service": srv, + "configmap": config_map, + // "deployment": Deployment(), }, ) return kz.Stack("glance") } + +func Deployment() apps.Deployment { + // MY_SECRET_TOKEN=123456 ? + // Config volume - ReadOnly? + // Assets volume - ReadOnly? + // Mount /etc/localtime (ReadOnly) + podSpec := core.PodSpec{ + Containers: []core.Container{{ + Name: root.Glance.Name, + Image: root.Glance.Image, + Env: kube.NewEnvVarWithSecret(nil, nil, Secret.Name), + }}, + Volumes: []core.Volume{ + kube.NewVolumeFrom(kube.VolumeSourceConfigMap, "config", config_map.Name), + }, + } + return kube.NewDeployment(meta, podSpec) +} diff --git a/pkg/root/services.go b/pkg/root/services.go index a3d2110..ea799e6 100644 --- a/pkg/root/services.go +++ b/pkg/root/services.go @@ -45,12 +45,12 @@ var Immich = Service{ var Glance = Service{ Name: "glance", - Image: "", - Port: 0, // Server Port - // Public: &Public{ - // URL: "https://photos.danicos.me", - // NodePort: 30011, - // }, + Image: "glanceapp/glance:v0.8.4", + Port: 8080, // Server Port + Public: &Public{ + URL: "https://home.danicos.me", + NodePort: 30009, + }, } var (