GithubHelp home page GithubHelp logo

tes / podpreset-webhook Goto Github PK

View Code? Open in Web Editor NEW

This project forked from redhat-cop/podpreset-webhook

0.0 2.0 0.0 120 KB

Implementation of Kubernetes PodPreset as an Admission Webhook.

Makefile 15.62% Dockerfile 3.14% Go 81.24%

podpreset-webhook's Introduction

podpreset-webhook

Build Status Docker Repository on Quay

Implementation of the now deprecated Kubernetes PodPreset feature 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 following steps describe the various methods for which the solution can be deployed:

Basic Deployment

Prerequisites

cert-manager is required to be deployed and available to generate and manage certificates needed by the webhook. Use any of the supported installation methods available.

Deployment

Execute the following command which will facilitate a deployment to a namespace calld podpreset-webhook

make deploy IMG=quay.io/redhat-cop/podpreset-webhook:latest

Example Implementation

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 any new pods have the environment variable FOO=bar

Development

Building/Pushing the operator image

export repo=redhatcopuser #replace with yours
docker login quay.io/$repo/podpreset-webhook
make docker-build IMG=quay.io/$repo/podpreset-webhook:latest
make docker-push IMG=quay.io/$repo/podpreset-webhook:latest

Deploy to OLM via bundle

make manifests
make bundle IMG=quay.io/$repo/podpreset-webhook:latest
operator-sdk bundle validate ./bundle --select-optional name=operatorhub
make bundle-build BUNDLE_IMG=quay.io/$repo/podpreset-webhook-bundle:latest
docker login quay.io/$repo/podpreset-webhook-bundle
docker push quay.io/$repo/podpreset-webhook-bundle:latest
operator-sdk bundle validate quay.io/$repo/podpreset-webhook-bundle:latest --select-optional name=operatorhub
oc new-project podpreset-webhook
operator-sdk cleanup podpreset-webhook -n podpreset-webhook
operator-sdk run bundle -n podpreset-webhook quay.io/$repo/podpreset-webhook-bundle:latest

Cleaning up

operator-sdk cleanup podpreset-webhook -n podpreset-webhook
oc delete operatorgroup operator-sdk-og
oc delete catalogsource podpreset-webhook-catalog

podpreset-webhook's People

Contributors

mathianasj avatar sabre1041 avatar

Watchers

 avatar  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.