$.status.containerStatuses[?(@.name == 'xxx-container')].restartCount
$.items[*].status.addresses[?(@.type=="InternalIP")].address
$[*].metadata.name
kubectl get events -A --sort-by=.metadata.creationTimestamp
kubectl api-resources --namespaced -o name
spec:
nodeName: my-node
spec:
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
Command:
kubectl get pods -L app,run
Note: This prevent using -o yaml
or describe
to just read a well-known label.
kubectl run my-pod \
--image=nginx:alpine \
--requests "cpu=10m,memory=10Mi" \
-o yaml \
--dry-run=client > my-pod.yaml
kubectl expose pod my-pod \
--name my-pod-service \
--type=NodePort \
--port 80
Command:
openssl x509 \
-noout \
-text \
-in /etc/kubernetes/pki/XXX.crt | grep Validity -A2
Output:
Validity
Not Before: Xxx xx xx:xx:xx xxxx GMT
Not After : Xxx xx xx:xx:xx xxxx GMT
Command:
kubeadm certs check-expiration
Output:
[check-expiration] Reading configuration from the cluster...
[check-expiration] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY EXTERNALLY MANAGED
admin.conf Xxx xx, xxxx xx:xx UTC xxxd no
apiserver Xxx xx, xxxx xx:xx UTC xxxd ca no
apiserver-etcd-client Xxx xx, xxxx xx:xx UTC xxxd etcd-ca no
apiserver-kubelet-client Xxx xx, xxxx xx:xx UTC xxxd ca no
controller-manager.conf Xxx xx, xxxx xx:xx UTC xxxd no
etcd-healthcheck-client Xxx xx, xxxx xx:xx UTC xxxd etcd-ca no
etcd-peer Xxx xx, xxxx xx:xx UTC xxxd etcd-ca no
etcd-server Xxx xx, xxxx xx:xx UTC xxxd etcd-ca no
front-proxy-client Xxx xx, xxxx xx:xx UTC xxxd front-proxy-ca no
scheduler.conf Xxx xx, xxxx xx:xx UTC xxxd no
CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED
ca Xxx xx, xxxx xx:xx UTC xy no
etcd-ca Xxx xx, xxxx xx:xx UTC xy no
front-proxy-ca Xxx xx, xxxx xx:xx UTC xy no
Command:
kubeadm certs renew apiserver
openssl x509 -noout -text -in /var/lib/kubelet/pki/kubelet-client-current.pem | grep Issuer
openssl x509 -noout -text -in /var/lib/kubelet/pki/kubelet.cert | grep Issuer
/etc/systemd/system/kubelet.service.d/10-kubeadm.conf
Get arguments:
cat /etc/kubernetes/manifests/kube-apiserver.yaml | grep etcd
Output:
- --etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt
- --etcd-certfile=/etc/kubernetes/pki/apiserver-etcd-client.crt
- --etcd-keyfile=/etc/kubernetes/pki/apiserver-etcd-client.key
- --etcd-servers=https://127.0.0.1:2379
Command:
ETCDCTL_API=3 etcdctl snapshot save /tmp/etcd-backup.db \
--cacert /etc/kubernetes/pki/etcd/ca.crt \
--cert /etc/kubernetes/pki/etcd/server.crt \
--key /etc/kubernetes/pki/etcd/server.key
Command:
ETCDCTL_API=3 etcdctl snapshot restore /tmp/etcd-backup.db \
--data-dir /var/lib/etcd-backup
Change volume in static etcd
pod:
vim /etc/kubernetes/manifests/etcd.yaml
volumes:
- hostPath:
path: /var/lib/etcd-backup
type: DirectoryOrCreate
name: etcd-data