# 模拟pod被删 root@k8s-master-50:/data/velero# kubectl delete pod net-test1 -n myserver pod "net-test1" deleted # 开始恢复pod root@k8s-master-50:/data/velero# velero restore create --from-backup dklwj-k8s-25112 --wait \ --kubeconfig=./awsuser.kubeconfig \ --namespace velero-system Restore request "dklwj-k8s-25112-20250102175358" submitted successfully. Waitingfor restore to complete. You may safely press ctrl-c to stop waiting - your restore will continue in the background.
Restore completed with status:Completed. You may check for more information using the commands `velero restore describe dklwj-k8s-25112-20250102175358`and`velero restore logs dklwj-k8s-25112-20250102175358`. # 查看pod root@k8s-master-50:/data/velero# kubectl get pod -n myserver NAMEREADYSTATUSRESTARTSAGE net-test1 1/1Running0 44s
# 删除myserver的所有控制器以及service root@k8s-master-50:/data/velero# kubectl delete deployment tomcat-app1-deployment -n myserver deployment.apps "tomcat-app1-deployment" deleted root@k8s-master-50:/data/velero# kubectl delete service tomcat-app1-service -n myserver service "tomcat-app1-service" deleted root@k8s-master-50:/data/velero# kubectl get deployment -A NAMESPACENAMEREADYUP-TO-DATEAVAILABLEAGE kube-system calico-kube-controllers 1/111 19d kube-system coredns 2/222 19d kubernetes-dashboard dashboard-metrics-scraper 1/111 18d kubernetes-dashboard kubernetes-dashboard 1/111 18d velero-system velero 1/111 13d root@k8s-master-50:/data/velero# kubectl get svc -A NAMESPACENAMETYPECLUSTER-IPEXTERNAL-IPPORT(S) AGE default kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 19d kube-system kube-dns ClusterIP 10.100.0.2 <none> 53/UDP,53/TCP,9153/TCP 19d kubernetes-dashboard dashboard-metrics-scraper ClusterIP 10.100.206.89 <none> 8000/TCP 18d kubernetes-dashboard kubernetes-dashboard NodePort10.100.110.26 <none> 443:30004/TCP 18d # 恢复 root@k8s-master-50:/data/velero# velero restore create --from-backup myserver-backup-20250116165618 --wait \ > --kubeconfig=./awsuser.kubeconfig \ > --namespace velero-system Restore request "myserver-backup-20250116165618-20250116171021" submitted successfully. Waitingfor restore to complete. You may safely press ctrl-c to stop waiting - your restore will continue in the background. . Restore completed with status:Completed. You may check for more information using the commands `velero restore describe myserver-backup-20250116165618-20250116171021`and`velero restore logs myserver-backup-20250116165618-20250116171021`. # 查看恢复后的deployment以及service信息 root@k8s-master-50:/data/velero# kubectl get svc -A NAMESPACENAMETYPECLUSTER-IPEXTERNAL-IPPORT(S) AGE default kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 19d kube-system kube-dns ClusterIP 10.100.0.2 <none> 53/UDP,53/TCP,9153/TCP 19d kubernetes-dashboard dashboard-metrics-scraper ClusterIP 10.100.206.89 <none> 8000/TCP 18d kubernetes-dashboard kubernetes-dashboard NodePort10.100.110.26 <none> 443:30004/TCP 18d myserver tomcat-app1-service NodePort10.100.226.94 <none> 80:38031/TCP 34s root@k8s-master-50:/data/velero# kubectl get deployment -A NAMESPACENAMEREADYUP-TO-DATEAVAILABLEAGE kube-system calico-kube-controllers 1/111 19d kube-system coredns 2/222 19d kubernetes-dashboard dashboard-metrics-scraper 1/111 18d kubernetes-dashboard kubernetes-dashboard 1/111 18d myserver tomcat-app1-deployment 1/111 45s velero-system velero 1/111 13d # 查看myserver这个名称空间下的pod是否被恢复回来 root@k8s-master-50:/data/velero# kubectl get pod -n myserver NAMEREADYSTATUSRESTARTSAGE tomcat-app1-deployment-768db4c897-xqpvv 1/1Running0 59s