-
Notifications
You must be signed in to change notification settings - Fork 1.2k
activator for 0->1 case #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 ca921d1
update one comment
akyyy 707ec26
Add unit test
akyyy 84a1c8c
Merge remote-tracking branch 'upstream/master'
akyyy d4a9397
remove retryingtripper.go
akyyy 8ead2f0
Add a couple of todo links
akyyy c3a9537
Merge remote-tracking branch 'upstream/master'
akyyy 304021e
watch works
akyyy a8aee63
Use a queue and watch object for each unique revision
akyyy 98e40ce
Merge remote-tracking branch 'upstream/master'
akyyy 3fefba6
Merge remote-tracking branch 'upstream/master'
akyyy 8786311
Use channels
akyyy c755379
Merge remote-tracking branch 'upstream/master'
akyyy 5de5ec4
activator with channels
akyyy e076285
merge
akyyy 9c36591
fieldSelector
akyyy 625ed28
update names
akyyy fe5c0aa
Send watch ready event to watch channel
akyyy 3be96da
delete a binary
akyyy a7e3646
merge
akyyy 5fefac0
merge
akyyy 443ce20
add unit tests
akyyy c54ed63
Merge remote-tracking branch 'upstream/master'
akyyy 22a7902
change back
akyyy 833704b
remove debug code
akyyy dcc0836
Update test since we allow configuration change based on revision cha…
akyyy 1e86a66
address cr comments
akyyy a445917
add error handling channel
akyyy d4d9542
Use sync.Map for pendingRequests
akyyy 8ab2981
Talk to endpoint directly
akyyy 0ee6a60
fix tests with existing endpoints
akyyy 95d35c6
disable activator by default
akyyy d58b834
delete extra comment
akyyy 74e60b2
Change scaleToZeroThreshold back to 5 min
akyyy cdeaed5
Update comments
akyyy ceafcde
Merge remote-tracking branch 'upstream/master'
akyyy cfc6d3d
Merge remote-tracking branch 'upstream/master'
akyyy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.