The blog about containerisation, virtual machines and useful shell snippets and findings

zsh func for updating port from docker container

put this in .zshrc if you want to update `kube/config` with new port from kind container

kupdate() {
DOCKER_ID=`docker ps -a | awk '/kind-control-plane/{print $1}'`
PORT=`docker inspect ${DOCKER_ID} | jq -r '.[0].NetworkSettings.Ports["6443/tcp"][0].HostPort'`
kubectl config set clusters.kind-kind.server https://127.0.0.1:${PORT}
echo "port set to ${PORT}"
}