If you’re using only HF, it’s a no brainer - go for the KX2.
The FT817 is a jack of all trades, good if you want to do a bit of everything. You seem pretty sure that you want to do CW and SSB, the FT817 isn’t exactly the best in these two areas.
SSB, the FT817 is 3dB down on power output compared to the KX2 and doesn’t have any TX audio adjustment besides mic gain. The RX on the FT817 uses technology from about 20 years ago.
CW, the FT817 doesn’t have any keyer memories and doesn’t even have any filtering as standard. The RX bandwidth is the same as for SSB unless the optional filter is installed.
I love my FT817 but for HF SOTA, the KX2 beats it in almost every way.