K8S 将节点调度了master节点上
查看master节点属性
kubectl describe node master
Taints: node-role.kubernetes.io/control-plane:NoSchedule
在deployment配置中添加
template
spec:
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/control-plane
如何固定NodePort端口
kubectl expose deployment quickstart-kb --name=kibana-svc --port=8089 --target-port=5601 --type=NodePort --dry-run=client -o yaml > quickstart-kb-svc.yaml
[root@k8s-master01 ~]# vi quickstart-kb-svc.yaml
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
common.k8s.elastic.co/template-hash: "3483830521"
common.k8s.elastic.co/type: kibana
kibana.k8s.elastic.co/name: quickstart
name: kibana-svc
spec:
ports:
- port: 8089
protocol: TCP
targetPort: 5601
nodePort: 30002 # 添加固定端口
selector:
common.k8s.elastic.co/type: kibana
kibana.k8s.elastic.co/name: quickstart
type: NodePort
status:
loadBalancer: {}
kubectl apply -f quickstart-kb-svc.yaml
[root@k8s-master01 ~]# kubectl get svc
主节点如何批量删除服务?
比如我们部署了一个 test-nginx 服务,但是想把它删了,释放其容器资源
kubectl get pods | grep test-nginx | awk '{print $1}' | xargs kubectl delete pod
#查看pods及详细信息, |grep $node 展示当前节点 ,$node 变量指定当前机器
kubectl get pods -o wide |grep $node
#查看node资源使用情况
$ kubectl top node -n <namespace>
#查看pod资源使用情况
$ kubectl top pod -n <namespace>
#进入容器
$ kubectl exec -it <pod_name> /bin/sh -n <namespace>
手动扩缩容scale
kubectl scale 资源名 --replicas=n #n为数字,大于当前副本数则是扩容,小于则是缩容
[root@k8s-y~]# kubectl scale deployment testapp --replicas=3 -n kube-public
deployment.apps/testapp scaled
[root@k8s-y~]# kubectl get pods --all-namespaces