kubernetes
Building
Docker images
Buildpacks.io
Buildpacks are pluggable, modular tools that translate source code into OCI images.
Scaling
[ 0/3 ] Articles
Kubernetes at home with K3s
blogpostKnown errors
Certificate expired
When launching kubectl
an error like this is found
Unable to connect to the server: x509: certificate has expired or is not yet valid
Relevant StackOverflow thread
On kubernetes docs
Solution
incompleteIMPORTANT: This is a compendium of notes during my own troubleshooting. Both of the two times I did this while taking notes there where additional issues, so consider this section a work in progress.
Connect to master node and check certificate expiration date. We can check this error if the current date is after the one marked "Not After".
openssl x509 -in /etc/kubernetes/pki/apiserver.crt -noout -text |grep ' Not '
# Not Before: May 9 21:10:55 2019 GMT
# Not After : May 8 21:10:55 2020 GMT
Run the renew command: kubeadm alpha certs renew apiserver
. Note that apart from the APIserver other certificates can be renewed through this command (apiserver-etcd-client
, apiserver-kubelet-client
, etcd-healthcheck-client
, etcd-peer
, etcd-server
, front-proxy-client
, or simply all
).
kubeadm certs renew apiserver
We can then check if the certificate is now valid for more time. Note that the expiration date has been extended 1 year.
openssl x509 -in /etc/kubernetes/pki/apiserver.crt -noout -text |grep ' Not '
# Not Before: May 9 21:10:55 2019 GMT
# Not After : May 11 09:20:07 2021 GMT
Copy over the updated kubeconfig
cp /etc/kubernetes/admin.conf $HOME/.kube/config