Open day0ops opened 3 years ago
If the cluster came up to this point then the api server is running (this is checked and the endpoint is used) so that only leaves the port forwarding. Podman is responsible for the port forwarding. Kind just tells it to setup a forward like 127.0.0.1:$random_port -> container:$apiserver_port
and then places the port detected into kubeconfig. If that port is not reachable on loopback something is wrong with podman on your host.
cc @aojea broken podman networking ...
is this podman remote? or running kind inside the VM?
@aojea so the setup is Vagrant with running with vbox. Podman server running in Fedora 34. Podman client and kind running locally
The only thing is I have both enabled IPv4 and IPv6 on my local machine (Mac OS X). So I suppose that would mean the kind cluster by default will also be dual stack If i don't specially disable a family right ?
If the client and kind are local then your kubectl will only be able to access the cluster if you do your own port forwarding from the host to the VM. KIND isn't responsible for the VM setup and since it creates local clusters it binds the port forward from the host running the container to the apiserver in the node container to the loopback IP. This limitation will apply to other containers forwarding ports when running podman in this way.
Alternatively you can configure the cluster / kind to bind to a non local address. https://kind.sigs.k8s.io/docs/user/configuration/#api-server
SSH port forwarding is one plausible option but you will need to get the port from the kubeconfig or similar and do the forward yourself. I don't know if podman intends to support forwarding to the actual host when using podman machine but docker desktop does do this.
Hi,
I just ran into the same problem and switched to check if I could use kind. I used the following config that adds an additional port (just changing the apiServerAddress did not work as proposed by @BenTheElder in https://github.com/kubernetes-sigs/kind/issues/2445#issuecomment-917333218):
% cat kind.cfg
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 6443
hostPort: 6443
listenAddress: "0.0.0.0"
In addition I had to fix the .kube/config
:
> server: https://:6443
< server: https://127.0.0.1:6443
This way I got the following result:
% kubectl cluster-info --context kind-kind
Kubernetes control plane is running at https://127.0.0.1:6443
CoreDNS is running at https://127.0.0.1:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Wasn't going any further from here, none the less hope this helps.
I was able to get this working on macOS using the new podman machine
functionality (no Vagrant):
# install and initialize podman
brew install podman
podman machine init --cpus=4 --memory=8096 --disk=50
# manually add helper_binaries_dir to ~/.config/containers/containers.conf
[engine]
helper_binaries_dir = ["/Users/jstafford/homebrew/Cellar/podman/3.4.2/libexec/", "/Users/jstafford/homebrew/Cellar/podman/3.4.2/bin/"]
# start podman and set the connection to the root user
podman machine start
podman system connection default podman-machine-default-root
# install kind
brew install kind
# setup a kind cluster
export KIND_EXPERIMENTAL_PROVIDER=podman
kind create cluster --config=<(echo '---
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
apiServerAddress: "0.0.0.0"
')
# fix kubeconfig http://: url
sed -i '' 's/https:\/\/:/https:\/\/localhost:/g' ~/.kube/config
I was able to get this working on macOS using the new
podman machine
functionality (no Vagrant):# install and initialize podman brew install podman podman machine init --cpus=4 --memory=8096 --disk=50 # manually add helper_binaries_dir to ~/.config/containers/containers.conf [engine] helper_binaries_dir = ["/Users/jstafford/homebrew/Cellar/podman/3.4.2/libexec/", "/Users/jstafford/homebrew/Cellar/podman/3.4.2/bin/"] # start podman and set the connection to the root user podman machine start podman system connection default podman-machine-default-root # install kind brew install kind # setup a kind cluster export KIND_EXPERIMENTAL_PROVIDER=podman kind create cluster --config=<(echo '--- kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 networking: apiServerAddress: "0.0.0.0" ') # fix kubeconfig http://: url sed -i '' 's/https:\/\/:/https:\/\/localhost:/g' ~/.kube/config
Thanks! Works for me!
I was able to get this working on macOS using the new
podman machine
functionality (no Vagrant):# install and initialize podman brew install podman podman machine init --cpus=4 --memory=8096 --disk=50 # manually add helper_binaries_dir to ~/.config/containers/containers.conf [engine] helper_binaries_dir = ["/Users/jstafford/homebrew/Cellar/podman/3.4.2/libexec/", "/Users/jstafford/homebrew/Cellar/podman/3.4.2/bin/"] # start podman and set the connection to the root user podman machine start podman system connection default podman-machine-default-root # install kind brew install kind # setup a kind cluster export KIND_EXPERIMENTAL_PROVIDER=podman kind create cluster --config=<(echo '--- kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 networking: apiServerAddress: "0.0.0.0" ') # fix kubeconfig http://: url sed -i '' 's/https:\/\/:/https:\/\/localhost:/g' ~/.kube/config
@jstaf You're a ROCK STAR! Thank you for sharing that. I can confirm that this worked for me as well. macOS Monterey (12.1) Podman 3.4.4 Kind 0.11.1
I was able to get this working on macOS using the new
podman machine
functionality (no Vagrant):# install and initialize podman brew install podman podman machine init --cpus=4 --memory=8096 --disk=50 # manually add helper_binaries_dir to ~/.config/containers/containers.conf [engine] helper_binaries_dir = ["/Users/jstafford/homebrew/Cellar/podman/3.4.2/libexec/", "/Users/jstafford/homebrew/Cellar/podman/3.4.2/bin/"] # start podman and set the connection to the root user podman machine start podman system connection default podman-machine-default-root # install kind brew install kind # setup a kind cluster export KIND_EXPERIMENTAL_PROVIDER=podman kind create cluster --config=<(echo '--- kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 networking: apiServerAddress: "0.0.0.0" ') # fix kubeconfig http://: url sed -i '' 's/https:\/\/:/https:\/\/localhost:/g' ~/.kube/config
@jstaf You're a ROCK STAR! Thank you for sharing that. I can confirm that this worked for me as well. macOS Monterey (12.1) Podman 3.4.4 Kind 0.11.1
This worked for me too! Thank you @jstaf
Same specs:
What happened: Unable to get a Kind cluster going on Mac OS X using podman 3.3.1. Podman server is running in Fedora 34 using Vagrant.
When creating kind cluster It says API server isnt available.
For reference:
What you expected to happen: Be able to create a cluster in rootless mode and access the API server
How to reproduce it (as minimally and precisely as possible): As above in a Vagrant environment (Fedora 34),
Environment:
kind version
): v0.12.0-alpha+f8e6aa668edd33 (head build)kubectl version
): 1.22.1docker info
): podmanServer: Version: 3.3.1 API Version: 3.3.1 Go Version: go1.16.6 Built: Tue Aug 31 08:46:36 2021 OS/Arch: linux/amd64