I have a coreos kubernetes cluster, which I started by following this article:
kubernetes coreos cluster on AWS
TLDR;
> kube-aws init
> kube-aws render
> kube-aws up
Everything worked good and I had a kubernetes coreos cluster on AWS. In the article there is a warning that said:
PRODUCTION NOTE: the TLS keys and certificates generated by kube-aws should not be used to deploy a production Kubernetes cluster. Each component certificate is only valid for 90 days, while the CA is valid for 365 days. If deploying a production Kubernetes cluster, consider establishing PKI independently of this tool first.
So I wanted to replace the default certificates, so I followed the following article:
TLDR;
- created the following self signed certificates: ca.pem, ca-key.pem
- created the certificates for the controller: apiserver.pem, apiserver-key.pem
- Replaced the certificates in the controller with the certificates created above, and rebooted the controller
- created a worker certificates and replaced the certificates in the workers and rebooted them
- configured kubectl to use the new certificates i created and also configured the context and user
Im getting a communication error between kubectl and the cluster, complaining about the certificate
Unable to connect to the server: x509: certificate signed by unknown authority
I also tried to use a signed certificate for kubectl which points to the cluster DNS, I set a DNS for the cluster.
How do I make kubectl communicate with my cluster?
Thanks in advance
EDIT:
My ~/.kube/config looks like this:
apiVersion: v1
clusters:
- cluster:
certificate-authority: /Users/Yariv/Development/workspace/bugeez/bugeez-kubernetes/credentials/ca2.pem
server: https://kubernetes.bugeez.io
name: bugeez
contexts:
- context:
cluster: bugeez
user: bugeez-admin
name: bugeez-system
current-context: bugeez-system
kind: Config
preferences: {}
users:
- name: bugeez-admin
user:
client-certificate: /Users/Yariv/Development/workspace/bugeez/bugeez-kubernetes/credentials/admin2.pem
client-key: /Users/Yariv/Development/workspace/bugeez/bugeez-kubernetes/credentials/admin-key2.pem
EDIT:
All my certificates are signed by ca2.pem, I also validated this fact by running:
openssl verify -CAfile ca2.pem <certificate-name>
EDIT:
What I think is the cause of the error is this: When I switch the keys in the controller and workers, seems like cloud-config is overwriting my new keys with the old ones. How do I replace the keys and also change cloud-config to adapt to my change?