Merge pull request #13 from howardlau1999/fix

Use Kubernetes recommended labels
This commit is contained in:
Howard Lau 2020-11-01 14:49:30 +08:00 committed by GitHub
commit f9b565e70a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
seaweedv1 "github.com/seaweedfs/seaweedfs-operator/api/v1"
label "github.com/seaweedfs/seaweedfs-operator/controllers/label"
)
func (r *SeaweedReconciler) ensureFilerServers(seaweedCR *seaweedv1.Seaweed) (done bool, result ctrl.Result, err error) {
@ -98,5 +99,10 @@ func (r *SeaweedReconciler) ensureFilerConfigMap(seaweedCR *seaweedv1.Seaweed) (
}
func labelsForFiler(name string) map[string]string {
return map[string]string{"app": "seaweedfs", "role": "filer", "name": name}
return map[string]string{
label.ManagedByLabelKey: "seaweedfs-operator",
label.NameLabelKey: "seaweedfs",
label.ComponentLabelKey: "filer",
label.InstanceLabelKey: name,
}
}

View File

@ -10,6 +10,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
seaweedv1 "github.com/seaweedfs/seaweedfs-operator/api/v1"
label "github.com/seaweedfs/seaweedfs-operator/controllers/label"
)
func (r *SeaweedReconciler) ensureMaster(seaweedCR *seaweedv1.Seaweed) (done bool, result ctrl.Result, err error) {
@ -117,5 +118,10 @@ func (r *SeaweedReconciler) ensureMasterPeerService(seaweedCR *seaweedv1.Seaweed
}
func labelsForMaster(name string) map[string]string {
return map[string]string{"app": "seaweedfs", "role": "master", "name": name}
return map[string]string{
label.ManagedByLabelKey: "seaweedfs-operator",
label.NameLabelKey: "seaweedfs",
label.ComponentLabelKey: "master",
label.InstanceLabelKey: name,
}
}

View File

@ -10,6 +10,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
seaweedv1 "github.com/seaweedfs/seaweedfs-operator/api/v1"
label "github.com/seaweedfs/seaweedfs-operator/controllers/label"
)
func (r *SeaweedReconciler) ensureVolumeServers(seaweedCR *seaweedv1.Seaweed) (done bool, result ctrl.Result, err error) {
@ -80,5 +81,10 @@ func (r *SeaweedReconciler) ensureVolumeServerService(seaweedCR *seaweedv1.Seawe
}
func labelsForVolumeServer(name string) map[string]string {
return map[string]string{"app": "seaweedfs", "role": "volume", "name": name}
return map[string]string{
label.ManagedByLabelKey: "seaweedfs-operator",
label.NameLabelKey: "seaweedfs",
label.ComponentLabelKey: "volume",
label.InstanceLabelKey: name,
}
}

View File

@ -0,0 +1,18 @@
package label
const (
// The following labels are recommended by kubernetes https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/
// ManagedByLabelKey is Kubernetes recommended label key, it represents the tool being used to manage the operation of an application
// For resources managed by SeaweedFS Operator, its value is always seaweedfs-operator
ManagedByLabelKey string = "app.kubernetes.io/managed-by"
// ComponentLabelKey is Kubernetes recommended label key, it represents the component within the architecture
ComponentLabelKey string = "app.kubernetes.io/component"
// NameLabelKey is Kubernetes recommended label key, it represents the name of the application
NameLabelKey string = "app.kubernetes.io/name"
// InstanceLabelKey is Kubernetes recommended label key, it represents a unique name identifying the instance of an application
// It's set by helm when installing a release
InstanceLabelKey string = "app.kubernetes.io/instance"
// VersionLabelKey is Kubernetes recommended label key, it represents the version of the app
VersionLabelKey string = "app.kubernetes.io/version"
)