Skip to content

Commit

Permalink
added support for running backend on windows server node
Browse files Browse the repository at this point in the history
  • Loading branch information
yliaog committed Jan 24, 2020
1 parent 50924ce commit 3e4ebcb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
3 changes: 3 additions & 0 deletions cmd/e2e-test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var (
gceEndpointOverride string
createILBSubnet bool
enableIstio bool
windows bool
}

Framework *e2e.Framework
Expand All @@ -73,6 +74,7 @@ func init() {
flag.StringVar(&flags.gceEndpointOverride, "gce-endpoint-override", "", "If set, talks to a different GCE API Endpoint. By default it talks to https://www.googleapis.com/compute/v1/")
flag.BoolVar(&flags.createILBSubnet, "createILBSubnet", false, "If set, creates a proxy subnet for the L7 ILB")
flag.BoolVar(&flags.enableIstio, "enable-istio", false, "set to true if Istio is enabled.")
flag.BoolVar(&flags.windows, "windows", false, "If set, run backend on windows node")
}

// TestMain is the entrypoint for the end-to-end test suite. This is where
Expand Down Expand Up @@ -129,6 +131,7 @@ func TestMain(m *testing.M) {
GceEndpointOverride: flags.gceEndpointOverride,
CreateILBSubnet: flags.createILBSubnet,
EnableIstio: flags.enableIstio,
Windows: flags.windows,
})
if flags.handleSIGINT {
Framework.CatchSIGINT()
Expand Down
16 changes: 12 additions & 4 deletions pkg/e2e/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ import (
)

const (
echoheadersImage = "gcr.io/k8s-ingress-image-push/ingress-gce-echo-amd64:master"
porterPort = 80
echoheadersImage = "gcr.io/k8s-ingress-image-push/ingress-gce-echo-amd64:master"
echoheadersImageWindows = "gcr.io/gke-windows-testing/ingress-gce-echo-amd64-windows:master"
porterPort = 80
)

var ErrSubnetExists = fmt.Errorf("ILB subnet in region already exists")
Expand Down Expand Up @@ -135,16 +136,21 @@ func EnsureEchoService(s *Sandbox, name string, annotations map[string]string, s

// EnsureEchoDeployment ensures that the Echo deployment with the given description is set up
func EnsureEchoDeployment(s *Sandbox, name string, numReplicas int32, modify func(deployment *apps.Deployment)) error {
image := echoheadersImage
if s.f.Windows {
image = echoheadersImageWindows
}
podTemplate := v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: map[string]string{"app": name},
},
Spec: v1.PodSpec{
NodeSelector: map[string]string{"kubernetes.io/os": "windows"},
Containers: []v1.Container{
{
Name: "echoheaders",
Image: echoheadersImage,
Image: image,
Ports: []v1.ContainerPort{
{ContainerPort: 8080, Name: "http-port"},
{ContainerPort: 8443, Name: "https-port"},
Expand Down Expand Up @@ -179,7 +185,9 @@ func EnsureEchoDeployment(s *Sandbox, name string, numReplicas int32, modify fun
},
},
}

if s.f.Windows {
podTemplate.Spec.NodeSelector = map[string]string{"kubernetes.io/os": "windows"}
}
deployment := &apps.Deployment{
ObjectMeta: metav1.ObjectMeta{Name: name},
Spec: apps.DeploymentSpec{
Expand Down
3 changes: 3 additions & 0 deletions pkg/e2e/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Options struct {
GceEndpointOverride string
CreateILBSubnet bool
EnableIstio bool
Windows bool
}

const (
Expand Down Expand Up @@ -83,6 +84,7 @@ func NewFramework(config *rest.Config, options Options) *Framework {
Rand: rand.New(rand.NewSource(options.Seed)),
destroySandboxes: options.DestroySandboxes,
CreateILBSubnet: options.CreateILBSubnet,
Windows: options.Windows,
}
f.statusManager = NewStatusManager(f)
if options.EnableIstio {
Expand Down Expand Up @@ -113,6 +115,7 @@ type Framework struct {

destroySandboxes bool
CreateILBSubnet bool
Windows bool

lock sync.Mutex
sandboxes []*Sandbox
Expand Down

0 comments on commit 3e4ebcb

Please sign in to comment.