Skip to content
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

Kyverno mutate eks-prow-build-cluster to pull images from ecr #4994

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions infra/aws/terraform/prow-build-cluster/resources/kyverno/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Please run this command to upgrade Kyverno:

```
helm template kyverno \
kyverno/kyverno \
-f=values \
-n=kyverno > kyverno.yaml
```

`helm template` does not properly template api resource versions, thus **PodDisruptionBudget** api version must be changed from `policy/v1beta1` to `policy/v1` after running the previous command.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: k8s-prow-gcr-to-ecr-registry
spec:
background: false
rules:
- name: replace-image-registry-gcr-k8s-prow-to-ecr-pod-containers
match:
any:
- resources:
kinds:
- Pod
mutate:
foreach:
- list: "request.object.spec.containers"
patchStrategicMerge:
spec:
containers:
- name: "{{ element.name }}"
image: "{{ regex_replace_all('gcr.io/k8s-(prow/|staging-)', '{{ element.image }}', '468814281478.dkr.ecr.us-east-2.amazonaws.com/k8s-${1}' )}}"
- name: replace-image-registry-gcr-k8s-prow-to-ecr-pod-initcontainers
match:
any:
- resources:
kinds:
- Pod
preconditions:
all:
- key: "{{ request.object.spec.initContainers[] || `[]` | length(@) }}"
operator: GreaterThanOrEquals
value: 1
mutate:
foreach:
- list: "request.object.spec.initContainers"
patchStrategicMerge:
spec:
initContainers:
- name: "{{ element.name }}"
image: "{{ regex_replace_all('gcr.io/k8s-(prow/|staging-)', '{{ element.image }}', '468814281478.dkr.ecr.us-east-2.amazonaws.com/k8s-${1}' )}}"
Loading