Giter Site home page Giter Site logo

jcam / podpreset-webhook Goto Github PK

View Code? Open in Web Editor NEW

This project forked from levindecaro/podpreset-webhook

0.0 1.0 0.0 50 KB

Implementation of Kubernetes PodPreset as an Admission Webhook.

Shell 7.70% Makefile 6.93% Dockerfile 1.00% Go 79.24% Smarty 5.13%

podpreset-webhook's Introduction

podpreset-webhook

Build Status Docker Repository on Quay

Implementation of Kubernetes PodPreset as an Admission Webhook.

Overview

Kubernetes features the ability to inject certain information into pods at creation time including secrets, volumes, volume mounts, and environment variables. Admission Webhooks are implemented as a webserver which receive requests from the Kubernetes API. A CustomResourceDefinition (CRD) called PodPreset in the redhatcop.redhat.io API group has an identical specification to the upstream API resource.

The following is an example of a PodPreset that injects an environment variable called FOO to pods with the label role: frontend

apiVersion: redhatcop.redhat.io/v1alpha1
kind: PodPreset
metadata:
  name: frontend
spec:
  env:
  - name: FOO
    value: bar
  selector:
    matchLabels:
      role: frontend

The goal is to be fully compatible with the existing Kubernetes resource.

Installation

The webserver supporting the webhook needs to be deployed to a namespace. By default, the example manifests expect this namespace to be called podpreset-webhook. Create a new namesapce called podpreset-webhook. You can choose to deploy the webserver in another namespace but you must be sure to update references in the manifests within the deploy folder.

Install the manifests to deploy the webhook webserver by executing the following commands:

$ kubectl apply -f deploy/crds/redhatcop_v1alpha1_podpreset_crd.yaml
$ kubectl apply -f deploy/service_account.yaml
$ kubectl apply -f deploy/clusterrole.yaml
$ kubectl apply -f deploy/cluster_role_binding.yaml
$ kubectl apply -f deploy/role.yaml
$ kubectl apply -f deploy/role_binding.yaml
$ kubectl apply -f deploy/secret.yaml
$ kubectl apply -f deploy/webhook.yaml

Example

Utilize the following steps to demonstrate the functionality of the PodPreset's in a cluster.

  1. Deploy any applications (as a DeploymentConfig or Deployment)
  2. Label the resource
kubectl patch dc/<name> -p '{"spec":{"template":{"metadata":{"labels":{"role":"frontend"}}}}}'
  1. Create the PodPreset
kubectl apply -f deploy/crds/redhatcop_v1alpha1_podpreset_cr.yaml

Verify the new pods have the environment variable FOO=bar

podpreset-webhook's People

Contributors

jcam avatar levindecaro avatar mathianasj avatar sabre1041 avatar

Watchers

 avatar

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.