前言
扩展资源是Kubernetes.io域名之外的标准资源名称。它们使得集群管理员能够颁布非Kubernetes内置资源,而用户可以使用它们,下面介绍节点级扩展资源的用法。
节点级扩展资源
1、生成证书
cat ~/.kube/config
echo LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lJTzZiVHJEM1FLWWd3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TWpBeU1UZ3dOREV5TXpsYUZ3MHlNekF5TVRnd05ERXlORFZhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQW8wM3lHRUdlbDRsb241em8KTlF3TmprR2hCQitPZmRYRUtPSDRjT2ZlS1BVdmFqSkVUelRHS0RGUE1rb2VPQ0h1aWNKRkdYY1krUDl3N3FCcwpqVVhsWDlhNTJMazJDakp3bkhWRU1PSVRycDM2RDZxMWV4c09MbWdTUlZnNVpEL2FnMVdMdDdOMVRqdkJWaW8vCnBMZGlER3FIQUZCZlI0WVptZDFDSXpZYlVtd3ZoejlYdDVFdk1LR2xvQllSMkNGQklpQktOVERBZU5oaFcvUGYKTXV2TXFySjg4d0tYUi9JdWdJNm5uVXpLdVhkYlBNbkRvcTFVZW1XYUVyWTRTd3krbVY2dWFDb1JaZ2hpdmJvMApmRDR5b09kYVllY0NwdGtyS2NxaFozTFkyWDl6TTVlTjg3eXlhUms1TlNFcHpsL1VhOFRjOWF3d014aTN5RTlGClpLY2NQd0lEQVFBQm8xWXdWREFPQmdOVkhROEJBZjhFQkFNQ0JhQXdFd1lEVlIwbEJBd3dDZ1lJS3dZQkJRVUgKQXdJd0RBWURWUjBUQVFIL0JBSXdBREFmQmdOVkhTTUVHREFXZ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RnR2UytmR0VaY1plWnBSV2p2MUN6ZS9JL1NnVGhzcDhLNGZOeFI4Z2JReEw3YXQzakhoaEhiUQpvVFZEN0FLbmJWZktjNlVRZXhYWXdkTHB6UnJhN0QxTTNWVEhKNGRIZHM1WFgzYjRYN2F6eno2RTNFcDZobDZIClRmT2x0cmJKbTZWeitxT1lHTVBwMGxrNUFvR0FaTSt5MDE1ZWpEWTFUZDIxcVpxaG52QU5CMi9lb0JUZ3ZOWjMKcklKbjNrWFVuQzJtWEgxMzJBQlkrbjRnRFlSc05YL2JmMkpwUzg3OVlvWDFBU0htNW95bGkzT3IzMks0UzRZWgoyTjlUOWxyZEM3RTBRTDRuWm9IQUx5VXZTRHc2c1Zoc2pFQmI5Rm4xdytuT0VwR3E4U2VCVE80VFVwWXV2Y3V3CnA2MVpuZ0VDZ1lBNWNGeXpSZ2pEbk90U1RaNHBDVXMwV0U3WWZxMDdna3JJYU9KMVNqOXNnRHdrQ0NzM3FoNlgKOGh5SGFCajNOWjNpS2JNQnBReVNmWGpHV3A4YmtUcGFNdVVLd3dHY3N6M3pSRjAzQ21adWs4bGQrcE9sR2lHVwptd3JtekNwcElrQVhwblhBTzNqekxUWStHS1NrbE1nK1I4cmUrTkdIMFpMU2JBMDFuZmMrL2c9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo= | base64 -d >admin.key
2、配置资源
curl --key admin.key --cert admin.crt --header "Content-Type: application/json-patch+json" \
--request PATCH -k \
--data '[{"op": "add", "path": "/status/capacity/xing.com~1reclaimed-cpu", "value": "2"}]' \
https://192.168.0.61:6443/api/v1/nodes/ops-node-1/status
kubectl get nodes ops-node-1 -oyaml
3、启动pod使用扩展资源
cat deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
resources:
limits:
xing.com/reclaimed-cpu: 2
requests:
xing.com/reclaimed-cpu: 2
kubectl apply -f deployment.yaml
扩展成功。
4、删除扩展资源
curl --key admin.key --cert admin.crt --header "Content-Type: application/json-patch+json" \
--request PATCH -k \
--data '[{"op": "remove", "path": "/status/capacity/xing.com~1reclaimed-cpu", "value": "2"}]' \
https://192.168.0.61:6443/api/v1/nodes/ops-node-1/status
删除成功。
|