<p>database-deployment.yaml</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: postgres
  name: postgres-db
spec:
  replicas:
  selector:
    matchLabels:  
      app: postgres-db
  template:
    metadata:
      labels:
        app: postgres-db
    spec:
      containers:
      - name: postgres-db
        image: postgres:latest
        ports:
        - protocol: TCP
          containerPort: 1234
        env:
        - name: POSTGRES_DB
          value: &quot;classroom&quot;
        - name: POSTGRES_USER
          value: temp
        - name: POSTGRES_PASSWORD
          value: temp
</code></pre>
<p>database-service.yaml</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: database-service
spec:
  selector: 
    app: postgres-db
  ports:
  - protocol: TCP
    port: 1234
    targetPort: 1234
</code></pre>
<p>I want to use this database-service url for other deployment so i tried to add it in configMap</p>
<p>my-configMap.yaml</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: classroom-configmap
data:
  database_url: database-service
</code></pre>
<p>[Not Working] Expected - database_url : database-service (will be replaced with corresponding service URL)</p>
<p><code>ERROR - Driver org.postgresql.Driver claims to not accept jdbcUrl, database-service</code></p>
<pre><code>$ kubectl describe configmaps classroom-configmap
</code></pre>
<p>Output :</p>
<pre><code>Name:         classroom-configmap
Namespace:    default
Labels:       &lt;none&gt;
Annotations:  &lt;none&gt;

Data
====
database_url:
----
database-service

BinaryData
====

Events:  &lt;none&gt;
</code></pre>

<p>According to the error you are having:</p>
<p><code>Driver org.postgresql.Driver claims to not accept jdbcUrl</code></p>
<p>It seems that there are a few issues with that URL, and a latest PSQL driver may complain.</p>
<ol>
<li><code>jdbc:postgres:</code> isn't right, use <code>jdbc:postgresql:</code>instead</li>
<li>Do not use <code>jdbc:postgresql://&lt;username&gt;:&lt;passwor&gt;..., user parameters instead: jdbc:postgresql://&lt;host&gt;:&lt;port&gt;/&lt;dbname&gt;?user=&lt;username&gt;&amp;password=&lt;password&gt;</code></li>
<li>In some cases you have to force SSL connection by adding <code>sslmode=require</code> parameter</li>
</ol>
