本地运行的时候是这个命令
docker run -d -p `172.24.0.120` :1337:1337 -p `172.24.0.120` :4000:4000 -v "`pwd`":/opt/cita-run cita/cita-release:20.2.0-secp256k1-sha3 /bin/bash -c 'cita setup test-chain/0 && cita start test-chain/0 && sleep infinity'
转换成k8s的yaml文件运行的时候,发现里面
cita-env 执行的命令有问题,有一段逻辑是
if ! docker ps | grep "${CONTAINER_NAME}" > '/dev/null' 2>&1; then
echo "Start docker container ${CONTAINER_NAME} ..."
docker rm "${CONTAINER_NAME}" > '/dev/null' 2>&1
# test network and set init cmd
timeout=3
target=www.google.com
ret_code=$(curl -I -s --connect-timeout $timeout $target -w "%{http_code}" | tail -n1)
if [ "x$ret_code" = "x200" ]; then
readonly INIT_CMD="sleep infinity"
else
readonly INIT_CMD="echo -e '[source.crates-io]\nreplace-with = \"rustcc\"\n[source.rustcc]\nregistry = \"https://code.aliyun.com/rustcc/crates.io-index.git\"' | sudo tee /opt/.cargo/config;sleep infinity"
fi
docker run -d --init \
--net="${SYSTEM_NET}" \
--volume "${SOURCE_DIR}:${WORKDIR}" \
--volume "${DOCKER_CARGO}/git:${CARGO_HOME}/git" \
--volume "${DOCKER_CARGO}/registry:${CARGO_HOME}/registry" \
--volume "${LOCALTIME_PATH}:/etc/localtime" \
--env "USER_ID=${USER_ID}" \
--workdir "${WORKDIR}" \
--name "${CONTAINER_NAME}" \
"${EXPOSE_PARAM[@]}" "${DOCKER_IMAGE}" \
/bin/bash -c "${INIT_CMD}"
# Wait entrypoint.sh to finish
sleep 3
fi
这段逻辑需要执行docker命令,在k8s环境中无法执行。