GithubHelp home page GithubHelp logo

justindavies / registryadmissioncontroller Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 2.0 17 KB

Kubernetes Admission Controller for Registry whitelisting

License: MIT License

Dockerfile 7.31% JavaScript 24.62% Shell 68.07%
kubernetes admission-controllers azure

registryadmissioncontroller's Introduction

Setting up Registry Admission Controller

Make sure you are using the current context for your Kubernetes cluster.

Create certificate authority and certificates on the cluster

./create-cert.sh

creating certs in certs/
Generating RSA private key, 2048 bit long modulus
.........+++
..........................................+++
e is 65537 (0x10001)
certificatesigningrequest.certificates.k8s.io/registry-admission-service.default created
NAME                                 AGE   REQUESTOR      CONDITION
registry-admission-service.default   0s    masterclient   Pending
certificatesigningrequest.certificates.k8s.io/registry-admission-service.default approved
secret/registry-admission-certs created

Inject CA bundle

This will inject the Certificate Authority bundle (Base64 encoded) into the WebHook definition.

./inject_ca_bundle.sh

LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUV5RENDQXJDZ0F3SUJBZ0lSQU5NYVBSRDMrdVlwN2RpTVZ5SGxVQjB3RFFZSktvWklodmNOQVFFTEJRQXcKRFRFTE1Ba0dBMVVFQXhNQ1kyRXdIaGNOTVRrd016STRNVFV5T1RFMVdoY05NakV3TXpJM01UVXlPVEUxV2pBTgpNUXN3Q1FZRFZRUURFd0pqWVRDQ0FpSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdn-{snip}-1anNwZVU5dkNkcFcwemc9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==

NOTE: This will automatically edit the denyreg-admission-webhook.yaml definition.

Create Controller Service

kubectl apply -f controller_svc.yaml

Configure the Admission Controller

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: registry-admission
  labels:
    app: registry-admission
spec:
  template:
    metadata:
      labels:
        app: registry-admission
    spec:
      containers:
      - name: registry-admission
        image: "inklin/controller:latest"
        env:
        - name: CONTAINER_REGISTRY
          value: "inklin"
        ports:
        - name: admission-port
          containerPort: 3000

Within the controller definition, set the prefix for the container registry (e.g. myregistry.azurecr.io), this will be the only allowed registry to use.

Deploy the controller

kubectl -f controller.yaml

Test a normal deployment

cd tests
kubectl apply -f invalid.yml

Check that the dployment is succesful, and then remove it...

kubectl delete -f invalid.yml

Deploy the Webhook

The webhook is the definition within the API server to hand off requests to the controller deployed earlier.

kubectl apply -f denyreg-admission-webhook.yaml

Retest the deployment

kubectl apply -f invalid.yml

registryadmissioncontroller's People

Contributors

justindavies avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

virajs vvalorous

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.