This is something I learn quite by chance. My mom has this old dresser table which has 4 drawers for storage of items. We store some items like stockings, extra grooming items and knick knacks that we sometimes don’t use often. At times, when we open the drawers, we would have the unpleasant surprise of finding evidence of bugs having stayed in the drawer before.
It so happened that one of the drawers was used to store ointments and balms that I bought from my travel from Sri Lanka (ayurveda ointments) and Thailand (ointments for painful joints).
You know what….the drawer never had any bugs. So I realized that there is something in these strong smelling ointments that repels them. The ointments are as per below:

After I discovered this, in my next trip to Thailand, I started buying the ointments by the dozen to be placed inside my cabinets. For the kitchen, the smell of the ointment may suffuse into your food smell so you need to take note of that. As I place literally all my items especially the flour, biscuits, can food, plates in plastic storage boxes, the smell does not get into the items.
What I do is I open the cover of the bottles up and place them on the entrance and corners of my cupboards, filling cabinet and kitchen cabinets. Because the opening of the bottle is small and as long as you keep it upright, the contents does not dry quickly unless the storage unit is affected by hot weather. You do not need to fill your cabinets with all this. Just try with one near the cabinet door or two at both corners (if you have a cabinet of more than 6 feet in length). The smell is not strong but the rats and roaches seemed to hate it.
If you are not able to find the strong smelling ointments, you can try using balms that have a strong smell.
Hopefully this simple trick would help you in keeping unwanted bugs and rats out of your cabinets.