Describe the bug I'm deploying Cloud Config in Kubernetes (with image springcloud/spring-cloud-kubernetes-configserver:3.0.0-SNAPSHOT), using a GitHub repo as a config source. All .properties files are in subfolders, and these folders have the profile name. And in the config, I'm using {profile} as searchPath.

But, if I try to list the properties of a specific app in a specific profile (e.g. curl -s http://cloud-config/service-a/dev) I get a 404 Not Found error with the message "Profile Not found".

The only way I found it working was by moving all files to the root folder, and renaming them with the profile name. What am I doing wrong here?

My config looks like this:

Repo structure that doesn't work
❯ tree .
├── dev
│   ├── application.properties
│   ├── service-a.properties
│   ├── service-a-dev.properties # <== this was an attempt to make it work
│   └── service-b.properties
├── local
│   ├── application.properties
│   ├── service-a.properties
│   └── service-b.properties
├── prod
│   ├── application.properties
│   ├── service-a.properties
│   └── service-b.properties
├── stage
│   ├── application.properties
│   ├── service-a.properties
│   └── service-b.properties
└── test
    ├── application.properties
    ├── service-a.properties
    └── service-b.properties
Repo structure that works (that will get out of hand as I add more services)
❯ tree .
.
├── application-dev.properties
├── application-local.properties
├── application-prod.properties
├── application-stage.properties
├── application-test.properties
├── service-a-dev.properties
├── service-a-local.properties
├── service-a-prod.properties
├── service-a-stage.properties
├── service-a-test.properties
├── service-b-dev.properties
├── service-b-local.properties
├── service-b-prod.properties
├── service-b-stage.properties
└── service-b-test.properties
Env vars passed to the Deployment:
- name: JAVA_TOOL_OPTIONS
  value: -Dlogging.level.org.springframework.boot.actuate=OFF -Dlogging.level.org.springframework.web=OFF -Dlogging.level.org.springframework=DEBUG
- name: SPRING_PROFILES_ACTIVE
  value: git # this is the only profile that makes CloudConfig clone the repo
- name: SPRING_JMX_DEFAULT_DOMAIN
  value: cloud-config.k8s.local
- name: SPRING_MAIN_BANNER_MODE
  value: "false"
- name: SPRING_APPLICATION_NAME
  value: cloud-config
- name: SPRING_CLOUD_CONFIG_SERVER_GIT_URI
  value: https://github.com/my-org/config-repo.git
- name: SPRING_CLOUD_CONFIG_SERVER_GIT_SEARCH_PATH
  value: "{profile}"
- name: SPRING_CLOUD_CONFIG_SERVER_GIT_CLONE_ON_START
  value: "true"
- name: SPRING_CLOUD_CONFIG_SERVER_GIT_DEFAULT_LABEL
  value: "test"
- name: SPRING_CLOUD_CONFIG_SERVER_ACCEPT_EMPTY
  value: "false"
- name: SPRING_CLOUD_CONFIG_SERVER_GIT_BASEDIR
  value: file:///${user.home}/config-repo
- name: SPRING_CLOUD_KUBERNETES_SECRETS_ENABLEAPI
  value: "false"
- name: SPRING_CLOUD_KUBERNETES_CONFIG_ENABLEAPI
  value: "false"
- name: SPRING_CLOUD_CONFIG_SERVER_GIT_USERNAME
  valueFrom:
    secretKeyRef:
      name: cloud-config-keys
      key: username
- name: SPRING_CLOUD_CONFIG_SERVER_GIT_PASSWORD
  valueFrom:
    secretKeyRef:
      name: cloud-config-keys
      key: password
- name: ENCRYPT_KEY
  valueFrom:
    secretKeyRef:
      name: cloud-config-keys
      key: encrypt_key
Error log
2022-09-15T15:09:30.450Z  INFO 1 --- [nio-8888-exec-3] .s.c.k.c.KubernetesEnvironmentRepository : Profiles: dev
2022-09-15T15:09:30.450Z  INFO 1 --- [nio-8888-exec-3] .s.c.k.c.KubernetesEnvironmentRepository : Application: service-a
2022-09-15T15:09:30.450Z  INFO 1 --- [nio-8888-exec-3] .s.c.k.c.KubernetesEnvironmentRepository : Label: null
2022-09-15T15:09:30.450Z DEBUG 1 --- [nio-8888-exec-3] o.s.core.env.StandardEnvironment         : Activating profiles [dev]
2022-09-15T15:09:30.470Z DEBUG 1 --- [nio-8888-exec-3] .s.c.c.s.s.GitCredentialsProviderFactory : Constructing UsernamePasswordCredentialsProvider for URI https://github.com/OTCMarketsGroup/config-repo.git
2022-09-15T15:09:31.008Z  INFO 1 --- [nio-8888-exec-3] .c.s.e.MultipleJGitEnvironmentRepository : Fetched for remote test and found 1 updates
2022-09-15T15:09:31.060Z DEBUG 1 --- [nio-8888-exec-3] o.s.c.e.PropertySourcesPropertyResolver  : Found key 'spring.profiles.active' in PropertySource 'config-data-setup' with value of type String
2022-09-15T15:09:31.060Z DEBUG 1 --- [nio-8888-exec-3] o.s.c.e.PropertySourcesPropertyResolver  : Found key 'spring.profiles.active' in PropertySource 'config-data-setup' with value of type String
2022-09-15T15:09:31.060Z DEBUG 1 --- [nio-8888-exec-3] o.s.core.env.StandardEnvironment         : Activating profiles [dev]
2022-09-15T15:09:31.062Z DEBUG 1 --- [nio-8888-exec-3] o.s.core.env.StandardEnvironment         : Activating profiles [dev]
2022-09-15T15:09:31.071Z  WARN 1 --- [nio-8888-exec-3] o.s.c.c.s.e.EnvironmentController        : Error getting the Environment with name=service-a profiles=dev label=null includeOrigin=false

org.springframework.cloud.config.server.environment.EnvironmentNotFoundException: Profile Not found
      at org.springframework.cloud.config.server.environment.EnvironmentController.getEnvironment(EnvironmentController.java:135) ~[spring-cloud-config-server-4.0.0-SNAPSHOT.jar:4.0.0-SNAPSHOT]
      at org.springframework.cloud.config.server.environment.EnvironmentController.defaultLabel(EnvironmentController.java:109) ~[spring-cloud-config-server-4.0.0-SNAPSHOT.jar:4.0.0-SNAPSHOT]
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
      at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
...

Comment From: ryanjbaxter

If you try this just by running a basic config server locally without using the docker image?

Comment From: igorbrites

If you try this just by running a basic config server locally without using the docker image?

Hi @ryanjbaxter! Let me try it and get back to you. If this works, what could be the issue with Docker?

Comment From: igorbrites

Indeed, launching it without Docker works. But, as I need it running in Kubernetes, should I build my own image to use it? Or is there another image to use?

Comment From: ryanjbaxter

Can you try springcloud/spring-cloud-kubernetes-configserver:2.1.4 and see if it works with that version?

Comment From: igorbrites

I've found my issue: the search path property I passed was like SPRING_CLOUD_CONFIG_SERVER_GIT_SEARCH_PATH, but the correct name is SPRING_CLOUD_CONFIG_SERVER_GIT_SEARCH_PATHS. So, it's working the way I expected.

Thanks, @ryanjbaxter!