parent
ff6ea15796
commit
0ea4eb563a
|
@ -57,8 +57,13 @@ func DaemonSet(namespace string, opts ...podTemplateOption) *appsv1.DaemonSet {
|
|||
userID := int64(0)
|
||||
mountPropagationMode := corev1.MountPropagationHostToContainer
|
||||
|
||||
dsName := "node-agent"
|
||||
if c.forWindows {
|
||||
dsName = "node-agent-windows"
|
||||
}
|
||||
|
||||
daemonSet := &appsv1.DaemonSet{
|
||||
ObjectMeta: objectMeta(namespace, "node-agent"),
|
||||
ObjectMeta: objectMeta(namespace, dsName),
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "DaemonSet",
|
||||
APIVersion: appsv1.SchemeGroupVersion.String(),
|
||||
|
@ -66,13 +71,14 @@ func DaemonSet(namespace string, opts ...podTemplateOption) *appsv1.DaemonSet {
|
|||
Spec: appsv1.DaemonSetSpec{
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"name": "node-agent",
|
||||
"name": dsName,
|
||||
},
|
||||
},
|
||||
Template: corev1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: podLabels(c.labels, map[string]string{
|
||||
"name": "node-agent",
|
||||
"name": dsName,
|
||||
"role": "node-agent",
|
||||
}),
|
||||
Annotations: c.annotations,
|
||||
},
|
||||
|
@ -107,7 +113,7 @@ func DaemonSet(namespace string, opts ...podTemplateOption) *appsv1.DaemonSet {
|
|||
},
|
||||
Containers: []corev1.Container{
|
||||
{
|
||||
Name: "node-agent",
|
||||
Name: dsName,
|
||||
Image: c.image,
|
||||
Ports: containerPorts(),
|
||||
ImagePullPolicy: pullPolicy,
|
||||
|
@ -205,6 +211,24 @@ func DaemonSet(namespace string, opts ...podTemplateOption) *appsv1.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 = &corev1.PodOS{
|
||||
Name: "windows",
|
||||
}
|
||||
} else {
|
||||
daemonSet.Spec.Template.Spec.NodeSelector = map[string]string{
|
||||
"kubernetes.io/os": "linux",
|
||||
}
|
||||
daemonSet.Spec.Template.Spec.OS = &corev1.PodOS{
|
||||
Name: "linux",
|
||||
}
|
||||
}
|
||||
|
||||
daemonSet.Spec.Template.Spec.Containers[0].Env = append(daemonSet.Spec.Template.Spec.Containers[0].Env, c.envVars...)
|
||||
|
||||
return daemonSet
|
||||
|
|
|
@ -58,6 +58,7 @@ type podTemplateConfig struct {
|
|||
repoMaintenanceJobConfigMap string
|
||||
nodeAgentConfigMap string
|
||||
itemBlockWorkerCount int
|
||||
forWindows bool
|
||||
}
|
||||
|
||||
func WithImage(image string) podTemplateOption {
|
||||
|
@ -219,6 +220,12 @@ func WithItemBlockWorkerCount(itemBlockWorkerCount int) podTemplateOption {
|
|||
}
|
||||
}
|
||||
|
||||
func WithForWinows() podTemplateOption {
|
||||
return func(c *podTemplateConfig) {
|
||||
c.forWindows = true
|
||||
}
|
||||
}
|
||||
|
||||
func Deployment(namespace string, opts ...podTemplateOption) *appsv1.Deployment {
|
||||
// TODO: Add support for server args
|
||||
c := &podTemplateConfig{
|
||||
|
|
|
@ -418,6 +418,13 @@ func AllResources(o *VeleroOptions) *unstructured.UnstructuredList {
|
|||
if err := appendUnstructured(resources, ds); err != nil {
|
||||
fmt.Printf("error appending DaemonSet %s: %s\n", ds.GetName(), err.Error())
|
||||
}
|
||||
|
||||
dsOpts = append(dsOpts, WithForWinows())
|
||||
|
||||
dsWin := DaemonSet(o.Namespace, dsOpts...)
|
||||
if err := appendUnstructured(resources, dsWin); err != nil {
|
||||
fmt.Printf("error appending DaemonSet %s: %s\n", dsWin.GetName(), err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
return resources
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -153,6 +154,7 @@ func (r *registry) readPluginsDir(dir string) ([]string, error) {
|
|||
}
|
||||
|
||||
if !executable(file) {
|
||||
r.logger.Warnf("Searching plugin skip file %s, not executable, mode %v, ext %s", file.Name(), file.Mode(), strings.ToLower(filepath.Ext(file.Name())))
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -163,6 +165,15 @@ func (r *registry) readPluginsDir(dir string) ([]string, error) {
|
|||
|
||||
// executable determines if a file is executable.
|
||||
func executable(info os.FileInfo) bool {
|
||||
return executableLinux(info) || executableWindows(info)
|
||||
}
|
||||
|
||||
func executableWindows(info os.FileInfo) bool {
|
||||
ext := strings.ToLower(filepath.Ext(info.Name()))
|
||||
return (ext == ".exe")
|
||||
}
|
||||
|
||||
func executableLinux(info os.FileInfo) bool {
|
||||
/*
|
||||
When we AND the mode with 0111:
|
||||
|
||||
|
|
|
@ -114,7 +114,9 @@ func TestReadPluginsDir(t *testing.T) {
|
|||
WithFileAndMode("/plugins/nonexecutable2", []byte("plugin2"), 0644).
|
||||
WithFileAndMode("/plugins/executable3", []byte("plugin3"), 0755).
|
||||
WithFileAndMode("/plugins/nested/executable4", []byte("plugin4"), 0755).
|
||||
WithFileAndMode("/plugins/nested/nonexecutable5", []byte("plugin4"), 0644)
|
||||
WithFileAndMode("/plugins/nested/nonexecutable5", []byte("plugin4"), 0644).
|
||||
WithFileAndMode("/plugins/nested/win-exe1.exe", []byte("plugin4"), 0600).
|
||||
WithFileAndMode("/plugins/nested/WIN-EXE2.EXE", []byte("plugin4"), 0600)
|
||||
|
||||
plugins, err := r.readPluginsDir(dir)
|
||||
require.NoError(t, err)
|
||||
|
@ -123,6 +125,8 @@ func TestReadPluginsDir(t *testing.T) {
|
|||
"/plugins/executable1",
|
||||
"/plugins/executable3",
|
||||
"/plugins/nested/executable4",
|
||||
"/plugins/nested/win-exe1.exe",
|
||||
"/plugins/nested/WIN-EXE2.EXE",
|
||||
}
|
||||
|
||||
sort.Strings(plugins)
|
||||
|
|
Loading…
Reference in New Issue