I would like to create component reused in many deployments. It has monitoring sidecar same for all applications. My problem is that I would like to apply strategic merge patch from this component but it only works when I'm using name of specific deployment
#------deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: sample-deploy
spec:
template:
metadata:
labels:
app: sample-app
spec:
containers:
- name: sample-container
#--------kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
components:
- ../../../.k8s/components/monitor-sidecar
#------kustomization.yaml (component)
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
patches:
- deployment-sidecar.yaml
#-------deployment-sidecar.yaml
apiVersion: apps/v1
kind: Deployment
# metadata:
# name: sample-deploy <-I have to uncoment this but it attach component to one deployment
spec:
template:
spec:
containers:
- name: monitor-sidecar
image: MONITOR-SIDECAR.IMG
When I skip the name (name: sample-deploy in examle) I have an error "missing metadata.name in object". How can I create generic component without attaching it to specific deployment name? I would like to init component when it is used and not define such things in definision.