Skip to content
This repository has been archived by the owner on Feb 5, 2020. It is now read-only.

tls: add aggregated apiserver certs. #2850

Merged
merged 1 commit into from
Feb 6, 2018
Merged

tls: add aggregated apiserver certs. #2850

merged 1 commit into from
Feb 6, 2018

Conversation

diegs
Copy link
Contributor

@diegs diegs commented Jan 29, 2018

This adds a new CA and certificate pair to support running aggregated
api-servers in the cluster. This is required for deploying
metrics-server (heapster replacement) and other aggregated api-server
components that will start to appear in 1.9+.

In the self-signed scenario these are derived from the kube_ca, which
happens to also be the apiserver serving ca. In practice the kube_ca
should be the parent of both this CA and the one that is used by the
--tls-ca-file flag in the apiserver. I added a TODO to fix that when
we implement the "single CA is the parent of all generated certs" change
for track 2.

@diegs
Copy link
Contributor Author

diegs commented Jan 29, 2018

cc @brancz

organization = "kube-master"
}

dns_names = [
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this should be used as a serving cert, just a client cert.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, remove the dns names and ip addresses?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. Allowed usages bellow should also drop "server_auth"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

private_key_pem = "${tls_private_key.apiserver_proxy.private_key_pem}"

subject {
common_name = "kube-apiserver-proxy"
Copy link
Contributor

Choose a reason for hiding this comment

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

Common name has to match the value specified by:

--requestheader-allowed-names

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I thought that was the CN in the CA. The docs are very unclear, and the metrics server appeared to be working. But I'll change the flag to this one in the operators-PR.

@diegs
Copy link
Contributor Author

diegs commented Jan 29, 2018

@cpanato @enxebre any hints on how to debug the failed custom_tls tests? Do I need to generate the new certs somehow? The user_provided_tls stuff in the smoke test directory doesn't have much documentation.

@diegs
Copy link
Contributor Author

diegs commented Jan 29, 2018

Ah, think I found the change I needed to make for smoke tests.

@diegs
Copy link
Contributor Author

diegs commented Jan 30, 2018

zomg ruby linter doesn't like methods with more than 30 lines?

@diegs diegs requested a review from squat January 30, 2018 01:50
@diegs
Copy link
Contributor Author

diegs commented Jan 30, 2018

I think azure flaked.

@diegs
Copy link
Contributor Author

diegs commented Jan 30, 2018

In azure it looks like some of the pods never came up, not sure if this is typical:

        	smoke_test.go:119: retrying in 3s
        	cluster_test.go:99: pod tectonic-system/alm-operator-56d954fc68-77b9q not running
        	cluster_test.go:99: pod tectonic-system/catalog-operator-78d4cdb8db-ksj4x not running
        	cluster_test.go:99: pod tectonic-system/prometheus-k8s-0 not running
        	cluster_test.go:99: pod tectonic-system/prometheus-operator-7445bc9f7f-gtml6 not running
        	cluster_test.go:99: pod tectonic-system/tectonic-monitoring-auth-prometheus-7746db47d8-qzt9j not running
        	smoke_test.go:118: failed with error: pods are not all ready
        	smoke_test.go:119: retrying in 3s
        	cluster_test.go:83: Timed out waiting for pods to be ready.

@brancz
Copy link
Contributor

brancz commented Jan 30, 2018

On a high level this looks good to me. I'm wondering how aggregated APIs are going to get their server certs, seems like we want something like the certificates API, but for multi CA (kubernetes components, etcd, aggregated APIs,...). Do we have a solid idea how to solve that?

@ericchiang
Copy link
Contributor

On a high level this looks good to me. I'm wondering how aggregated APIs are going to get their server certs, seems like we want something like the certificates API, but for multi CA (kubernetes components, etcd, aggregated APIs,...). Do we have a solid idea how to solve that?

Aggregated API servers get to advertise their own CA, which the API server then trusts https://github.com/kubernetes/kubernetes/blob/v1.9.2/staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/types.go#L56

So the metrics server can generate a self-signed one and that should be fine.

@brancz
Copy link
Contributor

brancz commented Jan 30, 2018

lgtm

@diegs
Copy link
Contributor Author

diegs commented Jan 30, 2018

@brancz @ericchiang plot twist: apparently we don't want the metrics server to generate self-signed certs?

kubernetes-sigs/metrics-server#37 (comment)

@diegs
Copy link
Contributor Author

diegs commented Jan 30, 2018

retest this please. azure and bare metal.

@diegs
Copy link
Contributor Author

diegs commented Jan 30, 2018

All tests passed!

@diegs
Copy link
Contributor Author

diegs commented Jan 31, 2018

May I please get a review on the installer side? @enxebre? @squat?

@ericchiang
Copy link
Contributor

ericchiang commented Feb 1, 2018

We probably want to provide the self-signed certs through a secret.

Mentioned this on JIRA, but I'm going to follow up on kubernetes/kubernetes#54960 to see if there are any specific concerns around this strategy. I'm not familiar with the subtitles.

aggregator_ca_cert_pem = "${module.kube_certs.aggregator_ca_cert_pem}"
apiserver_cert_pem = "${module.kube_certs.apiserver_cert_pem}"
apiserver_key_pem = "${module.kube_certs.apiserver_key_pem}"
apiserver_proxy_cert_pem = "${module.kube_certs.apiserver_cert_pem}"
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't this need to be module.kube_certs.apiserver_proxy_cert_pem and module.kube_certs.apiserver_proxy_key_pem? same question for all platforms

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch, thank you! Changed to the correct value.

@@ -0,0 +1,35 @@
# Kubernetes Aggregated API Server CA (resources/generated/tls/aggregator-ca.crt)
#
# TODO(diegs): this should be a sibling of the `--tls-ca-file` CA. However the
Copy link
Member

Choose a reason for hiding this comment

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

shall we add same todo in contrib module?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@diegs
Copy link
Contributor Author

diegs commented Feb 2, 2018

retest this please. govcloud and azure.

@diegs
Copy link
Contributor Author

diegs commented Feb 2, 2018

govcloud:

Error: Error applying plan:

1 error(s) occurred:

* aws_vpn_gateway.vpg (destroy): 1 error(s) occurred:

* aws_vpn_gateway.vpg: IncorrectState: The VPN gateway is in use.
	status code: 400, request id: 1d88c56e-d27f-4c6f-a01e-7f6e83624ab8

azure:

some pods never came up.

@diegs
Copy link
Contributor Author

diegs commented Feb 2, 2018

retest this please.

@diegs
Copy link
Contributor Author

diegs commented Feb 2, 2018

I give up.

@cpanato
Copy link
Contributor

cpanato commented Feb 3, 2018

all green now @diegs

value = "${tls_locally_signed_cert.aggregator_ca.cert_pem}"
}

output "aggregator_ca_key_pem" {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious: why does this module output an aggregator_ca_key but not the tls/kube/user-provided?

It seems like this output is not consumed anywhere either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, it's not a required output. Got copy-paste happy. Removed.

"digital_signature",
"client_auth",
]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this module also create local files for the aggregated ca key and crt just like modules/tls/kube/self-signed does? i.e.:

resource "local_file" "aggregator_ca_key" {
...
}
resource "local_file" "aggregator_ca_crt" {
...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

@diegs diegs left a comment

Choose a reason for hiding this comment

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

@squat thanks for catching those mistakes, should be fixed now.

value = "${tls_locally_signed_cert.aggregator_ca.cert_pem}"
}

output "aggregator_ca_key_pem" {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, it's not a required output. Got copy-paste happy. Removed.

"digital_signature",
"client_auth",
]
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

squat
squat previously approved these changes Feb 6, 2018
@squat
Copy link
Contributor

squat commented Feb 6, 2018

dang, we have some merge conflicts. Conflicts are only on markdown files. All tests have passed for TF. I'm removing the labels and pushing an extra commit to fix the conflicts with the docs.

@cpanato
Copy link
Contributor

cpanato commented Feb 6, 2018

ok

squat added a commit to squat/tectonic-docs that referenced this pull request Feb 6, 2018
This commit ports the documentation that was originally part of
coreos/tectonic-installer#2850.
This adds a new CA and certificate pair to support running aggregated
api-servers in the cluster. This is required for deploying
metrics-server (heapster replacement) and other aggregated api-server
components that will start to appear in 1.9+.

In the self-signed scenario these are derived from the kube_ca, which
happens to also be the apiserver serving ca. In practice the kube_ca
should be the parent of both this CA and the one that is used by the
--tls-ca-file flag in the apiserver. I added a TODO to fix that when
we implement the "single CA is the parent of all generated certs" change
for track 2.
@squat
Copy link
Contributor

squat commented Feb 6, 2018

@diegs: the tls module docs you wrote have been PRd to coreos/tectonic-docs#135 now that they no longer exist in this repo since #2678

@squat squat merged commit 96ca618 into coreos:master Feb 6, 2018
@diegs diegs deleted the crt branch February 6, 2018 16:34
@diegs
Copy link
Contributor Author

diegs commented Feb 6, 2018

@squat thanks!

abhinavdahiya pushed a commit to abhinavdahiya/tectonic-installer that referenced this pull request Feb 6, 2018
tls: add aggregated apiserver certs.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants