<p>I want to have a Kustomize manifest where value for some attribute comes from entire contents of some file or URI.</p>

<p>How can I do this?</p>

Ark-kun
<p>Usually <strong>with kustomize</strong> what you are going to use is an <a href="https://github.com/kubernetes-sigs/kustomize#2-create-variants-using-overlays" rel="nofollow noreferrer">overlay and patches</a> (which is one or multiple files) that are kind of merged into your base file. A Patch overrides an attribute. 
With those two features you predefine some probable manifest-compositions and just combine them right before you apply them to your cluster.</p>

<p>You can add or edit/set some specific attributes <a href="https://kubectl.docs.kubernetes.io/pages/app_management/container_images.html" rel="nofollow noreferrer">with patches</a> or with kustomize subcommands like so:</p>

<pre><code>kustomize edit set image your-registry.com:$image_tag

# just to identify version in metadata sections for service/deployment/pods - not just via image tag
kustomize edit add annotation appVersion:$image_tag
kustomize build . | kubectl -n ${your_ns} apply -f -
</code></pre>

<p>But if you want to have a single manifest file and manipulate the same attributes over and over again (on the fly), you should consider using <strong>helm's templating mechanism</strong>.
This is also an option if kustomize does not allow you to edit that single specific attribute you want to alter.</p>

<p>You just need a <em>values.yaml</em> file (containing key/value pairs) and a <em>template.yaml</em> file. You can pre-set some attributes in the <em>values.yaml</em> - on demand you can override them per CLI. The tool will generate you a k8s manifest with those values backed in.</p>

<p>template file:</p>

<pre><code>---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: {{ .Values.appSettings.appName }}
  namespace: {{ .Values.appSettings.namespace }}
  labels:
    name: {{ .Values.appSettings.appName }}
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: {{ .Values.appSettings.appName }}
    spec:
      containers:
        - name: {{ .Values.appSettings.appName }}
          image: "{{ .Values.appSettings.image }}"
          ports:
            - containerPort: 8080
[...]

---
apiVersion: v1
kind: Service
metadata:
  name: {{ .Values.appSettings.appName }}-svc
  namespace: {{ .Values.appSettings.namespace }}
  labels:
    name: {{ .Values.appSettings.appName }}
spec:
  ports:
    - port: 8080
      targetPort: 8080
  selector:
    name: {{ .Values.appSettings.appName }}
</code></pre>

<p>Values file:</p>

<pre><code>appSettings:  
  appName: your-fancy-app
  appDomain: please_override_via_cli
  namespace: please_override_via_cli
</code></pre>

<p>CLI:</p>

<pre><code>helm template
  --set appSettings.image=your-registry.com/service:$(cat versionTag.txt)
  --set appSettings.namespace=your-ns
  --set appSettings.appDomain=your-domain.com
  ./ -f ./values.yaml | kubectl apply -f -
</code></pre>
