Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when mesh gateway mode not set #421

Merged
merged 4 commits into from
Jan 25, 2021
Merged

Error when mesh gateway mode not set #421

merged 4 commits into from
Jan 25, 2021

Conversation

lkysow
Copy link
Member

@lkysow lkysow commented Jan 21, 2021

To prevent users from being confused as to why their traffic isn't being
routed, give an error on connect injection if they've configured an
upstream to use a datacenter but they don't have a proxy-defaults config
with mesh gateway mode set to local or remote.

NOTE: No ACL changes need to be made because proxy-defaults does not require an ACL for reads (https://www.consul.io/api-docs/config#get-configuration)

How I tested:

  • Install with:

    global:
      name: consul
      imageK8S: ghcr.io/lkysow/consul-k8s-dev:jan20
      acls:
        manageSystemACLs: true
    connectInject:
      enabled: true
    controller:
      enabled: true
    server:
      replicas: 1
  • Apply

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: static-client
    ---
    apiVersion: v1
    kind: Pod
    metadata:
      name: luke
      annotations:
        "consul.hashicorp.com/connect-inject": "true"
        "consul.hashicorp.com/connect-service-upstreams": "static-server:1234:dc2"
    spec:
      containers:
        - name: static-client
          image: tutum/curl:latest
          command: [ "/bin/sh", "-c", "--" ]
          args: [ "while true; do sleep 30; done;" ]
          ports:
            - containerPort: 8080
              name: http
      serviceAccountName: static-client
  • Errors with

    Error from server: error when creating "scratch/static-client.yaml": admission webhook "consul-connect-injector.consul.hashicorp.com" denied the request: Error configuring injection init container: upstream "static-server:1234:dc2" is invalid: there is no ProxyDefaults config to set mesh gateway mode
    
  • Apply

    apiVersion: consul.hashicorp.com/v1alpha1
    kind: ProxyDefaults
    metadata:
      name: global
    spec:
      meshGateway:
        mode: local
  • Re-apply static-client, it will schedule

Checklist:

  • Tests added
  • CHANGELOG entry added (HashiCorp engineers only, community PRs should not add a changelog entry)

@lkysow lkysow requested review from a team, kschoche and thisisnotashwin and removed request for a team January 22, 2021 20:54
Copy link
Contributor

@thisisnotashwin thisisnotashwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EXCELLENT!

Copy link
Contributor

@kschoche kschoche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a super nice fix to have, great work!

To prevent users from being confused as to why their traffic isn't being
routed, give an error on connect injection if they've configured an
upstream to use a datacenter but they don't have a proxy-defaults config
with mesh gateway mode set to local or remote.
@lkysow lkysow merged commit 4ef6eb8 into master Jan 25, 2021
@lkysow lkysow deleted the mesh-gateway-mode branch January 25, 2021 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants