In magento1 we use this code to set meta description and meta keywords.
$this->getLayout()->getBlock('head')->setDescription('test description');
$this->getLayout()->getBlock('head')->setKeywords('test keywords');
I know this will do that in blocks
$this->pageConfig->setDescription('test description');
$this->pageConfig->setKeywords('test keywords');
What is controller code replacement in Magento2.