The distinction to make isn't between CDs and bonds. They're actually just-about identical instruments. The key issue is the duration of the bond or CD. Longer duration bonds (and CDs!) expose you to more interest rate risk. If you buy and then rates go up, then nobody will want to accept your bond/CD on the secondary market at the old face value; you'll need to sell it for less, so the rate they get from it is on par with the new prevailing one.

With CDs some of these dynamics are more hidden, because most people cannot access a secondary market for their CDs and do not see what they are worth on a given day. They just hold to maturity. But --

-- you can also just hold a bond to maturity, and

-- if you buy your bank CD through a brokerage account (e.g. Fidelity, Schwab), then you can sell it early on the secondary market, for whatever a buyer will accept.

So there's less difference between bonds and CDs than people suppose.

(There is also the issue of default risk when the issuer of the bond is a private company or untrustworthy government. But I would say that US Treasuries and FDIC-backed CDs have similar low default risk, and you can make an argument that the T-bill is actually safer.)

One difference between CDs and US Treasury bonds is that interest on US Treasury bonds/notes/bills is exempt from state income tax. So if you live in a high income tax state, you need to account for taxes when comparing yields.