Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix name of feature to podspreadconstraints #387

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/generator/buildvalues.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type BuildValues struct {
SSHPrivateKey string `json:"sshPrivateKey"`
ForcePullImages []string `json:"forcePullImages"`
Volumes []ComposeVolume `json:"volumes,omitempty" description:"stores any additional persistent volume definitions"`
PodAntiAffinity bool `json:"podAntiAffinity"`
PodSpreadConstraints bool `json:"podSpreadConstraints"`
}

type Resources struct {
Expand Down
6 changes: 3 additions & 3 deletions internal/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ func NewGenerator(
}

// feature to enable pod antiaffinity on deployments
podAntiAffinity := CheckFeatureFlag("POD_SPREADCONSTRAINTS", buildValues.EnvironmentVariables, false)
if podAntiAffinity == "enabled" {
buildValues.PodAntiAffinity = true
podSpreadConstraints := CheckFeatureFlag("POD_SPREADCONSTRAINTS", buildValues.EnvironmentVariables, false)
if podSpreadConstraints == "enabled" {
buildValues.PodSpreadConstraints = true
}

// check for readwritemany to readwriteonce flag, disabled by default
Expand Down
47 changes: 1 addition & 46 deletions internal/templating/services/templates_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,7 @@ func GenerateDeploymentTemplate(
}
}
}
if buildValues.PodAntiAffinity {
// if deployment.Spec.Template.Spec.Affinity == nil {
// deployment.Spec.Template.Spec.Affinity = &corev1.Affinity{}
// }
if buildValues.PodSpreadConstraints {
deployment.Spec.Template.Spec.TopologySpreadConstraints = []corev1.TopologySpreadConstraint{
{
MaxSkew: 1,
Expand Down Expand Up @@ -181,48 +178,6 @@ func GenerateDeploymentTemplate(
},
},
}
// deployment.Spec.Template.Spec.Affinity.PodAntiAffinity = &corev1.PodAntiAffinity{
// PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{
// {
// Weight: 100,
// PodAffinityTerm: corev1.PodAffinityTerm{
// TopologyKey: "kubernetes.io/hostname",
// LabelSelector: &metav1.LabelSelector{
// MatchExpressions: []metav1.LabelSelectorRequirement{
// {
// Key: "app.kubernetes.io/name",
// Operator: metav1.LabelSelectorOpIn,
// Values: []string{
// serviceTypeValues.Name,
// },
// },
// {
// Key: "app.kubernetes.io/instance",
// Operator: metav1.LabelSelectorOpIn,
// Values: []string{
// serviceValues.OverrideName,
// },
// },
// {
// Key: "lagoon.sh/project",
// Operator: metav1.LabelSelectorOpIn,
// Values: []string{
// buildValues.Project,
// },
// },
// {
// Key: "lagoon.sh/environment",
// Operator: metav1.LabelSelectorOpIn,
// Values: []string{
// buildValues.Environment,
// },
// },
// },
// },
// },
// },
// },
// }
}

for key, value := range additionalLabels {
Expand Down
2 changes: 1 addition & 1 deletion internal/templating/services/templates_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ func TestGenerateDeploymentTemplate(t *testing.T) {
ImageReferences: map[string]string{
"myservice": "harbor.example.com/example-project/environment-name/myservice@latest",
},
PodAntiAffinity: true,
PodSpreadConstraints: true,
Services: []generator.ServiceValues{
{
Name: "myservice",
Expand Down
Loading