rancher 命令创建

Last updated on December 7, 2025 pm

🧙 Questions

使用命令模拟rancher界面操作

☄️ Ideas

cd /tmp
vim storageclass.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
kubectl apply -f storageclass.yaml
kubectl get storageclass
mkdir -p /data/harbor-dataœ
chown 10000:10000 /data/harbor-data

cd /tmp
vim harbor-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: harbor-pv
spec:
  capacity:
    storage: 50Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage
  hostPath:
    path: /data/harbor-data
kubectl apply -f harbor-pv.yaml
kubectl get pv -n harbor
cd /tmp
vim harbor-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: harbor-pvc
  namespace: harbor
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
  storageClassName: local-storage
kubectl apply -f harbor-pvc.yaml
kubectl get pvc -n harbor
# 查看pvc
kubectl describe pvc harbor-jobservice -n harbor

删除pvc

kubectl delete pvc -n harbor data-harbor-redis-0
kubectl delete pvc -n harbor data-harbor-trivy-0
kubectl delete pvc -n harbor database-data-harbor-database-0
kubectl delete pvc -n harbor harbor-jobservice
kubectl delete pvc -n harbor harbor-registry

查看日志

kubectl logs -n harbor deployment/harbor-core --tail=100
kubectl logs -n harbor harbor-redis-0 --tail=100
kubectl logs -n harbor harbor-nginx-64dc48855b-cmhrf --tail=100
kubectl logs -n kube-system rke2-coredns-rke2-coredns-5b7d84d764-tn4x8  --previous

查看事件

kubectl -n harbor describe pod harbor-redis-0
kubectl -n harbor describe pod harbor-nginx-64dc48855b-gzr4c 
kubectl -n isxcode describe pod zhiqingyun-647c4c5b46-m4zjs
kubectl -n local-path-storage describe pod helper-pod-create-pvc-a2e990d8-f14d-4049-8bba-a4aecdf953e7

删除所有pod

kubectl delete pod -n harbor --all --force --grace-period=0

获取所有pod

kubectl -n harbor get pods

查看helm状态

helm list -n harbor

获取helm的配置文件

helm get values harbor -n harbor

卸载helm

helm uninstall harbor -n harbor

查看svc

kubectl get svc -n harbor harbor-portal -o wide

重启节点

kubectl rollout restart deployment harbor-nginx -n harbor

rancher 命令创建
https://ispong.isxcode.com/kubernetes/rancher/rancher 命令创建/
Author
ispong
Posted on
December 2, 2025
Licensed under