Skip to content
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

Steve controller #597

Merged
merged 14 commits into from
Apr 9, 2018
1 change: 1 addition & 0 deletions cmd/ela-controller/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ go_library(
"//pkg/controller/configuration:go_default_library",
"//pkg/controller/revision:go_default_library",
"//pkg/controller/route:go_default_library",
"//pkg/controller/service:go_default_library",
"//pkg/signals:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/prometheus/client_golang/prometheus/promhttp:go_default_library",
Expand Down
2 changes: 2 additions & 0 deletions cmd/ela-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/elafros/elafros/pkg/controller/configuration"
"github.com/elafros/elafros/pkg/controller/revision"
"github.com/elafros/elafros/pkg/controller/route"
"github.com/elafros/elafros/pkg/controller/service"
"github.com/elafros/elafros/pkg/signals"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
Expand Down Expand Up @@ -84,6 +85,7 @@ func main() {
configuration.NewController,
revision.NewController,
route.NewController,
service.NewController,
}

// Build all of our controllers, with the clients constructed above.
Expand Down
2 changes: 1 addition & 1 deletion cmd/ela-queue/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ go_library(
visibility = ["//visibility:private"],
deps = [
"//pkg/autoscaler:go_default_library",
"//pkg/queue:go_default_library",
"//pkg/controller/revision:go_default_library",
"//pkg/queue:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/gorilla/websocket:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
Expand Down
6 changes: 5 additions & 1 deletion pkg/apis/ela/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package ela
const (
GroupName = "elafros.dev"

// ConfigurationLabelKey is the label key attached to a Revison indicating by
// ConfigurationLabelKey is the label key attached to a Revision indicating by
// which Configuration it is created.
ConfigurationLabelKey = GroupName + "/configuration"

Expand All @@ -38,4 +38,8 @@ const (
// AutoscalerLabelKey is the label key attached to a autoscaler pod indicating by
// which Autoscaler deployment it is created.
AutoscalerLabelKey = GroupName + "/autoscaler"

// ServiceLabelKey is the label key attached to a Route and Configuration indicating by
// which Service they are created.
ServiceLabelKey = GroupName + "/service"
)
52 changes: 52 additions & 0 deletions pkg/controller/service/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"ela_resource.go",
"service.go",
"service_configuration.go",
"service_route.go",
],
importpath = "github.com/elafros/elafros/pkg/controller/service",
visibility = ["//visibility:public"],
deps = [
"//pkg/apis/ela:go_default_library",
"//pkg/apis/ela/v1alpha1:go_default_library",
"//pkg/client/clientset/versioned:go_default_library",
"//pkg/client/informers/externalversions:go_default_library",
"//pkg/client/listers/ela/v1alpha1:go_default_library",
"//pkg/controller:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
"//vendor/k8s.io/api/core/v1: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/apimachinery/pkg/util/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/client-go/informers:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
"//vendor/k8s.io/client-go/tools/record:go_default_library",
"//vendor/k8s.io/client-go/util/workqueue:go_default_library",
],
)

go_test(
name = "go_default_test",
srcs = [
"service_configuration_test.go",
"service_route_test.go",
"service_test.go",
],
embed = [":go_default_library"],
deps = [
"//pkg/apis/ela:go_default_library",
"//pkg/apis/ela/v1alpha1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
],
)
18 changes: 18 additions & 0 deletions pkg/controller/service/ela_resource.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package service

import (
"github.com/elafros/elafros/pkg/apis/ela"
"github.com/elafros/elafros/pkg/apis/ela/v1alpha1"
)

// MakeElaResourceLabels constructs the labels we will apply to Route and Configuration
// resources.
func MakeElaResourceLabels(s *v1alpha1.Service) map[string]string {
labels := make(map[string]string, len(s.ObjectMeta.Labels)+1)
labels[ela.ServiceLabelKey] = s.Name

for k, v := range s.ObjectMeta.Labels {
labels[k] = v
}
return labels
}
Loading