Skip to content

Commit

Permalink
[NET-6809] Add chart related labels for mesh gateway deployments (#3396)
Browse files Browse the repository at this point in the history
* use set labels for setting labels on deployments

* incorporate changes for setting labels
  • Loading branch information
jm96441n authored Dec 20, 2023
1 parent 2d5694f commit 6f293d5
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 7 deletions.
44 changes: 40 additions & 4 deletions control-plane/gateways/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ func Test_meshGatewayBuilder_Deployment(t *testing.T) {
config: GatewayConfig{},
gcc: &meshv2beta1.GatewayClassConfig{
Spec: meshv2beta1.GatewayClassConfigSpec{
GatewayClassAnnotationsAndLabels: meshv2beta1.GatewayClassAnnotationsAndLabels{
Labels: meshv2beta1.GatewayClassAnnotationsLabelsConfig{
Set: map[string]string{
"app": "consul",
"chart": "consul-helm",
"heritage": "Helm",
"release": "consul",
},
},
},
Deployment: meshv2beta1.GatewayClassDeploymentConfig{
Container: &meshv2beta1.GatewayClassContainerConfig{
HostPort: 8080,
Expand All @@ -67,17 +77,37 @@ func Test_meshGatewayBuilder_Deployment(t *testing.T) {
},
want: &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Labels: defaultLabels,
Labels: map[string]string{
labelManagedBy: "consul-k8s",
"app": "consul",
"chart": "consul-helm",
"heritage": "Helm",
"release": "consul",
},

Annotations: map[string]string{},
},
Spec: appsv1.DeploymentSpec{
Replicas: pointer.Int32(1),
Selector: &metav1.LabelSelector{
MatchLabels: defaultLabels,
MatchLabels: map[string]string{
labelManagedBy: "consul-k8s",
"app": "consul",
"chart": "consul-helm",
"heritage": "Helm",
"release": "consul",
},
},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: defaultLabels,
Labels: map[string]string{
labelManagedBy: "consul-k8s",
"app": "consul",
"chart": "consul-helm",
"heritage": "Helm",
"release": "consul",
},

Annotations: map[string]string{
constants.AnnotationGatewayKind: meshGatewayAnnotationKind,
constants.AnnotationMeshInject: "false",
Expand Down Expand Up @@ -281,7 +311,13 @@ func Test_meshGatewayBuilder_Deployment(t *testing.T) {
Weight: 1,
PodAffinityTerm: corev1.PodAffinityTerm{
LabelSelector: &metav1.LabelSelector{
MatchLabels: defaultLabels,
MatchLabels: map[string]string{
labelManagedBy: "consul-k8s",
"app": "consul",
"chart": "consul-helm",
"heritage": "Helm",
"release": "consul",
},
},
TopologyKey: "kubernetes.io/hostname",
},
Expand Down
28 changes: 25 additions & 3 deletions control-plane/gateways/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ func Test_meshGatewayBuilder_Service(t *testing.T) {
config: GatewayConfig{},
gcc: &meshv2beta1.GatewayClassConfig{
Spec: meshv2beta1.GatewayClassConfigSpec{
GatewayClassAnnotationsAndLabels: meshv2beta1.GatewayClassAnnotationsAndLabels{
Labels: meshv2beta1.GatewayClassAnnotationsLabelsConfig{
Set: map[string]string{
"app": "consul",
"chart": "consul-helm",
"heritage": "Helm",
"release": "consul",
},
},
},
Deployment: meshv2beta1.GatewayClassDeploymentConfig{
Container: &meshv2beta1.GatewayClassContainerConfig{
PortModifier: 8000,
Expand All @@ -52,12 +62,24 @@ func Test_meshGatewayBuilder_Service(t *testing.T) {
},
want: &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Labels: defaultLabels,
Labels: map[string]string{
labelManagedBy: "consul-k8s",
"app": "consul",
"chart": "consul-helm",
"heritage": "Helm",
"release": "consul",
},
Annotations: map[string]string{},
},
Spec: corev1.ServiceSpec{
Selector: defaultLabels,
Type: corev1.ServiceTypeLoadBalancer,
Selector: map[string]string{
labelManagedBy: "consul-k8s",
"app": "consul",
"chart": "consul-helm",
"heritage": "Helm",
"release": "consul",
},
Type: corev1.ServiceTypeLoadBalancer,
Ports: []corev1.ServicePort{
{
Name: "wan",
Expand Down

0 comments on commit 6f293d5

Please sign in to comment.