我们在容器(pod)中运行了一个sctp Java应用程序(服务器)。我们想使用Nodeport将此sctp应用程序公开给外部网络(客户端)。我们正在使用最新的Kubernetes 1.14.3和Docker版本18.06。
SERVER的Java代码(在pod中运行):
SocketAddress serverSocketAddress = new InetSocketAddress(30030);
SctpServerChannel sctpServerChannel = SctpServerChannel.open().bind(serverSocketAddress);
SctpChannel sctpChannel;
while ((sctpChannel = sctpServerChannel.accept()) != null)
{
MessageInfo messageInfo = sctpChannel.receive(ByteBuffer.allocate(64000) , null, null);
}
config.yaml:
kind: ClusterConfiguration
kubernetesVersion: v1.14.3
networking:
podSubnet: 192.168.0.0/16
apiServer:
extraArgs:
feature-gates: SCTPSupport=true
部署Yaml:
apiVersion: v1
kind: Service
metadata:
name: sctpserver
labels:
app: testsctp
spec:
ports:
- name: sctpserver
protocol: SCTP
port: 30030
targetPort: 'sctpserver'
nodePort: 30030
selector:
app: testsctp
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: sctpserver
labels:
app: testsctp
spec:
selector:
matchLabels:
app: testsctp
strategy:
type: Recreate
template:
metadata:
labels:
app: testsctp
spec:
containers:
- image: sctpserver:latest
imagePullPolicy: IfNotPresent
name: sctpserver
ports:
- containerPort: 30030
hostPort: 30030
name: sctpserver
protocol: SCTP
我们在Wireshark中看到了INIT(来自外部网络)和INIT ACK(来自kubernetes服务器),但仅此而已。数据包不会从主机转发到容器,反之亦然。
当前使用的是Iptables,但在配置文件中使用ipvs尝试了kube-proxy模式,结果仍然相同。