Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
Only apply on explicitly labeled namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
choffmeister committed Aug 15, 2023
1 parent 6c16b4d commit 575201e
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 6 deletions.
7 changes: 3 additions & 4 deletions deploy/kubernetes/mutatingwebhookconfiguration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ webhooks:
name: kube-resourceless.airfocus.io
namespaceSelector:
matchExpressions:
- key: kubernetes.io/metadata.name
operator: NotIn
- key: kube-resourceless.airfocus.io/enabled
operator: In
values:
- "kube-system"
- "kube-resourceless"
- "true"
rules:
- apiGroups:
- ""
Expand Down
3 changes: 2 additions & 1 deletion test/examples/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
resources:
- deployment.yaml
- namespace-match
- namespace-notmatch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
labels:
app: deplpoyment
spec:
replicas: 5
replicas: 1
selector:
matchLabels:
app: deplpoyment
Expand Down
4 changes: 4 additions & 0 deletions test/examples/namespace-match/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace: namespace-match
resources:
- namespace.yaml
- deployment.yaml
6 changes: 6 additions & 0 deletions test/examples/namespace-match/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: namespace-match
labels:
kube-resourceless.airfocus.io/enabled: "true"
83 changes: 83 additions & 0 deletions test/examples/namespace-notmatch/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment
labels:
app: deplpoyment
spec:
replicas: 1
selector:
matchLabels:
app: deplpoyment
template:
metadata:
labels:
app: deplpoyment
spec:
terminationGracePeriodSeconds: 1
containers:
- name: container-1
image: nginx:alpine
command:
- sleep
args:
- infinite
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 100m
memory: 128Mi
- name: container-2
image: nginx:alpine
command:
- sleep
args:
- infinite
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 100m
memory: 128Mi
- name: container-3
image: nginx:alpine
command:
- sleep
args:
- infinite
initContainers:
- name: init-container-1
image: nginx:alpine
command:
- echo
args:
- done
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 100m
memory: 128Mi
- name: init-container-2
image: nginx:alpine
command:
- echo
args:
- done
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 100m
memory: 128Mi
- name: init-container-3
image: nginx:alpine
command:
- echo
args:
- done
4 changes: 4 additions & 0 deletions test/examples/namespace-notmatch/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace: namespace-notmatch
resources:
- namespace.yaml
- deployment.yaml
4 changes: 4 additions & 0 deletions test/examples/namespace-notmatch/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: namespace-notmatch

0 comments on commit 575201e

Please sign in to comment.