diff --git a/pom.xml b/pom.xml
index 1381a8d0..3d519439 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,19 +76,18 @@
- 1.3.74
+ 1.3.83
1.16.8
2.5
1.3.3.RELEASE
1.0.4.RELEASE
- 1.0.4.RELEASE
1.0.0.RC1
1.0.6.RELEASE
4.2.5.RELEASE
0.14.2
- 2.2.98
+ 2.2.103
3.5
@@ -100,6 +99,7 @@
spring-cloud-kubernetes-zipkin
spring-cloud-kubernetes-compat
spring-cloud-kubernetes-hystrix
+ spring-cloud-kubernetes-archaius
spring-cloud-starter-kubernetes-netflix
spring-cloud-starter-kubernetes-zipkin
spring-cloud-starter-kubernetes-all
@@ -114,6 +114,12 @@
${project.version}
+
+ io.fabric8
+ spring-cloud-kubernetes-archaius
+ ${project.version}
+
+
io.fabric8
spring-cloud-kubernetes-discovery
diff --git a/spring-cloud-kubernetes-archaius/pom.xml b/spring-cloud-kubernetes-archaius/pom.xml
new file mode 100644
index 00000000..da1f47b9
--- /dev/null
+++ b/spring-cloud-kubernetes-archaius/pom.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+ spring-cloud-kubernetes-project
+ io.fabric8
+ 0.1-SNAPSHOT
+
+ 4.0.0
+
+ io.fabric8
+ spring-cloud-kubernetes-archaius
+ Fabric8 :: Spring Cloud Kubernetes :: Archaius
+
+
+
+
+ io.fabric8
+ kubernetes-client
+
+
+
+ org.springframework.cloud
+ spring-cloud-commons
+ true
+
+
+
+ org.springframework.cloud
+ spring-cloud-context
+ true
+
+
+
+ org.springframework.cloud
+ spring-cloud-netflix-core
+ true
+
+
+
+ com.netflix.archaius
+ archaius-core
+ true
+
+
+
+ org.projectlombok
+ lombok
+ provided
+ true
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-cloud-kubernetes-archaius/src/main/java/io/fabric8/spring/cloud/kubernetes/archaius/ArchaiusConfigMapSource.java b/spring-cloud-kubernetes-archaius/src/main/java/io/fabric8/spring/cloud/kubernetes/archaius/ArchaiusConfigMapSource.java
new file mode 100644
index 00000000..a375b6a9
--- /dev/null
+++ b/spring-cloud-kubernetes-archaius/src/main/java/io/fabric8/spring/cloud/kubernetes/archaius/ArchaiusConfigMapSource.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2016 to the original authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.fabric8.spring.cloud.kubernetes.archaius;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Configuration
+@Import(ArchaiusConfigMapSourceRegistar.class)
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface ArchaiusConfigMapSource {
+
+
+ /**
+ * Synonym for name (the name of the ConfigMap).
+ */
+ String value() default "";
+
+ /**
+ * The name of the {@link io.fabric8.kubernetes.api.model.ConfigMap}.
+ */
+ String name() default "";
+
+ /**
+ * The namespacex of the {@link io.fabric8.kubernetes.api.model.ConfigMap}.
+ */
+ String namespace() default "";
+}
diff --git a/spring-cloud-kubernetes-archaius/src/main/java/io/fabric8/spring/cloud/kubernetes/archaius/ArchaiusConfigMapSourceConfiguration.java b/spring-cloud-kubernetes-archaius/src/main/java/io/fabric8/spring/cloud/kubernetes/archaius/ArchaiusConfigMapSourceConfiguration.java
new file mode 100644
index 00000000..0899dad5
--- /dev/null
+++ b/spring-cloud-kubernetes-archaius/src/main/java/io/fabric8/spring/cloud/kubernetes/archaius/ArchaiusConfigMapSourceConfiguration.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2016 to the original authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.fabric8.spring.cloud.kubernetes.archaius;
+
+import com.google.common.base.Strings;
+import com.netflix.config.WatchedConfigurationSource;
+import com.netflix.config.WatchedUpdateListener;
+import com.netflix.config.WatchedUpdateResult;
+import io.fabric8.kubernetes.api.model.ConfigMap;
+import io.fabric8.kubernetes.client.KubernetesClient;
+import io.fabric8.kubernetes.client.KubernetesClientException;
+import io.fabric8.kubernetes.client.Watch;
+import io.fabric8.kubernetes.client.Watcher;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.InitializingBean;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+
+public class ArchaiusConfigMapSourceConfiguration implements InitializingBean, DisposableBean, WatchedConfigurationSource, Closeable {
+
+ private final KubernetesClient client;
+ private final String name;
+ private final String namespace;
+ private final List listeners = new ArrayList<>();
+
+ private final AtomicBoolean started = new AtomicBoolean(false);
+ private final ExecutorService executorService = Executors.newSingleThreadExecutor();
+ private AtomicReference
+
+ org.springframework.cloud
+ spring-cloud-context
+ true
+
+
+ org.projectlombok
+ lombok
+
+ provided
+
\ No newline at end of file
diff --git a/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapBootstrapConfiguration.java b/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapBootstrapConfiguration.java
new file mode 100644
index 00000000..543bc4e9
--- /dev/null
+++ b/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapBootstrapConfiguration.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2016 to the original authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.fabric8.spring.cloud.kubernetes.config;
+
+import io.fabric8.kubernetes.client.KubernetesClient;
+import io.fabric8.spring.cloud.kubernetes.KubernetesAutoConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+@Configuration
+@ConditionalOnProperty(value = "spring.cloud.kubernetes.enabled", matchIfMissing = true)
+public class ConfigMapBootstrapConfiguration {
+
+ @Configuration
+ @EnableConfigurationProperties(ConfigMapConfigProperties.class)
+ @Import(KubernetesAutoConfiguration.class)
+ @ConditionalOnProperty(name = "spring.cloud.kubernetes.config.enabled", matchIfMissing = true)
+ protected static class KubernetesPropertySourceConfiguration {
+ @Autowired
+ private KubernetesClient client;
+
+ @Bean
+ public ConfigMapPropertySourceLocator configMapPropertySourceLocator(ConfigMapConfigProperties properties) {
+ return new ConfigMapPropertySourceLocator(client, properties);
+ }
+ }
+}
diff --git a/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapConfigProperties.java b/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapConfigProperties.java
new file mode 100644
index 00000000..245692ab
--- /dev/null
+++ b/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapConfigProperties.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2016 to the original authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.fabric8.spring.cloud.kubernetes.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@ConfigurationProperties("spring.cloud.kubernetes.config")
+public class ConfigMapConfigProperties {
+
+ private boolean enabled = true;
+ private String name;
+ private String namespace;
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+}
diff --git a/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapPropertySource.java b/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapPropertySource.java
new file mode 100644
index 00000000..74a2df7f
--- /dev/null
+++ b/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapPropertySource.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2016 to the original authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.fabric8.spring.cloud.kubernetes.config;
+
+import io.fabric8.kubernetes.api.model.ConfigMap;
+import io.fabric8.kubernetes.client.KubernetesClient;
+import org.springframework.core.env.MapPropertySource;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public class ConfigMapPropertySource extends MapPropertySource {
+
+ private static final String PREFIX = "configmap";
+ private static final String SEPARATOR = ".";
+
+ private final KubernetesClient client;
+ private final String name;
+ private final String namespace;
+
+ public ConfigMapPropertySource(KubernetesClient client, String name) {
+ this(client, name, null);
+ }
+
+ public ConfigMapPropertySource(KubernetesClient client, String name, String namespace) {
+ super(getName(client, name, namespace), asObjectMap(getData(client, name, namespace)));
+ this.client = client;
+ this.name = name;
+ this.namespace = namespace;
+ }
+
+ private static String getName(KubernetesClient client, String name, String namespace) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(PREFIX).append(SEPARATOR).append(name).append(SEPARATOR).append(namespace == null || namespace.isEmpty() ? client.getNamespace() : namespace);
+ return sb.toString();
+ }
+
+ private static Map getData(KubernetesClient client, String name, String namespace) {
+ ConfigMap map = namespace == null || namespace.isEmpty()
+ ? client.configMaps().withName(name).get()
+ : client.configMaps().inNamespace(namespace).withName(name).get();
+
+ return map != null ? map.getData() : Collections.emptyMap();
+ }
+
+ private static Map asObjectMap(Map source) {
+ return source.entrySet()
+ .stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+ }
+}
diff --git a/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapPropertySourceLocator.java b/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapPropertySourceLocator.java
new file mode 100644
index 00000000..ecedbf0d
--- /dev/null
+++ b/spring-cloud-kubernetes-core/src/main/java/io/fabric8/spring/cloud/kubernetes/config/ConfigMapPropertySourceLocator.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2016 to the original authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.fabric8.spring.cloud.kubernetes.config;
+
+import io.fabric8.kubernetes.client.KubernetesClient;
+import org.springframework.cloud.bootstrap.config.PropertySourceLocator;
+import org.springframework.core.annotation.Order;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.Environment;
+import org.springframework.core.env.PropertySource;
+
+@Order(0)
+public class ConfigMapPropertySourceLocator implements PropertySourceLocator {
+
+ private static final String SPRING_APPLICATION_NAME = "spring.application.name";
+
+ private final KubernetesClient client;
+ private final ConfigMapConfigProperties properties;
+
+ public ConfigMapPropertySourceLocator(KubernetesClient client, ConfigMapConfigProperties properties) {
+ this.client = client;
+ this.properties = properties;
+ }
+
+ @Override
+ public PropertySource> locate(Environment environment) {
+ if (environment instanceof ConfigurableEnvironment) {
+ ConfigurableEnvironment env = (ConfigurableEnvironment) environment;
+ String appName = env.getProperty(SPRING_APPLICATION_NAME);
+ String name = properties.getName() == null || properties.getName().isEmpty() ? appName : properties.getName();
+ String namespace = properties.getNamespace();
+ return new ConfigMapPropertySource(client, name, namespace);
+ }
+ return null;
+ }
+}
diff --git a/spring-cloud-kubernetes-core/src/main/resources/META-INF/spring.factories b/spring-cloud-kubernetes-core/src/main/resources/META-INF/spring.factories
index 6ed9c329..d055546b 100644
--- a/spring-cloud-kubernetes-core/src/main/resources/META-INF/spring.factories
+++ b/spring-cloud-kubernetes-core/src/main/resources/META-INF/spring.factories
@@ -1,5 +1,8 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
io.fabric8.spring.cloud.kubernetes.KubernetesAutoConfiguration
+org.springframework.cloud.bootstrap.BootstrapConfiguration=\
+io.fabric8.spring.cloud.kubernetes.config.ConfigMapBootstrapConfiguration
+
org.springframework.context.ApplicationContextInitializer=\
io.fabric8.spring.cloud.kubernetes.profile.KubernetesApplicationContextInitializer
diff --git a/spring-cloud-starter-kubernetes-all/pom.xml b/spring-cloud-starter-kubernetes-all/pom.xml
index 49bdbf12..f0143df8 100644
--- a/spring-cloud-starter-kubernetes-all/pom.xml
+++ b/spring-cloud-starter-kubernetes-all/pom.xml
@@ -41,6 +41,11 @@
spring-cloud-kubernetes-discovery
+
+ io.fabric8
+ spring-cloud-kubernetes-archaius
+
+
io.fabric8
spring-cloud-kubernetes-ribbon
@@ -70,7 +75,6 @@
org.aspectj
aspectjrt
-
\ No newline at end of file