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

add webhook - fixes #10 #13

Merged
merged 2 commits into from
Jan 21, 2020
Merged
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
2 changes: 1 addition & 1 deletion stable/anchore-admission-controller/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: anchore-admission-controller
description: A kubernetes admission controller for validating and mutating webhooks that operates against Anchore Engine to make access decisions and annotations
apiVersion: v1
appVersion: 0.2.2
version: 0.2.7
version: 0.2.8
home: https://github.com/anchore/kubernetes-admission-controller
maintainers:
- name: zhill
Expand Down

This file was deleted.

42 changes: 0 additions & 42 deletions stable/anchore-admission-controller/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1 @@
Anchore admission controller is now installed.

Create a validating webhook resources to start enforcement using the included script:

./files/get_validating_webhook_config.sh <releasename>
kubectl apply -f validating-webhook.yaml


KUBE_CA=$(kubectl config view --minify=true --flatten -o json | jq '.clusters[0].cluster."certificate-authority-data"' -r)
cat > validating-webhook.yaml <<EOF
apiVersion: admissionregistration.k8s.io/v1beta1
kind: ValidatingWebhookConfiguration
metadata:
name: {{ template "anchore-admission-controller.fullname" . }}.admission.anchore.io
webhooks:
- name: {{ template "anchore-admission-controller.fullname" . }}.admission.anchore.io
clientConfig:
service:
namespace: default
name: kubernetes
path: /apis/admission.anchore.io/v1beta1/imagechecks
caBundle: $KUBE_CA
rules:
- operations:
- CREATE
apiGroups:
- ""
apiVersions:
- "*"
resources:
- pods
failurePolicy: Fail
# Uncomment this and customize to exclude specific namespaces from the validation requirement
# namespaceSelector:
# matchExpressions:
# - key: exclude.admission.anchore.io
# operator: NotIn
# values: ["true"]
EOF




28 changes: 28 additions & 0 deletions stable/anchore-admission-controller/templates/webhook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.apiService.webhook.enabled }}
apiVersion: admissionregistration.k8s.io/v1beta1
kind: ValidatingWebhookConfiguration
metadata:
name: {{ template "anchore-admission-controller.name" . }}-admission.anchore.io
labels: {{- include "anchore-admission-controller.labels" . | nindent 4 }}
webhooks:
- name: {{ template "anchore-admission-controller.name" . }}-admission.anchore.io
clientConfig:
service:
namespace: default
name: kubernetes
path: /apis/{{ .Values.apiService.group }}/v1beta1/imagechecks
{{- with .Values.apiService.webhook.caBundle }}
caBundle: {{ . | b64enc }}
{{- end }}
rules:
- operations:
- CREATE
apiGroups:
- ""
apiVersions:
- "*"
resources:
- pods
failurePolicy: {{ .Values.apiService.webhook.failurePolicy }}
namespaceSelector: {{- toYaml .Values.apiService.namespaceSelector | nindent 4 }}
{{- end }}
10 changes: 10 additions & 0 deletions stable/anchore-admission-controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@ service:
externalPort: 443

apiService:
webhook:
enabled: true
zhill marked this conversation as resolved.
Show resolved Hide resolved
failurePolicy: Ignore
# caBundle value can be obtained with: kubectl config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.certificate-authority-data}'
# caBundle:
group: admission.anchore.io
version: v1beta1
namespaceSelector:
matchExpressions:
- key: exclude.admission.anchore.io
operator: NotIn
values: ["true"]

anchoreEndpoint: ""
policySelectors:
Expand Down