Giter Site home page Giter Site logo

doppler-injector's Introduction

Kubernetes Mutating Admission Webhook for doppler configuration injection

This webhook will automatically inject the configuration stored in doppler as environment variables on every pod.

The webhook will mutate deployments if:

  • They are not deployed on a system namespace
  • Includes the injector.doppler.com/inject: "yes" annotation.

The deployment should provide the following annotations:

  • injector.doppler.com/environment: "prod"
  • injector.doppler.com/pipeline: "100"

If any of this is missing, the default value will be used. A sample of a deployment configured to use the injector is available here.

This is heavily based on https://github.com/morvencao/kube-mutating-webhook-tutorial

Prerequisites

Kubernetes 1.9.0 or above with the admissionregistration.k8s.io/v1beta1 API enabled. Verify that by the following command:

kubectl api-versions | grep admissionregistration.k8s.io/v1beta1

The result should be:

admissionregistration.k8s.io/v1beta1

In addition, the MutatingAdmissionWebhook and ValidatingAdmissionWebhook admission controllers should be added and listed in the correct order in the admission-control flag of kube-apiserver.

Install

  1. Create a signed cert/key pair and store it in a Kubernetes secret that will be consumed by sidecar deployment
./deployment/webhook-create-signed-cert.sh \
    --service doppler-injector-webhook-svc \
    --secret doppler-injector-webhook-certs \
    --namespace doppler-injector
  1. Update the value of caBundle in mutatingwebhook.yaml with the value of your cluster's CA Bundle:
kubectl get configmap -n kube-system extension-apiserver-authentication -o=jsonpath='{.data.client-ca-file}' | base64 | tr -d '\n' | pbcopy
  1. Update the value of api in secret.yaml with your Doppler API key in base64:
echo -n "$YOUR_KEY" | base64

Optionally, you can also update the pipeline and environment values, if you want to have a default value. If not, they'll default 0, and "dev".

  1. Deploy the resources in the following order:
kubectl apply -f deployment/namespace.yaml
kubectl apply -f deployment/secret.yaml
kubectl apply -f deployment/deployment.yaml
kubectl apply -f deployment/service.yaml
kubectl apply -f deployment/mutatingwebhook.yaml

Verify

  1. The doppler inject webhook should be running
kubectl get pods --namespace=doppler-injector
NAME                                                   READY   STATUS    RESTARTS   AGE
doppler-injector-webhook-deployment-69fb7f8c79-stl2t   1/1     Running   0          3s
# kubectl get deployment --namespace=doppler-injector
NAME                                  DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
doppler-injector-webhook-deployment   1         1         1            1           39s
  1. Label the default namespace with doppler-injector=enabled
kubectl label namespace ramiro doppler-injector=enabled
kubectl get namespace -L doppler-injector
NAME          STATUS    AGE       DOPPLER-INJECTOR
default       Active    18h       enabled
kube-public   Active    18h
kube-system   Active    18h
  1. Deploy the sample deployment
kubectl apply -f deployment/sample.yaml
  1. Verify that your doppler variables were injected:
kubectl get pods
NAME                         READY     STATUS        RESTARTS   AGE
webserver-65b4b5bc46-zksgk   1/1       Running       0          1m

kubectl get pods webserver-65b4b5bc46-zksgk -o jsonpath='{.spec.containers[0].env}'

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.