How do I configure alternative security policy management solutions? | Как настроить альтернативные решения по управлению политиками безопасности? |
For DKP to work correctly, extended privileges are required to run and operate system component payloads. If you are using some alternative security policy management solution (e. g., Kyverno) instead of the admission-policy-engine module, you have to configure exceptions for the following namespaces:
| Для корректной работы DKP необходимы расширенные привилегии на запуск и работу полезной нагрузки системных компонентов. Если вместо модуля admission-policy-engine используется альтернативное решение по управлению политиками безопасности (например, Kyverno), необходима настройка исключений для следующих пространств имен:
|
How do I extend Pod Security Standards policies? | Как расширить политики Pod Security Standards? |
|
|
To extend the Pod Security Standards policy by adding your checks to existing checks, you need to:
| Чтобы расширить политику Pod Security Standards, добавив к существующим проверкам политики свои собственные, необходимо:
|
Example of the | Пример шаблона для проверки адреса репозитория образа контейнера: |
yaml apiVersion: templates.gatekeeper.sh/v1 kind: ConstraintTemplate metadata: name: k8sallowedrepos spec: crd: spec: names: kind: K8sAllowedRepos validation: openAPIV3Schema: type: object properties: repos: type: array items: type: string targets:
| yaml apiVersion: templates.gatekeeper.sh/v1 kind: ConstraintTemplate metadata: name: k8sallowedrepos spec: crd: spec: names: kind: K8sAllowedRepos validation: openAPIV3Schema: type: object properties: repos: type: array items: type: string targets:
|
violation[{“msg”: msg}] { container := input.review.object.spec.containers[] satisfied := [good | repo = input.parameters.repos[] ; good = startswith(container.image, repo)] not any(satisfied) msg := sprintf(“container <%v> has an invalid image repo <%v>, allowed repos are %v”, [container.name, container.image, input.parameters.repos]) } | violation[{“msg”: msg}] { container := input.review.object.spec.containers[] satisfied := [good | repo = input.parameters.repos[] ; good = startswith(container.image, repo)] not any(satisfied) msg := sprintf(“container <%v> has an invalid image repo <%v>, allowed repos are %v”, [container.name, container.image, input.parameters.repos]) } |
violation[{“msg”: msg}] { container := input.review.object.spec.initContainers[] satisfied := [good | repo = input.parameters.repos[] ; good = startswith(container.image, repo)] not any(satisfied) msg := sprintf(“container <%v> has an invalid image repo <%v>, allowed repos are %v”, [container.name, container.image, input.parameters.repos]) } | violation[{“msg”: msg}] { container := input.review.object.spec.initContainers[] satisfied := [good | repo = input.parameters.repos[] ; good = startswith(container.image, repo)] not any(satisfied) msg := sprintf(“container <%v> has an invalid image repo <%v>, allowed repos are %v”, [container.name, container.image, input.parameters.repos]) } |
Example of binding a check to the | Пример привязки проверки к политике |
yaml apiVersion: constraints.gatekeeper.sh/v1beta1 kind: K8sAllowedRepos metadata: name: prod-repo spec: match: kinds:
| yaml apiVersion: constraints.gatekeeper.sh/v1beta1 kind: K8sAllowedRepos metadata: name: prod-repo spec: match: kinds:
|
The example demonstrates the configuration of checking the repository address in the | Пример демонстрирует настройку проверки адреса репозитория в поле |
The Gatekeeper documentation may find more info about templates and policy language. | Подробнее о шаблонах и языке политик можно узнать в документации Gatekeeper. |
Find more examples of checks for policy extension in the Gatekeeper Library. | Больше примеров описания проверок для расширения политики можно найти в библиотеке Gatekeeper. |
How to allow some Pod Security Standards policies without disabling whole list? | Как включить одну или несколько политик Pod Security Standards, не отключая весь набор? |
To apply only the required security policies without turning off the entire built-in set: | Чтобы применить только нужные политики безопасности, не отключая весь предустановленный набор: |
|
|
SecurityPolicy that matches baseline standard: | SecurityPolicy, соответствующая baseline: |
yaml apiVersion: deckhouse.io/v1alpha1 kind: SecurityPolicy metadata: name: baseline spec: enforcementAction: Deny policies: allowHostIPC: false allowHostNetwork: false allowHostPID: false allowPrivilegeEscalation: true allowPrivileged: false allowedAppArmor:
| yaml apiVersion: deckhouse.io/v1alpha1 kind: SecurityPolicy metadata: name: baseline spec: enforcementAction: Deny policies: allowHostIPC: false allowHostNetwork: false allowHostPID: false allowPrivilegeEscalation: true allowPrivileged: false allowedAppArmor:
|
| SecurityPolicy, соответствующая restricted: |
yaml apiVersion: deckhouse.io/v1alpha1 kind: SecurityPolicy metadata: name: restricted spec: enforcementAction: Deny policies: allowHostIPC: false allowHostNetwork: false allowHostPID: false allowPrivilegeEscalation: false allowPrivileged: false allowedAppArmor:
| yaml apiVersion: deckhouse.io/v1alpha1 kind: SecurityPolicy metadata: name: restricted spec: enforcementAction: Deny policies: allowHostIPC: false allowHostNetwork: false allowHostPID: false allowPrivilegeEscalation: false allowPrivileged: false allowedAppArmor:
|
What if there are multiple policies (operational or security) that are applied to the same object? | Что, если несколько политик (операционных или безопасности) применяются на один объект? |
In that case the object’s specification have to fulfil all the requirements imposed by the policies. | В таком случае необходимо, чтобы конфигурация объекта соответствовала всем политикам, которые на него распространяются. |
For example, consider the following two security policies: | Например, рассмотрим две следующие политики безопасности: |
yaml apiVersion: deckhouse.io/v1alpha1 kind: SecurityPolicy metadata: name: foo spec: enforcementAction: Deny match: namespaceSelector: labelSelector: matchLabels: name: test policies: readOnlyRootFilesystem: true requiredDropCapabilities:
| yaml apiVersion: deckhouse.io/v1alpha1 kind: SecurityPolicy metadata: name: foo spec: enforcementAction: Deny match: namespaceSelector: labelSelector: matchLabels: name: test policies: readOnlyRootFilesystem: true requiredDropCapabilities:
|
Then, in order to fulfill the requirements of the above security policies, the following settings must be set in a container specification: | Тогда для выполнения требований приведенных политик безопасности в спецификации контейнера нужно указать: |
yaml securityContext: capabilities: drop:
| yaml securityContext: capabilities: drop:
|
Verification of image signatures | Проверка подписи образов |
This feature is available in the following editions: SE+, EE. | Доступно в следующих редакциях: SE+, EE, CSE Lite (1.67), CSE Pro (1.67). |
The module implements a function for checking the signatures of container images signed using Cosign. Checking the signatures of container images allows you to ensure their integrity (that the image has not been modified since its creation) and authenticity (that the image was created by a trusted source). You can enable container image signature verification in the cluster using the policies.verifyImageSignatures parameter of the SecurityPolicy resource. | В модуле реализована функция проверки подписи образов контейнеров, подписанных с помощью инструмента Cosign. Проверка подписи образов контейнеров позволяет убедиться в их целостности (что образ не был изменен после его создания) и подлинности (что образ был создан доверенным источником). Включить проверку подписи образов контейнеров в кластере можно с помощью параметра policies.verifyImageSignatures ресурса SecurityPolicy. |
Steps to sign an image:
| Шаги для подписания образа:
|
For more information on working with Cosign, you can check the documentation. | Подробнее о работе с Cosign можно узнать в документации. |
Example of SecurityPolicy for configuring the signature verification of container images: | Пример SecurityPolicy для настройки проверки подписи образов контейнеров: |
yaml apiVersion: deckhouse.io/v1alpha1 kind: SecurityPolicy metadata: name: verify-image-signatures spec: match: namespaceSelector: labelSelector: matchLabels: kubernetes.io/metadata.name: default policies: verifyImageSignatures:
| yaml apiVersion: deckhouse.io/v1alpha1 kind: SecurityPolicy metadata: name: verify-image-signatures spec: match: namespaceSelector: labelSelector: matchLabels: kubernetes.io/metadata.name: default policies: verifyImageSignatures:
|
Policies do not affect the creation of pods whose container image addresses do not match those described in the | Политика не влияет на создание подов, адреса образов контейнеров которых не подходят под описанные в параметре |
Example of an error output when creating a Pod with a container image that has not passed the signature verification: | Пример вывода ошибки при создании пода с образом контейнера, не прошедшим проверку подписи: |
console [verify-image-signatures] Image signature verification failed: nginx:1.17.2 | console [verify-image-signatures] Image signature verification failed: nginx:1.17.2 |