2026-05-07 11:51:35 -04:00
|
|
|
package glance
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"danicos.dev/daniel/go-kube/pkg/kube"
|
|
|
|
|
"danicos.dev/daniel/go-kube/pkg/stack"
|
|
|
|
|
"danicos.dev/daniel/homelab/pkg/root"
|
2026-05-07 12:17:47 -04:00
|
|
|
apps "k8s.io/api/apps/v1"
|
|
|
|
|
core "k8s.io/api/core/v1"
|
2026-05-07 11:51:35 -04:00
|
|
|
)
|
|
|
|
|
|
2026-05-07 12:17:47 -04:00
|
|
|
var Secret = struct {
|
|
|
|
|
Name string
|
|
|
|
|
TokenKey string
|
|
|
|
|
}{
|
|
|
|
|
Name: root.Glance.Name + "-secret",
|
|
|
|
|
TokenKey: "token",
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-07 11:51:35 -04:00
|
|
|
var Namespace = kube.Namespace(root.Glance.Name)
|
2026-05-07 12:17:47 -04:00
|
|
|
var meta kube.Metadata
|
|
|
|
|
var srv core.Service
|
2026-05-07 12:36:47 -04:00
|
|
|
var config_glance core.ConfigMap
|
|
|
|
|
var config_assets core.ConfigMap
|
2026-05-07 12:17:47 -04:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
2026-05-07 12:36:47 -04:00
|
|
|
config_glance = kube.ConfigFromFile("glance.yml", "./config/glance/config/glance.yml", meta)
|
|
|
|
|
config_glance.Data["home.yml"] = string(kube.ReadFileBytes("./config/glance/config/home.yml"))
|
|
|
|
|
meta_assets := kube.NewMetadata(root.Glance.Name+"-assets", Namespace)
|
|
|
|
|
config_assets = kube.ConfigFromFile("user.css", "./config/glance/assets/user.css", meta_assets)
|
2026-05-07 12:17:47 -04:00
|
|
|
}
|
2026-05-07 11:51:35 -04:00
|
|
|
|
|
|
|
|
func Stack() stack.Stack {
|
|
|
|
|
kz := kube.NewKuztomizedStack(
|
|
|
|
|
meta,
|
|
|
|
|
map[string]any{
|
2026-05-07 12:36:47 -04:00
|
|
|
"namespace": Namespace,
|
|
|
|
|
"service": srv,
|
|
|
|
|
"configmap-glance": config_glance,
|
|
|
|
|
"configmap-assets": config_assets,
|
|
|
|
|
"deployment": Deployment(),
|
2026-05-07 11:51:35 -04:00
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
return kz.Stack("glance")
|
|
|
|
|
}
|
2026-05-07 12:17:47 -04:00
|
|
|
|
|
|
|
|
func Deployment() apps.Deployment {
|
|
|
|
|
// MY_SECRET_TOKEN=123456 ?
|
|
|
|
|
// Config volume - ReadOnly?
|
|
|
|
|
// Assets volume - ReadOnly?
|
|
|
|
|
// Mount /etc/localtime (ReadOnly)
|
2026-05-07 12:36:47 -04:00
|
|
|
configVol := kube.NewVolumeFrom(kube.VolumeSourceConfigMap, "config", config_glance.Name)
|
|
|
|
|
assetsVol := kube.NewVolumeFrom(kube.VolumeSourceConfigMap, "assets", config_assets.Name)
|
|
|
|
|
localtimeVol := core.Volume{
|
|
|
|
|
Name: "localtime",
|
|
|
|
|
VolumeSource: core.VolumeSource{
|
|
|
|
|
HostPath: &core.HostPathVolumeSource{
|
|
|
|
|
Path: "/etc/localtime",
|
|
|
|
|
Type: new(core.HostPathFile),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
2026-05-07 12:17:47 -04:00
|
|
|
podSpec := core.PodSpec{
|
|
|
|
|
Containers: []core.Container{{
|
|
|
|
|
Name: root.Glance.Name,
|
|
|
|
|
Image: root.Glance.Image,
|
2026-05-07 12:36:47 -04:00
|
|
|
// Env: kube.NewEnvVarWithSecret(nil, nil, Secret.Name),
|
|
|
|
|
VolumeMounts: []core.VolumeMount{
|
|
|
|
|
{
|
|
|
|
|
Name: configVol.Name,
|
|
|
|
|
MountPath: "/app/config",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: assetsVol.Name,
|
|
|
|
|
MountPath: "/app/assets",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: localtimeVol.Name,
|
|
|
|
|
MountPath: "/etc/localtime",
|
|
|
|
|
ReadOnly: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-05-07 12:17:47 -04:00
|
|
|
}},
|
|
|
|
|
Volumes: []core.Volume{
|
2026-05-07 12:36:47 -04:00
|
|
|
configVol,
|
|
|
|
|
assetsVol,
|
|
|
|
|
localtimeVol,
|
2026-05-07 12:17:47 -04:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
return kube.NewDeployment(meta, podSpec)
|
|
|
|
|
}
|