<p>I am using Kustomize to manage multiple variations of the same cluster. I am using <code>nameSuffix</code> option to add a suffix to all my resources:</p>
<pre><code>nameSuffix: -mysfx
</code></pre>
<p>My problem is that everything works fine but adding this suffix only to one Service resource cause me an issue. My problem is that the application (Patroni) interact with a service that must be called:</p>
<pre><code>CLUSTER-NAME-config
</code></pre>
<p>so I want to exclude this single resource from the <code>nameSuffix</code>. I know this is not possible due to how this feature was designed. I read several articles here on StackOverflow and on the web. I know I can skip the use of <code>nameSuffix</code> for a category of resources. So I tried to put in my <code>kustomization.yaml</code> the rows:</p>
<pre><code>configurations:
- kustomize-config/kustomize-config.yaml
</code></pre>
<p>to skip all the Service resources. Then in the file <code>kustomize-config/kustomize-config.yaml</code></p>
<pre><code>nameSuffix:
- path: metadata/name
  apiVersion: v1
  kind: Service
  skip: true
</code></pre>
<p>but this doesn't work.</p>
<p>Does anyone know what's wrong with this configuration?</p>
<p>Then suppose I am able now to skip the use of <code>nameSuffix</code> for only Service resources, I have other two Services where I want to add this suffix. What do I have to do to add <code>nameSuffix</code> to these two Services and not the one mentioned above?</p>
<p>If there is a better solution for this, please let me know.</p>

<p>Skipping selected <code>kind</code>s doesn't work because this feature wasn't implemented - from <a href="https://github.com/kubernetes-sigs/kustomize/issues/519#issuecomment-527734888" rel="nofollow noreferrer">this comment on GitHub issue 519</a>.</p>
<p>Also <a href="https://github.com/keleustes/kustomize/tree/allinone/examples/issues/issue_0519#preparation-step-resource0" rel="nofollow noreferrer">this is an example</a> how it was supposed to be (what you tried)</p>
<hr />
<p>Based on <a href="https://github.com/kubernetes-sigs/kustomize/issues/519#issuecomment-557303870" rel="nofollow noreferrer">this comment</a>, it works on <code>kind</code>s that were explicitly mentioned:</p>
<blockquote>
<p>The plugin's config is currently oriented towards specifying which
kinds to modify, ignoring others.</p>
</blockquote>
<p>Also based on some tests I performed, it looks for <code>kind</code>s only, it doesn't look for names or anything, so only the whole <code>kind</code> can be included. Hence second part of your question is I'm afraid not possible (well, using kustomize, you can use <code>sed</code> for instance and modify everything you need on the go).</p>
<p>I created a simple structure and tested it:</p>
<pre><code>$ tree
.
├── cm1.yaml
├── cm2.yaml
├── kustomization.yaml
├── kustomizeconfig
│   └── skip-prefix.yaml
├── pod.yaml
├── secret.yaml
└── storageclass.yaml

1 directory, 7 files
</code></pre>
<p>There are two configmaps, pod, secret and storageclass, total 5 objects.</p>
<pre><code>$ cat kustomization.yaml 

namePrefix: prefix-
nameSuffix: -suffix
resources:
- cm1.yaml
- cm2.yaml
- secret.yaml
- pod.yaml
- storageclass.yaml
configurations:
- ./kustomizeconfig/skip-prefix.yaml
</code></pre>
<p>And configuration (specified explicitly all kinds except for configmaps). Also it's called <code>namePrefix</code>, however it works for both: <code>prefix</code> and <code>suffix</code>:</p>
<pre><code>$ cat kustomizeconfig/skip-prefix.yaml 

namePrefix:
- path: metadata/name
  apiVersion: v1
  kind: Secret
- path: metadata/name
  apiVersion: v1
  kind: Pod
- path: metadata/name
  apiVersion: v1
  kind: StorageClass
</code></pre>
<p>Eventually <code>kustomize build .</code> looks like:</p>
<pre><code>$ kustomize build .

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: prefix-local-storage-suffix # modified
provisioner: kubernetes.io/no-provisioner
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: cm1 # skipped
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: cm2 # skipped
---
apiVersion: v1
kind: Secret
metadata:
  name: prefix-secret-suffix # modified
---
apiVersion: v1
kind: Pod
metadata:
  name: prefix-pod-suffix # modified
spec:
  containers:
  - image: image
    name: pod
</code></pre>
<hr />
<p>Another potential option is to use <a href="https://kubectl.docs.kubernetes.io/guides/extending_kustomize/builtins/#_prefixsuffixtransformer_" rel="nofollow noreferrer"><code>PrefixSuffixTransformer</code> plugin</a> - it works differently in terms of specifying what <code>prefix</code> and/or <code>suffix</code> should be added and <code>fieldSpec</code>s where.</p>
<p>Please find an <a href="https://github.com/keleustes/kustomize/tree/allinone/examples/issues/issue_0519_b#preparation-step-resource10" rel="nofollow noreferrer">example</a> and final results below within this Feature Test for Issue 0519_b.</p>
<p>Also there's already a <a href="https://stackoverflow.com/a/66438033/15537201">good answer on StackOverflow</a> about using <code>PrefixSuffixTransformer</code>.</p>
