Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Update Operator to support Gatekeeper v3.5.1 #181

Merged
merged 34 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
33bf20a
Set Gatekeeper version to v3.5.1
font Jul 15, 2021
0fab940
make import-manifests
font Jul 16, 2021
97e94d2
Remove v1beta1 CRDs and webhook Gatekeeper configs
font Jul 16, 2021
48d41c6
make update-bindata
font Jul 16, 2021
5b7495d
Update operator Gatekeeper assets for v3.5.1
font Jul 16, 2021
951c672
Remove workaround to build Gatekeeper manifests
font Jul 16, 2021
8e13c78
Run actions gatekeeper e2e tests directly
font Jul 17, 2021
3a647ec
Remove duplicate Gatekeeper bats e2e tests
font Jul 17, 2021
9f85ba7
Update RELATED_IMAGE_GATEKEEPER version to v3.5.1
font Jul 17, 2021
fe8da6a
Update sample configs to use Gatekeeper v3.5.1
font Jul 17, 2021
e819023
make bundle
font Jul 17, 2021
83fb438
Add kubebuilder RBAC marker to CRUD resourcequotas
font Jul 17, 2021
e210f69
Add RBAC marker to CRUD poddisruptionbudgets
font Jul 17, 2021
a064f5a
make manifests
font Jul 17, 2021
29102a5
make bundle
font Jul 23, 2021
9401087
Update unit tests for Gatekeeper v3.5.1
font Jul 19, 2021
5418df7
Add audit mutation-status operation for mutation
font Jul 20, 2021
3ebfff9
Add unit tests for audit mutation-status operation
font Jul 20, 2021
58c4656
Add e2e tests for audit mutation-status operation
font Jul 20, 2021
6051155
Reorder deletes and creates or updates of assets
font Jul 22, 2021
12bf1b4
Always set failure policy to ignore for pods pending
font Jul 22, 2021
ad642bb
Add logs for verifying deployment readiness
font Jul 22, 2021
753ba82
Update unit tests after reordering CRUD for assets
font Jul 23, 2021
ab18af2
Add DisabledBuiltins field to WebhookConfig
font Jul 23, 2021
b68298f
make generate
font Jul 23, 2021
9b1c1ed
make manifests
font Jul 23, 2021
6bad031
make bundle
font Jul 23, 2021
43eb20c
Add support --disable-opa-builtin argument
font Jul 23, 2021
15abaad
Update unit tests for --disable-opa-builtin arg
font Jul 23, 2021
d7aef80
Update e2e tests for --disable-opa-builtin arg
font Jul 23, 2021
538beef
Convert mutation enabled check to be asynchronous
font Jul 26, 2021
664793e
Use MutatingCRDs global var to check CRDs exist
font Jul 26, 2021
ae928e0
Add poll-interval and timeout options to e2e tests
font Jul 26, 2021
a5d6580
Wait up to 10 minutes for Gatekeeper CR deletion
font Jul 26, 2021
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
62 changes: 28 additions & 34 deletions .github/workflows/ci_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ jobs:
name: Run verify and unit tests
runs-on: ubuntu-20.04

defaults:
run:
working-directory: gatekeeper-operator

steps:
- uses: actions/checkout@v2
with:
path: gatekeeper-operator
fetch-depth: 0 # Fetch all history for all tags and branches

# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
Expand Down Expand Up @@ -55,35 +50,9 @@ jobs:
make manifests
git diff --exit-code

- name: Set Up Environment Variables
run: |
GATEKEEPER_VERSION=$(awk '/^GATEKEEPER_VERSION/ {print $3}' Makefile)
echo "GATEKEEPER_VERSION=${GATEKEEPER_VERSION}" >> ${GITHUB_ENV}

# This step is necessary to use a local clone of the Gatekeeper repo.
# Otherwise kustomize bulid fails using the go-getter URL format as result
# of https://github.com/open-policy-agent/gatekeeper/issues/1112. Also see
# https://github.com/kubernetes-sigs/kustomize/issues/3515 for a feature
# request.
- name: Checkout Gatekeeper to verify imported manifests
uses: actions/checkout@v2
with:
repository: open-policy-agent/gatekeeper
ref: ${{ env.GATEKEEPER_VERSION }}
path: gatekeeper
fetch-depth: 0 # Fetch all history for all tags and branches

# Build Gatekeeper manifests with some workarounds due to issue described
# above.
- name: Prepare Gatekeeper manifests for importing
working-directory: gatekeeper
run: |
make patch-image IMG=openpolicyagent/gatekeeper:${GATEKEEPER_VERSION}
sed -i '/--emit-\(audit\|admission\)-events/d' config/overlays/dev/manager_image_patch.yaml

- name: Verify imported manifests
run: |
make import-manifests IMPORT_MANIFESTS_PATH=${GITHUB_WORKSPACE}/gatekeeper
make import-manifests
git diff --exit-code

- name: Verify bindata
Expand Down Expand Up @@ -145,9 +114,18 @@ jobs:
name: Run gatekeeper e2e tests
runs-on: ubuntu-20.04

defaults:
run:
working-directory: gatekeeper-operator

strategy:
matrix:
NAMESPACE: ["gatekeeper-system"]

steps:
- uses: actions/checkout@v2
with:
path: gatekeeper-operator
fetch-depth: 0 # Fetch all history for all tags and branches

# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
Expand Down Expand Up @@ -183,7 +161,23 @@ jobs:
make docker-build IMG=localhost:5000/gatekeeper-operator:$GITHUB_SHA
kind load docker-image localhost:5000/gatekeeper-operator:$GITHUB_SHA

- name: Set Up Environment Variables
run: |
GATEKEEPER_VERSION=$(awk '/^GATEKEEPER_VERSION/ {print $3}' Makefile)
echo "GATEKEEPER_VERSION=${GATEKEEPER_VERSION}" >> ${GITHUB_ENV}

# Checkout a local copy of Gatekeeper to use its bats e2e tests.
- name: Checkout Gatekeeper to verify imported manifests
uses: actions/checkout@v2
with:
repository: open-policy-agent/gatekeeper
ref: ${{ env.GATEKEEPER_VERSION }}
path: gatekeeper
fetch-depth: 0 # Fetch all history for all tags and branches

- name: Gatekeeper E2E Tests
run: |
make deploy-ci NAMESPACE=gatekeeper-system IMG=localhost:5000/gatekeeper-operator:$GITHUB_SHA
make test-gatekeeper-e2e ENABLE_MUTATION_TESTS=y
make deploy-ci NAMESPACE=${{ matrix.NAMESPACE }} IMG=localhost:5000/gatekeeper-operator:$GITHUB_SHA
make test-gatekeeper-e2e
cd ../gatekeeper
make test-e2e GATEKEEPER_NAMESPACE=${{ matrix.NAMESPACE }} ENABLE_MUTATION_TESTS=1
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ VERSION ?= v0.1.2
# Replaces Operator version
REPLACES_VERSION ?= $(VERSION)
# Current Gatekeeper version
GATEKEEPER_VERSION ?= v3.3.0
GATEKEEPER_VERSION ?= v3.5.1
# Default image repo
REPO ?= quay.io/gatekeeper
# Default bundle image tag
Expand Down Expand Up @@ -357,7 +357,6 @@ download-binaries:
test-gatekeeper-e2e:
kubectl -n $(NAMESPACE) apply -f ./config/samples/gatekeeper_e2e_test.yaml
bats --version
bats -t test/bats/test.bats

.PHONY: deploy-ci
deploy-ci: install patch-image deploy
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/gatekeeper_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ type WebhookConfig struct {
NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"`
// +optional
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
// +optional
DisabledBuiltins []string `json:"disabledBuiltins,omitempty"`
}

// +kubebuilder:validation:Enum:=DEBUG;INFO;WARNING;ERROR
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ metadata:
"replicas": 1
},
"image": {
"image": "docker.io/openpolicyagent/gatekeeper:v3.3.0"
"image": "docker.io/openpolicyagent/gatekeeper:v3.5.1"
},
"validatingWebhook": "Enabled",
"webhook": {
Expand Down Expand Up @@ -295,7 +295,7 @@ spec:
- /manager
env:
- name: RELATED_IMAGE_GATEKEEPER
value: openpolicyagent/gatekeeper:v3.3.0
value: openpolicyagent/gatekeeper:v3.5.1
image: quay.io/gatekeeper/gatekeeper-operator:v0.1.2
imagePullPolicy: Always
livenessProbe:
Expand Down Expand Up @@ -361,6 +361,7 @@ spec:
- apiGroups:
- ""
resources:
- resourcequotas
- secrets
- serviceaccounts
- services
Expand All @@ -372,6 +373,15 @@ spec:
- patch
- update
- watch
- apiGroups:
- policy
resources:
- poddisruptionbudgets
verbs:
- create
- delete
- update
- use
- apiGroups:
- rbac.authorization.k8s.io
resources:
Expand Down
4 changes: 4 additions & 0 deletions bundle/manifests/operator.gatekeeper.sh_gatekeepers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,10 @@ spec:
type: string
webhook:
properties:
disabledBuiltins:
items:
type: string
type: array
emitAdmissionEvents:
enum:
- Enabled
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/operator.gatekeeper.sh_gatekeepers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,10 @@ spec:
type: string
webhook:
properties:
disabledBuiltins:
items:
type: string
type: array
emitAdmissionEvents:
enum:
- Enabled
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
apiVersion: admissionregistration.k8s.io/v1beta1
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
creationTimestamp: null
name: gatekeeper-mutating-webhook-configuration
webhooks:
- clientConfig:
caBundle: Cg==
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: gatekeeper-webhook-service
namespace: gatekeeper-system
path: /v1/mutate
failurePolicy: Ignore
matchPolicy: Exact
name: mutation.gatekeeper.sh
namespaceSelector:
matchExpressions:
- key: admission.gatekeeper.sh/ignore
operator: DoesNotExist
rules:
- apiGroups:
- '*'
Expand All @@ -22,3 +29,5 @@ webhooks:
- UPDATE
resources:
- '*'
sideEffects: None
timeoutSeconds: 3
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
apiVersion: admissionregistration.k8s.io/v1beta1
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
labels:
gatekeeper.sh/system: "yes"
name: gatekeeper-validating-webhook-configuration
webhooks:
- clientConfig:
caBundle: Cg==
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: gatekeeper-webhook-service
namespace: gatekeeper-system
path: /v1/admit
failurePolicy: Ignore
matchPolicy: Exact
name: validation.gatekeeper.sh
namespaceSelector:
matchExpressions:
Expand All @@ -29,13 +32,16 @@ webhooks:
- '*'
sideEffects: None
timeoutSeconds: 3
- clientConfig:
caBundle: Cg==
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: gatekeeper-webhook-service
namespace: gatekeeper-system
path: /v1/admitlabel
failurePolicy: Fail
matchPolicy: Exact
name: check-ignore-label.gatekeeper.sh
rules:
- apiGroups:
Expand Down
Loading