{"id":344081,"date":"2023-01-17T15:04:08","date_gmt":"2023-01-17T15:04:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=344081"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=344081","title":{"rendered":"<span>Kyverno\u00a0\u2014 \u0437\u0430\u043c\u0435\u043d\u0430 PodSecurityPolicy \u0438\u043b\u0438 \u043d\u0435\u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0435?<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0445\u0430\u0431\u0440\u0430\u0432\u0447\u0430\u043d\u0435!<\/p>\n<p>\u0421\u043b\u044b\u0448\u0430\u043b\u0438 \u043b\u0438 \u0432\u044b, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Kyverno \u0438 \u0437\u0430\u0447\u0435\u043c \u043e\u043d \u043d\u0443\u0436\u0435\u043d? \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0438 \u043f\u043e\u043a\u0430\u0436\u0443 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445, \u043a\u0430\u043a \u043c\u044b \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c.<\/p>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041c\u0430\u043a\u0430\u0440\u0438\u0439 \u0411\u0430\u043b\u0430\u0448\u043e\u0432, \u044f SRE \u0432 Ak Bars Digital. \u041d\u0430\u0448\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u043e\u0439 \u0438 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u044d\u0442\u043e\u0442 \u0432\u0430\u0448 Kyverno?<\/h2>\n<p><strong><em>Kyverno<\/em><\/strong>\u00a0\u2014 policy engine \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f <em>Kubernetes.<\/em><\/p>\n<p>Kyverno \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0441\u0440\u0435\u0434\u044b \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0441\u0432\u043e\u0438\u0445 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u0432. Kyverno \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 best practises \u0438\u043b\u0438 \u0434\u043b\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0438\u0445 \u043f\u0443\u0442\u0435\u043c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 API.<\/p>\n<p>\u0412\u043e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u0440\u0443\u0442\u044b\u0445 \u0444\u0438\u0448\u0435\u043a Kyverno:<\/p>\n<ul>\n<li>\n<p>policy \u043a\u0430\u043a \u0440\u0435\u0441\u0443\u0440\u0441\u044b kubernetes (yaml \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u044b);<\/p>\n<\/li>\n<li>\n<p>\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b k8s;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u043e\u043a \u041f\u041e;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043c\u0435\u0442\u0430\u0434\u0430\u0442\u044b \u043e\u0431\u0440\u0430\u0437\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0432 Namespace\u2019\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u0438\u043b\u0438 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043e \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f\u0445 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0430\u043c\u0438 \u043a\u0430\u043a \u043a\u043e\u0434\u043e\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a\u00a0<code>git<\/code>\u00a0\u0438\u00a0<code>kustomize<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u0438\u0442\u0438\u043a (\u0443\u0436\u0435 244).<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432 Kyverno \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c\u00a0<a href=\"https:\/\/open-policy-agent.github.io\/gatekeeper\/website\/docs\/\">OPA\/Gatekeeper<\/a>,\u00a0<a href=\"https:\/\/www.kubewarden.io\/\">Kubewarden<\/a>\u00a0\u0438\u00a0<a href=\"https:\/\/www.jspolicy.com\/\">jsPolicy<\/a>.<\/p>\n<p>\u041f\u0440\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 \u0441\u0435\u0442\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440\u00a0<a href=\"https:\/\/neonmirrors.net\/post\/2021-02\/kubernetes-policy-comparison-opa-gatekeeper-vs-kyverno\/\">\u0442\u0443\u0442 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442 Kyverno \u0438 Gatekeeper<\/a>.<\/p>\n<h2>\u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0430\u043c?<\/h2>\n<p>\u0412 1.21 PodSecurityPolicy \u0441\u0442\u0430\u043b\u0430 \u0434\u0435\u043f\u0440\u0435\u043a\u0435\u0439\u0442\u0435\u0434 \u0444\u0438\u0447\u0435\u0439 Kubernetes, \u0430 \u0432 1.25 \u0431\u044b\u043b\u0430 \u0432\u043e\u0432\u0441\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0430.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0441\u0442\u0430\u043b \u0432\u043e\u043f\u0440\u043e\u0441, \u0430 \u043a\u0430\u043a \u0434\u0430\u043b\u044c\u0448\u0435 \u0436\u0438\u0442\u044c? \u0418 \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u043e\u0442\u0435\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0432\u044b\u0431\u043e\u0440 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 Kyverno. \u041d\u0430\u0441 \u043e\u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0440\u0430\u0434\u043e\u0432\u0430\u043b\u0430 \u0438 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u043b\u0430 \u043d\u0430\u0448\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438, \u043a\u0430\u043a \u0437\u0430\u043c\u0435\u043d\u0430 PSP.<\/p>\n<p>\u041d\u0430 \u0444\u043e\u043d\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432 Kyverno \u0432\u044b\u0434\u0435\u043b\u0438\u043b\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c \u0441\u0440\u0430\u0437\u0443 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0439 (\u043e\u0431\u044b\u0447\u043d\u044b\u0439 yaml), \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u043c \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430\u043c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0441 \u043d\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<h2>\u041a\u0430\u043a \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?<\/h2>\n<p>Kyverno \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0434\u043e\u043f\u0443\u0441\u043a\u0430 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 Kubernetes. Kyverno \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0438\u0435 \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0435 \u0432\u0435\u0431\u0445\u0443\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u043a\u0430 \u043e\u0442 kube-apiserver. \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u043a\u0430 \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u043e\u043d\u044f\u044e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e0f\/baa\/3c1\/e0fbaa3c1074f9143bdec717819667a0.png\" alt=\"\u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u044b Kyverno. \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a. \" title=\"\u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u044b Kyverno. \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a. \" width=\"2705\" height=\"1610\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e0f\/baa\/3c1\/e0fbaa3c1074f9143bdec717819667a0.png\"\/><figcaption>\u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u044b Kyverno. \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a. <\/figcaption><\/figure>\n<h2>\u0414\u043b\u044f \u0447\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c?<\/h2>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043c\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Kyverno \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043a \u0437\u0430\u043c\u0435\u043d\u0443 PodSecurityPolicy. \u041d\u0430\u0447\u0430\u043b\u0438 \u0441 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u043e\u0432 PSP \u0432 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u044b \u043f\u043e\u043b\u0438\u0442\u0438\u043a Kyverno c Validate \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438.<\/p>\n<h3>Validate\u00a0Resources<\/h3>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u0445\u043e\u0442\u0435\u043b\u0438 \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a privilege \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0447\u0440\u0435\u0432\u0430\u0442\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u0445\u043e\u0441\u0442\u0430 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c \u044f\u0434\u0440\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u0438\u0442\u0438\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">apiVersion: kyverno.io\/v1 kind: ClusterPolicy metadata:   name: disallow-privileged-containers   annotations:     policies.kyverno.io\/title: Disallow Privileged Containers     policies.kyverno.io\/category: Pod Security Standards (Baseline)     policies.kyverno.io\/severity: medium     policies.kyverno.io\/subject: Pod     kyverno.io\/kyverno-version: 1.6.0     kyverno.io\/kubernetes-version: \"1.22-1.23\"     policies.kyverno.io\/description: >-       Privileged mode disables most security mechanisms and must not be allowed. This policy       ensures Pods do not call for privileged mode.       spec:   validationFailureAction: audit   background: true   rules:     - name: privileged-containers       match:         any:         - resources:             kinds:               - Pod       validate:         message: >-           Privileged mode is disallowed. The fields spec.containers[*].securityContext.privileged           and spec.initContainers[*].securityContext.privileged must be unset or set to `false`.                   pattern:           spec:             =(ephemeralContainers):               - =(securityContext):                   =(privileged): \"false\"             =(initContainers):               - =(securityContext):                   =(privileged): \"false\"             containers:               - =(securityContext):                   =(privileged): \"false\"<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>Mutating Resources<\/h3>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c securityContext \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435. \u0412\u043e\u0442 \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u0438\u0442\u0438\u043a\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c securityContext<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">apiVersion: kyverno.io\/v1 kind: ClusterPolicy metadata:   name: add-default-securitycontext   annotations:     policies.kyverno.io\/title: Add Default securityContext     policies.kyverno.io\/category: Sample     policies.kyverno.io\/subject: Pod     policies.kyverno.io\/description: >-       A Pod securityContext entry defines fields such as the user and group which should be used to run the Pod.       Sometimes choosing default values for users rather than blocking is a better alternative to not impede       such Pod definitions. This policy will mutate a Pod to set default securityContext     spec:   background: false   rules:   - name: add-default-securitycontext-containers     match:       any:       - resources:           kinds:           - Pod     preconditions:       all:       - key: \"{{request.operation}}\"         operator: In         value:           - CREATE           - UPDATE     mutate:       foreach:       - list: \"request.object.spec.containers\"         patchStrategicMerge:           spec:             securityContext:               runAsUser: 10001               runAsGroup: 10001               fsGroup: 10001               seccompProfile:                 type: RuntimeDefault             containers:             - name: \"{{ element.name }}\"               securityContext:                 runAsUser: 10001                 runAsGroup: 10001                 capabilities:                   drop:                     - ALL                 runAsNonRoot: true                 allowPrivilegeEscalation: false privileged: false                 seccompProfile:                   type: RuntimeDefault   - name: add-default-securitycontext-initContainers     match:       any:       - resources:           kinds:           - Pod     preconditions:       all:       - key: \"{{request.operation}}\"         operator: In         value:           - CREATE           - UPDATE       - key: \"{{ request.object.spec.initContainers[] || '' | length(@) }}\"         operator: GreaterThanOrEquals         value: 1     mutate:       foreach:       - list: \"request.object.spec.initContainers\"         patchStrategicMerge:           spec:             securityContext:               runAsUser: 10001               fsGroup: 10001               seccompProfile:                 type: RuntimeDefault             initContainers:             - name: \"{{ element.name }}\"               securityContext:                 runAsUser: 10001                 runAsGroup: 10001                 capabilities:                   drop:                     - ALL                 runAsNonRoot: true                 allowPrivilegeEscalation: false privileged: false                 seccompProfile:                   type: RuntimeDefault<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>Generate Resources<\/h3>\n<p>\u041a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f generate-\u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u0430 \u0441 \u043a\u0440\u0435\u0434\u0430\u043c\u0438 \u043e\u0442 private registry (dockerconfigjson) \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 Namespace.<\/p>\n<p>\u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0448\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u2014 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u0430 \u0441 \u0441\u0430\u043c\u043e\u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u0440\u0443\u0442\u043e\u0432\u044b\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 cert-manager, \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 namespace \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430\u00a0<code>synchronize<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 Kyverno \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432\u0441\u0435\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0435\u044e \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u044d\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0445 \u043f\u043e\u0441\u043b\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0432\u044b\u043f\u0443\u0441\u043a\u0430 cert-manager\u2019\u043e\u043c.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u0430 \u043f\u043e Namespac\u2019\u0430\u043c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">apiVersion: kyverno.io\/v1 kind: ClusterPolicy metadata:   name: clone-cert   annotations:     policies.kyverno.io\/title: Clone Certificate's secret     policies.kyverno.io\/category: Cert-Manager     policies.kyverno.io\/subject: Certificate, Namespace     policies.kyverno.io\/description: >-       Clone certificate's secret to every namespace spec:   background: true   rules:   - name: clone-cert     match:       any:       - resources:           kinds:           - Namespace     exclude:       any:       - resources:           namespaces:           - \"kube-system\"           - \"kube-public\"           - \"default\"     generate:       synchronize: true       apiVersion: v1       kind: Secret       name: base-cert       namespace: \"{{request.object.metadata.name}}\"       clone:         namespace: cert-manager         name: base-cert<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u0435\u043b\u0430\u0435\u043c \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044e<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">apiVersion: kyverno.io\/v1 kind: ClusterPolicy metadata:   name: add-certificates-volume   annotations:     policies.kyverno.io\/title: Add Certificates as a Volume     policies.kyverno.io\/category: Sample     policies.kyverno.io\/subject: Pod,Volume     kyverno.io\/kyverno-version: 1.5.2     kyverno.io\/kubernetes-version: \"1.21\"     policies.kyverno.io\/minversion: 1.5.0     pod-policies.kyverno.io\/autogen-controllers: DaemonSet,Deployment,Job,StatefulSet     policies.kyverno.io\/description: >-       In some cases you would need to trust custom CA certificates for all the containers of a Pod.       It makes sense to be in a Secret so that you can automount them by only setting an annotation.       This policy adds a volume to all containers in a Pod containing the certificate if the annotation       called `inject-certs` with value `enabled` is found.       spec:   background: true   rules:   - name: add-ssl-certs     match:       any:       - resources:           kinds:           - Pod     exclude:       any:       - resources:           namespaces:           - \"kube-system\"           - \"kube-public\"           - \"default\"     preconditions:       all:       - key: \"{{request.operation}}\"         operator: In         value:           - CREATE           - UPDATE     mutate:       foreach:       - list: \"request.object.spec.containers\"          patchStrategicMerge:           spec:             containers:             - name: \"{{ element.name }}\"               volumeMounts:               - name: ssl-certs                 mountPath: \/etc\/ssl\/certs             volumes:             - name: ssl-certs               secret:                 secretName: base-cert<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>Verify Image<\/h3>\n<p>\u0422\u0430\u043a\u0436\u0435, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Kyverno \u0438 Sigstore Cosign \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u041c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0435\u0434\u0440\u044f\u0435\u043c \u044d\u0442\u0438 \u0444\u0438\u0447\u0438. \u041f\u043e\u0434\u0431\u043e\u0440\u043a\u0443 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u00a0\u00a0<a href=\"https:\/\/t.me\/k8security\/692\">\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u043a\u0430\u043d\u0430\u043b\u0435 k8s (in)security<\/a><\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>Kyverno \u0432\u0435\u043b\u0438\u043a\u043e\u043b\u0435\u043f\u0435\u043d, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430\u0448\u0438\u043c\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430\u043c\u0438 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0431\u0435\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u041d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0441 \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u044e\u0449\u0438\u043c\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0430 \u043b\u0435\u0442\u0443, \u0430 \u043d\u043e\u0432\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b. \u0421 \u044d\u0442\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u043e\u043f\u044b\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430\u043c\u0438 Kubernetes. \u0418 \u0431\u0443\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<h3>\u0421\u0441\u044b\u043b\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u043d\u044b, \u0435\u0441\u043b\u0438 \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Kyverno \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445:<\/h3>\n<ul>\n<li>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f &#8212;\u00a0<a href=\"https:\/\/kyverno.io\/docs\/\">https:\/\/kyverno.io\/docs\/<\/a><\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0431\u043e\u0440 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u0438\u0441\u0438 &#8212;\u00a0<a href=\"https:\/\/kyverno.io\/policies\/\">https:\/\/kyverno.io\/policies\/<\/a><\/p>\n<\/li>\n<li>\n<p>Replacing PSPs? Keep Bad Pods out of your cluster using Kyverno &#8212;\u00a0\u00a0<a href=\"https:\/\/youtu.be\/AmJUFH7n33c\">https:\/\/youtu.be\/AmJUFH7n33c<\/a><\/p>\n<\/li>\n<li>\n<p>PodSecurityPolicy Migrator &#8212;\u00a0<a href=\"https:\/\/appvia.github.io\/psp-migration\/\">https:\/\/appvia.github.io\/psp-migration\/<\/a>\u00a0,\u00a0<a href=\"https:\/\/github.com\/appvia\/psp-migration\">https:\/\/github.com\/appvia\/psp-migration<\/a><\/p>\n<\/li>\n<li>\n<p>Governing Multi-Tenant Kubernetes Clusters with Kyverno &#8212;\u00a0<a href=\"https:\/\/medium.com\/compass-true-north\/governing-multi-tenant-kubernetes-clusters-with-kyverno-3e11ba4a64ad\">https:\/\/medium.com\/compass-true-north\/governing-multi-tenant-kubernetes-clusters-with-kyverno-3e11ba4a64ad<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/akbarsdigital\/blog\/711102\/\"> https:\/\/habr.com\/ru\/company\/akbarsdigital\/blog\/711102\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0445\u0430\u0431\u0440\u0430\u0432\u0447\u0430\u043d\u0435!<\/p>\n<p>\u0421\u043b\u044b\u0448\u0430\u043b\u0438 \u043b\u0438 \u0432\u044b, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Kyverno \u0438 \u0437\u0430\u0447\u0435\u043c \u043e\u043d \u043d\u0443\u0436\u0435\u043d? \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0438 \u043f\u043e\u043a\u0430\u0436\u0443 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445, \u043a\u0430\u043a \u043c\u044b \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c.<\/p>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041c\u0430\u043a\u0430\u0440\u0438\u0439 \u0411\u0430\u043b\u0430\u0448\u043e\u0432, \u044f SRE \u0432 Ak Bars Digital. \u041d\u0430\u0448\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u043e\u0439 \u0438 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u044d\u0442\u043e\u0442 \u0432\u0430\u0448 Kyverno?<\/h2>\n<p><strong><em>Kyverno<\/em><\/strong>\u00a0\u2014 policy engine \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f <em>Kubernetes.<\/em><\/p>\n<p>Kyverno \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u0441\u0440\u0435\u0434\u044b \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0441\u0432\u043e\u0438\u0445 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u0432. Kyverno \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 best practises \u0438\u043b\u0438 \u0434\u043b\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0438\u0445 \u043f\u0443\u0442\u0435\u043c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 API.<\/p>\n<p>\u0412\u043e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u0440\u0443\u0442\u044b\u0445 \u0444\u0438\u0448\u0435\u043a Kyverno:<\/p>\n<ul>\n<li>\n<p>policy \u043a\u0430\u043a \u0440\u0435\u0441\u0443\u0440\u0441\u044b kubernetes (yaml \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u044b);<\/p>\n<\/li>\n<li>\n<p>\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b k8s;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u043e\u043a \u041f\u041e;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043c\u0435\u0442\u0430\u0434\u0430\u0442\u044b \u043e\u0431\u0440\u0430\u0437\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0432 Namespace\u2019\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u0438\u043b\u0438 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043e \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f\u0445 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0430\u043c\u0438 \u043a\u0430\u043a \u043a\u043e\u0434\u043e\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a\u00a0<code>git<\/code>\u00a0\u0438\u00a0<code>kustomize<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u0438\u0442\u0438\u043a (\u0443\u0436\u0435 244).<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432 Kyverno \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c\u00a0<a href=\"https:\/\/open-policy-agent.github.io\/gatekeeper\/website\/docs\/\">OPA\/Gatekeeper<\/a>,\u00a0<a href=\"https:\/\/www.kubewarden.io\/\">Kubewarden<\/a>\u00a0\u0438\u00a0<a href=\"https:\/\/www.jspolicy.com\/\">jsPolicy<\/a>.<\/p>\n<p>\u041f\u0440\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 \u0441\u0435\u0442\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440\u00a0<a href=\"https:\/\/neonmirrors.net\/post\/2021-02\/kubernetes-policy-comparison-opa-gatekeeper-vs-kyverno\/\">\u0442\u0443\u0442 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442 Kyverno \u0438 Gatekeeper<\/a>.<\/p>\n<h2>\u0417\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0430\u043c?<\/h2>\n<p>\u0412 1.21 PodSecurityPolicy \u0441\u0442\u0430\u043b\u0430 \u0434\u0435\u043f\u0440\u0435\u043a\u0435\u0439\u0442\u0435\u0434 \u0444\u0438\u0447\u0435\u0439 Kubernetes, \u0430 \u0432 1.25 \u0431\u044b\u043b\u0430 \u0432\u043e\u0432\u0441\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0430.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0441\u0442\u0430\u043b \u0432\u043e\u043f\u0440\u043e\u0441, \u0430 \u043a\u0430\u043a \u0434\u0430\u043b\u044c\u0448\u0435 \u0436\u0438\u0442\u044c? \u0418 \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u043e\u0442\u0435\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0432\u044b\u0431\u043e\u0440 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 Kyverno. \u041d\u0430\u0441 \u043e\u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0440\u0430\u0434\u043e\u0432\u0430\u043b\u0430 \u0438 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u043b\u0430 \u043d\u0430\u0448\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438, \u043a\u0430\u043a \u0437\u0430\u043c\u0435\u043d\u0430 PSP.<\/p>\n<p>\u041d\u0430 \u0444\u043e\u043d\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432 Kyverno \u0432\u044b\u0434\u0435\u043b\u0438\u043b\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c \u0441\u0440\u0430\u0437\u0443 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0439 (\u043e\u0431\u044b\u0447\u043d\u044b\u0439 yaml), \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u043c \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430\u043c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0441 \u043d\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<h2>\u041a\u0430\u043a \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?<\/h2>\n<p>Kyverno \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0434\u043e\u043f\u0443\u0441\u043a\u0430 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 Kubernetes. Kyverno \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0438\u0435 \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0435 \u0432\u0435\u0431\u0445\u0443\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u043a\u0430 \u043e\u0442 kube-apiserver. \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u043a\u0430 \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u043e\u043d\u044f\u044e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<figure class=\"full-width\"><figcaption>\u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u044b Kyverno. \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a. <\/figcaption><\/figure>\n<h2>\u0414\u043b\u044f \u0447\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c?<\/h2>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043c\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Kyverno \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043a \u0437\u0430\u043c\u0435\u043d\u0443 PodSecurityPolicy. \u041d\u0430\u0447\u0430\u043b\u0438 \u0441 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u043e\u0432 PSP \u0432 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u044b \u043f\u043e\u043b\u0438\u0442\u0438\u043a Kyverno c Validate \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438.<\/p>\n<h3>Validate\u00a0Resources<\/h3>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u0445\u043e\u0442\u0435\u043b\u0438 \u0437\u0430\u043f\u0440\u0435\u0442\u0438\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a privilege \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0447\u0440\u0435\u0432\u0430\u0442\u043e \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c \u0445\u043e\u0441\u0442\u0430 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c \u044f\u0434\u0440\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u0438\u0442\u0438\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">apiVersion: kyverno.io\/v1 kind: ClusterPolicy metadata:   name: disallow-privileged-containers   annotations:     policies.kyverno.io\/title: Disallow Privileged Containers     policies.kyverno.io\/category: Pod Security Standards (Baseline)     policies.kyverno.io\/severity: medium     policies.kyverno.io\/subject: Pod     kyverno.io\/kyverno-version: 1.6.0     kyverno.io\/kubernetes-version: \"1.22-1.23\"     policies.kyverno.io\/description: >-       Privileged mode disables most security mechanisms and must not be allowed. This policy       ensures Pods do not call for privileged mode.       spec:   validationFailureAction: audit   background: true   rules:     - name: privileged-containers       match:         any:         - resources:             kinds:               - Pod       validate:         message: >-           Privileged mode is disallowed. The fields spec.containers[*].securityContext.privileged           and spec.initContainers[*].securityContext.privileged must be unset or set to `false`.                   pattern:           spec:             =(ephemeralContainers):               - =(securityContext):                   =(privileged): \"false\"             =(initContainers):               - =(securityContext):                   =(privileged): \"false\"             containers:               - =(securityContext):                   =(privileged): \"false\"<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>Mutating Resources<\/h3>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c securityContext \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435. \u0412\u043e\u0442 \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u0438\u0442\u0438\u043a\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c securityContext<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">apiVersion: kyverno.io\/v1 kind: ClusterPolicy metadata:   name: add-default-securitycontext   annotations:     policies.kyverno.io\/title: Add Default securityContext     policies.kyverno.io\/category: Sample     policies.kyverno.io\/subject: Pod     policies.kyverno.io\/description: >-       A Pod securityContext entry defines fields such as the user and group which should be used to run the Pod.       Sometimes choosing default values for users rather than blocking is a better alternative to not impede       such Pod definitions. This policy will mutate a Pod to set default securityContext     spec:   background: false   rules:   - name: add-default-securitycontext-containers     match:       any:       - resources:           kinds:           - Pod     preconditions:       all:       - key: \"{{request.operation}}\"         operator: In         value:           - CREATE           - UPDATE     mutate:       foreach:       - list: \"request.object.spec.containers\"         patchStrategicMerge:           spec:             securityContext:               runAsUser: 10001               runAsGroup: 10001               fsGroup: 10001               seccompProfile:                 type: RuntimeDefault             containers:             - name: \"{{ element.name }}\"               securityContext:                 runAsUser: 10001                 runAsGroup: 10001                 capabilities:                   drop:                     - ALL                 runAsNonRoot: true                 allowPrivilegeEscalation: false privileged: false                 seccompProfile:                   type: RuntimeDefault   - name: add-default-securitycontext-initContainers     match:       any:       - resources:           kinds:           - Pod     preconditions:       all:       - key: \"{{request.operation}}\"         operator: In         value:           - CREATE           - UPDATE       - key: \"{{ request.object.spec.initContainers[] || '' | length(@) }}\"         operator: GreaterThanOrEquals         value: 1     mutate:       foreach:       - list: \"request.object.spec.initContainers\"         patchStrategicMerge:           spec:             securityContext:               runAsUser: 10001               fsGroup: 10001               seccompProfile:                 type: RuntimeDefault             initContainers:             - name: \"{{ element.name }}\"               securityContext:                 runAsUser: 10001                 runAsGroup: 10001                 capabilities:                   drop:                     - ALL                 runAsNonRoot: true                 allowPrivilegeEscalation: false privileged: false                 seccompProfile:                   type: RuntimeDefault<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>Generate Resources<\/h3>\n<p>\u041a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f generate-\u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u0430 \u0441 \u043a\u0440\u0435\u0434\u0430\u043c\u0438 \u043e\u0442 private registry (dockerconfigjson) \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 Namespace.<\/p>\n<p>\u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0448\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u2014 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u0430 \u0441 \u0441\u0430\u043c\u043e\u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u0440\u0443\u0442\u043e\u0432\u044b\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 cert-manager, \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 namespace \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430\u00a0<code>synchronize<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 Kyverno \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432\u0441\u0435\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0435\u044e \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u044d\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u0435\u043a\u0440\u0435\u0442\u0430\u0445 \u043f\u043e\u0441\u043b\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0432\u044b\u043f\u0443\u0441\u043a\u0430 cert-manager\u2019\u043e\u043c.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u0430 \u043f\u043e Namespac\u2019\u0430\u043c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">apiVersion: kyverno.io\/v1 kind: ClusterPolicy metadata:   name: clone-cert   annotations:     policies.kyverno.io\/title: Clone Certificate's secret     policies.kyverno.io\/category: Cert-Manager     policies.kyverno.io\/subject: Certificate, Namespace     policies.kyverno.io\/description: >-       Clone certificate's secret to every namespace spec:   background: true   rules:   - name: clone-cert     match:       any:       - resources:           kinds:           - Namespace     exclude:       any:       - resources:           namespaces:           - \"kube-system\"           - \"kube-public\"           - \"default\"     generate:       synchronize: true       apiVersion: v1       kind: Secret       name: base-cert       namespace: \"{{request.object.metadata.name}}\"       clone:         namespace: cert-manager         name: base-cert<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u0435\u043b\u0430\u0435\u043c \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044e<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">apiVersion: kyverno.io\/v1 kind: ClusterPolicy metadata:   name: add-certificates-volume   annotations:     policies.kyverno.io\/title: Add Certificates as a Volume     policies.kyverno.io\/category: Sample     policies.kyverno.io\/subject: Pod,Volume     kyverno.io\/kyverno-version: 1.5.2     kyverno.io\/kubernetes-version: \"1.21\"     policies.kyverno.io\/minversion: 1.5.0     pod-policies.kyverno.io\/autogen-controllers: DaemonSet,Deployment,Job,StatefulSet     policies.kyverno.io\/description: >-       In some cases you would need to trust custom CA certificates for all the containers of a Pod.       It makes sense to be in a Secret so that you can automount them by only setting an annotation.       This policy adds a volume to all containers in a Pod containing the certificate if the annotation       called `inject-certs` with value `enabled` is found.       spec:   background: true   rules:   - name: add-ssl-certs     match:       any:       - resources:           kinds:           - Pod     exclude:       any:       - resources:           namespaces:           - \"kube-system\"           - \"kube-public\"           - \"default\"     preconditions:       all:       - key: \"{{request.operation}}\"         operator: In         value:           - CREATE           - UPDATE     mutate:       foreach:       - list: \"request.object.spec.containers\"          patchStrategicMerge:           spec:<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-344081","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/344081","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=344081"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/344081\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=344081"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=344081"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=344081"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}