Skip to content

Commit

Permalink
downward tolerations to deployment&pod
Browse files Browse the repository at this point in the history
  • Loading branch information
free6om committed May 8, 2024
1 parent cbc8f56 commit 68f77ac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions pkg/operator/v1/polardbx/factory/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ done
`
)

func (f *objectFactory) getTolerationsFrom(polardbx *polardbxv1.PolarDBXCluster) []corev1.Toleration {
return polardbx.Spec.Tolerations
}

func (f *objectFactory) newDeployment4CN(group string, mr *matchingRule, mustStaticPorts bool) (*appsv1.Deployment, error) {
polardbx := f.rc.MustGetPolarDBX()
topology := polardbx.Status.SpecSnapshot.Topology
Expand Down Expand Up @@ -372,6 +376,8 @@ func (f *objectFactory) newDeployment4CN(group string, mr *matchingRule, mustSta
nodeSelector,
)

tolerations := f.getTolerationsFrom(polardbx)

// Name & Labels & Annotations
deployName := convention.NewDeploymentName(polardbx, polardbxmeta.RoleCN, group)
cnType := polardbxmeta.CNTypeRW
Expand Down Expand Up @@ -580,6 +586,7 @@ func (f *objectFactory) newDeployment4CN(group string, mr *matchingRule, mustSta
HostNetwork: template.HostNetwork,
ShareProcessNamespace: pointer.Bool(true),
Affinity: affinity,
Tolerations: tolerations,
},
},
},
Expand Down Expand Up @@ -655,6 +662,8 @@ func (f *objectFactory) newDeployment4CDC(group string, mr *matchingRule, mustSt
nodeSelector,
)

tolerations := f.getTolerationsFrom(polardbx)

// Name & Labels
deployName := convention.NewDeploymentName(polardbx, polardbxmeta.RoleCDC, group)

Expand Down Expand Up @@ -802,6 +811,7 @@ func (f *objectFactory) newDeployment4CDC(group string, mr *matchingRule, mustSt
DNSPolicy: dnsPolicy,
ShareProcessNamespace: pointer.Bool(true),
Affinity: affinity,
Tolerations: tolerations,
// FIXME host network for CDC isn't supported
// HostNetwork: template.HostNetwork,
},
Expand Down Expand Up @@ -880,6 +890,8 @@ func (f *objectFactory) newDeployment4Columnar(group string, mr *matchingRule, m
nodeSelector,
)

tolerations := f.getTolerationsFrom(polardbx)

// Name & Labels
deployName := convention.NewDeploymentName(polardbx, polardbxmeta.RoleColumnar, group)

Expand Down Expand Up @@ -956,6 +968,7 @@ func (f *objectFactory) newDeployment4Columnar(group string, mr *matchingRule, m
DNSPolicy: dnsPolicy,
ShareProcessNamespace: pointer.Bool(true),
Affinity: affinity,
Tolerations: tolerations,
HostNetwork: template.HostNetwork,
},
},
Expand Down
4 changes: 3 additions & 1 deletion pkg/operator/v1/polardbx/factory/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ func (f *objectFactory) newXStore(

// Build
affinity := f.newXStoreNodeSetAffinity(polardbx, nil)
tolerations := f.getTolerationsFrom(polardbx)
nodeTemplate := &polardbxv1xstore.NodeTemplate{
ObjectMeta: polardbxv1common.PartialObjectMeta{
Labels: labels,
Expand Down Expand Up @@ -468,7 +469,8 @@ func (f *objectFactory) newXStore(
Enable: polardbx.Spec.TDE.Enable,
KeyringPath: polardbx.Spec.TDE.KeyringPath,
},
Exclusive: polardbx.Spec.Exclusive,
Exclusive: polardbx.Spec.Exclusive,
Tolerations: tolerations,
},
}
restoreOpt := polardbx.Spec.Restore
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/v1/xstore/factory/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func NewPod(rc *reconcile.Context, xstore *polardbxv1.XStore, nodeSet *polardbxv
HostNetwork: boolutil.IsTrue(template.Spec.HostNetwork),
ShareProcessNamespace: pointer.BoolPtr(true),
Affinity: opts.NewAffinity(factoryCtx),
Tolerations: xstore.Spec.Tolerations,
NodeName: hostPathVolume.Host, // If already bound, then assign to the same host.
Containers: []corev1.Container{
{
Expand Down

0 comments on commit 68f77ac

Please sign in to comment.