<p>I tried to convert the below working kubernetes manifest from</p>
<pre class="lang-yaml prettyprint-override"><code>##namespace
---
apiVersion: v1
kind: Namespace
metadata:
  name: poc

##postgress
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: db
  name: db
  namespace: poc
spec:
  replicas: 1
  selector:
    matchLabels:
      app: db
  template:
    metadata:
      labels:
        app: db
    spec:
      containers:
      - image: postgres
        name: postgres
        env:
        - name: POSTGRES_USER
          value: postgres
        - name: POSTGRES_PASSWORD
          value: postgres
        ports:
        - containerPort: 5432
          name: postgres
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: db
  name: db
  namespace: poc
spec:
  type: ClusterIP
  ports:
  - name: &quot;db-service&quot;
    port: 5432
    targetPort: 5432
  selector:
    app: db

##adminer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: ui
  name: ui
  namespace: poc
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ui
  template:
    metadata:
      labels:
        app: ui
    spec:
      containers:
      - image: adminer
        name: adminer
        ports:
        - containerPort: 8080
          name: ui
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: ui
  name: ui
  namespace: poc
spec:
  type: NodePort
  ports:
  - name: &quot;ui-service&quot;
    port: 8080
    targetPort: 8080
  selector:
    app: ui
</code></pre>
<p>to</p>
<pre class="lang-js prettyprint-override"><code>import * as k8s from &quot;@pulumi/kubernetes&quot;;
import * as kx from &quot;@pulumi/kubernetesx&quot;;

//db
const dbLabels = { app: &quot;db&quot; };
const dbDeployment = new k8s.apps.v1.Deployment(&quot;db&quot;, {
    spec: {
        selector: { matchLabels: dbLabels },
        replicas: 1,
        template: {
            metadata: { labels: dbLabels },
            spec: { 
                containers: [
                    { 
                        name: &quot;postgres&quot;, 
                        image: &quot;postgres&quot;,
                        env: [{ name: &quot;POSTGRES_USER&quot;, value: &quot;postgres&quot;},{ name: &quot;POSTGRES_PASSWORD&quot;, value: &quot;postgres&quot;}],
                        ports: [{containerPort: 5432}]
                    }
                ] 
            }
        }
    }
});

const dbService = new k8s.core.v1.Service(&quot;db&quot;, {
    metadata: { labels: dbDeployment.spec.template.metadata.labels },
    spec: {
        selector: dbLabels,
        type: &quot;ClusterIP&quot;,
        ports: [{ port: 5432, targetPort: 5432, protocol: &quot;TCP&quot; }],
    }
});

//adminer
const uiLabels = { app: &quot;ui&quot; };
const uiDeployment = new k8s.apps.v1.Deployment(&quot;ui&quot;, {
    spec: {
        selector: { matchLabels: uiLabels },
        replicas: 1,
        template: {
            metadata: { labels: uiLabels },
            spec: { 
                containers: [
                    { 
                        name: &quot;adminer&quot;, 
                        image: &quot;adminer&quot;,
                        ports: [{containerPort: 8080}],
                    }
                ] 
            }
        }
    }
});

const uiService = new k8s.core.v1.Service(&quot;ui&quot;, {
    metadata: { labels: uiDeployment.spec.template.metadata.labels },
    spec: {
        selector: uiLabels,
        type: &quot;NodePort&quot;,
        ports: [{ port: 8080, targetPort: 8080, protocol: &quot;TCP&quot; }]
    }
});
</code></pre>
<p>With this <code>pulumi up -y</code> is SUCCESS without error but the application is not fully UP and RUNNING. Because the <code>adminer</code> image is trying to use Postgres database hostname as <code>db</code>, But looks like pulumi is changing the service name like below:</p>
<p><a href="https://i.stack.imgur.com/syjmB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/syjmB.png" alt="enter image description here" /></a></p>
<p>My question here is, How to make this workable?
Is there a way in pulumi to strict with the naming?</p>
<p>Note- I know we can easily pass the hostname as an env variable to the <code>adminer</code> image but I am wondering if there is anything that can allow us to not change the name.</p>

Samit Kumar Patel
<p>Pulumi automatically adds random strings to your resources to help with replacing resource. You can find more information about this in the <a href="https://www.pulumi.com/docs/troubleshooting/faq/#why-do-resource-names-have-random-hex-character-suffixes" rel="nofollow noreferrer">FAQ</a></p>
<p>If you'd like to disable this, you can override it using the <code>metadata</code>, like so:</p>
<pre class="lang-ts prettyprint-override"><code>import * as k8s from &quot;@pulumi/kubernetes&quot;;
import * as kx from &quot;@pulumi/kubernetesx&quot;;

//db
const dbLabels = { app: &quot;db&quot; };
const dbDeployment = new k8s.apps.v1.Deployment(&quot;db&quot;, {
    spec: {
        selector: { matchLabels: dbLabels },
        replicas: 1,
        template: {
            metadata: { labels: dbLabels },
            spec: { 
                containers: [
                    { 
                        name: &quot;postgres&quot;, 
                        image: &quot;postgres&quot;,
                        env: [{ name: &quot;POSTGRES_USER&quot;, value: &quot;postgres&quot;},{ name: &quot;POSTGRES_PASSWORD&quot;, value: &quot;postgres&quot;}],
                        ports: [{containerPort: 5432}]
                    }
                ] 
            }
        }
    }
});
    
const dbService = new k8s.core.v1.Service(&quot;db&quot;, {
    metadata: { 
        name: &quot;db&quot;, // explicitly set a name on the service
        labels: dbDeployment.spec.template.metadata.labels 
    },
    spec: {
        selector: dbLabels,
        type: &quot;ClusterIP&quot;,
        ports: [{ port: 5432, targetPort: 5432, protocol: &quot;TCP&quot; }],
    }
});
</code></pre>
<p>With that said, it's not always best practice to hardcode names like this, you should, if possible, reference outputs from your resources and pass them to new resources.</p>
