<p>Reading the <a href="https://github.com/Rapter1990/springbootmicroservicedailybuffer/blob/master/k8s/config-server-deployment.yaml" rel="nofollow noreferrer">config-server-deployment.yaml</a> you deploy a service under the name <code>config-server-svc</code>.
<code>config-server-svc</code> maps port <code>80</code> to <code>9296</code> of pods port with label <code>config-server-app</code>.<br />
<a href="https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service" rel="nofollow noreferrer">K8s documentation for svc definition</a><br />
Your error states:</p>
<pre><code>GET request for &quot;http://config-server-svc:9296/ORDER-SERVICE/default
</code></pre>
<p>Your <code>svc</code> serves to port <code>80</code> and not to port <code>9296</code> which is the pod's port.<br />
Change the port you perform the request.
At <a href="https://github.com/Rapter1990/springbootmicroservicedailybuffer/blob/master/apigateway/src/main/resources/application.yml#L12" rel="nofollow noreferrer">github spring app</a> you pass an environment variable called <code>CONFIG_SERVER_URL</code>.<br />
If it's empty, you use the <code>localhost:9296</code>. It seems that you pass <code>CONFIG_SERVER_URL</code> environmental variable that spring app will read with wrong port.<br />
When provide a value to CONFIG_SERVER_URL you have to override also the port. Try to add port 80 at <a href="https://github.com/Rapter1990/springbootmicroservicedailybuffer/blob/f50995902c0374751c12a904d9daf511df63158d/k8s/config-maps.yaml#L6" rel="nofollow noreferrer">config-maps.yaml</a> so the line
<code>config_url: &quot;config-server-svc&quot;</code> will become <code>config_url: &quot;config-server-svc:80&quot;</code></p>

CC BY-SA 4.0
2023-01-19T14:01:06.323Z
Which line should I change? port : 80 targetport : 80  Is it right?
qwercan
CC BY-SA 4.0
2023-01-19T14:31:20.330Z
https://github.com/Rapter1990/springbootmicroservicedailybuffer/blob/master/apigateway/src/main/resources/application.yml#L12 Here you pass an environment variable called CONFIG_SERVER_URL if its empty u use the http://localhost:9296
It seems tha you pass CONFIG_SERVER_URL  with wrong port.
igiannak
CC BY-SA 4.0
2023-01-19T15:53:02.473Z
What should it be?
qwercan
CC BY-SA 4.0
2023-01-19T16:09:58.693Z
Your applications should perform GET requests at http://config-server-svc/ORDER-SERVICE/default. You should check and modify the port you provide to the application code
igiannak
CC BY-SA 4.0
2023-01-19T16:15:40.797Z
When provide CONFIG_SERVER_URL a value the port at ${CONFIG_SERVER_URL:http://localhost:9296} will remain the same So
provide a value for CONFIG_SERVER_URL that will contain and port
igiannak
CC BY-SA 4.0
2023-01-19T16:47:45.430Z
Your approach didn't help me fix the issue.
qwercan
CC BY-SA 4.0
2023-01-19T22:09:42.627Z
I create README.md file can you test it if you don't mind? I'vent't still solved it.
qwercan
CC BY-SA 4.0
2023-01-20T13:58:28.417Z
I still couldn't fix it. In Kubernetes all the services will start simultaneously. Config Server is the Dependent Service for all other Services. i.e Order, Payment, and Product.
qwercan
CC BY-SA 4.0
2023-01-20T14:15:10.900Z
I edited my post.
qwercan
CC BY-SA 4.0
2023-01-21T19:49:57.863Z
@igianmak I still couldn't fix the issue.
qwercan
CC BY-SA 4.0
2023-01-25T14:15:41.077Z
@qwercan you need to fix the java code to use 80 port in config-server-svc instead of 9296. The error is clear. when hitting 9296 at config-server-svc nothing listens there.
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://config-server-svc:9296/ORDER-SERVICE/default": connect timed out; nested exception is java.net.SocketTimeoutException: connect timed out
igiannak
CC BY-SA 4.0
2023-01-25T18:33:43.710Z
Is it possible to write it if you don't mind? I can run config server by the port 9296 in local and docker.
qwercan
CC BY-SA 4.0
2023-01-19T11:59:37.627Z
2023-01-19T16:18:40.073Z
2023-01-19T16:18:40.073Z
igiannak
<p>I have a problem about running Spring Boot Microservices on Kubernetes. After I installed minikube, I started it and open its dashboard.</p>
<p>Here is the commands to open dashboards.</p>
<pre><code>1 ) minikube start
2 ) minikube dashboard 
</code></pre>
<p>Next, I run all services through this command.</p>
<pre><code>kubectl apply -f k8s
</code></pre>
<p>After waiting for a certain amount of time, I got this issue shown below.</p>
<pre><code>15:22:37.395 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
org.springframework.cloud.config.client.ConfigClientFailFastException: Could not locate PropertySource and the resource is not optional, failing
 at org.springframework.cloud.config.client.ConfigServerConfigDataLoader.doLoad(ConfigServerConfigDataLoader.java:197)
 at org.springframework.cloud.config.client.ConfigServerConfigDataLoader.load(ConfigServerConfigDataLoader.java:102)
 at org.springframework.cloud.config.client.ConfigServerConfigDataLoader.load(ConfigServerConfigDataLoader.java:61)
 at org.springframework.boot.context.config.ConfigDataLoaders.load(ConfigDataLoaders.java:107)
 at org.springframework.boot.context.config.ConfigDataImporter.load(ConfigDataImporter.java:128)
 at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:86)
 at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:116)
 at org.springframework.boot.context.config.ConfigDataEnvironment.processWithProfiles(ConfigDataEnvironment.java:311)
 at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:232)
 at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:102)
 at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:94)
 at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:102)
 at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:87)
 at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
 at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
 at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
 at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
 at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:85)
 at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:66)
 at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
 at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:120)
 at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:114)
 at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65)
 at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:344)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
 at com.microservice.orderservice.OrderServiceApplication.main(OrderServiceApplication.java:15)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
 at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
 at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
 at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
 at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for &quot;http://config-server-svc:9296/ORDER-SERVICE/default&quot;: connect timed out; nested exception is java.net.SocketTimeoutException: connect timed out
 at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:785)
 at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:711)
 at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:602)
 at org.springframework.cloud.config.client.ConfigServerConfigDataLoader.getRemoteEnvironment(ConfigServerConfigDataLoader.java:303)
 at org.springframework.cloud.config.client.ConfigServerConfigDataLoader.doLoad(ConfigServerConfigDataLoader.java:118)
 ... 35 common frames omitted
