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

Adding Kubernetes recommended labels to resources #596

Merged
merged 10 commits into from
Feb 5, 2020
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ IMAGE_REPO ?= kedacore
IMAGE_CONTROLLER = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda:$(IMAGE_TAG)
IMAGE_ADAPTER = $(IMAGE_REGISTRY)/$(IMAGE_REPO)/keda-metrics-adapter:$(IMAGE_TAG)


ARCH ?=amd64
CGO ?=0
TARGET_OS ?=linux
Expand Down Expand Up @@ -68,12 +67,12 @@ build: checkenv build-adapter build-controller
.PHONY: build-controller
build-controller: generate-api pkg/scalers/liiklus/LiiklusService.pb.go
$(GO_BUILD_VARS) operator-sdk build $(IMAGE_CONTROLLER) \
--go-build-args "-ldflags -X=main.GitCommit=$(GIT_COMMIT) -o build/_output/bin/keda"
--go-build-args "-ldflags -X=main.GitCommit=$(GIT_COMMIT) -ldflags -X=github.com/kedacore/keda/version.Version=$(IMAGE_TAG) -o build/_output/bin/keda"

.PHONY: build-adapter
build-adapter: generate-api pkg/scalers/liiklus/LiiklusService.pb.go
$(GO_BUILD_VARS) go build \
-ldflags "-X=main.GitCommit=$(GIT_COMMIT)" \
-ldflags "-X=main.GitCommit=$(GIT_COMMIT) -X=github.com/kedacore/keda/version.Version=$(IMAGE_TAG)" \
-o build/_output/bin/keda-adapter \
cmd/adapter/main.go
docker build -f build/Dockerfile.adapter -t $(IMAGE_ADAPTER) .
Expand Down
12 changes: 12 additions & 0 deletions RELEASE-PROCESS.MD
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ Update sections related to images in these yamls:
https://github.com/kedacore/keda/blob/master/deploy/12-operator.yaml
https://github.com/kedacore/keda/blob/master/deploy/22-metrics-deployment.yaml

Update sections related to the version label in these yamls:
https://github.com/kedacore/keda/blob/master/deploy/00-namespace.yaml
https://github.com/kedacore/keda/blob/master/deploy/01-service_account.yaml
https://github.com/kedacore/keda/blob/master/deploy/10-cluster_role.yaml
https://github.com/kedacore/keda/blob/master/deploy/11-role_binding.yaml
https://github.com/kedacore/keda/blob/master/deploy/12-operator.yaml
https://github.com/kedacore/keda/blob/master/deploy/20-metrics-cluster_role.yaml
https://github.com/kedacore/keda/blob/master/deploy/21-metrics-role_binding.yaml
https://github.com/kedacore/keda/blob/master/deploy/22-metrics-deployment.yaml
https://github.com/kedacore/keda/blob/master/deploy/23-metrics-service.yaml
https://github.com/kedacore/keda/blob/master/deploy/24-metrics-api_service.yaml

Commit these changes.

