Spawn sidecar container for every pod with specified label. Based on https://medium.com/@mohllal/kubernetes-sidecar-container-injection-61ecfcc7b22b and https://latest.gost.run/en/tutorials/redirect/.
- Install the
kubernetes-sidecar-injector
chart
helm install kubernetes-sidecar-injector charts/kubernetes-sidecar-injector/ \
--values charts/kubernetes-sidecar-injector/values.yaml \
--namespace default
- Install the
gateway
deployment and service (don't forget to changenodeSelectorTerms
option in./gateway.yaml
!)
kubectl apply -f ./gateway.yaml -n default
- Create pod with label for inject:
apiVersion: v1
kind: Pod
metadata:
name: test-pod
labels:
app: test-pod
sidecar.me/inject: 'True'
spec:
# affinity:
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: kubernetes.io/hostname
# operator: In
# values:
# - cl14dmjve12llfgs08eq-ysac
containers:
- name: test-pod
command: ["tail","-f","/dev/null"]
image: ubuntu