Caused by: java.net.SocketTimeoutException: connect timed out
 at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
 at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)
 at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)
 at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)
 at java.base/java.net.Socket.connect(Socket.java:609)
 at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:177)
 at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:508)
 at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:603)
 at java.base/sun.net.www.http.HttpClient.&lt;init&gt;(HttpClient.java:276)
 at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:375)
 at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:396)
 at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1253)
 at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187)
 at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
 at java.base/sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:1015)
 at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:76)
 at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
 at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:66)
 at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:776)
 ... 39 common frames omitted
</code></pre>
<p>Here is my deployment.yaml file shown below.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: auth-service-app
spec:
  selector:
    matchLabels:
      app: auth-service-app
  template:
    metadata:
      labels:
        app: auth-service-app
    spec:
      containers:
        - name: auth-service-app
          image: noyandocker/authservice
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 7777
          env:
            - name: CONFIG_SERVER_URL
              valueFrom:
                configMapKeyRef:
                  name: config-cm
                  key: config_url
            - name: EUREKA_SERVER_ADDRESS
              valueFrom:
                configMapKeyRef:
                  name: eureka-cm
                  key: eureka_service_address
            - name: DB_HOST
              valueFrom:
                configMapKeyRef:
                  name: mysql-cm
                  key: hostname

---

apiVersion: v1
kind: Service
metadata:
  name: auth-service-svc
spec:
  selector:
    app: auth-service-app
  ports:
    - port: 80
      targetPort: 7777
</code></pre>
<p>Here is the config map yaml file</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: config-cm
data:
  config_url: &quot;config-server-svc&quot;

---

apiVersion: v1
kind: ConfigMap
metadata:
  name: eureka-cm
data:
  eureka_service_address: &quot;http://eureka-0.eureka:8761/eureka&quot;

---

apiVersion: v1
kind: ConfigMap
metadata:
  name: mysql-cm
data:
  hostname: &quot;mysql-0.mysql&quot;
</code></pre>
<p>Here is the config-server-deployment.yaml file</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: config-server-app
spec:
  selector:
    matchLabels:
      app: config-server-app
  template:
    metadata:
      labels:
        app: config-server-app
    spec:
      containers:
        - name: config-server-app
          image: noyandocker/configserver
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 9296
          readinessProbe:
            httpGet:
              path: /actuator/health
              port: 9296
            initialDelaySeconds: 20
            timeoutSeconds: 10
            periodSeconds: 3
            failureThreshold: 2
          livenessProbe:
            httpGet:
              path: /actuator/health
              port: 9296
            initialDelaySeconds: 30
            timeoutSeconds: 2
            periodSeconds: 8
            failureThreshold: 1
          env:
            - name: EUREKA_SERVER_ADDRESS
              valueFrom:
                configMapKeyRef:
                  name: eureka-cm
                  key: eureka_service_address

