文章目录
-
- 1、kubectl oom问题处理,把oomkill进程的权限交给k8s去killpod
- 2、pod statfulset 分配到不同机器上,使用亲和性反亲和
- 3、pod添加启动依赖,顺序
- 4、使用pod的名字作为变量
- 5、ingress各种规则修改
- 6、kubernetes node失效后的调度过程以及时间调整参数(kube-controller-manager)
- 7、时区问题
- 8、使用initcontainer容器初始化服务容器
- 9、一个pods启动多个容器
- 10、kubelet优化
- 11、QoS
- 12、pod分配策略详解
- 13、pod指定启动用户(Security Context和PSP)
- 14、把pod调度到不可调度的机器上,容忍污点
- 15、flannel租约问题
- 16、java程序内存限制问题,limit给的内存特别大,java程序还是出现oom问题。tomcat容器需要添加相关环境变量参数
- 17、kube-proxy开启ipvs模块
- 18、kubelet配置自动注册到集群的功能
- 19、k8s开启聚合层(Aggregation Layer),部署metrics-server
- 20、 pod中指定hosts
- 21、 自动轮换kubelet证书
1、kubectl oom问题处理,把oomkill进程的权限交给k8s去killpod
https://blog.csdn.net/liukuan73/article/details/78787911
https://github.com/kubernetes/community/blob/master/contributors/design-proposals/node/kubelet-eviction.md#enforce-node-allocatable
2、pod statfulset 分配到不同机器上,使用亲和性反亲和
https://www.cnblogs.com/breezey/tag/kubernetes/
3、pod添加启动依赖,顺序
initContainers:
- name: init
image: reg.xiaoneng.cn/library/k8s-kubectl:v1.10.4
command:
- "/bin/sh"
- "-c"
- "until kubectl get pods |grep dolphin-setting|grep \"Running\"|grep \"1/1\"; do echo waiting for dolphin-setting;sleep 2;done && \
until if [[ `kubectl get pods |grep \"zk-\" |grep \"Running\"|grep \"1/1\"|wc -l` -ge 5 ]];then echo ok;else asd >/dev/null 2&>1 ;fi;do e
cho waiting for zookeeper;sleep 2;done " env:
- name: KUBECONFIG
value: "/etc/kubernetes/admin.conf"
volumeMounts:
- name: kubectl-admin
mountPath: /etc/kubernetes/
volumes:
- name: kubectl-admin
configMap:
name: kubectl-admin
4、使用pod的名字作为变量
https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MY_POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: MY_POD_SERVICE_ACCOUNT
valueFrom:
fieldRef:
fieldPath: spec.serviceAccountName
使用limit/request作为变量
resources:
requests:
memory: "32Mi"
cpu: "125m"
limits:
memory: "64Mi"
cpu: "250m"
env:
- name: MY_CPU_REQUEST
valueFrom:
resourceFieldRef:
containerName: test-container
resource: requests.cpu
- name: MY_CPU_LIMIT
valueFrom:
resourceFieldRef:
containerName: test-container
resource: limits.cpu
- name: MY_MEM_REQUEST
valueFrom:
resourceFieldRef:
containerName: test-container
resource: requests.memory
- name: MY_MEM_LIMIT
valueFrom:
resourceFieldRef:
containerName: test-container
resource: limits.memory
5、ingress各种规则修改
6、kubernetes node失效后的调度过程以及时间调整参数(kube-controller-manager)
#https://blog.csdn.net/levy_cui/article/details/70229818
# https://k8smeetup.github.io/docs/admin/kube-controller-manager/
kubernetes节点失效后pod的调度过程
0、Master每隔一段时间和node联系一次,判定node是否失联,这个时间周期配置项为 node-monitor-period ,默认5s
1、当node失联后一段时间后,kubernetes判定node为notready状态,这段时长的配置项为 node-monitor-grace-period ,默认40s
2、当node失联后一段时间后,kubernetes判定node为unhealthy,这段时长的配置项为 node-start