我正在尝试通过AWS集群中的Kubernetes部署一些Docker容器。我的部署本身没有问题,但是我无法从容器内部执行netcat。
如果我输入容器(nc -w 1 -q 1 127.0.0.1 2181
)并尝试执行:(UNKNOWN) [127.0.0.1] 2181 (?) : Connection refused
,它将失败并显示:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: zookeeper
labels:
app: zookeeper
spec:
serviceName: zookeeper
replicas: 1
selector:
matchLabels:
app: zookeeper
template:
metadata:
labels:
app: zookeeper
spec:
terminationGracePeriodSeconds: 1800
nodeSelector:
proc_host: "yes"
host_role: "iw"
containers:
- name: zookeeper
image: imageregistry:443/mydomain/zookeeper
imagePullPolicy: Always
ports:
- containerPort: 2181
name: client
- containerPort: 2888
name: peer
- containerPort: 3888
name: leader-election
resources:
limits:
memory: 120Mi
requests:
cpu: "10m"
memory: 100Mi
lifecycle:
preStop:
exec:
command: ["sh", "-ce", "kill -s TERM 1; while $(kill -0 1 2>/dev/null); do sleep 1; done"]
env:
- name: LOGGING_LEVEL
value: WARN
- name: ID_OFFSET
value: "4"
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
readinessProbe:
exec:
command:
- /bin/bash
- -c
- '[ "imok" = "$(echo ruok | nc -w 1 -q 1 127.0.0.1 2181)" ]'
initialDelaySeconds: 15
timeoutSeconds: 5
volumeMounts:
- name: zookeeper
mountPath: /tmp/zookeeper
volumes:
- name: zookeeper
hostPath:
path: /var/lib/kafka/zookeeper
这对我的某些容器来说是个问题,因为我正在使用netcat命令来实现相应的就绪探针。
示例:
部署Zookeeper容器:
Readiness probe failed: (UNKNOWN) [127.0.0.1] 2181 (?) : Connection refused
,并且部署良好,但是就绪探针失败并显示以下错误:
for (c = 8; c >= 0; c--){
k = ip4 >> c;
if (k & 1)
printf("1");
else
printf("0");
}
我是Kubernetes的新手,有人知道我缺少什么吗?
谢谢您的帮助。