• 沒有找到結果。

节点访问(NodePort)类型的Service的服务亲和需选择“节点级别”而不是“集群级 别”,即Service的spec.externalTrafficPolicy需要设置为Local。

说明

云原生网络2.0模型下,NodePort类型的Service无法设置服务亲和选项为“节点级别”,暂不支 持此方式获取源IP。

3-45 服务亲和选择节点级别

3.10 通过配置容器内核参数增大监听队列长度

使用场景

net.core.somaxconn默认监听队列(backlog)长度为128,当服务繁忙不能满足要求 时,需要增大监听队列长度。

操作步骤

步骤1 登录对应节点。

1.15及以上版本集群

登录CCE控制台,单击左侧栏目树中的“资源管理 > 节点池管理”,单击您创建 的节点池卡片右上角的“配置管理”,修改kubelet配置参数。

1.13及以下版本的集群

编辑“/var/paas/kubernetes/kubelet/kubelet”文件,开启net.core.somaxconn 开关。

--allowed-unsafe-sysctls=net.core.somaxconn

说明

1.13及以下版本的集群在修改kubelet后,如果升级集群到更高版本则该配置会还原。

步骤2 重启kubelet。

1.15及以上版本的集群

通过在CCE控制台中修改节点池的“配置管理”参数后,后台会自动重启 kubelet,不需要手动重启。

1.13版本集群

systemctl restart kubelet 查看kubelet状态:

systemctl status kubelet

1.11版本集群:

su paas -c '/var/paas/monit/bin/monit restart kubelet' 查看kubelet状态:

su paas -c '/var/paas/monit/bin/monit summary' 重启1.13版本集群示例如下:

步骤3 创建pod安全策略。

CCE从1.17.17集群版本开始,kube-apiserver开启了pod安全策略,需要在pod安全策 略的allowedUnsafeSysctls中增加net.core.somaxconn配置才能生效(1.17.17以下版 本的集群可跳过此步骤)。

● CCE的安全策略介绍,详情请参见Pod安全策略配置。

● K8S社区安全策略介绍,详情请参见PodSecurityPolicy。

● 对于开启net.core.somaxconn开关的集群,需要在对应的Pod安全策略的 allowedUnsafeSysctls中增加此项配置,如创建新的Pod安全策略,示例如下:

apiVersion: policy/v1beta1 kind: PodSecurityPolicy metadata:

annotations:

seccomp.security.alpha.kubernetes.io/allowedProfileNames: '*' name: sysctl-psp

spec:

allowedUnsafeSysctls:

- net.core.somaxconn allowPrivilegeEscalation: true allowedCapabilities:

- '*' fsGroup:

rule: RunAsAny hostIPC: true hostNetwork: true hostPID: true hostPorts:

- max: 65535 min: 0 privileged: true runAsGroup:

rule: RunAsAny runAsUser:

rule: RunAsAny seLinux:

rule: RunAsAny supplementalGroups:

rule: RunAsAny volumes:

- '*'

创建Pod安全策略sysctl-psp后,还需要为它绑定RBAC权限控制。

示例如下:

kind: ClusterRole

apiVersion: rbac.authorization.k8s.io/v1 metadata:

name: sysctl-psp rules:

---apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding

metadata:

name: sysctl-psp roleRef:

kind: ClusterRole name: sysctl-psp

apiGroup: rbac.authorization.k8s.io subjects:

- kind: Group

name: system:authenticated apiGroup: rbac.authorization.k8s.io

步骤4 登录CCE控制台,创建工作负载,具体请参见创建无状态工作负载。

创建工作负载时,“高级设置 > 调度策略 > 工作负载和节点的亲和性 > 与节点的亲和 性”中选择步骤1中登录的节点。

步骤5 单击“YAML创建”,配置内核参数值,如下黑体部分。

apiVersion: apps/v1 kind: Deployment metadata:

annotations:

description: '' labels:

appgroup: '' name: test1 namespace: default spec:

metrics.alpha.kubernetes.io/custom-endpoints: '[{"api":"","path":"","port":"","names":""}]' labels:

securityContext:

requiredDuringSchedulingIgnoredDuringExecution:

nodeSelectorTerms:

例如,查看工作负载containerid ,test为工作负载名称。

docker ps –a |grep test 进入容器。

docker exec -it containerid /bin/sh 查询配置参数是否生效。

sysctl -a |grep somax

3-46 查看参数配置

----结束

3.11 CCE Turbo 共池 BMS 节点容器网卡多队列配置

由于BMS节点支持配置网卡的队列数,以及保障带宽等配置,所以BMS的预绑定策略 跟ECS的大不一样,目前BMS只有节点级别的,没有全局的缺省配置。

网卡多队列是一种技术手段,可以解决网络I/O带宽QoS(Quality of Service)问题。

网卡多队列驱动将各个队列通过中断绑定到不同的核上,从而解决网络I/O带宽升高时

"extendParam": {

"nicMultiqueue": "[{\"queue\":4}]",