mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-15 19:56:06 +00:00
support customized host os
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
@@ -494,10 +494,14 @@ func (e *genericRestoreExposer) createRestorePod(
|
||||
volumeName := string(ownerObject.UID)
|
||||
|
||||
if selectedNode != "" {
|
||||
affinity = &kube.LoadAffinity{}
|
||||
affinity = nil
|
||||
e.log.Infof("Selected node for restore pod. Ignore affinity from the node-agent config.")
|
||||
}
|
||||
|
||||
if affinity == nil {
|
||||
affinity = &kube.LoadAffinity{}
|
||||
}
|
||||
|
||||
podInfo, err := getInheritedPodInfo(ctx, e.kubeClient, ownerObject.Namespace, nodeOS)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error to get inherited pod info from node-agent")
|
||||
|
||||
@@ -235,12 +235,28 @@ func DaemonSet(namespace string, opts ...podTemplateOption) *appsv1api.DaemonSet
|
||||
if c.forWindows {
|
||||
daemonSet.Spec.Template.Spec.SecurityContext = nil
|
||||
daemonSet.Spec.Template.Spec.Containers[0].SecurityContext = nil
|
||||
daemonSet.Spec.Template.Spec.NodeSelector = map[string]string{
|
||||
"kubernetes.io/os": "windows",
|
||||
}
|
||||
daemonSet.Spec.Template.Spec.OS = &corev1api.PodOS{
|
||||
Name: "windows",
|
||||
}
|
||||
|
||||
daemonSet.Spec.Template.Spec.Affinity = &corev1api.Affinity{
|
||||
NodeAffinity: &corev1api.NodeAffinity{
|
||||
RequiredDuringSchedulingIgnoredDuringExecution: &corev1api.NodeSelector{
|
||||
NodeSelectorTerms: []corev1api.NodeSelectorTerm{
|
||||
{
|
||||
MatchExpressions: []corev1api.NodeSelectorRequirement{
|
||||
{
|
||||
Key: "kubernetes.io/os",
|
||||
Values: []string{"windows"},
|
||||
Operator: corev1api.NodeSelectorOpIn,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
daemonSet.Spec.Template.Spec.Tolerations = []corev1api.Toleration{
|
||||
{
|
||||
Key: "os",
|
||||
|
||||
@@ -364,12 +364,26 @@ func Deployment(namespace string, opts ...podTemplateOption) *appsv1api.Deployme
|
||||
Spec: corev1api.PodSpec{
|
||||
RestartPolicy: corev1api.RestartPolicyAlways,
|
||||
ServiceAccountName: c.serviceAccountName,
|
||||
NodeSelector: map[string]string{
|
||||
"kubernetes.io/os": "linux",
|
||||
},
|
||||
OS: &corev1api.PodOS{
|
||||
Name: "linux",
|
||||
},
|
||||
Affinity: &corev1api.Affinity{
|
||||
NodeAffinity: &corev1api.NodeAffinity{
|
||||
RequiredDuringSchedulingIgnoredDuringExecution: &corev1api.NodeSelector{
|
||||
NodeSelectorTerms: []corev1api.NodeSelectorTerm{
|
||||
{
|
||||
MatchExpressions: []corev1api.NodeSelectorRequirement{
|
||||
{
|
||||
Key: "kubernetes.io/os",
|
||||
Values: []string{"windows"},
|
||||
Operator: corev1api.NodeSelectorOpNotIn,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Containers: []corev1api.Container{
|
||||
{
|
||||
Name: "velero",
|
||||
|
||||
@@ -33,7 +33,7 @@ const (
|
||||
NodeOSLabel = "kubernetes.io/os"
|
||||
)
|
||||
|
||||
var nodeOSMap map[string]string = map[string]string{
|
||||
var realNodeOSMap map[string]string = map[string]string{
|
||||
"linux": NodeOSLinux,
|
||||
"windows": NodeOSWindows,
|
||||
}
|
||||
@@ -129,7 +129,7 @@ func HasNodeWithOS(ctx context.Context, os string, nodeClient corev1client.CoreV
|
||||
}
|
||||
|
||||
func getRealOS(osLabel string) string {
|
||||
if os, found := nodeOSMap[osLabel]; !found {
|
||||
if os, found := realNodeOSMap[osLabel]; !found {
|
||||
return NodeOSLinux
|
||||
} else {
|
||||
return os
|
||||
|
||||
Reference in New Issue
Block a user