Files
atmosphere/internal/openstack_helm/openstack_helm.go
T
Jason Hall dea3c67d19 Feature: pod affinity changes for OVN
Deploy OVN northd using the same pod affinity rules
used with the NB and SB statefulsets. Also change
default anti-affinity for NB and SB statefulsets
to requiredDuringSchedulingIgnoredDuringExecution
over preferredDuringSchedulingIgnoredDuringExecution

Change-Id: I844bbdc53fe10a8b8d9f017b9a3c68d93b695b98

Add unit tests to for OVN Anti-Affinity Rules

These unit tests go over all the statefulset and
deployment  pods using the and make sure they are
all using the right anti-affinity rules.

Change-Id: I2c8b5bf7515040e715bdeed4410acf6656578133
2025-02-17 17:08:04 -06:00

96 lines
2.5 KiB
Go

package openstack_helm
import (
"gopkg.in/yaml.v2"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/chartutil"
)
type HelmValues struct {
Pod `yaml:"pod"`
Conf `yaml:"conf"`
}
type PodPriorityClassConfig map[string]string
type PodRuntimeClassConfig map[string]string
type PodMount map[string]interface{}
type Pod struct {
PriorityClass PodPriorityClassConfig `yaml:"priorityClassName,omitempty"`
RuntimeClass PodRuntimeClassConfig `yaml:"runtimeClassName,omitempty"`
Mounts map[string]PodMount `yaml:"mounts,omitempty"`
AntiAffinityType PodAntiAffinityTypeConfig `yaml:"affinity.anti.type,omitempty"`
}
type PodAntiAffinityTypeConfig map[string]interface{}
type Conf struct {
Barbican *BarbicanConf `yaml:"barbican,omitempty"`
Cinder *CinderConf `yaml:"cinder,omitempty"`
Designate *DesignateConf `yaml:"designate,omitempty"`
Glance *GlanceConf `yaml:"glance,omitempty"`
Heat *HeatConf `yaml:"heat,omitempty"`
Ironic *IronicConf `yaml:"ironic,omitempty"`
Keystone *KeystoneConf `yaml:"keystone,omitempty"`
Magnum *MagnumConf `yaml:"magnum,omitempty"`
Manila *ManilaConf `yaml:"manila,omitempty"`
Memcached *MemcachedConf `yaml:"memcached,omitempty"`
Neutron *NeutronConf `yaml:"neutron,omitempty"`
Nova *NovaConf `yaml:"nova,omitempty"`
Octavia *OctaviaConf `yaml:"octavia,omitempty"`
Placement *PlacementConf `yaml:"placement,omitempty"`
Staffeln *StaffelnConf `yaml:"staffeln,omitempty"`
}
func (h *HelmValues) YAML() ([]byte, error) {
return yaml.Marshal(h)
}
func (h *HelmValues) NativeHelmValues() (chartutil.Values, error) {
yamlData, err := h.YAML()
if err != nil {
return nil, err
}
return chartutil.ReadValues(yamlData)
}
func FromYAML(yamlData []byte) (*HelmValues, error) {
var helmValues HelmValues
err := yaml.Unmarshal(yamlData, &helmValues)
if err != nil {
return nil, err
}
return &helmValues, nil
}
func FromYAMLString(yamlString string) (*HelmValues, error) {
return FromYAML([]byte(yamlString))
}
func CoalescedHelmValues(name string, values *HelmValues) (*HelmValues, error) {
chart, err := loader.Load(name)
if err != nil {
return nil, err
}
releaseValues, err := values.NativeHelmValues()
if err != nil {
return nil, err
}
mergedValues, err := chartutil.CoalesceValues(chart, releaseValues)
if err != nil {
return nil, err
}
yamlData, err := mergedValues.YAML()
if err != nil {
return nil, err
}
return FromYAMLString(yamlData)
}