在CentOS上部署和管理Kubernetes(k8s)集群的資源,通常涉及以下幾個關鍵步驟和工具:
nodeName
或nodeSelector
進行簡單調度,使用nodeAffinity
、podAffinity
和podAntiAffinity
實現復雜調度規則。apiVersion: v1
kind: ResourceQuota
metadata:
name: resource-test
spec:
hard:
pods: 50
requests.cpu: "1"
requests.memory: "1Gi"
limits.cpu: "2"
limits.memory: "2Gi"
kubectl apply -f resource-quota.yaml -n rq-test
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespace: rq-test
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.15.2
resources:
limits:
memory: "80Mi"
cpu: "80m"
requests:
memory: "60Mi"
cpu: "40m"
kubectl apply -f nginx.yaml -n rq-test
通過上述步驟和工具,可以在CentOS上有效地管理Kubernetes集群的資源,確保集群的高可用性、穩定性和安全性。建議在實際部署前,參考Kubernetes官方文檔進行詳細的規劃和測試。