kubectl --patch
rancher 纳管自建集群,rancher-agent 无法连接 rancher server 报如下错误,
ERROR: https://rancher-dev.com/ping is not accessible (Could not resolve host: rancher-dev.com)
解决方案参考官网:Agent 无法连接 Rancher server
# 用 patch 更新 deployments
kubectl -n cattle-system patch deployments cattle-cluster-agent \
--patch '{"spec": {"template": {"spec": {"hostAliases": [{"hostnames": \
["rancher-dev.com"], "ip": "192.168.15.1"}]}}}}'
重建非 HostNetwork 网络的容器
echo "Delete pod that not in host network mode"
for ns in $(kubectl get ns --no-headers -o custom-columns=NAME:.metadata.name); do
for pod in $(kubectl get pod --no-headers -n "$ns" -o custom-columns=NAME:.metadata.name,HOST:spec.hostNetwork | awk '{if ($2!="true") print $1}'); do
kubectl delete pod "$pod" -n "$ns"
done
done
部署 netshoot
kubectl run netshoot --rm -it --image nicolaka/netshoot -- /bin/bash