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

Support Consul namespaces in consul-k8s #197

Merged
merged 1 commit into from
Feb 21, 2020
Merged

Support Consul namespaces in consul-k8s #197

merged 1 commit into from
Feb 21, 2020

Conversation

adilyse
Copy link
Contributor

@adilyse adilyse commented Feb 5, 2020

Placeholder PR for namespaces feature branch.

@ishustava
Copy link
Contributor

FYI: we'll need #202 before we merge this. Otherwise, envoy fails to start because the bootstrap config has values that aren't supported in our default version.

@adilyse adilyse marked this pull request as ready for review February 20, 2020 08:24
@adilyse adilyse requested a review from a team February 20, 2020 08:24
go.mod Outdated Show resolved Hide resolved
Copy link
Member

@lkysow lkysow left a comment

Choose a reason for hiding this comment

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

🎉 only 7000 lines of code, no big deal 😆

@adilyse adilyse force-pushed the namespace branch 2 times, most recently from 3c9da96 to 08038cb Compare February 20, 2020 23:12
@adilyse
Copy link
Contributor Author

adilyse commented Feb 20, 2020

Personally I find the Files changed: 36 even more shocking 🙃

This was a major change to the internals of most of the consul-k8s
commands. As part of the work, there were other changes that affect
folks not using namespaces as well. Details are broken down by process.

--> Catalog Sync

Namespaces:

This allows the catalog sync process to support Consul namespaces,
an Enterprise feature. It supports no namespaces (OSS), syncing k8s
services into a single Consul namespace and mirroring k8s namespaces
in Consul with an optional prefix.

Beyond namespaces:

It updates the settings for which k8s namespaces to sync. These
are now based on allow and deny lists, rather than the two previous
options of (1) a single k8s namespace, or (2) all k8s namespaces
except `kube-system`. This change is backwards compatible, however
if a user upgrades consul-k8s without upgrading the Helm chart as well,
there will be a slight difference in behavior for (2) in that it won't
automatically exclude `kube-system` on its own.

The underlying call to Consul to retrieve services has been switched
to retrieve services by the synthetic node `k8s-sync`. This causes a
slight behavior change in that we will no longer remove services with
the `ConsulK8STag` if it's not attached to the `k8s-sync` node.

Fixes a hot loop bug when getting an error from Consul when retrieving
service information.

Moves `c.sigCh` initialization to the init method to fix a race
condition occurring in tests.

Adds additional debug logging to resource.go and syncer.go.

--> ACL Bootstrapping

Namespaces:

Updates all policies that are created by the bootstrapper to include
namespace permissions as needed. Updates the Connect Injector's AuthMethod
to reflect the namespace registration settings (single destination,
mirroring, mirroring with prefix).

When namespaces are enabled, all policies and tokens for consul-k8s
components are being created within the `Consul` default namespace.
This is required for any cross-namespace permissions, and in the case
of catalog sync and the connect injector, the ability to create
Consul namespaces. Additionally, a specific cross-namespace policy
is created so that it can be attached to all created namespaces
to allow service discovery between Consul namespaces.

This makes sure all policies are updated if the acl bootstrapping
job is rerun, which happens on a helm upgrade. This allows someone
upgrading to a version that includes namespaces or changes their
namespacing config to also update the policies associated with
their acl tokens to reflect that change.

Beyond namespaces:

This separates auth method and binding rule checking logic.
If it exists already, binding rules are now always updated, which
supports config updates.

To make it easier to work with the code, it now uses a shared logger
and has been split into smaller files.

Updates mesh gateway acl policies with the correct permissions

-->  Connect Injector

Namespaces:

This adds namespace config options for registering injected
services into a single namespace as well as mirroring k8s
namespaces in Consul with an optional prefix.

It adds functionality to check for Consul namespace existence
and create new namespaces.

Service and proxy registration as well as service-defaults
have been updated to be namespace aware.

Adds additional parsing of the upstream annotation to support namespaces.
The format of the annotation becomes:

    `service_name.namespace:port:optional_datacenter`

The `service_name.namespace` is only parsed if namespaces are enabled. If
someone has added a `.namespace` in that case, the upstream will not work
correctly, as is the case where someone has put in an incorrect service
name, port or datacenter.

The upstream definitions in the service registration file includes the
namespace from the annotation. If it wasn't present in the annotation, no
namespace is included. This will automatically fallback to assuming the
service is in the same namespace as the service defining the upstream.

Beyond namespaces:

Updates the default envoy version to 1.13.0.
@adilyse adilyse merged commit 2373e85 into master Feb 21, 2020
@adilyse adilyse deleted the namespace branch February 21, 2020 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants