Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

HTTPRoute automatic service intention config entry  #532

@joshRooz

Description

@joshRooz

Overview of the Issue

Applying an HTTPRoute automatically creates an accompanying service intention config entry for the destination service directly through the Consul API.

Attempting to manage the service intentions for the same destination service afterwards, using a ServiceIntentions custom resource, will silently fail as the Consul K8s controller responsible for reconciliation of ServiceIntentions does not merge an existing config entry.

Reproduction Steps

  1. Create API-Gateway CRDs
  2. helm install consul ...
  3. Deploy API Gateway resource agw
  4. Deploy public-api service
  5. Create HTTPRoute for public-api
  6. Deploy frontend service
  7. Attempt to create ServiceIntentions for public-api to add frontend to sources array

Logs

Logs

config entry output after HTTPRoute creation:

#consul config read -kind=service-intentions -namespace=hashicups -name=public-api
{
    "Kind": "service-intentions",
    "Name": "public-api",
    "Partition": "default",
    "Namespace": "hashicups",
    "Sources": [
        {
            "Name": "agw",
            "Partition": "default",
            "Namespace": "api-gateway",
            "Action": "allow",
            "Precedence": 9,
            "Type": "consul",
            "Description": "Allow traffic from Consul API Gateway. Reconciled by controller at 2023-03-10T23:29:36Z."
        }
    ],
    "CreateIndex": 7252,
    "ModifyIndex": 7252
}

output from 'kubectl logs':

consul-connect-injector-7c8985d9fb-cpq6s sidecar-injector 2023-03-10T23:38:34.028Z	ERROR	controller.serviceintentions	Reconciler error	{"reconciler group": "consul.hashicorp.com", "reconciler kind": "ServiceIntentions", "name": "public-api", "namespace": "hashicups", "error": "config entry already exists in Consul"}
consul-connect-injector-7c8985d9fb-cpq6s sidecar-injector sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
consul-connect-injector-7c8985d9fb-cpq6s sidecar-injector 	/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.10.2/pkg/internal/controller/controller.go:266
consul-connect-injector-7c8985d9fb-cpq6s sidecar-injector sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
consul-connect-injector-7c8985d9fb-cpq6s sidecar-injector 	/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.10.2/pkg/internal/controller/controller.go:227
consul-connect-injector-7c8985d9fb-cpq6s sidecar-injector 2023-03-10T23:38:34.055Z	ERROR	controller.serviceintentions	sync failed	{"request": "hashicups/public-api", "error": "config entry already exists in Consul"}

Expected behavior

Capability to create an HTTPRoute while maintaining the ability to define [additional] service intentions for the same destination service through the ServiceIntentions CRD.

Environment details

  • consul-api-gateway version: 0.5.1
  • configuration used to deploy the gateway controller:
    # consul 1.0.4 helm chart
    apiGateway:
      enabled: true
      image: hashicorp/consul-api-gateway:0.5.1
      imageEnvoy: envoyproxy/envoy:v1.24.2
  • Kubernetes version: v1.23.12
  • Consul Server version: hashicorp/consul-enterprise:1.14.4-ent-ubi
  • Consul-K8s version: hashicorp/consul-k8s-control-plane:1.0.4-ubi
  • Cloud Provider: OpenShift 4.10.40
  • Networking CNI plugin in use: OpenShift SDN with Multus + Consul CNI

Metadata

Metadata

Assignees

No one assigned

    Labels

    runtime/kubernetesDeployed on self-managed Kubernetestype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions