https://github.com/oam-dev/trait-injector
Injector trait as a webhook to inject data into Workload.
https://github.com/oam-dev/trait-injector
Last synced: about 1 year ago
JSON representation
Injector trait as a webhook to inject data into Workload.
- Host: GitHub
- URL: https://github.com/oam-dev/trait-injector
- Owner: oam-dev
- License: apache-2.0
- Created: 2020-02-06T18:48:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-14T07:09:09.000Z (about 5 years ago)
- Last Synced: 2025-03-26T19:03:38.868Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 264 KB
- Stars: 15
- Watchers: 6
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Trait Injector
Trait injector is a k8s admission webhook to inject data into workload.
How it works with AppConfig controller:

## Build
```bash
make generate
make manifests
make
```
## Test
```bash
make test
```
## SSL
the `ssl/` dir contains a script to create a self-signed certificate, not sure this will even work when running in k8s but that's part of figuring this out I guess
_NOTE: the app expects the cert/key to be in `ssl/` dir relative to where the app is running/started and currently is hardcoded to `mutateme.{key,pem}`_
```bash
pushd ssl/
make
popd
```
## Docker
```bash
make docker-build
```
## Quickstart
Gererate SSL certs if haven't done yet:
```bash
pushd ssl/
make
popd
```
Replace `caBundle` field value in `example/manager.yaml` with the data from below:
```bash
kubectl config view --raw --minify --flatten -o jsonpath='{.clusters[].cluster.certificate-authority-data}'
```
Deploy to Minikube:
```bash
make minikube
```
## Inject Deployment
Create ServiceBinding:
```bash
kubectl create -f ./example/servicebinding.yaml
```
Create the Deployment whose env to inject secret to, and also the Secret:
```bash
kubectl create -f ./example/test-deploy.yaml
```
Verify the `envFrom` field of the Deployment updated:
```bash
kubectl get deploy busybox1 -o json | jq -r '.spec.template.spec.containers[0]'
```

## Inject StatefulSet
Create ServiceBinding for StatefulSet example:
```bash
kubectl create -f ./example/statefulSet/binding.yaml
```
Create the StatefulSet whose env to inject secret to, and also the Secret:
```bash
kubectl create -f ./example/statefulSet/statefulset.yaml
```
Verify the `envFrom` field of the Deployment updated:
```bash
kubectl get statefulset busybox1 -o json | jq -r '.spec.template.spec.containers[0]'
```