<repo_name>prezi/cloudbees-pse-pod-mutator-admission-controller<file_sep>/scripts/build.sh
#!/bin/bash

set -x

script_dir=$(dirname $0)

cd ${script_dir}/..
dep ensure
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o kube-mutating-webhook .
docker build --no-cache -t 783721547467.dkr.ecr.us-east-1.amazonaws.com/jenkins-executor-helpers:cloudbees-fixer .

docker push 783721547467.dkr.ecr.us-east-1.amazonaws.com/jenkins-executor-helpers:cloudbees-fixer
<file_sep>/Dockerfile
FROM alpine:latest

ADD kube-mutating-webhook /kube-mutating-webhook
ENTRYPOINT ["./kube-mutating-webhook"]
<file_sep>/scripts/deploy.sh
#!/bin/bash

set -euo pipefail
set -x

script_dir=$(dirname $0)

aws eks update-kubeconfig --name ci
kubectl config use-context arn:aws:eks:us-east-1:783721547467:cluster/ci

cat > ${script_dir}/../helm/ca_bundle.yaml <<EOF
---
ca_bundle: $(kubectl config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.certificate-authority-data}')
EOF

cd ${script_dir}/../helm

COMMAND=${1:-sync}

helm tiller run -- helmfile ${COMMAND}
<file_sep>/README.md
# Mutating admission controller to fix jenkin's crap

Based on: https://github.com/morvencao/kube-mutating-webhook-tutorial

# What it does

When it's deployed if a pod has this annotation:

```yaml
cloudbees-pse-fixer.prezi.com/activate: "yes"
```

All volume mounts mounting /var/lib/jenkins will be removed from the pod. Why? Because we are installing stuff there and we only need /var/lib/jenkins/workspace to be a volume.

# Deploying

No fancy integrations yet, the jist of it is this:

```yaml

./scripts/build.sh  # build and upload image
./scripts/deploy.sh # deploy it
```

# Certificates

The admission controller depend on some certificates to be availabe
for the API to work. To regenerate that please use

```yaml

./scripts/create-signed-cert.sh
```
