-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added example resources helping in integrating Webhook to a K8s cluster.
- Loading branch information
Showing
7 changed files
with
124 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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,43 @@ | ||
FROM alpine:3.9 | ||
MAINTAINER Levente Kale <[email protected]> | ||
|
||
ENV GOPATH /go | ||
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH | ||
ENV GOOS=linux | ||
|
||
WORKDIR / | ||
|
||
RUN mkdir -p $GOPATH/bin \ | ||
&& mkdir -p $GOPATH/src | ||
|
||
RUN apk add --no-cache libcap iputils | ||
|
||
RUN apk add --no-cache --virtual .tools ca-certificates gcc musl-dev go glide git tar curl \ | ||
&& mkdir -p $GOPATH/src/github.com/nokia/danm \ | ||
&& git clone -b 'webhook' --depth 1 https://github.com/nokia/danm.git $GOPATH/src/github.com/nokia/danm \ | ||
&& cd $GOPATH/src/github.com/nokia/danm \ | ||
&& glide install --strip-vendor \ | ||
&& go get -d github.com/vishvananda/netlink \ | ||
&& go get github.com/containernetworking/plugins/pkg/ns \ | ||
&& go get github.com/golang/groupcache/lru \ | ||
&& rm -rf $GOPATH/src/k8s.io/code-generator \ | ||
&& git clone -b 'kubernetes-1.13.4' --depth 1 https://github.com/kubernetes/code-generator.git $GOPATH/src/k8s.io/code-generator \ | ||
&& go install k8s.io/code-generator/cmd/deepcopy-gen \ | ||
&& go install k8s.io/code-generator/cmd/client-gen \ | ||
&& go install k8s.io/code-generator/cmd/lister-gen \ | ||
&& go install k8s.io/code-generator/cmd/informer-gen \ | ||
&& deepcopy-gen --alsologtostderr --input-dirs github.com/nokia/danm/crd/apis/danm/v1 -O zz_generated.deepcopy --bounding-dirs github.com/nokia/danm/crd/apis \ | ||
&& client-gen --alsologtostderr --clientset-name versioned --input-base "" --input github.com/nokia/danm/crd/apis/danm/v1 --clientset-path github.com/nokia/danm/crd/client/clientset \ | ||
&& lister-gen --alsologtostderr --input-dirs github.com/nokia/danm/crd/apis/danm/v1 --output-package github.com/nokia/danm/crd/client/listers \ | ||
&& informer-gen --alsologtostderr --input-dirs github.com/nokia/danm/crd/apis/danm/v1 --versioned-clientset-package github.com/nokia/danm/crd/client/clientset/versioned --listers-package github.com/nokia/danm/crd/client/listers --output-package github.com/nokia/danm/crd/client/informers \ | ||
&& go install -a -ldflags '-extldflags "-static"' github.com/nokia/danm/cmd/webhook \ | ||
&& cp $GOPATH/bin/webhook /usr/local/bin/webhook \ | ||
&& rm -rf $GOPATH/src \ | ||
&& rm -rf $GOPATH/bin \ | ||
&& apk del .tools \ | ||
&& rm -rf /var/cache/apk/* \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& rm -rf /tmp/* \ | ||
&& rm -rf ~/.glide | ||
|
||
ENTRYPOINT ["/usr/local/bin/webhook"] |
This file contains 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
This file contains 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
This file contains 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,76 @@ | ||
--- | ||
apiVersion: admissionregistration.k8s.io/v1beta1 | ||
kind: MutatingWebhookConfiguration | ||
metadata: | ||
name: danm-webhook-config | ||
namespace: kube-system | ||
webhooks: | ||
- name: danm-webhook.nokia.k8s.io | ||
clientConfig: | ||
service: | ||
name: danm-webhook-svc | ||
namespace: kube-system | ||
path: "/webhook" | ||
# Configure your pre-generated certificate matching the details of your environment | ||
caBundle: <CA_BUNDLE> | ||
rules: | ||
- operations: ["CREATE","UPDATE"] | ||
apiGroups: ["danm.k8s.io"] | ||
apiVersions: ["v1"] | ||
resources: ["danmnets"] | ||
failurePolicy: Fail | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: danm-webhook-svc | ||
namespace: kube-system | ||
labels: | ||
danm: webhook | ||
spec: | ||
ports: | ||
- name: webhook | ||
port: 443 | ||
targetPort: 8443 | ||
selector: | ||
danm: webhook | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: danm-webhook-deployment | ||
namespace: kube-system | ||
labels: | ||
danm: webhook | ||
spec: | ||
selector: | ||
matchLabels: | ||
danm: webhook | ||
template: | ||
metadata: | ||
annotations: | ||
# Adapt to your own network environment! | ||
danm.k8s.io/interfaces: | | ||
[ | ||
{ | ||
"network":"flannel" | ||
} | ||
] | ||
name: danm-webhook | ||
labels: | ||
danm: webhook | ||
spec: | ||
containers: | ||
- name: danm-webhook | ||
image: danm_webhook | ||
command: [ "/usr/local/bin/webhook", "-tls-cert-bundle=/etc/webhook/certs/danm_webhook.crt", "-tls-private-key-file=/etc/webhook/certs/danm_webhook.key", "bind-port=8443" ] | ||
imagePullPolicy: IfNotPresent | ||
volumeMounts: | ||
- name: webhook-certs | ||
mountPath: /etc/webhook/certs | ||
readOnly: true | ||
# Configure the directory holding the Webhook's server certificates | ||
volumes: | ||
- name: webhook-certs | ||
hostPath: | ||
path: /etc/kubernetes/ssl/ |
This file contains 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
This file contains 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
This file contains 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