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