Unverified Commit 1e6709db authored by julienmancuso's avatar julienmancuso Committed by GitHub
Browse files

feat: allow to override any podSpec property (#2116)

parent 096d117d
......@@ -16,5 +16,5 @@ apiVersion: v2
name: dynamo-crds
description: A Helm chart for dynamo CRDs
type: application
version: 0.3.2
version: 0.4.0
dependencies: []
\ No newline at end of file
......@@ -73,12 +73,12 @@ spec:
{{- if .Values.natsAddr }}
- --natsAddr={{ .Values.natsAddr }}
{{- else }}
- --natsAddr=nats://{{ .Release.Name }}-nats:4222
- --natsAddr=nats://{{ .Release.Name }}-nats.{{ .Release.Namespace }}:4222
{{- end }}
{{- if .Values.etcdAddr }}
- --etcdAddr={{ .Values.etcdAddr }}
{{- else }}
- --etcdAddr={{ .Release.Name }}-etcd:2379
- --etcdAddr={{ .Release.Name }}-etcd.{{ .Release.Namespace }}:2379
{{- end }}
{{- if and .Values.dynamo.istio.enabled .Values.dynamo.istio.gateway }}
- --istio-virtual-service-gateway={{ .Values.dynamo.istio.gateway }}
......
......@@ -54,13 +54,6 @@ type ExtraPodMetadata struct {
}
type ExtraPodSpec struct {
SchedulerName string `json:"schedulerName,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
Containers []corev1.Container `json:"containers,omitempty"`
ServiceAccountName string `json:"serviceAccountName,omitempty"`
PriorityClassName string `json:"priorityClassName,omitempty"`
*corev1.PodSpec `json:",inline"`
MainContainer *corev1.Container `json:"mainContainer,omitempty"`
}
......@@ -118,39 +118,11 @@ func (in *ExtraPodMetadata) DeepCopy() *ExtraPodMetadata {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ExtraPodSpec) DeepCopyInto(out *ExtraPodSpec) {
*out = *in
if in.NodeSelector != nil {
in, out := &in.NodeSelector, &out.NodeSelector
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
if in.Affinity != nil {
in, out := &in.Affinity, &out.Affinity
*out = new(v1.Affinity)
if in.PodSpec != nil {
in, out := &in.PodSpec, &out.PodSpec
*out = new(v1.PodSpec)
(*in).DeepCopyInto(*out)
}
if in.Tolerations != nil {
in, out := &in.Tolerations, &out.Tolerations
*out = make([]v1.Toleration, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.TopologySpreadConstraints != nil {
in, out := &in.TopologySpreadConstraints, &out.TopologySpreadConstraints
*out = make([]v1.TopologySpreadConstraint, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.Containers != nil {
in, out := &in.Containers, &out.Containers
*out = make([]v1.Container, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.MainContainer != nil {
in, out := &in.MainContainer, &out.MainContainer
*out = new(v1.Container)
......
......@@ -1477,11 +1477,6 @@ func (r *DynamoComponentDeploymentReconciler) generatePodTemplateSpec(ctx contex
podLabels[commonconsts.KubeLabelDynamoSelector] = kubeName
podSpec := corev1.PodSpec{
Containers: containers,
Volumes: volumes,
}
imagePullSecrets := []corev1.LocalObjectReference{}
if r.DockerSecretRetriever == nil {
......@@ -1500,9 +1495,13 @@ func (r *DynamoComponentDeploymentReconciler) generatePodTemplateSpec(ctx contex
})
}
if len(imagePullSecrets) > 0 {
podSpec.ImagePullSecrets = imagePullSecrets
podSpec := &corev1.PodSpec{}
if opt.dynamoComponentDeployment.Spec.ExtraPodSpec != nil && opt.dynamoComponentDeployment.Spec.ExtraPodSpec.PodSpec != nil {
podSpec = opt.dynamoComponentDeployment.Spec.ExtraPodSpec.PodSpec.DeepCopy()
}
podSpec.Containers = append(podSpec.Containers, containers...)
podSpec.Volumes = append(podSpec.Volumes, volumes...)
podSpec.ImagePullSecrets = append(podSpec.ImagePullSecrets, imagePullSecrets...)
extraPodMetadata := opt.dynamoComponentDeployment.Spec.ExtraPodMetadata
......@@ -1516,18 +1515,6 @@ func (r *DynamoComponentDeploymentReconciler) generatePodTemplateSpec(ctx contex
}
}
extraPodSpec := opt.dynamoComponentDeployment.Spec.ExtraPodSpec
if extraPodSpec != nil {
podSpec.SchedulerName = extraPodSpec.SchedulerName
podSpec.NodeSelector = extraPodSpec.NodeSelector
podSpec.Affinity = extraPodSpec.Affinity
podSpec.Tolerations = extraPodSpec.Tolerations
podSpec.TopologySpreadConstraints = extraPodSpec.TopologySpreadConstraints
podSpec.Containers = append(podSpec.Containers, extraPodSpec.Containers...)
podSpec.ServiceAccountName = extraPodSpec.ServiceAccountName
}
if podSpec.ServiceAccountName == "" {
serviceAccounts := &corev1.ServiceAccountList{}
err = r.List(ctx, serviceAccounts, client.InNamespace(opt.dynamoComponentDeployment.Namespace), client.MatchingLabels{
......@@ -1565,7 +1552,7 @@ func (r *DynamoComponentDeploymentReconciler) generatePodTemplateSpec(ctx contex
Labels: podLabels,
Annotations: podAnnotations,
},
Spec: podSpec,
Spec: *podSpec,
}
return
......
......@@ -842,6 +842,9 @@ func TestDynamoComponentDeploymentReconciler_generateLeaderWorkerSet(t *testing.
},
},
ExtraPodSpec: &dynamoCommon.ExtraPodSpec{
PodSpec: &corev1.PodSpec{
TerminationGracePeriodSeconds: ptr.To(int64(10)),
},
MainContainer: &corev1.Container{
Image: "test-image:latest",
Command: []string{
......@@ -902,6 +905,7 @@ func TestDynamoComponentDeploymentReconciler_generateLeaderWorkerSet(t *testing.
},
Spec: corev1.PodSpec{
SchedulerName: "volcano",
TerminationGracePeriodSeconds: ptr.To(int64(10)),
Containers: []corev1.Container{
{
Name: "main",
......@@ -953,6 +957,7 @@ func TestDynamoComponentDeploymentReconciler_generateLeaderWorkerSet(t *testing.
},
},
Spec: corev1.PodSpec{
TerminationGracePeriodSeconds: ptr.To(int64(10)),
SchedulerName: "volcano",
Containers: []corev1.Container{
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment