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

Inject-connect command: deprecate the -consul-ca-cert flag #217

Merged
merged 1 commit into from
Mar 3, 2020

Conversation

ishustava
Copy link
Contributor

Now that the inject-connect command has Consul's HTTP flags, we should use only one flag to control TLS communications with the local agents.

Currently, we set both flags. The -consul-ca-cert flag sets the CA cert for the init container, the envoy proxy sidecar, and the lifecycle sidecar, and they use that CA to talk to their local agent.

The -ca-file flag controls the CA cert that is used by the handler to talk to its local agent (this happens only if namespaces are enabled).

Although these agents could be on different hosts, the CA that singed their certificates must be the same, so there is no need to have two different flags.

@ishustava ishustava added the area/connect Related to Connect service mesh, e.g. injection label Feb 21, 2020
@@ -62,7 +62,7 @@ type Command struct {
http *flags.HTTPFlags

consulClient *api.Client
clientset *kubernetes.Clientset
clientset kubernetes.Interface
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing this for tests. Also we should be using interfaces rather than structs.

@@ -282,7 +290,7 @@ func (c *Command) certWatcher(ctx context.Context, ch <-chan cert.Bundle, client
// The CA Bundle value must be base64 encoded
value := base64.StdEncoding.EncodeToString(bundle.CACert)

_, err := clientset.Admissionregistration().
_, err := clientset.AdmissionregistrationV1beta1().
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Admissionregistration() is deprecated. Under the hood, both functions return the same client: https://github.com/kubernetes/client-go/blob/7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65/kubernetes/clientset.go#L161-L170. I'll try to update the client version in a separate PR.

},
{
flags: []string{"-consul-k8s-image", "foo", "-ca-file", "bar"},
expErr: "Error reading Consul's CA cert file",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
expErr: "Error reading Consul's CA cert file",
expErr: "Error reading Consul's CA cert file \"bar\"",

var err error
consulCACert, err = ioutil.ReadFile(cfg.TLSConfig.CAFile)
if err != nil {
c.UI.Error(fmt.Sprintf("Error reading Consul's CA cert file %s: %s", c.flagConsulCACert, err))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
c.UI.Error(fmt.Sprintf("Error reading Consul's CA cert file %s: %s", c.flagConsulCACert, err))
c.UI.Error(fmt.Sprintf("Error reading Consul's CA cert file %q: %s", c.flagConsulCACert, err))

I think having the filename quoted might make the error clearer that the filename is coming from an arg.

Now that the inject-connect command has Consul's HTTP flags,
we should use only one flag to control TLS communications with the local agents.

Currently, we set both flags. The -consul-ca-cert flag sets the
CA cert for the init container, the envoy proxy sidecar, and the lifecycle
sidecar, and they use that CA to talk to their local agent.

The -ca-file flag controls the CA cert that is used by the handler
to talk to its local agent (this happens only if namespaces are enabled).

Although these agents could be on different hosts,
the CA that singed their certificates must be the same,
so there is no need to have two different flags.
@ishustava ishustava force-pushed the connect-inject/deprecate-consul-ca-flag branch from c7d3706 to d8ae2a5 Compare March 3, 2020 18:20
@ishustava ishustava merged commit 7792238 into master Mar 3, 2020
@ishustava ishustava deleted the connect-inject/deprecate-consul-ca-flag branch March 3, 2020 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connect Related to Connect service mesh, e.g. injection
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants