この文書は自動機械翻訳技術を使用して翻訳されています。 正確な翻訳を提供するように努めておりますが、翻訳された内容の完全性、正確性、信頼性については一切保証いたしません。 相違がある場合は、元の英語版 英語 が優先され、正式なテキストとなります。

これは未公開の文書です Admission Controller 1.34-dev.

ポリシーの配布

SUSE Security Admission Controllerポリシーは、Admission Controllerポリシーサーバーによって評価されるWebAssembly(Wasm)バイナリです。

Admission Controllerポリシーサーバーは、これらのソースからポリシーを読み込みます:

Admission Controllerは、通常のOCI準拠のレジストリを介してAdmission Controllerポリシーを配布することを推奨します。コンテナレジストリは、すべてのKubernetesクラスターにとって必須の要件です。クラスターに必要なすべてのアーティファクトを保存し、保護するための単一の場所を持つことは有益です。

OCI準拠のレジストリにポリシーをプッシュする

OCIイメージフォーマット仕様は、通常のOCI準拠のコンテナレジストリ内に任意のバイナリブロブを保存することを許可します。

ターゲットOCI準拠のレジストリは、アーティファクトをサポートする必要があります。これにより、Admission Controllerポリシーを正常にプッシュできます。

kwctl CLIを使用して、Admission ControllerポリシーをOCI準拠のレジストリにプッシュできます。

ポリシーの注釈付け

ポリシーには、`kwctl`を使用して注釈を付けることもできます。ポリシーの注釈付けは、Admission ControllerポリシーのバイナリにWasmカスタムセクションを追加することで行われます。これは、ポリシーが独自のメタデータをパッケージ化することを意味します。

`kwctl annotate`コマンドは、2つの入力を必要とします:

  • Admission Controllerポリシーに注釈を付けるための、ファイルシステム内のローカルファイル。

  • 注釈ファイル、ポリシーメタデータのYAML記述を含むファイル。 このファイルは通常、ポリシーのルートプロジェクトフォルダーにあります。

例えば、このファイルを現在のディレクトリに`metadata.yml`として保存できます:

rules:
- apiGroups: ["*"]
  apiVersions: ["*"]
  resources: ["*"]
  operations: ["*"]
mutating: false
annotations:
  io.kubewarden.policy.title: palindromify
  io.kubewarden.policy.version: 0.1.0
  io.kubewarden.policy.description: Allows you to reject palindrome names in resources and namespace names, or to only accept palindrome names
  io.kubewarden.policy.author: Name Surname <name.surname@example.com>
  io.kubewarden.policy.url: https://github.com/<org>/palindromify
  io.kubewarden.policy.source: https://github.com/<org>/palindromify
  io.kubewarden.policy.license: Apache-2.0
  io.kubewarden.policy.usage: |
    This is markdown text and as such allows you to define a free form usage text.

    This policy allows you to reject requests if:
    - The name of the resource is a palindrome name.
    - The namespace name where this resource is created has a palindrome name.

    This policy accepts the following settings:

    - `+invert_behavior+`: bool that inverts the policy behavior. If enabled, only palindrome names will be accepted.

では、ポリシーに注釈を付けましょう:

$ kwctl annotate policy.wasm \
    --metadata-path metadata.yml \
    --output-path annotated-policy.wasm

注釈処理はポリシーに対して特定の最適化を行うため、注釈付きポリシーはしばしば元のものよりも小さくなります。これは、元のWasmオブジェクトを生成するために使用されるツールチェーンに大きく依存します。

kwctl inspectを使用してポリシーを確認してください。
$ kwctl inspect annotated-policy.wasm
2023-08-24T12:06:27.986401Z  INFO sigstore::cosign::client_builder: Rekor public key not provided. Rekor integration disabled
2023-08-24T12:06:27.986449Z  INFO sigstore::cosign::client_builder: No Fulcio cert has been provided. Fulcio integration disabled
Details
title:                    palindromify
description:              Allows you to reject palindrome names in resources and namespace names, or to only accept palindrome names
author:                   Name Surname <name.surname@example.com>
url:                      https://github.com/<org>/palindromify
source:                   https://github.com/<org>/palindromify
license:                  Apache-2.0
mutating:                 false
background audit support: true
context aware:            false
execution mode:           kubewarden-wapc
protocol version:         1

Annotations
io.kubewarden.kwctl       1.7.0-rc2

Rules
────────────────────
- apiGroups:
  - '*'
  apiVersions:
  - '*'
  resources:
  - '*'
  operations:
  - '*'
────────────────────

Usage
This is markdown text and as such allows you to define a free form usage text.

This policy allows you to reject requests if:

• The name of the resource is a palindrome name.
• The namespace name where this resource is created has a palindrome name.

This policy accepts the following settings:

• invert_behavior: bool that inverts the policy behavior. If enabled, only palindrome names will be accepted.

Cannot determine if the policy has been signed. There was an error while attempting to fetch its signatures from the remote registry: invalid uri

ポリシーをプッシュする

このようにして注釈付きポリシーをプッシュできます:

$ kwctl push annotated-policy.wasm \
     <oci-registry>/kubewarden-policies/palindromify-policy:v0.0.1

注釈のないポリシーをプッシュすることは推奨されません。ポリシーサーバーは、注釈によって提供されたメタデータを使用して、ポリシーを正しく実行します。デフォルトでは、kwctl push`はそのようなポリシーをOCIレジストリにプッシュすることを拒否します。注釈のないポリシーが必要な場合は、-‍-‍force`の`kwctl push`フラグを使用してください。

Admission Controllerポリシーサーバーまたは`kwctl`から`registry://<oci-registry>/kubewarden-policies/palindromify-policy:v0.0.1`としてポリシーを参照できます。