certificates

[!TIP]

certificates

generic

  • certificates for CA

    • ca-key.pem

    • ca.pem

    • kubernetes-key.pem

    • kubernetes.pem

    • kube-proxy.pem

    • kube-proxy-key.pem

    • admin.pem

    • admin-key.pem

  • certificate component

    SERVICES
    CERTIFICATES

    etcd

    ca.pem, kubernetes-key.pem, kubernetes.pem

    kube-apiserver

    ca.pem, kubernetes-key.pem, kubernetes.pem

    kubelet

    ca.pem

    kube-proxy

    ca.pem, kube-proxy-key.pem, kube-proxy.pem

    kubectl

    ca.pem, admin-key.pem, admin.pem

    kube-controller-manager

    ca-key.pem, ca.pem

etcd

kube-apiserver

show secrets tls.crt

[!TIP|label:references:]

create secrets

  • by command

  • by yaml

duplicate secrets to the other ns

show tls

show tls in all namespace

show tls.crt

  • or

manually update server.crt and server.key

[!TIP|label:see also:]

renew both certificates and kubeconfig

check info

crt

  • or

  • or

  • or

  • or

backup

clean environment

restore backup

TBD

v1.12.3

[!TIP]

for [stacked etcd topology](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/ha-topology/#stacked-etcd-topology)

references:

renew certificates

Available Commands:

commands
comments

all

renew all available certificates

apiserver

Generates the certificate for serving the kubernetes API

apiserver-etcd-client

Generates the client apiserver uses to access etcd

apiserver-kubelet-client

Generates the Client certificate for the API server to connect to kubelet

front-proxy-client

Generates the client for the front proxy

etcd-healthcheck-client

Generates the client certificate for liveness probes to healtcheck etcd

etcd-peer

Generates the credentials for etcd nodes to communicate with each other

etcd-server

Generates the certificate for serving etcd

  • i.e.

generate new certificates

commands
comments

all

Generates all PKI assets necessary to establish the control plane

apiserver

Generates the certificate for serving the kubernetes API

apiserver-etcd-client

Generates the client apiserver uses to access etcd

apiserver-kubelet-client

Generates the Client certificate for the API server to connect to kubelet

ca

Generates the self-signed kubernetes CA to provision identities for other kuberenets components

etcd-ca

Generates the self-signed CA to provision identities for etcd

etcd-healthcheck-client

Generates the client certificate for liveness probes to healtcheck etcd

etcd-peer

Generates the credentials for etcd nodes to communicate with each other

etcd-server

Generates the certificate for serving etcd

front-proxy-ca

Generates the self-signed CA to provision identities for front proxy

front-proxy-client

Generates the client for the front proxy

sa

Generates a private key for signing service account tokens along with its public key

renew

Renews certificates for a Kubernetes cluster

  • re-generate /etc/kubernetes/pki/etcd/*.crt for modify X509 Subject Alternative Name:

    • check X509 Subject Alternative Name

    • check expire date

renew kubeconfig

renew all kubeconfig

Available Commands:

commands
comments

all

Generates all kubeconfig files necessary to establish the control plane and the admin kubeconfig file

admin

Generates a kubeconfig file for the admin to use and for kubeadm itself

controller_manager

Generates a kubeconfig file for the controller manager to use

kubelet

Generates a kubeconfig file for the kubelet to use. Please note that this should be used *only* for bootstrapping purposes

scheduler

Generates a kubeconfig file for the scheduler to use

user

Outputs a kubeconfig file for an additional user

update ~/.kube/config

sync to peer controllers

[!NOTE|label:login to peer controller first]

restart kubelet

kill all services

restart service

v1.15.3

reference:

[!TIP] for external etcd topology

renew certificates

[!NOTE|label:in major controller] NOTE: major controller is the controller node bind with load balance ip. the key controller node picked by keepalived. check it by using:

references: - [kubeadm-conf.yaml](https://raw.githubusercontent.com/marslo/mytools/controller/kubernetes/init/kubeadm-conf.yaml)

CERTIFICATE FILES
PATH
  • apiserver.crt

  • apiserver.key

  • apiserver-kubelet-client.crt

  • apiserver-kubelet-client.key

  • front-proxy-client.crt

  • front-proxy-client.key

/etc/kubernetes/pki

  • or

sync to peer controllers

[!NOTE] sync renewed certificates to peer controllers

  • verify

    • or

renew kubeconfig

CONFIG FILES
PATH
  • admin.conf

  • kubelet.conf

  • controller-manager.conf

  • scheduler.conf

/etc/kubernetes/

setup ~/.kube/config

configuration file
path

config

~/.kube

  • or

restart kubelet service

  • verify

verify

via kubernetes api (load.balance.ip.address:6443)

using new certificate for apiserver

renew work node

backup

restart kubelet

certificates generation

pfx

renew kubeconfig only

basic environment

[!TIP]

renew kubeconfig

references:

generate new certificate (csr)

  • or

signing the certificate via ca.crt

  • result

[!TIP]

renew via kubeadm alpha

  • 1.15-

    • renew all certs

    • re-generate all certs

  • v1.15+

    • renew all certs

renew via kubectl config

reference:

renew via base64 manually

vaildate

more details

reference:

  • conf:

    • certs

    • about system:masters

tricky

modify default certificate to 10 years

[!NOTE|label:references:]

reference

[!TIP] reference:

required certificates

DEFAULT CN
PARENT CA
O (IN SUBJECT)
KIND
HOSTS (SAN)

kube-etcd

etcd-ca

-

server, client

hostname Host_IP localhost 127.0.0.1

kube-etcd-peer

etcd-ca

-

server, client

hostname Host_IP localhost 127.0.0.1

kube-etcd-healthcheck-client

etcd-ca

-

client

-

kube-apiserver-etcd-client

etcd-ca

system:masters

client

-

kube-apiserver

kubernetes-ca

-

server

hostname, Host_IP, advertise_IP, [1]

kube-apiserver-kubelet-client

kubernetes-ca

system:masters

client

-

front-proxy-client

kubernetes-front-proxy-ca

-

client

-

DEFAULT CN
RECOMMENDED KEY PATH
RECOMMENDED CERT PATH
COMMAND
KEY ARGUMENT
CERT ARGUMENT

etcd-ca

etcd/ca.key

etcd/ca.crt

kube-apiserver

-

--etcd-cafile

kube-apiserver-etcd-client

apiserver-etcd-client.key

apiserver-etcd-client.crt

kube-apiserver

--etcd-keyfile

--etcd-certfile

kubernetes-ca

ca.key

ca.crt

kube-apiserver

-

--client-ca-file

kubernetes-ca

ca.key

ca.crt

kube-controller-manager

--cluster-signing-key-file

--client-ca-file --root-ca-file --cluster-signing-cert-file

kube-apiserver

apiserver.key

apiserver.crt

kube-apiserver

--tls-private-key-file

--tls-cert-file

kube-apiserver-kubelet-client

apiserver-kubelet-client.key

apiserver-kubelet-client.crt

kube-apiserver

--kubelet-client-key

--kubelet-client-certificate

front-proxy-ca

front-proxy-ca.key

front-proxy-ca.crt

kube-apiserver

-

--requestheader-client-ca-file

front-proxy-ca

front-proxy-ca.key

front-proxy-ca.crt

kube-controller-manager

-

--requestheader-client-ca-file

front-proxy-client

front-proxy-client.key

front-proxy-client.crt

kube-apiserver

--proxy-client-key-file

--proxy-client-cert-file

etcd-ca

etcd/ca.key

etcd/ca.crt

etcd

-

--trusted-ca-file --peer-trusted-ca-file

kube-etcd

etcd/server.key

etcd/server.crt

etcd

--key-file

--cert-file

kube-etcd-peer

etcd/peer.key

etcd/peer.crt

etcd

--peer-key-file

--peer-cert-file

etcd-ca

-

etcd/ca.crt

etcdctl

-

--cacert

kube-etcd-healthcheck-client

etcd/healthcheck-client.key

etcd/healthcheck-client.crt

etcdctl

--key

--cert

FILENAME
CREDENTIAL NAME
DEFAULT CN
O (IN SUBJECT)

admin.conf

default-admin

kubernetes-admin

system:masters

kubelet.conf

default-auth

system:node:<nodeName> (see note)

system:nodes

controller-manager.conf

default-controller-manager

system:kube-controller-manager

-

scheduler.conf

default-scheduler

system:kube-scheduler

-

files are used as follows

FILENAME
COMMAND
COMMENT

admin.conf

kubectl

Configures administrator user for the cluster

kubelet.conf

kubelet

One required for each node in the cluster.

controller-manager.conf

kube-controller-manager

Must be added to manifest in manifests/kube-controller-manager.yaml

scheduler.conf

kube-scheduler

Must be added to manifest in manifests/kube-scheduler.yaml

Last updated

Was this helpful?