To get coconuts in Kingdom Hearts, you need to hit the coconut trees with your sword.
It's not guaranteed that every tree drops one, so the simplest approach is to give them all a few whacks and see what falls out. Keep at it and you'll gather what you need.