Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9aa89dd
Add activator for 0->1 case.
akyyy Mar 30, 2018
ca921d1
update one comment
akyyy Mar 30, 2018
707ec26
Add unit test
akyyy Apr 5, 2018
84a1c8c
Merge remote-tracking branch 'upstream/master'
akyyy Apr 8, 2018
d4a9397
remove retryingtripper.go
akyyy Apr 8, 2018
8ead2f0
Add a couple of todo links
akyyy Apr 9, 2018
c3a9537
Merge remote-tracking branch 'upstream/master'
akyyy Apr 9, 2018
304021e
watch works
akyyy Apr 9, 2018
a8aee63
Use a queue and watch object for each unique revision
akyyy Apr 9, 2018
98e40ce
Merge remote-tracking branch 'upstream/master'
akyyy Apr 11, 2018
3fefba6
Merge remote-tracking branch 'upstream/master'
akyyy Apr 11, 2018
8786311
Use channels
akyyy Apr 12, 2018
c755379
Merge remote-tracking branch 'upstream/master'
akyyy Apr 12, 2018
5de5ec4
activator with channels
akyyy Apr 13, 2018
e076285
merge
akyyy Apr 14, 2018
9c36591
fieldSelector
akyyy Apr 14, 2018
625ed28
update names
akyyy Apr 16, 2018
fe5c0aa
Send watch ready event to watch channel
akyyy Apr 17, 2018
3be96da
delete a binary
akyyy Apr 17, 2018
a7e3646
merge
akyyy Apr 17, 2018
5fefac0
merge
akyyy Apr 17, 2018
443ce20
add unit tests
akyyy Apr 18, 2018
c54ed63
Merge remote-tracking branch 'upstream/master'
akyyy Apr 18, 2018
22a7902
change back
akyyy Apr 18, 2018
833704b
remove debug code
akyyy Apr 18, 2018
dcc0836
Update test since we allow configuration change based on revision cha…
akyyy Apr 18, 2018
1e86a66
address cr comments
akyyy Apr 19, 2018
a445917
add error handling channel
akyyy Apr 20, 2018
d4d9542
Use sync.Map for pendingRequests
akyyy Apr 20, 2018
8ab2981
Talk to endpoint directly
akyyy Apr 20, 2018
0ee6a60
fix tests with existing endpoints
akyyy Apr 20, 2018
95d35c6
disable activator by default
akyyy Apr 20, 2018
d58b834
delete extra comment
akyyy Apr 20, 2018
74e60b2
Change scaleToZeroThreshold back to 5 min
akyyy Apr 20, 2018
cdeaed5
Update comments
akyyy Apr 20, 2018
ceafcde
Merge remote-tracking branch 'upstream/master'
akyyy Apr 20, 2018
cfc6d3d
Merge remote-tracking branch 'upstream/master'
akyyy Apr 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ k8s_object(
template = "webhook.yaml",
)

k8s_object(
name = "activator",
images = {
"ela-activator:latest": "//cmd/ela-activator:image",
},
template = "activator.yaml",
)

k8s_object(
name = "namespace",
template = "namespace.yaml",
Expand All @@ -57,6 +65,11 @@ k8s_object(
template = "elawebhookservice.yaml",
)

k8s_object(
name = "ela-activator-service",
template = "ela-activator-service.yaml",
)

k8s_object(
name = "configuration",
template = "configuration.yaml",
Expand Down Expand Up @@ -109,6 +122,8 @@ k8s_objects(
":controllerservice",
":webhook",
":elawebhookservice",
":activator",
":ela-activator-service",
],
)

Expand Down
39 changes: 39 additions & 0 deletions activator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: ela-activator
namespace: ela-system
spec:
# TODO: Increase the replicas
# https://github.com/elafros/elafros/issues/695
replicas: 1
template:
metadata:
labels:
app: ela-activator
role: ela-activator
spec:
serviceAccountName: ela-controller
containers:
- name: ela-activator
image: ela-activator:latest
ports:
- name: http
containerPort: 8080
args:
- "-logtostderr=true"
- "-stderrthreshold=INFO"
31 changes: 31 additions & 0 deletions cmd/ela-activator/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "github.com/elafros/elafros/cmd/ela-activator",
visibility = ["//visibility:private"],
deps = [
"//pkg/activator:go_default_library",
"//pkg/client/clientset/versioned:go_default_library",
"//pkg/signals:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
],
)

go_binary(
name = "ela-activator",
embed = [":go_default_library"],
pure = "on",
visibility = ["//visibility:public"],
)

load("@io_bazel_rules_docker//go:image.bzl", "go_image")

go_image(
name = "image",
binary = ":ela-activator",
visibility = ["//visibility:public"],
)
54 changes: 54 additions & 0 deletions cmd/ela-activator/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Copyright 2018 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"flag"
"net/http"

"github.com/elafros/elafros/pkg/activator"
clientset "github.com/elafros/elafros/pkg/client/clientset/versioned"
"github.com/elafros/elafros/pkg/signals"
"github.com/golang/glog"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
)

func main() {
flag.Parse()
glog.Info("Starting the elafros activator...")

// set up signals so we handle the first shutdown signal gracefully
stopCh := signals.SetupSignalHandler()

clusterConfig, err := rest.InClusterConfig()
if err != nil {
glog.Fatal(err)
}
kubeClient, err := kubernetes.NewForConfig(clusterConfig)
if err != nil {
glog.Fatal(err)
}
elaClient, err := clientset.NewForConfig(clusterConfig)
if err != nil {
glog.Fatalf("Error building ela clientset: %v", err)
}
a, err := activator.NewActivator(kubeClient, elaClient, http.DefaultTransport.(*http.Transport))
if err != nil {
glog.Fatalf("Failed to create an activator: %v", err)
}

a.Run(stopCh)
glog.Flush()
}
2 changes: 2 additions & 0 deletions controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ spec:
- ela-queue:latest
- "-autoscalerImage"
- ela-autoscaler:latest
# The flag to turn on the activator.
- "-enableActivatorExperiment=false"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're turning on scale to zero by default, you should turn on zero to one by default.

Copy link
Copy Markdown
Contributor Author

@akyyy akyyy Apr 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Activator is off by default. This is in sync with the autoscaler behavior in ela-autoscaler/main.go. I'll wait for your flag to update activator on/off switch in controller.

ports:
- name: metrics
containerPort: 9090
30 changes: 30 additions & 0 deletions ela-activator-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: Service
metadata:
name: activator-service
namespace: ela-system
labels:
app: ela-activator
spec:
selector:
app: ela-activator
ports:
- name: http
protocol: TCP
port: 80
targetPort: 8080
type: NodePort
34 changes: 34 additions & 0 deletions pkg/activator/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"activator.go",
],
importpath = "github.com/elafros/elafros/pkg/activator",
visibility = ["//visibility:public"],
deps = [
"//pkg/apis/ela/v1alpha1:go_default_library",
"//pkg/client/clientset/versioned:go_default_library",
"//pkg/controller:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
"//vendor/k8s.io/client-go/util/workqueue:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
],
)

go_test(
name = "go_default_test",
srcs = ["activator_test.go"],
embed = [":go_default_library"],
deps = [
"//pkg/apis/ela:go_default_library",
"//pkg/client/clientset/versioned/fake:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/fake:go_default_library",
],
)
1 change: 1 addition & 0 deletions pkg/activator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See the [section](https://github.com/elafros/elafros/blob/master/pkg/autoscaler/README.md#activator) in the Autoscaler documentation.
Loading