Xe's Kubernetes custom resources
0

Configure Feed

Select the types of activity you want to include in your feed.

feat(app): add configmap support for the knot

Signed-off-by: Xe Iaso <me@xeiaso.net>

+49 -1
+8 -1
within-website-app/v1/app.go
··· 42 42 Role *Role `json:"role,omitempty" yaml:"role,omitempty"` 43 43 Anubis *Anubis `json:"anubis,omitempty" yaml:"anubis,omitempty"` 44 44 45 - Secrets []Secret `json:"secrets,omitempty" yaml:"secrets,omitempty"` 45 + Secrets []Secret `json:"secrets,omitempty" yaml:"secrets,omitempty"` 46 + ConfigMaps []ConfigMap `json:"configMaps,omitempty yaml:"configmaps,omitempty"` 46 47 } 47 48 48 49 type Healthcheck struct { ··· 172 173 Difficulty int `json:"difficulty"` 173 174 ServeRobotsTxt bool `json:"serveRobotsTXT"` 174 175 } `json:"settings,omitempty,omitzero"` 176 + } 177 + 178 + type ConfigMap struct { 179 + Name string `json:"name" yaml:"name"` 180 + Data map[string]string `json:"data" yaml:"data"` 181 + Folder string `json:"folder" yaml:"folder"` 175 182 } 176 183 177 184 // Custom Marshalling Logic so that users do not need to explicity fill out the Kind and ApiVersion.
+41
within-website-app/v1/flight/main.go
··· 58 58 result = append(result, createOnepasswordSecret(app, sec)) 59 59 } 60 60 61 + var configmaps []any 62 + for _, cm := range app.Spec.ConfigMaps { 63 + configmaps = append(configmaps, createConfigMap(app, cm)) 64 + } 65 + if len(configmaps) != 0 { 66 + result = append(result, configmaps...) 67 + } 68 + 61 69 result = append(result, createDeployment(app)) 62 70 result = append(result, createService(app)) 63 71 ··· 301 309 result.Spec.Template.Spec.Containers[0].VolumeMounts = append(result.Spec.Template.Spec.Containers[0].VolumeMounts, corev1.VolumeMount{ 302 310 Name: "storage", 303 311 MountPath: backend.Spec.Storage.Path, 312 + }) 313 + } 314 + 315 + for _, cm := range backend.Spec.ConfigMaps { 316 + result.Spec.Template.Spec.Volumes = append(result.Spec.Template.Spec.Volumes, corev1.Volume{ 317 + Name: "cm-" + cm.Name, 318 + VolumeSource: corev1.VolumeSource{ 319 + ConfigMap: &corev1.ConfigMapVolumeSource{ 320 + LocalObjectReference: corev1.LocalObjectReference{ 321 + Name: backend.Name + "-" + cm.Name, 322 + }, 323 + }, 324 + }, 325 + }) 326 + 327 + result.Spec.Template.Spec.Containers[0].VolumeMounts = append(result.Spec.Template.Spec.Containers[0].VolumeMounts, corev1.VolumeMount{ 328 + Name: "cm-" + cm.Name, 329 + MountPath: cm.Folder, 304 330 }) 305 331 } 306 332 ··· 603 629 Labels: app.Labels, 604 630 }, 605 631 AutomountServiceAccountToken: ptr.To(true), 632 + } 633 + } 634 + 635 + func createConfigMap(app v1.App, cm v1.ConfigMap) *corev1.ConfigMap { 636 + return &corev1.ConfigMap{ 637 + TypeMeta: metav1.TypeMeta{ 638 + APIVersion: corev1.SchemeGroupVersion.Identifier(), 639 + Kind: "ConfigMap", 640 + }, 641 + ObjectMeta: metav1.ObjectMeta{ 642 + Name: app.Name + "-" + cm.Name, 643 + Namespace: app.Namespace, 644 + Labels: app.Labels, 645 + }, 646 + Data: cm.Data, 606 647 } 607 648 } 608 649