There's a log compaction cleanup policy yes. Never used it myself but if I'm not mistaken it works like this: for each message you send to Kafka, you set a key with it. When Kafka does log compaction, it keeps only the last value for each key.
The other cleanup policy is to just have a retention time. After X minutes/days/weeks segments of the log are simply deleted.