  The IllustrisTNG project is a new suite of cosmological
magneto-hydrodynamical simulations of galaxy formation performed with the Arepo
code and updated models for feedback physics. Here we introduce the first two
simulations of the series, TNG100 and TNG300, and quantify the stellar mass
content of about 4000 massive galaxy groups and clusters ($10^{13} \leq M_{\rm
200c}/M_{\rm sun} \leq 10^{15}$) at recent times ($z \leq 1$). The richest
clusters have half of their total stellar mass bound to satellite galaxies,
with the other half being associated with the central galaxy and the diffuse
intra-cluster light. The exact ICL fraction depends sensitively on the
definition of a central galaxy's mass and varies in our most massive clusters
between 20 to 40% of the total stellar mass. Haloes of $5\times 10^{14}M_{\rm
sun}$ and above have more diffuse stellar mass outside 100 kpc than within 100
kpc, with power-law slopes of the radial mass density distribution as shallow
as the dark matter's ( $-3.5 < \alpha_{\rm 3D} < -3$). Total halo mass is a
very good predictor of stellar mass, and vice versa: at $z=0$, the 3D stellar
mass measured within 30 kpc scales as $\propto (M_{\rm 500c})^{0.49}$ with a
$\sim 0.12$ dex scatter. This is possibly too steep in comparison to the
available observational constraints, even though the abundance of TNG less
massive galaxies ($< 10^{11}M_{\rm sun}$ in stars) is in good agreement with
the measured galaxy stellar mass functions at recent epochs. The 3D sizes of
massive galaxies fall too on a tight ($\sim$0.16 dex scatter) power-law
relation with halo mass, with $r^{\rm stars}_{\rm 0.5} \propto (M_{\rm
500c})^{0.53}$. Even more fundamentally, halo mass alone is a good predictor
for the whole stellar mass profiles beyond the inner few kpc, and we show how
on average these can be precisely recovered given a single mass measurement of
the galaxy or its halo.
