-
Notifications
You must be signed in to change notification settings - Fork 17
chore(website) update politecnico di torino logo url #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f60d3c6
chore(website): update politecnico di torino logo url
Svarrogh1337 634f45e
chore(website): update politecnico di torino logo url
Svarrogh1337 e12c3d6
Merge remote-tracking branch 'live/chore/fix-polito-logo' into chore/…
Svarrogh1337 d039719
chore(website): add missing rules.md page
Svarrogh1337 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,265 @@ | ||
| --- | ||
| title: Rules | ||
| weight: 5 | ||
| description: > | ||
| Configure policies and restrictions on tenant-basis with Rules | ||
| --- | ||
|
|
||
| Enforcement rules allow Bill, the cluster admin, to set policies and restrictions on a per-`Tenant` basis. These rules are enforced by Capsule Admission Webhooks when Alice, the `TenantOwner`, creates or modifies resources in her `Namespaces`. With the Rule Construct we can profile namespaces within a tenant to adhere to specific policies, depending on metadata. | ||
|
|
||
| ## Namespace Selector | ||
|
|
||
| By default a rule is applied to all namespaces within a `Tenant`. However you can select a subset of namespaces to apply the rule on, by using a `namespaceSelector`. This selector works the same way as a standard Kubernetes label selector: | ||
|
|
||
| ```yaml | ||
| --- | ||
| apiVersion: capsule.clastix.io/v1beta2 | ||
| kind: Tenant | ||
| metadata: | ||
| name: solar | ||
| spec: | ||
| ... | ||
| rules: | ||
| # Matches all Namespaces and enforces the rule for all of them | ||
| - enforce: | ||
| registries: | ||
| - url: "harbor/v2/customer-registry/.*" | ||
| policy: [ "ifNotPresent" ] | ||
Svarrogh1337 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Select a subset of namespaces (enviornment=prod) to allow further registries | ||
Svarrogh1337 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - namespaceSelector: | ||
| matchExpressions: | ||
| - key: env | ||
| operator: In | ||
| values: ["prod"] | ||
| enforce: | ||
| registries: | ||
| - url: "harbor/v2/prod-registry/.*" | ||
| policy: [ "ifNotPresent" ] | ||
Svarrogh1337 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| Note that rules are combined together. In the above example, all namespaces within the `solar` tenant will be enforced to use images from `harbor/v2/customer-registry/*`, while namespaces labeled with `env=prod` will also be allowed to pull images from `harbor/v2/prod-registry/*`. | ||
|
|
||
| ## Enforcement | ||
|
|
||
| Declare Enforcement rules for the selected namespaces. | ||
|
|
||
| ### Registries | ||
|
|
||
| Define allowed image registries for `Pods` with rules. Each registry can have specific policies and validation targets. We use Regexp pattern matching for the registry URL, so you can specify patterns like `harbor/v2/customer-registry/*` to match all images from that registry. The matching is done against the full image name, including the path and tag. The ordering is based on the order of declaration, so the first matching rule will be applied. The later the match is found, the higher the precedence. This allows you to build constructs like these: | ||
Svarrogh1337 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ```yaml | ||
| --- | ||
| apiVersion: capsule.clastix.io/v1beta2 | ||
| kind: Tenant | ||
| metadata: | ||
| name: solar | ||
| spec: | ||
| ... | ||
| rules: | ||
| - enforce: | ||
| registries: | ||
|
|
||
| # Enforce PullPolicy "always" for all registries (For Container Images and Volume Images) | ||
| - url: ".*" | ||
| policy: [ "Always" ] | ||
|
|
||
| # If we are pulling from a harbor registry we want to verify the images for Containers only | ||
| - url: "harbor/.*" | ||
|
|
||
| - namespaceSelector: | ||
| matchExpressions: | ||
| - key: env | ||
| operator: In | ||
| values: ["prod"] | ||
| enforce: | ||
| registries: | ||
| - url: "harbor/v2/customer-registry/prod-image/.*" | ||
| policy: [ "Always" ] | ||
| ``` | ||
|
|
||
| Let's try to apply the following pod in the namespace `solar-test` (Does not match the `env=prod` selector): | ||
|
|
||
| ```yaml | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: image-volume | ||
| spec: | ||
| containers: | ||
|
|
||
| - name: shell | ||
| command: ["sleep", "infinity"] | ||
| imagePullPolicy: Never | ||
| image: harbor/v2/prod-registry/debian | ||
| volumeMounts: | ||
| - name: volume | ||
| mountPath: /volume | ||
|
|
||
| volumes: | ||
| - name: volume | ||
| image: | ||
| reference: quay.io/crio/artifact:v2 | ||
| pullPolicy: IfNotPresent | ||
|
|
||
|
|
||
| ``` | ||
|
|
||
| **What do you expect to happen?** | ||
|
|
||
| ```bash | ||
| kubectl apply -f pod.yaml -n solar-test | ||
|
|
||
| Error from server (Forbidden): error when creating "pod.yaml": admission webhook "pods.projectcapsule.dev" denied the request: containers[0] reference "harbor/v2/prod-registry/debian" uses pullPolicy=Never which is not allowed (allowed: Always) | ||
| ``` | ||
|
|
||
| Because our first rule enforces all registries to use the `always` image pull policy, the pod creation is denied because it uses the `Never` policy. We can either allow the `Never` policy for this specific registry: | ||
|
|
||
| ```yaml | ||
| --- | ||
| apiVersion: capsule.clastix.io/v1beta2 | ||
| kind: Tenant | ||
| metadata: | ||
| name: solar | ||
| spec: | ||
| ... | ||
| rules: | ||
| - enforce: | ||
| registries: | ||
|
|
||
| # Enforce PullPolicy "always" for all registries (For Container Images and Volume Images) | ||
| - url: ".*" | ||
| policy: [ "Always" ] | ||
|
|
||
| # If we are pulling from a harbor registry we want to verify the images for Containers only | ||
| - url: "harbor/.*" | ||
| policy: [ "Never" ] | ||
|
|
||
| - namespaceSelector: | ||
| matchExpressions: | ||
| - key: env | ||
| operator: In | ||
| values: ["prod"] | ||
| enforce: | ||
| registries: | ||
| - url: "harbor/v2/customer-registry/prod-image/.*" | ||
| policy: [ "always" ] | ||
Svarrogh1337 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| But let's for now also remove the generic rule for all registries and only keep the harbor one: | ||
|
|
||
| ```yaml | ||
| --- | ||
| apiVersion: capsule.clastix.io/v1beta2 | ||
| kind: Tenant | ||
| metadata: | ||
| name: solar | ||
| spec: | ||
| ... | ||
| rules: | ||
| - enforce: | ||
| registries: | ||
|
|
||
| # If we are pulling from a harbor registry we want to verify the images for Containers only | ||
| - url: "harbor/.*" | ||
| policy: [ "Never" ] | ||
|
|
||
| - namespaceSelector: | ||
| matchExpressions: | ||
| - key: env | ||
| operator: In | ||
| values: ["prod"] | ||
| enforce: | ||
| registries: | ||
| - url: "harbor/v2/customer-registry/prod-image/.*" | ||
| policy: [ "Always" ] | ||
| ``` | ||
|
|
||
| If we try to apply the pod again, it we will still get an error. The problem is that we are mounting an image volume that is not coming from the allowed harbor registry: | ||
Svarrogh1337 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ```bash | ||
| Error from server (Forbidden): error when creating "pod.yaml": admission webhook "pods.projectcapsule.dev" denied the request: volumes[0](volume) reference "quay.io/crio/artifact:v2" is not allowed | ||
| ``` | ||
|
|
||
| However we would like to only validate the images used in the Pod spec (Containers, InitContainers, EphemeralContainers) and not the ones used in the Volumes. We can achieve this by specifying the [`validation`](#validation) field for the harbor registry: | ||
|
|
||
| ```yaml | ||
| --- | ||
| apiVersion: capsule.clastix.io/v1beta2 | ||
| kind: Tenant | ||
| metadata: | ||
| name: solar | ||
| spec: | ||
| ... | ||
| rules: | ||
| - enforce: | ||
| registries: | ||
| # If we are pulling from a harbor registry we want to verify the images for Containers only | ||
| - url: "harbor/.*" | ||
| policy: [ "Never" ] | ||
| validation: | ||
| - "pod/images" | ||
|
|
||
| - namespaceSelector: | ||
| matchExpressions: | ||
| - key: env | ||
| operator: In | ||
| values: ["prod"] | ||
| enforce: | ||
| registries: | ||
| - url: "harbor/v2/customer-registry/prod-image/.*" | ||
| policy: [ "Always" ] | ||
| ``` | ||
|
|
||
| #### Policy | ||
|
|
||
| Define the allowed image pull policies for the specified registry URL. Supported policies are: | ||
|
|
||
| * `Always`: The image is always pulled. | ||
| * `IfNotPresent`: The image is pulled only if it is not already present on the node. | ||
| * `Never`: The image is never pulled. If the image is not present on the node, the Pod will fail to start. | ||
|
|
||
| This configuration is optional. If no policy is specified, all image pull policies are allowed for the given registry. | ||
|
|
||
| ```yaml | ||
| --- | ||
| apiVersion: capsule.clastix.io/v1beta2 | ||
| kind: Tenant | ||
| metadata: | ||
| name: solar | ||
| spec: | ||
| ... | ||
| rules: | ||
| # Matches all Namespaces and enforces the rule for all of them | ||
| - enforce: | ||
| registries: | ||
| - url: "harbor/v2/customer-registry/.*" | ||
| policy: [ "IfNotPresent", "Always" ] | ||
| ``` | ||
|
|
||
|
|
||
| #### Validation | ||
|
|
||
| Define on which parts of the Pod the registry policy must be validated. Currently supported validation targets are: | ||
|
|
||
| * `pod/images`: Validate the images used in the Pod spec (For `Containers`, `InitContainers` and `EphemeralContainers`). | ||
| * `pod/volumes`: Validate the images used in the Pod `Volumes` ([Read More](https://kubernetes.io/docs/tasks/configure-pod-container/image-volumes/)) | ||
|
|
||
| **By default, both targets are validated**. You can override this behavior by specifying the `validation` field for each registry: | ||
|
|
||
| ```yaml | ||
| --- | ||
| apiVersion: capsule.clastix.io/v1beta2 | ||
| kind: Tenant | ||
| metadata: | ||
| name: solar | ||
| spec: | ||
| ... | ||
| rules: | ||
| # Matches all Namespaces and enforces the rule for all of them | ||
| - enforce: | ||
| registries: | ||
| - url: "harbor/v2/customer-registry/.*" | ||
| validation: | ||
| - "pod/images" | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.