Question: How to connect rados with ceph cluster deployed using Rook
I have deployed a ceph cluster on kubernetes using rook. I have added the codes as documented and building the project using Dockerfile. Since ceph was deployed in kubernest, that's why intead of using mon host IP, I was using the server port address and a nodeport "32201" which is forwarder to mon default port "6789". The project ran successfully in docker. I have created some pools but no pools are showing. Can anyone please help me with this? I have attached my code.
func main() {
conn, err := rados.NewConn()
if err != nil {
fmt.Println("error when invoke a new connection:", err)
return
}
args := []string{ "--mon-host", "122.34.94.105:32201" }
err = conn.ParseCmdLineArgs(args)
//err = conn.ReadDefaultConfigFile()
if err != nil {
fmt.Println("error when read default config file:", err)
conn.Shutdown()
return
}
pools, _ := conn.ListPools()
fmt.Println("Here is the list of pools")
conn.Shutdown()
}
The idea is that if you have the Ceph client tools configured (e.g. the ceph and rbd command), the defaults of go-ceph should be sufficient.
Alternatively, you can pass the configuration file and other parameters to the ParseCmdLineArgs() function. This function accepts the same options as the standard Ceph tools.
@nixpanic I have added all the necessary dependencies in Dockerfile. I am trying to connect with the mon host pod using
you can pass the configuration file and other parameters to the
ParseCmdLineArgs()function. This function accepts the same options as the standard Ceph tools
You may need to pass some credentials? It really depends on how you configured your Ceph environment... Make sure that the ceph command works with the arguments that you pass, and if that works, you can pass the same arguments through go-ceph.
This really sounds like a Ceph client configuration issue, not really unique to go-ceph.
Your example code also does not list pools as the pools variable is not printed. If you are actually using the code you pasted you probably want to fix that.
Similar to nixpanic's suggestion you might want to start with the rook toolbox which ought to have all the needed ceph connectivity bits. Verify it by using standard ceph commands. Then copy your go-ceph binary into the container manually and verify that with the correct environment your code works as desired. Finally, try rebuilding your container image and then if it still doesn't work compare the environment and config files between the container images / setup to find out what is different.
@phlogistonjohn in above code I was actually watching the pools variable from debugging mode. I have also printed the pools but it was giving empty array.
@nixpanic @phlogistonjohn I have checked the connectivity and ceph commands from toolbox pod and it works fine from it. Previously I was working on s3 apis with ceph object storage. I was able to connect the ceph object storage pod from outside using nodeport which is why I thought connecting the monitor pod will be similar.
Thank you very much for your suggestions.
Hi @shaekhhasanshoron, were you able to get it working now? If so, please close this issue.
@nixpanic I couldn't connect mon pod from outside. Maybe its the connection issue where I am struggling. It's not a go-ceph client issue.
re you able to get it working now? If so, please close this issue.