Skip to content

Commit

Permalink
Add gateway-kind and gateway-consul-service-name annotations to API g…
Browse files Browse the repository at this point in the history
…ateway pods
  • Loading branch information
nathancoleman authored and sarahalsmiller committed Jan 16, 2024
1 parent c2bed3e commit 98b2dd9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 8 additions & 5 deletions control-plane/api-gateway/gatekeeper/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ package gatekeeper
import (
"context"

"github.com/hashicorp/consul-k8s/control-plane/api-gateway/common"
"github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1"
"k8s.io/apimachinery/pkg/types"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/hashicorp/consul-k8s/control-plane/api-gateway/common"
"github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/constants"
)

const (
Expand Down Expand Up @@ -110,7 +111,9 @@ func (g *Gatekeeper) deployment(gateway gwv1beta1.Gateway, gcc v1alpha1.GatewayC
ObjectMeta: metav1.ObjectMeta{
Labels: common.LabelsForGateway(&gateway),
Annotations: map[string]string{
"consul.hashicorp.com/connect-inject": "false",
constants.AnnotationInject: "false",
constants.AnnotationGatewayConsulServiceName: gateway.Name,
constants.AnnotationGatewayKind: "api-gateway",
},
},
Spec: corev1.PodSpec{
Expand Down
6 changes: 5 additions & 1 deletion control-plane/api-gateway/gatekeeper/gatekeeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/hashicorp/consul-k8s/control-plane/api-gateway/common"
"github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/constants"
)

var (
Expand Down Expand Up @@ -1007,6 +1008,7 @@ func validateResourcesExist(t *testing.T, client client.Client, resources resour
require.NotNil(t, actual.Spec.Replicas)
require.EqualValues(t, *expected.Spec.Replicas, *actual.Spec.Replicas)
}
require.Equal(t, expected.Spec.Template.ObjectMeta.Annotations, actual.Spec.Template.ObjectMeta.Annotations)

// Ensure there is a consul-dataplane container dropping ALL capabilities, adding
// back the NET_BIND_SERVICE capability, and establishing a read-only root filesystem
Expand Down Expand Up @@ -1189,7 +1191,9 @@ func configureDeployment(name, namespace string, labels map[string]string, repli
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
Annotations: map[string]string{
"consul.hashicorp.com/connect-inject": "false",
constants.AnnotationInject: "false",
constants.AnnotationGatewayConsulServiceName: name,
constants.AnnotationGatewayKind: "api-gateway",
},
},
Spec: corev1.PodSpec{
Expand Down

0 comments on commit 98b2dd9

Please sign in to comment.