The kidneys produce urine through three main processes:
1) Filtration of water and dissolved substances from the blood in the glomeruli into the Bowman's capsule.
2) Reabsorption of water, nutrients like glucose, and ions like sodium out of the kidney tubules and back into the bloodstream, preventing their loss in urine.
3) Secretion of substances like hydrogen and potassium ions, ammonia, and drugs from the blood into the kidney tubules to be eliminated in urine, which helps regulate acid-base balance.