**2) Deploy the new KEDA images to Docker Hub**
Expand Down
4 changes: 4 additions & 0 deletions deploy/00-namespace.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
apiVersion: v1
kind: Namespace
metadata:
labels:
app.kubernetes.io/name: keda
app.kubernetes.io/version: "1.1.0"
app.kubernetes.io/part-of: keda-operator
name: keda
4 changes: 4 additions & 0 deletions deploy/01-service_account.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/name: keda-operator
app.kubernetes.io/version: "1.1.0"
app.kubernetes.io/part-of: keda-operator
name: keda-operator
namespace: keda
4 changes: 4 additions & 0 deletions deploy/10-cluster_role.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: keda-operator
app.kubernetes.io/version: "1.1.0"
app.kubernetes.io/part-of: keda-operator
creationTimestamp: null
name: keda-operator
rules:
Expand Down
4 changes: 4 additions & 0 deletions deploy/11-role_binding.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app.kubernetes.io/name: keda-operator
app.kubernetes.io/version: "1.1.0"
app.kubernetes.io/part-of: keda-operator
name: keda-operator
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down
4 changes: 4 additions & 0 deletions deploy/12-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ kind: Deployment
metadata:
labels:
app: keda-operator
app.kubernetes.io/name: keda-operator
app.kubernetes.io/version: "1.1.0"
app.kubernetes.io/component: operator
app.kubernetes.io/part-of: keda-operator
name: keda-operator
namespace: keda
spec:
Expand Down
4 changes: 4 additions & 0 deletions deploy/20-metrics-cluster_role.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: keda-external-metrics-reader
app.kubernetes.io/version: "1.1.0"
app.kubernetes.io/part-of: keda-operator
creationTimestamp: null
name: keda-external-metrics-reader
rules:
Expand Down
12 changes: 12 additions & 0 deletions deploy/21-metrics-role_binding.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app.kubernetes.io/name: keda-system-auth-delegator
app.kubernetes.io/version: "1.1.0"
app.kubernetes.io/part-of: keda-operator
name: keda:system:auth-delegator
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand All @@ -14,6 +18,10 @@ subjects:
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
labels:
app.kubernetes.io/name: keda-auth-reader
app.kubernetes.io/version: "1.1.0"
app.kubernetes.io/part-of: keda-operator
name: keda-auth-reader
namespace: kube-system
roleRef:
Expand All @@ -28,6 +36,10 @@ subjects:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app.kubernetes.io/name: keda-hpa-controller-external-metrics
app.kubernetes.io/version: "1.1.0"
app.kubernetes.io/part-of: keda-operator
name: keda-hpa-controller-external-metrics
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down
3 changes: 3 additions & 0 deletions deploy/22-metrics-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: Deployment
metadata:
labels:
app: keda-metrics-apiserver
app.kubernetes.io/name: keda-metrics-apiserver
app.kubernetes.io/version: "1.1.0"
app.kubernetes.io/part-of: keda-operator
name: keda-metrics-apiserver
namespace: keda
spec:
Expand Down
34 changes: 19 additions & 15 deletions deploy/23-metrics-service.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
---
apiVersion: v1
kind: Service
metadata:
name: keda-metrics-apiserver
namespace: keda
spec:
ports:
- name: https
port: 443
targetPort: 6443
- name: http
port: 80
targetPort: 8080
selector:
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/name: keda-metrics-apiserver
app.kubernetes.io/version: "1.1.0"
app.kubernetes.io/part-of: keda-operator
name: keda-metrics-apiserver
namespace: keda
spec:
ports:
- name: https
port: 443
targetPort: 6443
- name: http
port: 80
targetPort: 8080
selector:
app: keda-metrics-apiserver
4 changes: 4 additions & 0 deletions deploy/24-metrics-api_service.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apiVersion: apiregistration.k8s.io/v1beta1
kind: APIService
metadata:
labels:
app.kubernetes.io/name: v1beta1.external.metrics.k8s.io
app.kubernetes.io/version: "1.1.0"
app.kubernetes.io/part-of: keda-operator
name: v1beta1.external.metrics.k8s.io
spec:
service:
Expand Down
8 changes: 8 additions & 0 deletions pkg/controller/scaledobject/scaledobject_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/go-logr/logr"
kedav1alpha1 "github.com/kedacore/keda/pkg/apis/keda/v1alpha1"
scalehandler "github.com/kedacore/keda/pkg/handler"
version "github.com/kedacore/keda/version"

autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1"
batchv1 "k8s.io/api/batch/v1"
Expand Down Expand Up @@ -355,6 +356,12 @@ func (r *ReconcileScaledObject) scaledObjectGenerationChanged(logger logr.Logger
func (r *ReconcileScaledObject) newHPAForScaledObject(logger logr.Logger, scaledObject *kedav1alpha1.ScaledObject) (*autoscalingv2beta1.HorizontalPodAutoscaler, error) {
deploymentName := scaledObject.Spec.ScaleTargetRef.DeploymentName
scaledObjectMetricSpecs, err := r.getScaledObjectMetricSpecs(logger, scaledObject, deploymentName)
labels := map[string]string{
"app.kubernetes.io/name": getHpaName(deploymentName),
"app.kubernetes.io/version": version.Version,
"app.kubernetes.io/part-of": scaledObject.GetName(),
"app.kubernetes.io/managed-by": "keda-operator",
}

if err != nil {
return nil, err
Expand All @@ -373,6 +380,7 @@ func (r *ReconcileScaledObject) newHPAForScaledObject(logger logr.Logger, scaled
ObjectMeta: metav1.ObjectMeta{
Name: getHpaName(deploymentName),
Namespace: scaledObject.Namespace,
Labels: labels,
},
TypeMeta: metav1.TypeMeta{
APIVersion: "v2beta1",
Expand Down
6 changes: 6 additions & 0 deletions pkg/handler/scale_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"

kedav1alpha1 "github.com/kedacore/keda/pkg/apis/keda/v1alpha1"
version "github.com/kedacore/keda/version"

batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -59,6 +61,10 @@ func (h *ScaleHandler) createJobs(scaledObject *kedav1alpha1.ScaledObject, scale
GenerateName: scaledObject.GetName() + "-",
Namespace: scaledObject.GetNamespace(),
Labels: map[string]string{
"app.kubernetes.io/name": scaledObject.GetName(),
"app.kubernetes.io/version": version.Version,
"app.kubernetes.io/part-of": scaledObject.GetName(),
"app.kubernetes.io/managed-by": "keda-operator",
"scaledobject": scaledObject.GetName(),
},
},
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package version

var (
Version = "1.0.0"
Version = "1.1.0"
)