kubernetes + coreos cluster - replacing certificates

荒凉一梦 提交于 2019-12-05 12:09:34

An alternative solution that worked for me was to start a new cluster, and use custom certificates initially, without ever relying on the default temporary credentials.

Following the same tutorial that you used, I made the following changes:

> kube-aws init
> kube-aws render

Before kube-aws up, I created the certificates by following the tutorial. The only issue with the tutorial is that it is geared toward creating new certificates for an existing cluster. Therefore, the following changes are necessary:

  • This line: $ openssl req -x509 -new -nodes -key ca-key.pem -days 10000 -out ca.pem -subj "/CN=kube-ca" needs to be replaced by: $ openssl req -x509 -new -nodes -key ca-key.pem -days 10000 -out ca.pem

  • In the openssl.cnf file, remove the lines that define the IP for the master host, and the loadbalancer, since we don't know what they will be yet. The final openssl.cnf should look something like this:

openssl.cnf

[req]
...
[req_distinguished_name]
[ v3_req ]
...
[alt_names]
DNS.1 = kubernetes
DNS.2 = kubernetes.default
DNS.3 = kubernetes.default.svc
DNS.4 = kubernetes.default.svc.cluster.local
DNS.5 = mydomain.net
IP.1 = ${K8S_SERVICE_IP} # 10.3.0.1
IP.2 = ${MASTER_IP} # 10.0.0.50

I also used the same worker certificate for all the worker nodes.

After the certificates are in place, enter kube-aws up.

I hope this helps you get off the ground

If the keys are indeed getting overwritten by your older ones, you will need to update the CloudFormation template to use the new userdata, which contains the new keys.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks.html

This error message basically means, that the server certificate is signed by an root ca, which the HTTP client doesn't know about. This could be caused by:

  • The server certificate (apiserver.pem) wasn't signed by the ca obtained in the kubeconfig.yml (ca2.pem in your case). You can verify this with: openssl verify -CAfile ca2.pem apiserver.pem. The file apiserver.pem is the certificate passed via --tls-cert-file to the apiserver (see http://kubernetes.io/docs/admin/kube-apiserver/).
  • The server certificate is self-signed. This was done in the how-to, but when the --tls-cert-file and the --tls-private-key-file flags were not set in the apiserver, then it creates self-signed ones.
  • The apiserver.pem doesn't contain the ca certificate (see description of the --tls-cert-file flag in http://kubernetes.io/docs/admin/kube-apiserver/). I am not entirely sure whether the HTTPS server needs to know about the root ca, but this may also cause the problem.

Also this error message doesn't make it clear, whether this is a problem with the client certificate or the server certificate. This means the client certificate has also to be signed by a root ca.

  • The client certificate ca is set by the --client-ca-file flag in the apiserver. Assuming this file is also named ca2.pem, then the client cert can be verified with: openssl verify -CAfile ca2.pem admin2.pem
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!