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
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.0.0"
Cottonglow marked this conversation as resolved.
Show resolved Hide resolved
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.0.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.0.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.0.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.0.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.0.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.0.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.0.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.0.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.0.0"
app.kubernetes.io/part-of: keda-operator
name: keda-metrics-apiserver
namespace: keda
spec:
Expand Down
4 changes: 4 additions & 0 deletions deploy/23-metrics-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/name: keda-metrics-apiserver
app.kubernetes.io/version: "1.0.0"
app.kubernetes.io/part-of: keda-operator
name: keda-metrics-apiserver
namespace: keda
spec:
Expand Down
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.0.0"
app.kubernetes.io/part-of: keda-operator
name: v1beta1.external.metrics.k8s.io
spec:
service:
Expand Down
7 changes: 7 additions & 0 deletions pkg/controller/scaledobject/scaledobject_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ func (r *ReconcileScaledObject) startScaleLoop(logger logr.Logger, scaledObject
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": "1.0.0",
Cottonglow marked this conversation as resolved.
Show resolved Hide resolved
"app.kubernetes.io/part-of": deploymentName,
Cottonglow marked this conversation as resolved.
Show resolved Hide resolved
"app.kubernetes.io/managed-by": "keda-operator",
}

if err != nil {
return nil, err
Expand All @@ -339,6 +345,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
4 changes: 4 additions & 0 deletions pkg/handler/scale_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,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": "1.0.0",
Cottonglow marked this conversation as resolved.
Show resolved Hide resolved
"app.kubernetes.io/part-of": scaledObject.GetName(),
"app.kubernetes.io/managed-by": "keda-operator",
"scaledobject": scaledObject.GetName(),
},
},
Expand Down