kubectl get cs -o wide
kubectl get nodes -o wide
kubectl get svc kuberneteshtml
kube-scheduler 负责调度,查看这个服务的日志node
看 kube-proxy 的日志,若是出现 "Failed to list *core.Endpoints: endpoints is forbidden: User "system:node:foo" cannot list endpoints at the cluster scope" ,则是 RBAC 的缘由。
kube-proxy 没有权限访问 apiserver 的相应接口,致使获取不到 CLUSTER-IP,从而没法配置 iptables 策略致使访问失败。json
cat <<EOF | kubectl apply -f - apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata: name: system:kube-nodes namespace: "" roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: system:node-proxier subjects: - apiGroup: rbac.authorization.k8s.io kind: Group name: system:nodes EOF
kubernets 1.10 完整的 rbac.yamlbootstrap
--- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRole metadata: annotations: rbac.authorization.kubernetes.io/autoupdate: "true" labels: kubernetes.io/bootstrapping: rbac-defaults name: system:kube-apiserver-to-kubelet rules: - apiGroups: - "" resources: - nodes/proxy - nodes/stats - nodes/log - nodes/spec - nodes/metrics verbs: - "*" --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata: name: system:kube-apiserver namespace: "" roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: system:kube-apiserver-to-kubelet subjects: - apiGroup: rbac.authorization.k8s.io kind: User name: kubernetes --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1beta1 metadata: name: system:kube-nodes namespace: "" roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: system:node-proxier subjects: - apiGroup: rbac.authorization.k8s.io kind: Group name: system:nodes
E0329 14:33:39.634406 1 vxlan_network.go:158] failed to add vxlanRoute (10.244.0.0/24 -> 10.244.0.0): invalid argument
其余网卡的 ip 地址设置和 flannel 的网段冲突了。api
缘由: 使用了 bridge 模块,致使跨主机不通。删除全部 node 节点的 /etc/cni/net.d/10-bridge.conf 文件,并重启全部 node 系统。服务器
flannel: host-gw 或 vxlan+DirectRouting
calico: 关闭 ipip
kube-router
以上三种网络状况,我也遇到过跨主机网络不通的状况,主机 A ping 主机 B 上的容器,容器有回包,可是只到了主机B,以后就被丢弃了。问题没有直接解决。
绕过的办法:
flannel: vxlan 模式,不要开启 DirectRouting (默认就是这样设置的)
calico: 开启 ipip 模式 (默认就是这样设置的)
cilium:vxlan 模式(默认设置)网络
缘由:calico-node 检测 ip 地址的时候,判断不许确。 解决方法: 在 calico.yml 中,autodetect 下面增长 IP_AUTODETECTION_METHOD :app
# Auto-detect the BGP IP address. - name: IP value: "autodetect" - name: IP_AUTODETECTION_METHOD value: "can-reach=8.8.8.8"
如下内容能够不加,不加上也不会报错。ide
# Set noderef for node controller. - name: CALICO_K8S_NODE_REF valueFrom: fieldRef: fieldPath: spec.nodeName - name: NODENAME valueFrom: fieldRef: fieldPath: spec.nodeName
这个解决方法也是受 https://mritd.me/2017/07/31/calico-yml-bug/ 启发,再各类查资料综合而来。
若是服务器有外网网卡和内网网卡,须要把上面的 8.8.8.8 替换为内网网段的地址。spa
若是宿主机不超过200台的中小规模的集群,尽量全部宿主机使用相同的vlan,
flannel 使用 vxlan ,并开启 DirectRouting (替代默认的 vxlan )
kube-flannel.yaml 中 增长一行 "DirectRouting": true,
net-conf.json: | { "Network": "10.244.0.0/16", "Backend": { "DirectRouting": true, "Type": "vxlan" } }
待解决。目前设置的是 "DirectRouting": false, 来绕过这个问题。
若是宿主机不超过200台的中小规模的集群,尽量全部宿主机使用相同的vlan,
calico 使用 CALICO_IPV4POOL_IPIP 设为 Off ( Off, Always, CrossSubnet )
对于不一样网段的宿主机,再部署一台 RR 节点
在大量的 services 时,IPVS 效率显著提高。kube-proxy 的参数设置为
--ipvs-scheduler=wrr --ipvs-min-sync-period=5s --ipvs-sync-period=5s --proxy-mode=ipvs