---

apiVersion: v1
kind: Service
metadata:
  name: config-server-svc
spec:
  selector:
    app: config-server-app
  ports:
    - port: 80
      targetPort: 9296
</code></pre>
<p>I thought all the services will start simultaneously. Config Server is the Dependent Service for all other Serivces like auth service and this Auth service should not start until Config Server service is up and running.</p>
<p>How can I do that?</p>
<p>Here is my repo : <a href="https://github.com/Rapter1990/springbootmicroservicedailybuffer" rel="nofollow noreferrer">Link</a></p>
<p>Here is my docker hub : <a href="https://hub.docker.com/search?q=noyandocker" rel="nofollow noreferrer">Link</a></p>
<p>Here is git backend system : <a href="https://github.com/Rapter1990/springappconfig" rel="nofollow noreferrer">Link</a></p>

<kubernetes><java><minikube><spring-boot>
Spring Boot Microservices cannot run on Kubernetes (java.net.SocketTimeoutException: connect timed out)
qwercan
# Spring Boot Microservices cannot run on Kubernetes (java.net.SocketTimeoutException: connect timed out)

(Asked by: username_0 on 2023-01-17)

I have a problem about running Spring Boot Microservices on Kubernetes. After I installed minikube, I started it and open its dashboard.
Here is the commands to open dashboards.
1 ) minikube start
2 ) minikube dashboard 

Next, I run all services through this command.
kubectl apply -f k8s

After waiting for a certain amount of time, I got this issue shown below.
15:22:37.395 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
org.springframework.cloud.config.client.ConfigClientFailFastException: Could not locate PropertySource and the resource is not optional, failing
 at org.springframework.cloud.config.client.ConfigServerConfigDataLoader.doLoad(ConfigServerConfigDataLoader.java:197)
 at org.springframework.cloud.config.client.ConfigServerConfigDataLoader.load(ConfigServerConfigDataLoader.java:102)
 at org.springframework.cloud.config.client.ConfigServerConfigDataLoader.load(ConfigServerConfigDataLoader.java:61)
 at org.springframework.boot.context.config.ConfigDataLoaders.load(ConfigDataLoaders.java:107)
 at org.springframework.boot.context.config.ConfigDataImporter.load(ConfigDataImporter.java:128)
 at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:86)
 at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:116)
 at org.springframework.boot.context.config.ConfigDataEnvironment.processWithProfiles(ConfigDataEnvironment.java:311)
 at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:232)
 at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:102)
 at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:94)
 at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:102)
 at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:87)
 at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
 at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
 at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
 at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
 at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:85)
 at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:66)
 at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
 at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:120)
 at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:114)
 at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65)
 at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:344)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
 at com.microservice.orderservice.OrderServiceApplication.main(OrderServiceApplication.java:15)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
 at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
 at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
 at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
 at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://config-server-svc:9296/ORDER-SERVICE/default": connect timed out; nested exception is java.net.SocketTimeoutException: connect timed out
 at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:785)
 at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:711)
 at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:602)
 at org.springframework.cloud.config.client.ConfigServerConfigDataLoader.getRemoteEnvironment(ConfigServerConfigDataLoader.java:303)
 at org.springframework.cloud.config.client.ConfigServerConfigDataLoader.doLoad(ConfigServerConfigDataLoader.java:118)
 ... 35 common frames omitted
Caused by: java.net.SocketTimeoutException: connect timed out
 at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
 at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)
 at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)
 at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)
 at java.base/java.net.Socket.connect(Socket.java:609)
 at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:177)
 at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:508)
 at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:603)
 at java.base/sun.net.www.http.HttpClient.(HttpClient.java:276)
 at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:375)
 at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:396)
 at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1253)
 at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187)
 at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
 at java.base/sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:1015)
 at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:76)
 at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
 at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:66)
 at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:776)
 ... 39 common frames omitted

Here is my deployment.yaml file shown below.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: auth-service-app
spec:
  selector:
    matchLabels:
      app: auth-service-app
  template:
    metadata:
      labels:
        app: auth-service-app
    spec:
      containers:
        - name: auth-service-app
          image: noyandocker/authservice
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 7777
          env:
            - name: CONFIG_SERVER_URL
              valueFrom:
                configMapKeyRef:
                  name: config-cm
                  key: config_url
            - name: EUREKA_SERVER_ADDRESS
              valueFrom:
                configMapKeyRef:
                  name: eureka-cm
                  key: eureka_service_address
            - name: DB_HOST
              valueFrom:
                configMapKeyRef:
                  name: mysql-cm
                  key: hostname

