We give a recursive method for computing all values of a basis of Whittaker functions for unramified principal series invariant under an Iwahori or parahoric subgroup of a split reductive group $G$ over a nonarchimedean local field $F$. Structures in the proof have surprising analogies to features of certain solvable lattice models. In the case $G=mathrm{GL}_r$ we show that there exist solvable lattice models whose partition functions give precisely all of these values. Here `solvable means that the models have a family of Yang-Baxter equations which imply, among other things, that their partition functions satisfy the same recursions as those for Iwahori or parahoric Whittaker functions. The R-matrices for these Yang-Baxter equations come from a Drinfeld twist of the quantum group $U_q(widehat{mathfrak{gl}}(r|1))$, which we then connect to the standard intertwining operators on the unramified principal series. We use our results to connect Iwahori and parahoric Whittaker functions to variations of Macdonald polynomials.