NodePort
在 Kubernetes 中如何给 NodePort 配置 NetworkPolicy
· ☕ 5 分钟
1. 需求背景 如上图,业务方需要隔离 namespae 的服务,禁止 bar 空间的负载访问,而允许用户从 Load Balancer (LB) 通过 NodePort 访问服务。可以很容易地写出一个网络策略: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: test-network-policy namespace: foo spec: podSelector: matchLabels: {} policyTypes: - Ingress ingress: - from: - ipBlock: cidr: 10.2.3.4/32 - namespaceSelector: matchExpressions: - key: region operator: NotIn values: - bar 然而

开发 Tips(16)
· ☕ 2 分钟
主要记录最近遇到的一些开发问题,解决方法。 1. Kubernetes 服务仅在负载节点可用 正常情况下 NodePort 类型的 Service ,任意 Node 节点 IP + 端口,都可以访问。但是,也有可能仅负载的 Node 节点 IP + 端口可以访问。 首先,可以尝试配置转发相关参数: 1 2 3 4 5 6 cat <<EOF > /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 net.ipv4.ip_forward=1 vm.swappiness=0 EOF 1 sysctl

开发 Tips(13)
· ☕ 2 分钟
主要记录最近遇到的一些开发问题,解决方法。 1. NodePort 服务仅指定 Node 可以访问 通过 NodePort 暴露的服务,在集群外可以使用 Kubernetes 任意 Node IP 加端口的形式访问。kube-proxy 会将访问流量以轮询的方式转发给 service 中的每个 Pod。 但是,发现并不是每一个 Node IP 加端口都可以访问,