---

apiVersion: v1
kind: Service
metadata:
  name: auth-service-svc
spec:
  selector:
    app: auth-service-app
  ports:
    - port: 80
      targetPort: 7777

Here is the config map yaml file
apiVersion: v1
kind: ConfigMap
metadata:
  name: config-cm
data:
  config_url: "config-server-svc"

---

apiVersion: v1
kind: ConfigMap
metadata:
  name: eureka-cm
data:
  eureka_service_address: "http://eureka-0.eureka:8761/eureka"

---

apiVersion: v1
kind: ConfigMap
metadata:
  name: mysql-cm
data:
  hostname: "mysql-0.mysql"

Here is the config-server-deployment.yaml file
apiVersion: apps/v1
kind: Deployment
metadata:
  name: config-server-app
spec:
  selector:
    matchLabels:
      app: config-server-app
  template:
    metadata:
      labels:
        app: config-server-app
    spec:
      containers:
        - name: config-server-app
          image: noyandocker/configserver
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 9296
          readinessProbe:
            httpGet:
              path: /actuator/health
              port: 9296
            initialDelaySeconds: 20
            timeoutSeconds: 10
            periodSeconds: 3
            failureThreshold: 2
          livenessProbe:
            httpGet:
              path: /actuator/health
              port: 9296
            initialDelaySeconds: 30
            timeoutSeconds: 2
            periodSeconds: 8
            failureThreshold: 1
          env:
            - name: EUREKA_SERVER_ADDRESS
              valueFrom:
                configMapKeyRef:
                  name: eureka-cm
                  key: eureka_service_address

---

apiVersion: v1
kind: Service
metadata:
  name: config-server-svc
spec:
  selector:
    app: config-server-app
  ports:
    - port: 80
      targetPort: 9296

I thought all the services will start simultaneously. Config Server is the Dependent Service for all other Serivces like auth service and this Auth service should not start until Config Server service is up and running.
How can I do that?
Here is my repo : Link
Here is my docker hub : Link
Here is git backend system : Link

**Tags:** kubernetes, java, minikube, spring-boot


---

## 1 answers

### Answer by username_1 on 2023-01-19. Score: 1

Reading the config-server-deployment.yaml you deploy a service under the name config-server-svc.
config-server-svc maps port 80 to 9296 of pods port with label config-server-app.
K8s documentation for svc definition
Your error states:
GET request for "http://config-server-svc:9296/ORDER-SERVICE/default

Your svc serves to port 80 and not to port 9296 which is the pod's port.
Change the port you perform the request.
At github spring app you pass an environment variable called CONFIG_SERVER_URL.
If it's empty, you use the localhost:9296. It seems that you pass CONFIG_SERVER_URL environmental variable that spring app will read with wrong port.
When provide a value to CONFIG_SERVER_URL you have to override also the port. Try to add port 80 at config-maps.yaml so the line
config_url: "config-server-svc" will become config_url: "config-server-svc:80"

> **Comments:**
> **username_0**: Which line should I change? port : 80 targetport : 80  Is it right?  
> **username_1**: https://github.com/Rapter1990/springbootmicroservicedailybuffer/blob/master/apigateway/src/main/resources/application.yml#L12 Here you pass an environment variable called CONFIG_SERVER_URL if its empty u use the http://localhost:9296 It seems tha you pass CONFIG_SERVER_URL  with wrong port.  
> **username_0**: What should it be?  
> **username_1**: Your applications should perform GET requests at http://config-server-svc/ORDER-SERVICE/default. You should check and modify the port you provide to the application code  
> **username_1**: When provide CONFIG_SERVER_URL a value the port at ${CONFIG_SERVER_URL:http://localhost:9296} will remain the same So provide a value for CONFIG_SERVER_URL that will contain and port  
> **username_0**: Your approach didn't help me fix the issue.  
> **username_0**: I create README.md file can you test it if you don't mind? I'vent't still solved it.  
> **username_0**: I still couldn't fix it. In Kubernetes all the services will start simultaneously. Config Server is the Dependent Service for all other Services. i.e Order, Payment, and Product.  
> **username_0**: I edited my post.  
> **username_0**: @igianmak I still couldn't fix the issue.  
> **username_1**: @username_0 you need to fix the java code to use 80 port in config-server-svc instead of 9296. The error is clear. when hitting 9296 at config-server-svc nothing listens there. Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://config-server-svc:9296/ORDER-SERVICE/default": connect timed out; nested exception is java.net.SocketTimeoutException: connect timed out  
> **username_0**: Is it possible to write it if you don't mind? I can run config server by the port 9296 in local and docker.  

---

