Skip to content

Commit

Permalink
feat: Add label for the greptimedb services and controllers (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
daviderli614 authored Nov 26, 2024
1 parent 73de659 commit 90a4b73
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
6 changes: 6 additions & 0 deletions controllers/greptimedbcluster/deployers/datanode.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ func (b *datanodeBuilder) BuildService() deployer.Builder {
ObjectMeta: metav1.ObjectMeta{
Namespace: b.Cluster.Namespace,
Name: common.ResourceName(b.Cluster.Name, b.ComponentKind),
Labels: map[string]string{
constant.GreptimeDBComponentName: common.ResourceName(b.Cluster.Name, b.ComponentKind),
},
},
Spec: corev1.ServiceSpec{
ClusterIP: corev1.ClusterIPNone,
Expand Down Expand Up @@ -376,6 +379,9 @@ func (b *datanodeBuilder) BuildStatefulSet() deployer.Builder {
ObjectMeta: metav1.ObjectMeta{
Name: common.ResourceName(b.Cluster.Name, b.ComponentKind),
Namespace: b.Cluster.Namespace,
Labels: map[string]string{
constant.GreptimeDBComponentName: common.ResourceName(b.Cluster.Name, b.ComponentKind),
},
},
Spec: appsv1.StatefulSetSpec{
PodManagementPolicy: appsv1.ParallelPodManagement,
Expand Down
6 changes: 6 additions & 0 deletions controllers/greptimedbcluster/deployers/flownode.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ func (b *flownodeBuilder) BuildService() deployer.Builder {
ObjectMeta: metav1.ObjectMeta{
Namespace: b.Cluster.Namespace,
Name: common.ResourceName(b.Cluster.Name, b.ComponentKind),
Labels: map[string]string{
constant.GreptimeDBComponentName: common.ResourceName(b.Cluster.Name, b.ComponentKind),
},
},
Spec: corev1.ServiceSpec{
ClusterIP: corev1.ClusterIPNone,
Expand Down Expand Up @@ -182,6 +185,9 @@ func (b *flownodeBuilder) BuildStatefulSet() deployer.Builder {
ObjectMeta: metav1.ObjectMeta{
Name: common.ResourceName(b.Cluster.Name, b.ComponentKind),
Namespace: b.Cluster.Namespace,
Labels: map[string]string{
constant.GreptimeDBComponentName: common.ResourceName(b.Cluster.Name, b.ComponentKind),
},
},
Spec: appsv1.StatefulSetSpec{
PodManagementPolicy: appsv1.ParallelPodManagement,
Expand Down
7 changes: 6 additions & 1 deletion controllers/greptimedbcluster/deployers/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ func (b *frontendBuilder) BuildService() deployer.Builder {
Namespace: b.Cluster.Namespace,
Name: common.ResourceName(b.Cluster.Name, b.ComponentKind),
Annotations: b.Cluster.Spec.Frontend.Service.Annotations,
Labels: b.Cluster.Spec.Frontend.Service.Labels,
Labels: util.MergeStringMap(b.Cluster.Spec.Frontend.Service.Labels, map[string]string{
constant.GreptimeDBComponentName: common.ResourceName(b.Cluster.Name, b.ComponentKind),
}),
},
Spec: corev1.ServiceSpec{
Type: b.Cluster.Spec.Frontend.Service.Type,
Expand Down Expand Up @@ -161,6 +163,9 @@ func (b *frontendBuilder) BuildDeployment() deployer.Builder {
ObjectMeta: metav1.ObjectMeta{
Name: common.ResourceName(b.Cluster.Name, b.ComponentKind),
Namespace: b.Cluster.Namespace,
Labels: map[string]string{
constant.GreptimeDBComponentName: common.ResourceName(b.Cluster.Name, b.ComponentKind),
},
},
Spec: appsv1.DeploymentSpec{
Replicas: b.Cluster.Spec.Frontend.Replicas,
Expand Down
6 changes: 6 additions & 0 deletions controllers/greptimedbcluster/deployers/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ func (b *metaBuilder) BuildService() deployer.Builder {
ObjectMeta: metav1.ObjectMeta{
Namespace: b.Cluster.Namespace,
Name: common.ResourceName(b.Cluster.Name, b.ComponentKind),
Labels: map[string]string{
constant.GreptimeDBComponentName: common.ResourceName(b.Cluster.Name, b.ComponentKind),
},
},
Spec: corev1.ServiceSpec{
Type: corev1.ServiceTypeClusterIP,
Expand Down Expand Up @@ -238,6 +241,9 @@ func (b *metaBuilder) BuildDeployment() deployer.Builder {
ObjectMeta: metav1.ObjectMeta{
Name: common.ResourceName(b.Cluster.Name, b.ComponentKind),
Namespace: b.Cluster.Namespace,
Labels: map[string]string{
constant.GreptimeDBComponentName: common.ResourceName(b.Cluster.Name, b.ComponentKind),
},
},
Spec: appsv1.DeploymentSpec{
Replicas: b.Cluster.Spec.Meta.Replicas,
Expand Down
7 changes: 6 additions & 1 deletion controllers/greptimedbstandalone/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ func (b *standaloneBuilder) BuildService() deployer.Builder {
Namespace: b.standalone.Namespace,
Name: common.ResourceName(b.standalone.Name, v1alpha1.StandaloneKind),
Annotations: b.standalone.Spec.Service.Annotations,
Labels: b.standalone.Spec.Service.Labels,
Labels: util.MergeStringMap(b.standalone.Spec.Service.Labels, map[string]string{
constant.GreptimeDBComponentName: common.ResourceName(b.standalone.Name, v1alpha1.StandaloneKind),
}),
},
Spec: corev1.ServiceSpec{
Type: b.standalone.Spec.Service.Type,
Expand Down Expand Up @@ -242,6 +244,9 @@ func (b *standaloneBuilder) BuildStatefulSet() deployer.Builder {
ObjectMeta: metav1.ObjectMeta{
Name: common.ResourceName(b.standalone.Name, v1alpha1.StandaloneKind),
Namespace: b.standalone.Namespace,
Labels: map[string]string{
constant.GreptimeDBComponentName: common.ResourceName(b.standalone.Name, v1alpha1.StandaloneKind),
},
},
Spec: appsv1.StatefulSetSpec{
// Always set replicas to 1 for standalone mode.
Expand Down

0 comments on commit 90a4b73

Please sign in to comment.