Sync docs from vGreenwich.M3 to gh-pages
This commit is contained in:
File diff suppressed because one or more lines are too long
47
Greenwich.M3/multi/multi__building.html
Normal file
47
Greenwich.M3/multi/multi__building.html
Normal file
@@ -0,0 +1,47 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>140. Building</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__other_resources.html" title="Part XXVI. Other Resources"><link rel="prev" href="multi__other_resources.html" title="Part XXVI. Other Resources"><link rel="next" href="multi__contributing.html" title="141. Contributing"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">140. Building</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__other_resources.html">Prev</a> </td><th width="60%" align="center">Part XXVI. Other Resources</th><td width="20%" align="right"> <a accesskey="n" href="multi__contributing.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_building" href="#_building"></a>140. Building</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_basic_compile_and_test" href="#_basic_compile_and_test"></a>140.1 Basic Compile and Test</h2></div></div></div><p>To build the source you will need to install JDK 1.7.</p><p>Spring Cloud uses Maven for most build-related activities, and you
|
||||
should be able to get off the ground quite quickly by cloning the
|
||||
project you are interested in and typing</p><pre class="screen">$ ./mvnw install</pre><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>You can also install Maven (>=3.3.3) yourself and run the <code class="literal">mvn</code> command
|
||||
in place of <code class="literal">./mvnw</code> in the examples below. If you do that you also
|
||||
might need to add <code class="literal">-P spring</code> if your local Maven settings do not
|
||||
contain repository declarations for spring pre-release artifacts.</p></td></tr></table></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Be aware that you might need to increase the amount of memory
|
||||
available to Maven by setting a <code class="literal">MAVEN_OPTS</code> environment variable with
|
||||
a value like <code class="literal">-Xmx512m -XX:MaxPermSize=128m</code>. We try to cover this in
|
||||
the <code class="literal">.mvn</code> configuration, so if you find you have to do it to make a
|
||||
build succeed, please raise a ticket to get the settings added to
|
||||
source control.</p></td></tr></table></div><p>For hints on how to build the project look in <code class="literal">.travis.yml</code> if there
|
||||
is one. There should be a "script" and maybe "install" command. Also
|
||||
look at the "services" section to see if any services need to be
|
||||
running locally (e.g. mongo or rabbit). Ignore the git-related bits
|
||||
that you might find in "before_install" since they’re related to setting git
|
||||
credentials and you already have those.</p><p>The projects that require middleware generally include a
|
||||
<code class="literal">docker-compose.yml</code>, so consider using
|
||||
<a class="link" href="http://compose.docker.io/" target="_top">Docker Compose</a> to run the middeware servers
|
||||
in Docker containers. See the README in the
|
||||
<a class="link" href="https://github.com/spring-cloud-samples/scripts" target="_top">scripts demo
|
||||
repository</a> for specific instructions about the common cases of mongo,
|
||||
rabbit and redis.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>If all else fails, build with the command from <code class="literal">.travis.yml</code> (usually
|
||||
<code class="literal">./mvnw install</code>).</p></td></tr></table></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_documentation" href="#_documentation"></a>140.2 Documentation</h2></div></div></div><p>The spring-cloud-build module has a "docs" profile, and if you switch
|
||||
that on it will try to build asciidoc sources from
|
||||
<code class="literal">src/main/asciidoc</code>. As part of that process it will look for a
|
||||
<code class="literal">README.adoc</code> and process it by loading all the includes, but not
|
||||
parsing or rendering it, just copying it to <code class="literal">${main.basedir}</code>
|
||||
(defaults to <code class="literal">$../../../..</code>, i.e. the root of the project). If there are
|
||||
any changes in the README it will then show up after a Maven build as
|
||||
a modified file in the correct place. Just commit it and push the change.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_working_with_the_code" href="#_working_with_the_code"></a>140.3 Working with the code</h2></div></div></div><p>If you don’t have an IDE preference we would recommend that you use
|
||||
<a class="link" href="http://www.springsource.com/developer/sts" target="_top">Spring Tools Suite</a> or
|
||||
<a class="link" href="http://eclipse.org" target="_top">Eclipse</a> when working with the code. We use the
|
||||
<a class="link" href="http://eclipse.org/m2e/" target="_top">m2eclipse</a> eclipse plugin for maven support. Other IDEs and tools
|
||||
should also work without issue as long as they use Maven 3.3.3 or better.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_importing_into_eclipse_with_m2eclipse" href="#_importing_into_eclipse_with_m2eclipse"></a>140.3.1 Importing into eclipse with m2eclipse</h3></div></div></div><p>We recommend the <a class="link" href="http://eclipse.org/m2e/" target="_top">m2eclipse</a> eclipse plugin when working with
|
||||
eclipse. If you don’t already have m2eclipse installed it is available from the "eclipse
|
||||
marketplace".</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>Older versions of m2e do not support Maven 3.3, so once the
|
||||
projects are imported into Eclipse you will also need to tell
|
||||
m2eclipse to use the right profile for the projects. If you
|
||||
see many different errors related to the POMs in the projects, check
|
||||
that you have an up to date installation. If you can’t upgrade m2e,
|
||||
add the "spring" profile to your <code class="literal">settings.xml</code>. Alternatively you can
|
||||
copy the repository settings from the "spring" profile of the parent
|
||||
pom into your <code class="literal">settings.xml</code>.</p></td></tr></table></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_importing_into_eclipse_without_m2eclipse" href="#_importing_into_eclipse_without_m2eclipse"></a>140.3.2 Importing into eclipse without m2eclipse</h3></div></div></div><p>If you prefer not to use m2eclipse you can generate eclipse project metadata using the
|
||||
following command:</p><pre class="screen">$ ./mvnw eclipse:eclipse</pre><p>The generated eclipse projects can be imported by selecting <code class="literal">import existing projects</code>
|
||||
from the <code class="literal">file</code> menu.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__other_resources.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="multi__other_resources.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="multi__contributing.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part XXVI. Other Resources </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> 141. Contributing</td></tr></table></div></body></html>
|
||||
105
Greenwich.M3/multi/multi__configmap_propertysource.html
Normal file
105
Greenwich.M3/multi/multi__configmap_propertysource.html
Normal file
@@ -0,0 +1,105 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>134. ConfigMap PropertySource</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__kubernetes_propertysource_implementations.html" title="Part XIX. Kubernetes PropertySource implementations"><link rel="prev" href="multi__kubernetes_propertysource_implementations.html" title="Part XIX. Kubernetes PropertySource implementations"><link rel="next" href="multi__secrets_propertysource.html" title="135. Secrets PropertySource"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">134. ConfigMap PropertySource</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__kubernetes_propertysource_implementations.html">Prev</a> </td><th width="60%" align="center">Part XIX. Kubernetes PropertySource implementations</th><td width="20%" align="right"> <a accesskey="n" href="multi__secrets_propertysource.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_configmap_propertysource" href="#_configmap_propertysource"></a>134. ConfigMap PropertySource</h2></div></div></div><p>Kubernetes provides a resource named <a class="link" href="http://kubernetes.io/docs/user-guide/configmap/" target="_top">ConfigMap</a> to externalize the
|
||||
parameters to pass to your application in the form of key-value pairs or embedded <code class="literal">application.properties|yaml</code> files.
|
||||
The <a class="link" href="./spring-cloud-kubernetes-config" target="_top">Spring Cloud Kubernetes Config</a> project makes Kubernetes `ConfigMap`s available
|
||||
during application bootstrapping and triggers hot reloading of beans or Spring context when changes are detected on
|
||||
observed `ConfigMap`s.</p><p>The default behavior is to create a <code class="literal">ConfigMapPropertySource</code> based on a Kubernetes <code class="literal">ConfigMap</code> which has <code class="literal">metadata.name</code> of either the name of
|
||||
your Spring application (as defined by its <code class="literal">spring.application.name</code> property) or a custom name defined within the
|
||||
<code class="literal">bootstrap.properties</code> file under the following key <code class="literal">spring.cloud.kubernetes.config.name</code>.</p><p>However, more advanced configuration are possible where multiple ConfigMaps can be used
|
||||
This is made possible by the <code class="literal">spring.cloud.kubernetes.config.sources</code> list.
|
||||
For example one could define the following ConfigMaps</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">spring</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> application</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> name</span>: cloud-k8s-app
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> cloud</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> kubernetes</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> config</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> name</span>: default-name
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> namespace</span>: default-namespace
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> sources</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment"># Spring Cloud Kubernetes will lookup a ConfigMap named c1 in namespace default-namespace</span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> - name</span>: c1
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment"># Spring Cloud Kubernetes will lookup a ConfigMap named default-name in whatever namespace n2</span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> - namespace</span>: n2
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment"># Spring Cloud Kubernetes will lookup a ConfigMap named c3 in namespace n3</span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> - namespace</span>: n3
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> name</span>: c3</pre><p>In the example above, it <code class="literal">spring.cloud.kubernetes.config.namespace</code> had not been set,
|
||||
then the ConfigMap named <code class="literal">c1</code> would be looked up in the namespace that the application runs</p><p>Any matching <code class="literal">ConfigMap</code> that is found, will be processed as follows:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">apply individual configuration properties.</li><li class="listitem">apply as <code class="literal">yaml</code> the content of any property named <code class="literal">application.yaml</code></li><li class="listitem">apply as properties file the content of any property named <code class="literal">application.properties</code></li></ul></div><p>The single exception to the aforementioned flow is when the <code class="literal">ConfigMap</code> contains a <span class="strong"><strong>single</strong></span> key that indicates
|
||||
the file is a YAML or Properties file. In that case the name of the key does NOT have to be <code class="literal">application.yaml</code> or
|
||||
<code class="literal">application.properties</code> (it can be anything) and the value of the property will be treated correctly.
|
||||
This features facilitates the use case where the <code class="literal">ConfigMap</code> was created using something like:</p><p><code class="literal">kubectl create configmap game-config --from-file=/path/to/app-config.yaml</code></p><p>Example:</p><p>Let’s assume that we have a Spring Boot application named <code class="literal">demo</code> that uses properties to read its thread pool
|
||||
configuration.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><code class="literal">pool.size.core</code></li><li class="listitem"><code class="literal">pool.size.maximum</code></li></ul></div><p>This can be externalized to config map in <code class="literal">yaml</code> format:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">kind</span>: ConfigMap
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">apiVersion</span>: v1
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">metadata</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> name</span>: demo
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">data</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> pool.size.core</span>: <span class="hl-number">1</span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> pool.size.max</span>: <span class="hl-number">16</span></pre><p>Individual properties work fine for most cases but sometimes embedded <code class="literal">yaml</code> is more convenient. In this case we will
|
||||
use a single property named <code class="literal">application.yaml</code> to embed our <code class="literal">yaml</code>:</p><pre class="literallayout"> ```yaml
|
||||
kind: ConfigMap
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: demo
|
||||
data:
|
||||
application.yaml: |-
|
||||
pool:
|
||||
size:
|
||||
core: 1
|
||||
max:16</pre><pre class="screen">The following also works:
|
||||
|
||||
```yaml
|
||||
kind: ConfigMap
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: demo
|
||||
data:
|
||||
custom-name.yaml: |-
|
||||
pool:
|
||||
size:
|
||||
core: 1
|
||||
max:16</pre><p>Spring Boot applications can also be configured differently depending on active profiles which will be merged together
|
||||
when the ConfigMap is read. It is possible to provide different property values for different profiles using an
|
||||
<code class="literal">application.properties|yaml</code> property, specifying profile-specific values each in their own document
|
||||
(indicated by the <code class="literal">---</code> sequence) as follows:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">kind</span>: ConfigMap
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">apiVersion</span>: v1
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">metadata</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> name</span>: demo
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">data</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> application.yml</span>: |-
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> greeting</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> message</span>: Say Hello to the World
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> farewell</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> message</span>: Say Goodbye
|
||||
---
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> spring</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> profiles</span>: development
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> greeting</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> message</span>: Say Hello to the Developers
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> farewell</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> message</span>: Say Goodbye to the Developers
|
||||
---
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> spring</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> profiles</span>: production
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> greeting</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> message</span>: Say Hello to the Ops</pre><p>In the above case, the configuration loaded into your Spring Application with the <code class="literal">development</code> profile will be:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> greeting</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> message</span>: Say Hello to the Developers
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> farewell</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> message</span>: Say Goodbye to the Developers</pre><p>whereas if the <code class="literal">production</code> profile is active, the configuration will be:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> greeting</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> message</span>: Say Hello to the Ops
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> farewell</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> message</span>: Say Goodbye</pre><p>If both profiles are active, the property which appears last within the configmap will overwrite preceding values.</p><p>To tell to Spring Boot which <code class="literal">profile</code> should be enabled at bootstrap, a system property can be passed to the Java
|
||||
command launching your Spring Boot application using an env variable that you will define with the OpenShift
|
||||
<code class="literal">DeploymentConfig</code> or Kubernetes <code class="literal">ReplicationConfig</code> resource file as follows:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">apiVersion</span>: v1
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">kind</span>: DeploymentConfig
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">spec</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> replicas</span>: <span class="hl-number">1</span>
|
||||
...
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> spec</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> containers</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> - env</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> - name</span>: JAVA_APP_DIR
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> value</span>: /deployments
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> - name</span>: JAVA_OPTIONS
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> value</span>: -Dspring.profiles.active=developer</pre><p><span class="strong"><strong>Notes:</strong></span>
|
||||
- check the security configuration section, to access config maps from inside a pod you need to have the correct
|
||||
Kubernetes service accounts, roles and role bindings.</p><div class="table"><a name="d0e34410" href="#d0e34410"></a><p class="title"><b>Table 134.1. Properties:</b></p><div class="table-contents"><table summary="Properties:" style="border-collapse: collapse;border-top: 0.5pt solid ; border-bottom: 0.5pt solid ; "><colgroup><col class="col_1"><col class="col_2"><col class="col_3"><col class="col_4"></colgroup><thead><tr><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">Name</th><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">Type</th><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">Default</th><th style="border-bottom: 0.5pt solid ; " align="left" valign="top">Description</th></tr></thead><tfoot><tr><th style="border-right: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.config.enableApi</p></th><th style="border-right: 0.5pt solid ; " align="left" valign="top"><p>Boolean</p></th><th style="border-right: 0.5pt solid ; " align="left" valign="top"><p>true</p></th><th style="" align="left" valign="top"><p>Enable/Disable consuming ConfigMaps via APIs</p></th></tr></tfoot><tbody><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.config.enabled</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Boolean</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>true</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Enable Secrets PropertySource</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.config.name</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>String</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>${spring.application.name}</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Sets the name of ConfigMap to lookup</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.config.namespace</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>String</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Client namespace</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Sets the Kubernetes namespace where to lookup</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.config.paths</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>List</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>null</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Sets the paths where ConfigMaps are mounted</p></td></tr></tbody></table></div></div><br class="table-break"></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__kubernetes_propertysource_implementations.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="multi__kubernetes_propertysource_implementations.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="multi__secrets_propertysource.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part XIX. Kubernetes PropertySource implementations </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> 135. Secrets PropertySource</td></tr></table></div></body></html>
|
||||
28
Greenwich.M3/multi/multi__contributing.html
Normal file
28
Greenwich.M3/multi/multi__contributing.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>141. Contributing</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__other_resources.html" title="Part XXVI. Other Resources"><link rel="prev" href="multi__building.html" title="140. Building"><link rel="next" href="multi__appendix_compendium_of_configuration_properties.html" title="Part XXVII. Appendix: Compendium of Configuration Properties"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">141. Contributing</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__building.html">Prev</a> </td><th width="60%" align="center">Part XXVI. Other Resources</th><td width="20%" align="right"> <a accesskey="n" href="multi__appendix_compendium_of_configuration_properties.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_contributing" href="#_contributing"></a>141. Contributing</h2></div></div></div><p>Spring Cloud is released under the non-restrictive Apache 2.0 license,
|
||||
and follows a very standard Github development process, using Github
|
||||
tracker for issues and merging pull requests into master. If you want
|
||||
to contribute even something trivial please do not hesitate, but
|
||||
follow the guidelines below.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_sign_the_contributor_license_agreement" href="#_sign_the_contributor_license_agreement"></a>141.1 Sign the Contributor License Agreement</h2></div></div></div><p>Before we accept a non-trivial patch or pull request we will need you to sign the
|
||||
<a class="link" href="https://cla.pivotal.io/sign/spring" target="_top">Contributor License Agreement</a>.
|
||||
Signing the contributor’s agreement does not grant anyone commit rights to the main
|
||||
repository, but it does mean that we can accept your contributions, and you will get an
|
||||
author credit if we do. Active contributors might be asked to join the core team, and
|
||||
given the ability to merge pull requests.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_code_of_conduct" href="#_code_of_conduct"></a>141.2 Code of Conduct</h2></div></div></div><p>This project adheres to the Contributor Covenant <a class="link" href="https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc" target="_top">code of
|
||||
conduct</a>. By participating, you are expected to uphold this code. Please report
|
||||
unacceptable behavior to <a class="link" href="mailto:spring-code-of-conduct@pivotal.io" target="_top">spring-code-of-conduct@pivotal.io</a>.</p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_code_conventions_and_housekeeping" href="#_code_conventions_and_housekeeping"></a>141.3 Code Conventions and Housekeeping</h2></div></div></div><p>None of these is essential for a pull request, but they will all help. They can also be
|
||||
added after the original pull request but before a merge.</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">Use the Spring Framework code format conventions. If you use Eclipse
|
||||
you can import formatter settings using the
|
||||
<code class="literal">eclipse-code-formatter.xml</code> file from the
|
||||
<a class="link" href="https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml" target="_top">Spring
|
||||
Cloud Build</a> project. If using IntelliJ, you can use the
|
||||
<a class="link" href="http://plugins.jetbrains.com/plugin/6546" target="_top">Eclipse Code Formatter
|
||||
Plugin</a> to import the same file.</li><li class="listitem">Make sure all new <code class="literal">.java</code> files to have a simple Javadoc class comment with at least an
|
||||
<code class="literal">@author</code> tag identifying you, and preferably at least a paragraph on what the class is
|
||||
for.</li><li class="listitem">Add the ASF license header comment to all new <code class="literal">.java</code> files (copy from existing files
|
||||
in the project)</li><li class="listitem">Add yourself as an <code class="literal">@author</code> to the .java files that you modify substantially (more
|
||||
than cosmetic changes).</li><li class="listitem">Add some Javadocs and, if you change the namespace, some XSD doc elements.</li><li class="listitem">A few unit tests would help a lot as well — someone has to do it.</li><li class="listitem">If no-one else is using your branch, please rebase it against the current master (or
|
||||
other target branch in the main project).</li><li class="listitem">When writing a commit message please follow <a class="link" href="http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html" target="_top">these conventions</a>,
|
||||
if you are fixing an existing issue please add <code class="literal">Fixes gh-XXXX</code> at the end of the commit
|
||||
message (where XXXX is the issue number).</li></ul></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__building.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="multi__other_resources.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="multi__appendix_compendium_of_configuration_properties.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">140. Building </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> Part XXVII. Appendix: Compendium of Configuration Properties</td></tr></table></div></body></html>
|
||||
@@ -0,0 +1,20 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Part XVIII. DiscoveryClient for Kubernetes</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="prev" href="multi__why_do_you_need_spring_cloud_kubernetes.html" title="133. Why do you need Spring Cloud Kubernetes?"><link rel="next" href="multi__kubernetes_propertysource_implementations.html" title="Part XIX. Kubernetes PropertySource implementations"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Part XVIII. DiscoveryClient for Kubernetes</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__why_do_you_need_spring_cloud_kubernetes.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__kubernetes_propertysource_implementations.html">Next</a></td></tr></table><hr></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a name="_discoveryclient_for_kubernetes" href="#_discoveryclient_for_kubernetes"></a>Part XVIII. DiscoveryClient for Kubernetes</h1></div></div></div><div class="partintro"><div></div><p>This project provides an implementation of <a class="link" href="https://github.com/spring-cloud/spring-cloud-commons/blob/master/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java" target="_top">Discovery Client</a>
|
||||
for <a class="link" href="http://kubernetes.io" target="_top">Kubernetes</a>.
|
||||
This allows you to query Kubernetes endpoints <span class="strong"><strong>(see <a class="link" href="http://kubernetes.io/docs/user-guide/services/" target="_top">services</a>)</strong></span> by name.
|
||||
A service is typically exposed by the Kubernetes API server as a collection of endpoints which represent <code class="literal">http</code>, <code class="literal">https</code> addresses that a client can
|
||||
access from a Spring Boot application running as a pod. This discovery feature is also used by the Spring Cloud Kubernetes Ribbon project
|
||||
to fetch the list of the endpoints defined for an application to be load balanced.</p><p>This is something that you get for free just by adding the following dependency inside your project:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><dependency></span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><groupId></span>org.springframework.cloud<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></groupId></span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><artifactId></span>spring-cloud-starter-kubernetes<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></artifactId></span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><version></span>${latest.version}<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></version></span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></dependency></span></pre><p>To enable loading of the <code class="literal">DiscoveryClient</code>, add <code class="literal">@EnableDiscoveryClient</code> to the according configuration or application class like this:</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@SpringBootApplication</span></em>
|
||||
<em><span class="hl-annotation" style="color: gray">@EnableDiscoveryClient</span></em>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> Application {
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">void</span> main(String[] args) {
|
||||
SpringApplication.run(Application.<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span>, args);
|
||||
}
|
||||
}</pre><p>Then you can inject the client in your code simply by:</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@Autowired</span></em>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">private</span> DiscoveryClient discoveryClient;</pre><p>If for any reason you need to disable the <code class="literal">DiscoveryClient</code> you can simply set the following property in <code class="literal">application.properties</code>:</p><pre class="screen">spring.cloud.kubernetes.discovery.enabled=false</pre><p>Some Spring Cloud components use the <code class="literal">DiscoveryClient</code> in order to obtain info about the local service instance. For
|
||||
this to work you need to align the Kubernetes service name with the <code class="literal">spring.application.name</code> property.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__why_do_you_need_spring_cloud_kubernetes.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__kubernetes_propertysource_implementations.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">133. Why do you need Spring Cloud Kubernetes? </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> Part XIX. Kubernetes PropertySource implementations</td></tr></table></div></body></html>
|
||||
3
Greenwich.M3/multi/multi__examples_2.html
Normal file
3
Greenwich.M3/multi/multi__examples_2.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Part XXV. Examples</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="prev" href="multi__service_account.html" title="139. Service Account"><link rel="next" href="multi__other_resources.html" title="Part XXVI. Other Resources"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Part XXV. Examples</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__service_account.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__other_resources.html">Next</a></td></tr></table><hr></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a name="_examples_2" href="#_examples_2"></a>Part XXV. Examples</h1></div></div></div><div class="partintro"><div></div><p>List of examples using these projects:</p><p><TBD></p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__service_account.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__other_resources.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">139. Service Account </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> Part XXVI. Other Resources</td></tr></table></div></body></html>
|
||||
9
Greenwich.M3/multi/multi__kubernetes_awareness.html
Normal file
9
Greenwich.M3/multi/multi__kubernetes_awareness.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Part XXI. Kubernetes Awareness</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="prev" href="multi__ribbon_discovery_in_kubernetes.html" title="Part XX. Ribbon discovery in Kubernetes"><link rel="next" href="multi__kubernetes_profile_autoconfiguration.html" title="137. Kubernetes Profile Autoconfiguration"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Part XXI. Kubernetes Awareness</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__ribbon_discovery_in_kubernetes.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__kubernetes_profile_autoconfiguration.html">Next</a></td></tr></table><hr></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a name="_kubernetes_awareness" href="#_kubernetes_awareness"></a>Part XXI. Kubernetes Awareness</h1></div></div></div><div class="partintro"><div></div><p>All of the features described above will work equally well regardless of whether your application is running inside
|
||||
Kubernetes or not. This is really helpful for development and troubleshooting.
|
||||
From a development point of view, this is really helpful as you can start your Spring Boot application and debug one
|
||||
of the modules part of this project. It is not required to deploy it in Kubernetes
|
||||
as the code of the project relies on the
|
||||
[Fabric8 Kubernetes Java client](<a class="link" href="https://github.com/fabric8io/kubernetes-client" target="_top">https://github.com/fabric8io/kubernetes-client</a>) which is a fluent DSL able to
|
||||
communicate using <code class="literal">http</code> protocol to the REST API of Kubernetes Server.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__ribbon_discovery_in_kubernetes.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__kubernetes_profile_autoconfiguration.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part XX. Ribbon discovery in Kubernetes </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> 137. Kubernetes Profile Autoconfiguration</td></tr></table></div></body></html>
|
||||
@@ -0,0 +1,5 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>137. Kubernetes Profile Autoconfiguration</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__kubernetes_awareness.html" title="Part XXI. Kubernetes Awareness"><link rel="prev" href="multi__kubernetes_awareness.html" title="Part XXI. Kubernetes Awareness"><link rel="next" href="multi__pod_health_indicator.html" title="Part XXII. Pod Health Indicator"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">137. Kubernetes Profile Autoconfiguration</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__kubernetes_awareness.html">Prev</a> </td><th width="60%" align="center">Part XXI. Kubernetes Awareness</th><td width="20%" align="right"> <a accesskey="n" href="multi__pod_health_indicator.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_kubernetes_profile_autoconfiguration" href="#_kubernetes_profile_autoconfiguration"></a>137. Kubernetes Profile Autoconfiguration</h2></div></div></div><p>When the application runs as a pod inside Kubernetes a Spring profile named <code class="literal">kubernetes</code> will automatically get activated.
|
||||
This allows the developer to customize the configuration, to define beans that will be applied when the Spring Boot application is deployed
|
||||
within the Kubernetes platform <span class="strong"><strong>(e.g. different dev and prod configuration)</strong></span>.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__kubernetes_awareness.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="multi__kubernetes_awareness.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="multi__pod_health_indicator.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part XXI. Kubernetes Awareness </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> Part XXII. Pod Health Indicator</td></tr></table></div></body></html>
|
||||
@@ -0,0 +1,6 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Part XIX. Kubernetes PropertySource implementations</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="prev" href="multi__discoveryclient_for_kubernetes.html" title="Part XVIII. DiscoveryClient for Kubernetes"><link rel="next" href="multi__configmap_propertysource.html" title="134. ConfigMap PropertySource"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Part XIX. Kubernetes PropertySource implementations</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__discoveryclient_for_kubernetes.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__configmap_propertysource.html">Next</a></td></tr></table><hr></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a name="_kubernetes_propertysource_implementations" href="#_kubernetes_propertysource_implementations"></a>Part XIX. Kubernetes PropertySource implementations</h1></div></div></div><div class="partintro"><div></div><p>The most common approach to configure your Spring Boot application is to create an <code class="literal">application.properties|yaml</code> or
|
||||
an <code class="literal">application-profile.properties|yaml</code> file containing key-value pairs providing customization values to your
|
||||
application or Spring Boot starters. Users may override these properties by specifying system properties or environment
|
||||
variables.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__discoveryclient_for_kubernetes.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__configmap_propertysource.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part XVIII. DiscoveryClient for Kubernetes </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> 134. ConfigMap PropertySource</td></tr></table></div></body></html>
|
||||
3
Greenwich.M3/multi/multi__leader_election.html
Normal file
3
Greenwich.M3/multi/multi__leader_election.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Part XXIII. Leader Election</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="prev" href="multi__pod_health_indicator.html" title="Part XXII. Pod Health Indicator"><link rel="next" href="multi__security_configurations_inside_kubernetes.html" title="Part XXIV. Security Configurations inside Kubernetes"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Part XXIII. Leader Election</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__pod_health_indicator.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__security_configurations_inside_kubernetes.html">Next</a></td></tr></table><hr></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a name="_leader_election" href="#_leader_election"></a>Part XXIII. Leader Election</h1></div></div></div><div class="partintro"><div></div><p><TBD></p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__pod_health_indicator.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__security_configurations_inside_kubernetes.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part XXII. Pod Health Indicator </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> Part XXIV. Security Configurations inside Kubernetes</td></tr></table></div></body></html>
|
||||
8
Greenwich.M3/multi/multi__namespace.html
Normal file
8
Greenwich.M3/multi/multi__namespace.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>138. Namespace</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__security_configurations_inside_kubernetes.html" title="Part XXIV. Security Configurations inside Kubernetes"><link rel="prev" href="multi__security_configurations_inside_kubernetes.html" title="Part XXIV. Security Configurations inside Kubernetes"><link rel="next" href="multi__service_account.html" title="139. Service Account"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">138. Namespace</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__security_configurations_inside_kubernetes.html">Prev</a> </td><th width="60%" align="center">Part XXIV. Security Configurations inside Kubernetes</th><td width="20%" align="right"> <a accesskey="n" href="multi__service_account.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_namespace" href="#_namespace"></a>138. Namespace</h2></div></div></div><p>Most of the components provided in this project need to know the namespace. For Kubernetes (1.3+) the namespace is made available to pod as part of the service account secret and automatically detected by the client.
|
||||
For earlier version it needs to be specified as an env var to the pod. A quick way to do this is:</p><pre class="literallayout">env:
|
||||
- name: "KUBERNETES_NAMESPACE"
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: "metadata.namespace"</pre></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__security_configurations_inside_kubernetes.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="multi__security_configurations_inside_kubernetes.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="multi__service_account.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part XXIV. Security Configurations inside Kubernetes </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> 139. Service Account</td></tr></table></div></body></html>
|
||||
3
Greenwich.M3/multi/multi__other_resources.html
Normal file
3
Greenwich.M3/multi/multi__other_resources.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Part XXVI. Other Resources</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="prev" href="multi__examples_2.html" title="Part XXV. Examples"><link rel="next" href="multi__building.html" title="140. Building"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Part XXVI. Other Resources</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__examples_2.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__building.html">Next</a></td></tr></table><hr></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a name="_other_resources" href="#_other_resources"></a>Part XXVI. Other Resources</h1></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__examples_2.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__building.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part XXV. Examples </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> 140. Building</td></tr></table></div></body></html>
|
||||
4
Greenwich.M3/multi/multi__pod_health_indicator.html
Normal file
4
Greenwich.M3/multi/multi__pod_health_indicator.html
Normal file
@@ -0,0 +1,4 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Part XXII. Pod Health Indicator</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="prev" href="multi__kubernetes_profile_autoconfiguration.html" title="137. Kubernetes Profile Autoconfiguration"><link rel="next" href="multi__leader_election.html" title="Part XXIII. Leader Election"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Part XXII. Pod Health Indicator</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__kubernetes_profile_autoconfiguration.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__leader_election.html">Next</a></td></tr></table><hr></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a name="_pod_health_indicator" href="#_pod_health_indicator"></a>Part XXII. Pod Health Indicator</h1></div></div></div><div class="partintro"><div></div><p>Spring Boot uses <a class="link" href="https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpoint.java" target="_top">HealthIndicator</a> to expose info about the health of an application.
|
||||
That makes it really useful for exposing health related information to the user and are also a good fit for use as <a class="link" href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/" target="_top">readiness probes</a>.</p><p>The Kubernetes health indicator which is part of the core module exposes the following info:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">pod name, ip address, namespace, service account, node name and its ip address</li><li class="listitem">flag that indicates if the Spring Boot application is internal or external to Kubernetes</li></ul></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__kubernetes_profile_autoconfiguration.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__leader_election.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">137. Kubernetes Profile Autoconfiguration </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> Part XXIII. Leader Election</td></tr></table></div></body></html>
|
||||
49
Greenwich.M3/multi/multi__propertysource_reload.html
Normal file
49
Greenwich.M3/multi/multi__propertysource_reload.html
Normal file
@@ -0,0 +1,49 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>136. PropertySource Reload</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__kubernetes_propertysource_implementations.html" title="Part XIX. Kubernetes PropertySource implementations"><link rel="prev" href="multi__secrets_propertysource.html" title="135. Secrets PropertySource"><link rel="next" href="multi__ribbon_discovery_in_kubernetes.html" title="Part XX. Ribbon discovery in Kubernetes"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">136. PropertySource Reload</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__secrets_propertysource.html">Prev</a> </td><th width="60%" align="center">Part XIX. Kubernetes PropertySource implementations</th><td width="20%" align="right"> <a accesskey="n" href="multi__ribbon_discovery_in_kubernetes.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_propertysource_reload" href="#_propertysource_reload"></a>136. PropertySource Reload</h2></div></div></div><p>Some applications may need to detect changes on external property sources and update their internal status to reflect the new configuration.
|
||||
The reload feature of Spring Cloud Kubernetes is able to trigger an application reload when a related <code class="literal">ConfigMap</code> or
|
||||
<code class="literal">Secret</code> changes.</p><p>This feature is disabled by default and can be enabled using the configuration property <code class="literal">spring.cloud.kubernetes.reload.enabled=true</code>
|
||||
(eg. in the <span class="strong"><strong>application.properties</strong></span> file).</p><p>The following levels of reload are supported (property <code class="literal">spring.cloud.kubernetes.reload.strategy</code>):
|
||||
- <span class="strong"><strong><code class="literal">refresh</code> (default)</strong></span>: only configuration beans annotated with <code class="literal">@ConfigurationProperties</code> or <code class="literal">@RefreshScope</code> are reloaded.
|
||||
This reload level leverages the refresh feature of Spring Cloud Context.
|
||||
- <span class="strong"><strong><code class="literal">restart_context</code></strong></span>: the whole Spring <span class="emphasis"><em>ApplicationContext</em></span> is gracefully restarted. Beans are recreated with the new configuration.
|
||||
- <span class="strong"><strong><code class="literal">shutdown</code></strong></span>: the Spring <span class="emphasis"><em>ApplicationContext</em></span> is shut down to activate a restart of the container.
|
||||
When using this level, make sure that the lifecycle of all non-daemon threads is bound to the ApplicationContext
|
||||
and that a replication controller or replica set is configured to restart the pod.</p><p>Example:</p><p>Assuming that the reload feature is enabled with default settings (<span class="strong"><strong><code class="literal">refresh</code></strong></span> mode), the following bean will be refreshed when the config map changes:</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@Configuration</span></em>
|
||||
<em><span class="hl-annotation" style="color: gray">@ConfigurationProperties(prefix = "bean")</span></em>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> MyConfig {
|
||||
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">private</span> String message = <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"a message that can be changed live"</span>;
|
||||
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-comment">// getter and setters</span>
|
||||
|
||||
}</pre><p>A way to see that changes effectively happen is creating another bean that prints the message periodically.</p><pre class="programlisting"><em><span class="hl-annotation" style="color: gray">@Component</span></em>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> MyBean {
|
||||
|
||||
<em><span class="hl-annotation" style="color: gray">@Autowired</span></em>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">private</span> MyConfig config;
|
||||
|
||||
<em><span class="hl-annotation" style="color: gray">@Scheduled(fixedDelay = 5000)</span></em>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">void</span> hello() {
|
||||
System.out.println(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"The message is: "</span> + config.getMessage());
|
||||
}
|
||||
}</pre><p>The message printed by the application can be changed using a <code class="literal">ConfigMap</code> as follows:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">apiVersion</span>: v1
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">kind</span>: ConfigMap
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">metadata</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> name</span>: reload-example
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">data</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> application.properties</span>: |-
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> bean.message</span>=Hello World!</pre><p>Any change to the property named <code class="literal">bean.message</code> in the <code class="literal">ConfigMap</code> associated to the pod will be reflected in the
|
||||
output. More generally speaking, changes associated to properties prefixed with the value defined by the <code class="literal">prefix</code>
|
||||
field of the <code class="literal">@ConfigurationProperties</code> annotation will be detected and reflected in the application.
|
||||
[Associating a <code class="literal">ConfigMap</code> to a pod](#configmap-propertysource) is explained above.</p><p>The full example is available in [spring-cloud-kubernetes-reload-example](spring-cloud-kubernetes-examples/kubernetes-reload-example).</p><p>The reload feature supports two operating modes:
|
||||
- <span class="strong"><strong>event (default)</strong></span>: watches for changes in config maps or secrets using the Kubernetes API (web socket).
|
||||
Any event will produce a re-check on the configuration and a reload in case of changes.
|
||||
The <code class="literal">view</code> role on the service account is required in order to listen for config map changes. A higher level role (eg. <code class="literal">edit</code>) is required for secrets
|
||||
(secrets are not monitored by default).
|
||||
- <span class="strong"><strong>polling</strong></span>: re-creates the configuration periodically from config maps and secrets to see if it has changed.
|
||||
The polling period can be configured using the property <code class="literal">spring.cloud.kubernetes.reload.period</code> and defaults to <span class="strong"><strong>15 seconds</strong></span>.
|
||||
It requires the same role as the monitored property source.
|
||||
This means, for example, that using polling on file mounted secret sources does not require particular privileges.</p><div class="table"><a name="d0e34805" href="#d0e34805"></a><p class="title"><b>Table 136.1. Properties:</b></p><div class="table-contents"><table summary="Properties:" style="border-collapse: collapse;border-top: 0.5pt solid ; border-bottom: 0.5pt solid ; "><colgroup><col class="col_1"><col class="col_2"><col class="col_3"><col class="col_4"></colgroup><thead><tr><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">Name</th><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">Type</th><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">Default</th><th style="border-bottom: 0.5pt solid ; " align="left" valign="top">Description</th></tr></thead><tfoot><tr><th style="border-right: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.reload.period</p></th><th style="border-right: 0.5pt solid ; " align="left" valign="top"><p>Long</p></th><th style="border-right: 0.5pt solid ; " align="left" valign="top"><p>15000</p></th><th style="" align="left" valign="top"><p>The period in milliseconds for verifying changes when using the <span class="strong"><strong>polling</strong></span> strategy</p></th></tr></tfoot><tbody><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.reload.enabled</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Boolean</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>false</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Enables monitoring of property sources and configuration reload</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.reload.monitoring-config-maps</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Boolean</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>true</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Allow monitoring changes in config maps</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.reload.monitoring-secrets</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Boolean</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>false</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Allow monitoring changes in secrets</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.reload.strategy</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Enum</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>refresh</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>The strategy to use when firing a reload (<span class="strong"><strong>refresh</strong></span>, <span class="strong"><strong>restart_context</strong></span>, <span class="strong"><strong>shutdown</strong></span>)</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.reload.mode</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Enum</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>event</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Specifies how to listen for changes in property sources (<span class="strong"><strong>event</strong></span>, <span class="strong"><strong>polling</strong></span>)</p></td></tr></tbody></table></div></div><br class="table-break"><p><span class="strong"><strong>Notes</strong></span>:
|
||||
- Properties under <span class="strong"><strong>spring.cloud.kubernetes.reload.</strong></span> should not be used in config maps or secrets: changing such properties at runtime may lead to unexpected results;
|
||||
- Deleting a property or the whole config map does not restore the original state of the beans when using the <span class="strong"><strong>refresh</strong></span> level.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__secrets_propertysource.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="multi__kubernetes_propertysource_implementations.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="multi__ribbon_discovery_in_kubernetes.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">135. Secrets PropertySource </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> Part XX. Ribbon discovery in Kubernetes</td></tr></table></div></body></html>
|
||||
@@ -0,0 +1,21 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Part XX. Ribbon discovery in Kubernetes</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="prev" href="multi__propertysource_reload.html" title="136. PropertySource Reload"><link rel="next" href="multi__kubernetes_awareness.html" title="Part XXI. Kubernetes Awareness"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Part XX. Ribbon discovery in Kubernetes</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__propertysource_reload.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__kubernetes_awareness.html">Next</a></td></tr></table><hr></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a name="_ribbon_discovery_in_kubernetes" href="#_ribbon_discovery_in_kubernetes"></a>Part XX. Ribbon discovery in Kubernetes</h1></div></div></div><div class="partintro"><div></div><p>Spring Cloud client applications calling a microservice should be interested on relying on a client load-balancing
|
||||
feature in order to automatically discover at which endpoint(s) it can reach a given service. This mechanism has been
|
||||
implemented within the [spring-cloud-kubernetes-ribbon](spring-cloud-kubernetes-ribbon/pom.xml) project where a
|
||||
Kubernetes client will populate a <a class="link" href="https://github.com/Netflix/ribbon" target="_top">Ribbon</a> <code class="literal">ServerList</code> containing information
|
||||
about such endpoints.</p><p>The implementation is part of the following starter that you can use by adding its dependency to your pom file:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><dependency></span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><groupId></span>org.springframework.cloud<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></groupId></span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><artifactId></span>spring-cloud-starter-kubernetes-netflix<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></artifactId></span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><version></span>${latest.version}<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></version></span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></dependency></span></pre><p>When the list of the endpoints is populated, the Kubernetes client will search the registered endpoints living in
|
||||
the current namespace/project matching the service name defined using the Ribbon Client annotation:</p><pre class="programlisting">@RibbonClient(name = <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"name-service"</span>)</pre><p>You can configure Ribbon’s behavior by providing properties in your <code class="literal">application.properties</code> (via your application’s
|
||||
dedicated <code class="literal">ConfigMap</code>) using the following format: <code class="literal"><name of your service>.ribbon.<Ribbon configuration key></code> where:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><code class="literal"><name of your service></code> corresponds to the service name you’re accessing over Ribbon, as configured using the
|
||||
<code class="literal">@RibbonClient</code> annotation (e.g. <code class="literal">name-service</code> in the example above)</li><li class="listitem"><code class="literal"><Ribbon configuration key></code> is one of the Ribbon configuration key defined by
|
||||
<a class="link" href="https://github.com/Netflix/ribbon/blob/master/ribbon-core/src/main/java/com/netflix/client/config/CommonClientConfigKey.java" target="_top">Ribbon’s CommonClientConfigKey class</a></li></ul></div><p>Additionally, the <code class="literal">spring-cloud-kubernetes-ribbon</code> project defines two additional configuration keys to further
|
||||
control how Ribbon interacts with Kubernetes. In particular, if an endpoint defines multiple ports, the default
|
||||
behavior is to use the first one found. To select more specifically which port to use, in a multi-port service, use
|
||||
the <code class="literal">PortName</code> key. If you want to specify in which Kubernetes' namespace the target service should be looked up, use
|
||||
the <code class="literal">KubernetesNamespace</code> key, remembering in both instances to prefix these keys with your service name and
|
||||
<code class="literal">ribbon</code> prefix as specified above.</p><p>Examples that are using this module for ribbon discovery are:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><a class="link" href="./spring-cloud-kubernetes-examples/kubernetes-circuitbreaker-ribbon-example" target="_top">Spring Cloud Circuitbreaker and Ribbon</a></li><li class="listitem"><a class="link" href="https://github.com/fabric8-quickstarts/spring-boot-ribbon" target="_top">fabric8-quickstarts - Spring Boot - Ribbon</a></li><li class="listitem"><a class="link" href="https://github.com/fabric8io/kubeflix/tree/master/examples/loanbroker/bank" target="_top">Kubeflix - LoanBroker - Bank</a></li></ul></div><p><span class="strong"><strong>Note</strong></span>: The Ribbon discovery client can be disabled by setting this key within the application properties file
|
||||
<code class="literal">spring.cloud.kubernetes.ribbon.enabled=false</code>.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__propertysource_reload.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__kubernetes_awareness.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">136. PropertySource Reload </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> Part XXI. Kubernetes Awareness</td></tr></table></div></body></html>
|
||||
58
Greenwich.M3/multi/multi__secrets_propertysource.html
Normal file
58
Greenwich.M3/multi/multi__secrets_propertysource.html
Normal file
@@ -0,0 +1,58 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>135. Secrets PropertySource</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__kubernetes_propertysource_implementations.html" title="Part XIX. Kubernetes PropertySource implementations"><link rel="prev" href="multi__configmap_propertysource.html" title="134. ConfigMap PropertySource"><link rel="next" href="multi__propertysource_reload.html" title="136. PropertySource Reload"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">135. Secrets PropertySource</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__configmap_propertysource.html">Prev</a> </td><th width="60%" align="center">Part XIX. Kubernetes PropertySource implementations</th><td width="20%" align="right"> <a accesskey="n" href="multi__propertysource_reload.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_secrets_propertysource" href="#_secrets_propertysource"></a>135. Secrets PropertySource</h2></div></div></div><p>Kubernetes has the notion of [Secrets](<a class="link" href="https://kubernetes.io/docs/concepts/configuration/secret/" target="_top">https://kubernetes.io/docs/concepts/configuration/secret/</a>) for storing
|
||||
sensitive data such as password, OAuth tokens, etc. This project provides integration with <code class="literal">Secrets</code> to make secrets
|
||||
accessible by Spring Boot applications. This feature can be explicitly enabled/disabled using the <code class="literal">spring.cloud.kubernetes.secrets.enabled</code> property.</p><p>The <code class="literal">SecretsPropertySource</code> when enabled will lookup Kubernetes for <code class="literal">Secrets</code> from the following sources:
|
||||
1. reading recursively from secrets mounts
|
||||
2. named after the application (as defined by <code class="literal">spring.application.name</code>)
|
||||
3. matching some labels</p><p>Please note that by default, consuming Secrets via API (points 2 and 3 above) <span class="strong"><strong>is not enabled</strong></span> for security reasons
|
||||
and it is recommend that containers share secrets via mounted volumes.</p><p>If the secrets are found their data is made available to the application.</p><p><span class="strong"><strong>Example:</strong></span></p><p>Let’s assume that we have a spring boot application named <code class="literal">demo</code> that uses properties to read its database
|
||||
configuration. We can create a Kubernetes secret using the following command:</p><pre class="screen">oc create secret generic db-secret --from-literal=username=user --from-literal=password=p455w0rd</pre><p>This would create the following secret (shown using <code class="literal">oc get secrets db-secret -o yaml</code>):</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">apiVersion</span>: v1
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">data</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> password</span>: cDQ1NXcwcmQ=
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> username</span>: dXNlcg==
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">kind</span>: Secret
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">metadata</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> creationTimestamp</span>: <span class="hl-number">2017</span>-<span class="hl-number">07</span>-<span class="hl-number">04</span>T09:<span class="hl-number">15</span>:<span class="hl-number">57</span>Z
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> name</span>: db-secret
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> namespace</span>: default
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> resourceVersion</span>: <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"357496"</span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> selfLink</span>: /api/v1/namespaces/default/secrets/db-secret
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> uid</span>: <span class="hl-number">63</span>c89263-<span class="hl-number">6099</span>-<span class="hl-number">11e7</span>-b3da-<span class="hl-number">76d</span>6186905a8
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">type</span>: Opaque</pre><p>Note that the data contains Base64-encoded versions of the literal provided by the create command.</p><p>This secret can then be used by your application for example by exporting the secret’s value as environment variables:</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">apiVersion</span>: v1
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">kind</span>: Deployment
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">metadata</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> name</span>: ${project.artifactId<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">}</span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute">spec</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> template</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> spec</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> containers</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> - env</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> - name</span>: DB_USERNAME
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> valueFrom</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> secretKeyRef</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> name</span>: db-secret
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> key</span>: username
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> - name</span>: DB_PASSWORD
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> valueFrom</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> secretKeyRef</span>:
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> name</span>: db-secret
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-attribute"> key</span>: password</pre><p>You can select the Secrets to consume in a number of ways:</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p class="simpara">By listing the directories where secrets are mapped:
|
||||
<code class="literal">`
|
||||
-Dspring.cloud.kubernetes.secrets.paths=/etc/secrets/db-secret,etc/secrets/postgresql
|
||||
</code>`</p><pre class="literallayout">If you have all the secrets mapped to a common root, you can set them like:</pre><pre class="literallayout">```
|
||||
-Dspring.cloud.kubernetes.secrets.paths=/etc/secrets
|
||||
```</pre></li><li class="listitem">By setting a named secret:
|
||||
<code class="literal">`
|
||||
-Dspring.cloud.kubernetes.secrets.name=db-secret
|
||||
</code>`</li><li class="listitem">By defining a list of labels:
|
||||
<code class="literal">`
|
||||
-Dspring.cloud.kubernetes.secrets.labels.broker=activemq
|
||||
-Dspring.cloud.kubernetes.secrets.labels.db=postgresql
|
||||
</code>`</li></ol></div><div class="table"><a name="d0e34575" href="#d0e34575"></a><p class="title"><b>Table 135.1. Properties:</b></p><div class="table-contents"><table summary="Properties:" style="border-collapse: collapse;border-top: 0.5pt solid ; border-bottom: 0.5pt solid ; "><colgroup><col class="col_1"><col class="col_2"><col class="col_3"><col class="col_4"></colgroup><thead><tr><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">Name</th><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">Type</th><th style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top">Default</th><th style="border-bottom: 0.5pt solid ; " align="left" valign="top">Description</th></tr></thead><tfoot><tr><th style="border-right: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.secrets.enableApi</p></th><th style="border-right: 0.5pt solid ; " align="left" valign="top"><p>Boolean</p></th><th style="border-right: 0.5pt solid ; " align="left" valign="top"><p>false</p></th><th style="" align="left" valign="top"><p>Enable/Disable consuming secrets via APIs (examples 2 and 3)</p></th></tr></tfoot><tbody><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.secrets.enabled</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Boolean</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>true</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Enable Secrets PropertySource</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.secrets.name</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>String</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>${spring.application.name}</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Sets the name of the secret to lookup</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.secrets.namespace</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>String</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Client namespace</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Sets the Kubernetes namespace where to lookup</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.secrets.labels</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Map</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>null</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Sets the labels used to lookup secrets</p></td></tr><tr><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>spring.cloud.kubernetes.secrets.paths</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>List</p></td><td style="border-right: 0.5pt solid ; border-bottom: 0.5pt solid ; " align="left" valign="top"><p>null</p></td><td style="border-bottom: 0.5pt solid ; " align="left" valign="top"><p>Sets the paths where secrets are mounted (example 1)</p></td></tr></tbody></table></div></div><br class="table-break"><p><span class="strong"><strong>Notes:</strong></span>
|
||||
- The property <code class="literal">spring.cloud.kubernetes.secrets.labels</code> behaves as defined by
|
||||
<a class="link" href="https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Configuration-Binding#map-based-binding" target="_top">Map-based binding</a>.
|
||||
- The property <code class="literal">spring.cloud.kubernetes.secrets.paths</code> behaves as defined by
|
||||
<a class="link" href="https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Configuration-Binding#collection-based-binding" target="_top">Collection-based binding</a>.
|
||||
- Access to secrets via API may be restricted for security reasons, the preferred way is to mount secret to the POD.</p><p>Example of application using secrets (though it hasn’t been updated to use the new <code class="literal">spring-cloud-kubernetes</code> project):
|
||||
<a class="link" href="https://github.com/fabric8-quickstarts/spring-boot-camel-config" target="_top">spring-boot-camel-config</a></p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__configmap_propertysource.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="multi__kubernetes_propertysource_implementations.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="multi__propertysource_reload.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">134. ConfigMap PropertySource </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> 136. PropertySource Reload</td></tr></table></div></body></html>
|
||||
@@ -0,0 +1,3 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Part XXIV. Security Configurations inside Kubernetes</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="prev" href="multi__leader_election.html" title="Part XXIII. Leader Election"><link rel="next" href="multi__namespace.html" title="138. Namespace"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Part XXIV. Security Configurations inside Kubernetes</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__leader_election.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__namespace.html">Next</a></td></tr></table><hr></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a name="_security_configurations_inside_kubernetes" href="#_security_configurations_inside_kubernetes"></a>Part XXIV. Security Configurations inside Kubernetes</h1></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__leader_election.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__namespace.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part XXIII. Leader Election </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> 138. Namespace</td></tr></table></div></body></html>
|
||||
@@ -1,6 +1,6 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>132. Serverless Platform Adapters</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_function_2.html" title="Part XVI. Spring Cloud Function"><link rel="prev" href="multi__dynamic_compilation.html" title="131. Dynamic Compilation"><link rel="next" href="multi__appendix_compendium_of_configuration_properties.html" title="Part XVII. Appendix: Compendium of Configuration Properties"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">132. Serverless Platform Adapters</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__dynamic_compilation.html">Prev</a> </td><th width="60%" align="center">Part XVI. Spring Cloud Function</th><td width="20%" align="right"> <a accesskey="n" href="multi__appendix_compendium_of_configuration_properties.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_serverless_platform_adapters" href="#_serverless_platform_adapters"></a>132. Serverless Platform Adapters</h2></div></div></div><p>As well as being able to run as a standalone process, a Spring Cloud
|
||||
<title>132. Serverless Platform Adapters</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_function_2.html" title="Part XVI. Spring Cloud Function"><link rel="prev" href="multi__dynamic_compilation.html" title="131. Dynamic Compilation"><link rel="next" href="multi__spring_cloud_kubernetes.html" title="Part XVII. Spring Cloud Kubernetes"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">132. Serverless Platform Adapters</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__dynamic_compilation.html">Prev</a> </td><th width="60%" align="center">Part XVI. Spring Cloud Function</th><td width="20%" align="right"> <a accesskey="n" href="multi__spring_cloud_kubernetes.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_serverless_platform_adapters" href="#_serverless_platform_adapters"></a>132. Serverless Platform Adapters</h2></div></div></div><p>As well as being able to run as a standalone process, a Spring Cloud
|
||||
Function application can be adapted to run one of the existing
|
||||
serverless platforms. In the project there are adapters for
|
||||
<a class="link" href="https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-adapters/spring-cloud-function-adapter-aws" target="_top">AWS
|
||||
@@ -46,4 +46,4 @@ ENTRYPOINT [ "java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "runner.
|
||||
EXPOSE 8080</pre><div class="blockquote"><blockquote class="blockquote"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>you could use a Spring Cloud Function app, instead of just a jar with a POF in it, in which case you would have to change the way the app runs in the container so that it picks up the main class as a source file. For example, you could change the <code class="literal">ENTRYPOINT</code> above and add <code class="literal">--spring.main.sources=com.example.SampleApplication</code>.</p></td></tr></table></div></blockquote></div><p>Build the Docker image:</p><pre class="screen">docker build -t [username/appname] .</pre><p>Push the Docker image:</p><pre class="screen">docker push [username/appname]</pre><p>Use the OpenWhisk CLI (e.g. after <code class="literal">vagrant ssh</code>) to create the action:</p><pre class="screen">wsk action create example --docker [username/appname]</pre><p>Invoke the action:</p><pre class="screen">wsk action invoke example --result --param payload foo
|
||||
{
|
||||
"result": "FOO"
|
||||
}</pre></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__dynamic_compilation.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_function_2.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="multi__appendix_compendium_of_configuration_properties.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">131. Dynamic Compilation </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> Part XVII. Appendix: Compendium of Configuration Properties</td></tr></table></div></body></html>
|
||||
}</pre></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__dynamic_compilation.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_function_2.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="multi__spring_cloud_kubernetes.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">131. Dynamic Compilation </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> Part XVII. Spring Cloud Kubernetes</td></tr></table></div></body></html>
|
||||
4
Greenwich.M3/multi/multi__service_account.html
Normal file
4
Greenwich.M3/multi/multi__service_account.html
Normal file
@@ -0,0 +1,4 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>139. Service Account</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__security_configurations_inside_kubernetes.html" title="Part XXIV. Security Configurations inside Kubernetes"><link rel="prev" href="multi__namespace.html" title="138. Namespace"><link rel="next" href="multi__examples_2.html" title="Part XXV. Examples"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">139. Service Account</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__namespace.html">Prev</a> </td><th width="60%" align="center">Part XXIV. Security Configurations inside Kubernetes</th><td width="20%" align="right"> <a accesskey="n" href="multi__examples_2.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_service_account" href="#_service_account"></a>139. Service Account</h2></div></div></div><p>For distros of Kubernetes that support more fine-grained role-based access within the cluster, you need to make sure a pod that runs with spring-cloud-kubernetes has access to the Kubernetes API.
|
||||
For any service accounts you assign to a deployment/pod, you need to make sure it has the correct roles. For example, you can add <code class="literal">cluster-reader</code> permissions to your <code class="literal">default</code> service account depending on the project you’re in:</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__namespace.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="multi__security_configurations_inside_kubernetes.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="multi__examples_2.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">138. Namespace </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> Part XXV. Examples</td></tr></table></div></body></html>
|
||||
3
Greenwich.M3/multi/multi__spring_cloud_kubernetes.html
Normal file
3
Greenwich.M3/multi/multi__spring_cloud_kubernetes.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>Part XVII. Spring Cloud Kubernetes</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="prev" href="multi__serverless_platform_adapters.html" title="132. Serverless Platform Adapters"><link rel="next" href="multi__why_do_you_need_spring_cloud_kubernetes.html" title="133. Why do you need Spring Cloud Kubernetes?"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Part XVII. Spring Cloud Kubernetes</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__serverless_platform_adapters.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="multi__why_do_you_need_spring_cloud_kubernetes.html">Next</a></td></tr></table><hr></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a name="_spring_cloud_kubernetes" href="#_spring_cloud_kubernetes"></a>Part XVII. Spring Cloud Kubernetes</h1></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__serverless_platform_adapters.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__why_do_you_need_spring_cloud_kubernetes.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">132. Serverless Platform Adapters </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> 133. Why do you need Spring Cloud Kubernetes?</td></tr></table></div></body></html>
|
||||
@@ -0,0 +1,4 @@
|
||||
<html><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>133. Why do you need Spring Cloud Kubernetes?</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_kubernetes.html" title="Part XVII. Spring Cloud Kubernetes"><link rel="prev" href="multi__spring_cloud_kubernetes.html" title="Part XVII. Spring Cloud Kubernetes"><link rel="next" href="multi__discoveryclient_for_kubernetes.html" title="Part XVIII. DiscoveryClient for Kubernetes"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">133. Why do you need Spring Cloud Kubernetes?</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__spring_cloud_kubernetes.html">Prev</a> </td><th width="60%" align="center">Part XVII. Spring Cloud Kubernetes</th><td width="20%" align="right"> <a accesskey="n" href="multi__discoveryclient_for_kubernetes.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_why_do_you_need_spring_cloud_kubernetes" href="#_why_do_you_need_spring_cloud_kubernetes"></a>133. Why do you need Spring Cloud Kubernetes?</h2></div></div></div><p>Spring Cloud Kubernetes provide Spring Cloud common interfaces implementations to consume Kubernetes native services.
|
||||
The main objective of the projects provided in this repository is to facilitate the integration of Spring Cloud/Spring Boot applications running inside Kubernetes.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__spring_cloud_kubernetes.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_kubernetes.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="multi__discoveryclient_for_kubernetes.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part XVII. Spring Cloud Kubernetes </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> Part XVIII. DiscoveryClient for Kubernetes</td></tr></table></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -27341,6 +27341,789 @@ EXPOSE 8080</screen>
|
||||
</section>
|
||||
</chapter>
|
||||
</part>
|
||||
<part xml:id="_spring_cloud_kubernetes">
|
||||
<title>Spring Cloud Kubernetes</title>
|
||||
<chapter xml:id="_why_do_you_need_spring_cloud_kubernetes">
|
||||
<title>Why do you need Spring Cloud Kubernetes?</title>
|
||||
<simpara>Spring Cloud Kubernetes provide Spring Cloud common interfaces implementations to consume Kubernetes native services.
|
||||
The main objective of the projects provided in this repository is to facilitate the integration of Spring Cloud/Spring Boot applications running inside Kubernetes.</simpara>
|
||||
</chapter>
|
||||
</part>
|
||||
<part xml:id="_discoveryclient_for_kubernetes">
|
||||
<title>DiscoveryClient for Kubernetes</title>
|
||||
<partintro>
|
||||
<simpara>This project provides an implementation of <link xl:href="https://github.com/spring-cloud/spring-cloud-commons/blob/master/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/DiscoveryClient.java">Discovery Client</link>
|
||||
for <link xl:href="http://kubernetes.io">Kubernetes</link>.
|
||||
This allows you to query Kubernetes endpoints <emphasis role="strong">(see <link xl:href="http://kubernetes.io/docs/user-guide/services/">services</link>)</emphasis> by name.
|
||||
A service is typically exposed by the Kubernetes API server as a collection of endpoints which represent <literal>http</literal>, <literal>https</literal> addresses that a client can
|
||||
access from a Spring Boot application running as a pod. This discovery feature is also used by the Spring Cloud Kubernetes Ribbon project
|
||||
to fetch the list of the endpoints defined for an application to be load balanced.</simpara>
|
||||
<simpara>This is something that you get for free just by adding the following dependency inside your project:</simpara>
|
||||
<programlisting language="xml" linenumbering="unnumbered"><dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-kubernetes</artifactId>
|
||||
<version>${latest.version}</version>
|
||||
</dependency></programlisting>
|
||||
<simpara>To enable loading of the <literal>DiscoveryClient</literal>, add <literal>@EnableDiscoveryClient</literal> to the according configuration or application class like this:</simpara>
|
||||
<programlisting language="java" linenumbering="unnumbered">@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
}</programlisting>
|
||||
<simpara>Then you can inject the client in your code simply by:</simpara>
|
||||
<programlisting language="java" linenumbering="unnumbered">@Autowired
|
||||
private DiscoveryClient discoveryClient;</programlisting>
|
||||
<simpara>If for any reason you need to disable the <literal>DiscoveryClient</literal> you can simply set the following property in <literal>application.properties</literal>:</simpara>
|
||||
<screen>spring.cloud.kubernetes.discovery.enabled=false</screen>
|
||||
<simpara>Some Spring Cloud components use the <literal>DiscoveryClient</literal> in order to obtain info about the local service instance. For
|
||||
this to work you need to align the Kubernetes service name with the <literal>spring.application.name</literal> property.</simpara>
|
||||
</partintro>
|
||||
</part>
|
||||
<part xml:id="_kubernetes_propertysource_implementations">
|
||||
<title>Kubernetes PropertySource implementations</title>
|
||||
<partintro>
|
||||
<simpara>The most common approach to configure your Spring Boot application is to create an <literal>application.properties|yaml</literal> or
|
||||
an <literal>application-profile.properties|yaml</literal> file containing key-value pairs providing customization values to your
|
||||
application or Spring Boot starters. Users may override these properties by specifying system properties or environment
|
||||
variables.</simpara>
|
||||
</partintro>
|
||||
<chapter xml:id="_configmap_propertysource">
|
||||
<title>ConfigMap PropertySource</title>
|
||||
<simpara>Kubernetes provides a resource named <link xl:href="http://kubernetes.io/docs/user-guide/configmap/">ConfigMap</link> to externalize the
|
||||
parameters to pass to your application in the form of key-value pairs or embedded <literal>application.properties|yaml</literal> files.
|
||||
The <link xl:href="./spring-cloud-kubernetes-config">Spring Cloud Kubernetes Config</link> project makes Kubernetes `ConfigMap`s available
|
||||
during application bootstrapping and triggers hot reloading of beans or Spring context when changes are detected on
|
||||
observed `ConfigMap`s.</simpara>
|
||||
<simpara>The default behavior is to create a <literal>ConfigMapPropertySource</literal> based on a Kubernetes <literal>ConfigMap</literal> which has <literal>metadata.name</literal> of either the name of
|
||||
your Spring application (as defined by its <literal>spring.application.name</literal> property) or a custom name defined within the
|
||||
<literal>bootstrap.properties</literal> file under the following key <literal>spring.cloud.kubernetes.config.name</literal>.</simpara>
|
||||
<simpara>However, more advanced configuration are possible where multiple ConfigMaps can be used
|
||||
This is made possible by the <literal>spring.cloud.kubernetes.config.sources</literal> list.
|
||||
For example one could define the following ConfigMaps</simpara>
|
||||
<programlisting language="yaml" linenumbering="unnumbered">spring:
|
||||
application:
|
||||
name: cloud-k8s-app
|
||||
cloud:
|
||||
kubernetes:
|
||||
config:
|
||||
name: default-name
|
||||
namespace: default-namespace
|
||||
sources:
|
||||
# Spring Cloud Kubernetes will lookup a ConfigMap named c1 in namespace default-namespace
|
||||
- name: c1
|
||||
# Spring Cloud Kubernetes will lookup a ConfigMap named default-name in whatever namespace n2
|
||||
- namespace: n2
|
||||
# Spring Cloud Kubernetes will lookup a ConfigMap named c3 in namespace n3
|
||||
- namespace: n3
|
||||
name: c3</programlisting>
|
||||
<simpara>In the example above, it <literal>spring.cloud.kubernetes.config.namespace</literal> had not been set,
|
||||
then the ConfigMap named <literal>c1</literal> would be looked up in the namespace that the application runs</simpara>
|
||||
<simpara>Any matching <literal>ConfigMap</literal> that is found, will be processed as follows:</simpara>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>apply individual configuration properties.</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>apply as <literal>yaml</literal> the content of any property named <literal>application.yaml</literal></simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>apply as properties file the content of any property named <literal>application.properties</literal></simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<simpara>The single exception to the aforementioned flow is when the <literal>ConfigMap</literal> contains a <emphasis role="strong">single</emphasis> key that indicates
|
||||
the file is a YAML or Properties file. In that case the name of the key does NOT have to be <literal>application.yaml</literal> or
|
||||
<literal>application.properties</literal> (it can be anything) and the value of the property will be treated correctly.
|
||||
This features facilitates the use case where the <literal>ConfigMap</literal> was created using something like:</simpara>
|
||||
<simpara><literal>kubectl create configmap game-config --from-file=/path/to/app-config.yaml</literal></simpara>
|
||||
<simpara>Example:</simpara>
|
||||
<simpara>Let’s assume that we have a Spring Boot application named <literal>demo</literal> that uses properties to read its thread pool
|
||||
configuration.</simpara>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara><literal>pool.size.core</literal></simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara><literal>pool.size.maximum</literal></simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<simpara>This can be externalized to config map in <literal>yaml</literal> format:</simpara>
|
||||
<programlisting language="yaml" linenumbering="unnumbered">kind: ConfigMap
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: demo
|
||||
data:
|
||||
pool.size.core: 1
|
||||
pool.size.max: 16</programlisting>
|
||||
<simpara>Individual properties work fine for most cases but sometimes embedded <literal>yaml</literal> is more convenient. In this case we will
|
||||
use a single property named <literal>application.yaml</literal> to embed our <literal>yaml</literal>:</simpara>
|
||||
<literallayout class="monospaced"> ```yaml
|
||||
kind: ConfigMap
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: demo
|
||||
data:
|
||||
application.yaml: |-
|
||||
pool:
|
||||
size:
|
||||
core: 1
|
||||
max:16</literallayout>
|
||||
<screen>The following also works:
|
||||
|
||||
```yaml
|
||||
kind: ConfigMap
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: demo
|
||||
data:
|
||||
custom-name.yaml: |-
|
||||
pool:
|
||||
size:
|
||||
core: 1
|
||||
max:16</screen>
|
||||
<simpara>Spring Boot applications can also be configured differently depending on active profiles which will be merged together
|
||||
when the ConfigMap is read. It is possible to provide different property values for different profiles using an
|
||||
<literal>application.properties|yaml</literal> property, specifying profile-specific values each in their own document
|
||||
(indicated by the <literal>---</literal> sequence) as follows:</simpara>
|
||||
<programlisting language="yaml" linenumbering="unnumbered">kind: ConfigMap
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: demo
|
||||
data:
|
||||
application.yml: |-
|
||||
greeting:
|
||||
message: Say Hello to the World
|
||||
farewell:
|
||||
message: Say Goodbye
|
||||
---
|
||||
spring:
|
||||
profiles: development
|
||||
greeting:
|
||||
message: Say Hello to the Developers
|
||||
farewell:
|
||||
message: Say Goodbye to the Developers
|
||||
---
|
||||
spring:
|
||||
profiles: production
|
||||
greeting:
|
||||
message: Say Hello to the Ops</programlisting>
|
||||
<simpara>In the above case, the configuration loaded into your Spring Application with the <literal>development</literal> profile will be:</simpara>
|
||||
<programlisting language="yaml" linenumbering="unnumbered"> greeting:
|
||||
message: Say Hello to the Developers
|
||||
farewell:
|
||||
message: Say Goodbye to the Developers</programlisting>
|
||||
<simpara>whereas if the <literal>production</literal> profile is active, the configuration will be:</simpara>
|
||||
<programlisting language="yaml" linenumbering="unnumbered"> greeting:
|
||||
message: Say Hello to the Ops
|
||||
farewell:
|
||||
message: Say Goodbye</programlisting>
|
||||
<simpara>If both profiles are active, the property which appears last within the configmap will overwrite preceding values.</simpara>
|
||||
<simpara>To tell to Spring Boot which <literal>profile</literal> should be enabled at bootstrap, a system property can be passed to the Java
|
||||
command launching your Spring Boot application using an env variable that you will define with the OpenShift
|
||||
<literal>DeploymentConfig</literal> or Kubernetes <literal>ReplicationConfig</literal> resource file as follows:</simpara>
|
||||
<programlisting language="yaml" linenumbering="unnumbered">apiVersion: v1
|
||||
kind: DeploymentConfig
|
||||
spec:
|
||||
replicas: 1
|
||||
...
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
- name: JAVA_APP_DIR
|
||||
value: /deployments
|
||||
- name: JAVA_OPTIONS
|
||||
value: -Dspring.profiles.active=developer</programlisting>
|
||||
<simpara><emphasis role="strong">Notes:</emphasis>
|
||||
- check the security configuration section, to access config maps from inside a pod you need to have the correct
|
||||
Kubernetes service accounts, roles and role bindings.</simpara>
|
||||
<table frame="topbot" rowsep="1" colsep="1">
|
||||
<title>Properties:</title>
|
||||
<tgroup cols="4">
|
||||
<colspec colname="col_1" colwidth="25*"/>
|
||||
<colspec colname="col_2" colwidth="25*"/>
|
||||
<colspec colname="col_3" colwidth="25*"/>
|
||||
<colspec colname="col_4" colwidth="25*"/>
|
||||
<thead>
|
||||
<row>
|
||||
<entry align="left" valign="top">Name</entry>
|
||||
<entry align="left" valign="top">Type</entry>
|
||||
<entry align="left" valign="top">Default</entry>
|
||||
<entry align="left" valign="top">Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.config.enableApi</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Boolean</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>true</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Enable/Disable consuming ConfigMaps via APIs</simpara></entry>
|
||||
</row>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.config.enabled</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Boolean</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>true</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Enable Secrets PropertySource</simpara></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.config.name</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>String</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>${spring.application.name}</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Sets the name of ConfigMap to lookup</simpara></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.config.namespace</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>String</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Client namespace</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Sets the Kubernetes namespace where to lookup</simpara></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.config.paths</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>List</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>null</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Sets the paths where ConfigMaps are mounted</simpara></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</chapter>
|
||||
<chapter xml:id="_secrets_propertysource">
|
||||
<title>Secrets PropertySource</title>
|
||||
<simpara>Kubernetes has the notion of [Secrets](<link xl:href="https://kubernetes.io/docs/concepts/configuration/secret/">https://kubernetes.io/docs/concepts/configuration/secret/</link>) for storing
|
||||
sensitive data such as password, OAuth tokens, etc. This project provides integration with <literal>Secrets</literal> to make secrets
|
||||
accessible by Spring Boot applications. This feature can be explicitly enabled/disabled using the <literal>spring.cloud.kubernetes.secrets.enabled</literal> property.</simpara>
|
||||
<simpara>The <literal>SecretsPropertySource</literal> when enabled will lookup Kubernetes for <literal>Secrets</literal> from the following sources:
|
||||
1. reading recursively from secrets mounts
|
||||
2. named after the application (as defined by <literal>spring.application.name</literal>)
|
||||
3. matching some labels</simpara>
|
||||
<simpara>Please note that by default, consuming Secrets via API (points 2 and 3 above) <emphasis role="strong">is not enabled</emphasis> for security reasons
|
||||
and it is recommend that containers share secrets via mounted volumes.</simpara>
|
||||
<simpara>If the secrets are found their data is made available to the application.</simpara>
|
||||
<simpara><emphasis role="strong">Example:</emphasis></simpara>
|
||||
<simpara>Let’s assume that we have a spring boot application named <literal>demo</literal> that uses properties to read its database
|
||||
configuration. We can create a Kubernetes secret using the following command:</simpara>
|
||||
<screen>oc create secret generic db-secret --from-literal=username=user --from-literal=password=p455w0rd</screen>
|
||||
<simpara>This would create the following secret (shown using <literal>oc get secrets db-secret -o yaml</literal>):</simpara>
|
||||
<programlisting language="yaml" linenumbering="unnumbered">apiVersion: v1
|
||||
data:
|
||||
password: cDQ1NXcwcmQ=
|
||||
username: dXNlcg==
|
||||
kind: Secret
|
||||
metadata:
|
||||
creationTimestamp: 2017-07-04T09:15:57Z
|
||||
name: db-secret
|
||||
namespace: default
|
||||
resourceVersion: "357496"
|
||||
selfLink: /api/v1/namespaces/default/secrets/db-secret
|
||||
uid: 63c89263-6099-11e7-b3da-76d6186905a8
|
||||
type: Opaque</programlisting>
|
||||
<simpara>Note that the data contains Base64-encoded versions of the literal provided by the create command.</simpara>
|
||||
<simpara>This secret can then be used by your application for example by exporting the secret’s value as environment variables:</simpara>
|
||||
<programlisting language="yaml" linenumbering="unnumbered">apiVersion: v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: ${project.artifactId}
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
- name: DB_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-secret
|
||||
key: username
|
||||
- name: DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-secret
|
||||
key: password</programlisting>
|
||||
<simpara>You can select the Secrets to consume in a number of ways:</simpara>
|
||||
<orderedlist numeration="arabic">
|
||||
<listitem>
|
||||
<simpara>By listing the directories where secrets are mapped:
|
||||
<literal>`
|
||||
-Dspring.cloud.kubernetes.secrets.paths=/etc/secrets/db-secret,etc/secrets/postgresql
|
||||
</literal>`</simpara>
|
||||
<literallayout class="monospaced">If you have all the secrets mapped to a common root, you can set them like:</literallayout>
|
||||
<literallayout class="monospaced">```
|
||||
-Dspring.cloud.kubernetes.secrets.paths=/etc/secrets
|
||||
```</literallayout>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>By setting a named secret:
|
||||
<literal>`
|
||||
-Dspring.cloud.kubernetes.secrets.name=db-secret
|
||||
</literal>`</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>By defining a list of labels:
|
||||
<literal>`
|
||||
-Dspring.cloud.kubernetes.secrets.labels.broker=activemq
|
||||
-Dspring.cloud.kubernetes.secrets.labels.db=postgresql
|
||||
</literal>`</simpara>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
<table frame="topbot" rowsep="1" colsep="1">
|
||||
<title>Properties:</title>
|
||||
<tgroup cols="4">
|
||||
<colspec colname="col_1" colwidth="25*"/>
|
||||
<colspec colname="col_2" colwidth="25*"/>
|
||||
<colspec colname="col_3" colwidth="25*"/>
|
||||
<colspec colname="col_4" colwidth="25*"/>
|
||||
<thead>
|
||||
<row>
|
||||
<entry align="left" valign="top">Name</entry>
|
||||
<entry align="left" valign="top">Type</entry>
|
||||
<entry align="left" valign="top">Default</entry>
|
||||
<entry align="left" valign="top">Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.secrets.enableApi</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Boolean</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>false</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Enable/Disable consuming secrets via APIs (examples 2 and 3)</simpara></entry>
|
||||
</row>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.secrets.enabled</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Boolean</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>true</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Enable Secrets PropertySource</simpara></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.secrets.name</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>String</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>${spring.application.name}</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Sets the name of the secret to lookup</simpara></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.secrets.namespace</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>String</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Client namespace</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Sets the Kubernetes namespace where to lookup</simpara></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.secrets.labels</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Map</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>null</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Sets the labels used to lookup secrets</simpara></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.secrets.paths</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>List</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>null</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Sets the paths where secrets are mounted (example 1)</simpara></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
<simpara><emphasis role="strong">Notes:</emphasis>
|
||||
- The property <literal>spring.cloud.kubernetes.secrets.labels</literal> behaves as defined by
|
||||
<link xl:href="https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Configuration-Binding#map-based-binding">Map-based binding</link>.
|
||||
- The property <literal>spring.cloud.kubernetes.secrets.paths</literal> behaves as defined by
|
||||
<link xl:href="https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Configuration-Binding#collection-based-binding">Collection-based binding</link>.
|
||||
- Access to secrets via API may be restricted for security reasons, the preferred way is to mount secret to the POD.</simpara>
|
||||
<simpara>Example of application using secrets (though it hasn’t been updated to use the new <literal>spring-cloud-kubernetes</literal> project):
|
||||
<link xl:href="https://github.com/fabric8-quickstarts/spring-boot-camel-config">spring-boot-camel-config</link></simpara>
|
||||
</chapter>
|
||||
<chapter xml:id="_propertysource_reload">
|
||||
<title>PropertySource Reload</title>
|
||||
<simpara>Some applications may need to detect changes on external property sources and update their internal status to reflect the new configuration.
|
||||
The reload feature of Spring Cloud Kubernetes is able to trigger an application reload when a related <literal>ConfigMap</literal> or
|
||||
<literal>Secret</literal> changes.</simpara>
|
||||
<simpara>This feature is disabled by default and can be enabled using the configuration property <literal>spring.cloud.kubernetes.reload.enabled=true</literal>
|
||||
(eg. in the <emphasis role="strong">application.properties</emphasis> file).</simpara>
|
||||
<simpara>The following levels of reload are supported (property <literal>spring.cloud.kubernetes.reload.strategy</literal>):
|
||||
- <emphasis role="strong"><literal>refresh</literal> (default)</emphasis>: only configuration beans annotated with <literal>@ConfigurationProperties</literal> or <literal>@RefreshScope</literal> are reloaded.
|
||||
This reload level leverages the refresh feature of Spring Cloud Context.
|
||||
- <emphasis role="strong"><literal>restart_context</literal></emphasis>: the whole Spring <emphasis>ApplicationContext</emphasis> is gracefully restarted. Beans are recreated with the new configuration.
|
||||
- <emphasis role="strong"><literal>shutdown</literal></emphasis>: the Spring <emphasis>ApplicationContext</emphasis> is shut down to activate a restart of the container.
|
||||
When using this level, make sure that the lifecycle of all non-daemon threads is bound to the ApplicationContext
|
||||
and that a replication controller or replica set is configured to restart the pod.</simpara>
|
||||
<simpara>Example:</simpara>
|
||||
<simpara>Assuming that the reload feature is enabled with default settings (<emphasis role="strong"><literal>refresh</literal></emphasis> mode), the following bean will be refreshed when the config map changes:</simpara>
|
||||
<programlisting language="java" linenumbering="unnumbered">@Configuration
|
||||
@ConfigurationProperties(prefix = "bean")
|
||||
public class MyConfig {
|
||||
|
||||
private String message = "a message that can be changed live";
|
||||
|
||||
// getter and setters
|
||||
|
||||
}</programlisting>
|
||||
<simpara>A way to see that changes effectively happen is creating another bean that prints the message periodically.</simpara>
|
||||
<programlisting language="java" linenumbering="unnumbered">@Component
|
||||
public class MyBean {
|
||||
|
||||
@Autowired
|
||||
private MyConfig config;
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
public void hello() {
|
||||
System.out.println("The message is: " + config.getMessage());
|
||||
}
|
||||
}</programlisting>
|
||||
<simpara>The message printed by the application can be changed using a <literal>ConfigMap</literal> as follows:</simpara>
|
||||
<programlisting language="yaml" linenumbering="unnumbered">apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: reload-example
|
||||
data:
|
||||
application.properties: |-
|
||||
bean.message=Hello World!</programlisting>
|
||||
<simpara>Any change to the property named <literal>bean.message</literal> in the <literal>ConfigMap</literal> associated to the pod will be reflected in the
|
||||
output. More generally speaking, changes associated to properties prefixed with the value defined by the <literal>prefix</literal>
|
||||
field of the <literal>@ConfigurationProperties</literal> annotation will be detected and reflected in the application.
|
||||
[Associating a <literal>ConfigMap</literal> to a pod](#configmap-propertysource) is explained above.</simpara>
|
||||
<simpara>The full example is available in [spring-cloud-kubernetes-reload-example](spring-cloud-kubernetes-examples/kubernetes-reload-example).</simpara>
|
||||
<simpara>The reload feature supports two operating modes:
|
||||
- <emphasis role="strong">event (default)</emphasis>: watches for changes in config maps or secrets using the Kubernetes API (web socket).
|
||||
Any event will produce a re-check on the configuration and a reload in case of changes.
|
||||
The <literal>view</literal> role on the service account is required in order to listen for config map changes. A higher level role (eg. <literal>edit</literal>) is required for secrets
|
||||
(secrets are not monitored by default).
|
||||
- <emphasis role="strong">polling</emphasis>: re-creates the configuration periodically from config maps and secrets to see if it has changed.
|
||||
The polling period can be configured using the property <literal>spring.cloud.kubernetes.reload.period</literal> and defaults to <emphasis role="strong">15 seconds</emphasis>.
|
||||
It requires the same role as the monitored property source.
|
||||
This means, for example, that using polling on file mounted secret sources does not require particular privileges.</simpara>
|
||||
<table frame="topbot" rowsep="1" colsep="1">
|
||||
<title>Properties:</title>
|
||||
<tgroup cols="4">
|
||||
<colspec colname="col_1" colwidth="25*"/>
|
||||
<colspec colname="col_2" colwidth="25*"/>
|
||||
<colspec colname="col_3" colwidth="25*"/>
|
||||
<colspec colname="col_4" colwidth="25*"/>
|
||||
<thead>
|
||||
<row>
|
||||
<entry align="left" valign="top">Name</entry>
|
||||
<entry align="left" valign="top">Type</entry>
|
||||
<entry align="left" valign="top">Default</entry>
|
||||
<entry align="left" valign="top">Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.reload.period</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Long</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>15000</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>The period in milliseconds for verifying changes when using the <emphasis role="strong">polling</emphasis> strategy</simpara></entry>
|
||||
</row>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.reload.enabled</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Boolean</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>false</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Enables monitoring of property sources and configuration reload</simpara></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.reload.monitoring-config-maps</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Boolean</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>true</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Allow monitoring changes in config maps</simpara></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.reload.monitoring-secrets</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Boolean</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>false</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Allow monitoring changes in secrets</simpara></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.reload.strategy</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Enum</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>refresh</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>The strategy to use when firing a reload (<emphasis role="strong">refresh</emphasis>, <emphasis role="strong">restart_context</emphasis>, <emphasis role="strong">shutdown</emphasis>)</simpara></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry align="left" valign="top"><simpara>spring.cloud.kubernetes.reload.mode</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Enum</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>event</simpara></entry>
|
||||
<entry align="left" valign="top"><simpara>Specifies how to listen for changes in property sources (<emphasis role="strong">event</emphasis>, <emphasis role="strong">polling</emphasis>)</simpara></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
<simpara><emphasis role="strong">Notes</emphasis>:
|
||||
- Properties under <emphasis role="strong">spring.cloud.kubernetes.reload.</emphasis> should not be used in config maps or secrets: changing such properties at runtime may lead to unexpected results;
|
||||
- Deleting a property or the whole config map does not restore the original state of the beans when using the <emphasis role="strong">refresh</emphasis> level.</simpara>
|
||||
</chapter>
|
||||
</part>
|
||||
<part xml:id="_ribbon_discovery_in_kubernetes">
|
||||
<title>Ribbon discovery in Kubernetes</title>
|
||||
<partintro>
|
||||
<simpara>Spring Cloud client applications calling a microservice should be interested on relying on a client load-balancing
|
||||
feature in order to automatically discover at which endpoint(s) it can reach a given service. This mechanism has been
|
||||
implemented within the [spring-cloud-kubernetes-ribbon](spring-cloud-kubernetes-ribbon/pom.xml) project where a
|
||||
Kubernetes client will populate a <link xl:href="https://github.com/Netflix/ribbon">Ribbon</link> <literal>ServerList</literal> containing information
|
||||
about such endpoints.</simpara>
|
||||
<simpara>The implementation is part of the following starter that you can use by adding its dependency to your pom file:</simpara>
|
||||
<programlisting language="xml" linenumbering="unnumbered"><dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-kubernetes-netflix</artifactId>
|
||||
<version>${latest.version}</version>
|
||||
</dependency></programlisting>
|
||||
<simpara>When the list of the endpoints is populated, the Kubernetes client will search the registered endpoints living in
|
||||
the current namespace/project matching the service name defined using the Ribbon Client annotation:</simpara>
|
||||
<programlisting language="java" linenumbering="unnumbered">@RibbonClient(name = "name-service")</programlisting>
|
||||
<simpara>You can configure Ribbon’s behavior by providing properties in your <literal>application.properties</literal> (via your application’s
|
||||
dedicated <literal>ConfigMap</literal>) using the following format: <literal><name of your service>.ribbon.<Ribbon configuration key></literal> where:</simpara>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara><literal><name of your service></literal> corresponds to the service name you’re accessing over Ribbon, as configured using the
|
||||
<literal>@RibbonClient</literal> annotation (e.g. <literal>name-service</literal> in the example above)</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara><literal><Ribbon configuration key></literal> is one of the Ribbon configuration key defined by
|
||||
<link xl:href="https://github.com/Netflix/ribbon/blob/master/ribbon-core/src/main/java/com/netflix/client/config/CommonClientConfigKey.java">Ribbon’s CommonClientConfigKey class</link></simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<simpara>Additionally, the <literal>spring-cloud-kubernetes-ribbon</literal> project defines two additional configuration keys to further
|
||||
control how Ribbon interacts with Kubernetes. In particular, if an endpoint defines multiple ports, the default
|
||||
behavior is to use the first one found. To select more specifically which port to use, in a multi-port service, use
|
||||
the <literal>PortName</literal> key. If you want to specify in which Kubernetes' namespace the target service should be looked up, use
|
||||
the <literal>KubernetesNamespace</literal> key, remembering in both instances to prefix these keys with your service name and
|
||||
<literal>ribbon</literal> prefix as specified above.</simpara>
|
||||
<simpara>Examples that are using this module for ribbon discovery are:</simpara>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara><link xl:href="./spring-cloud-kubernetes-examples/kubernetes-circuitbreaker-ribbon-example">Spring Cloud Circuitbreaker and Ribbon</link></simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara><link xl:href="https://github.com/fabric8-quickstarts/spring-boot-ribbon">fabric8-quickstarts - Spring Boot - Ribbon</link></simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara><link xl:href="https://github.com/fabric8io/kubeflix/tree/master/examples/loanbroker/bank">Kubeflix - LoanBroker - Bank</link></simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<simpara><emphasis role="strong">Note</emphasis>: The Ribbon discovery client can be disabled by setting this key within the application properties file
|
||||
<literal>spring.cloud.kubernetes.ribbon.enabled=false</literal>.</simpara>
|
||||
</partintro>
|
||||
</part>
|
||||
<part xml:id="_kubernetes_awareness">
|
||||
<title>Kubernetes Awareness</title>
|
||||
<partintro>
|
||||
<simpara>All of the features described above will work equally well regardless of whether your application is running inside
|
||||
Kubernetes or not. This is really helpful for development and troubleshooting.
|
||||
From a development point of view, this is really helpful as you can start your Spring Boot application and debug one
|
||||
of the modules part of this project. It is not required to deploy it in Kubernetes
|
||||
as the code of the project relies on the
|
||||
[Fabric8 Kubernetes Java client](<link xl:href="https://github.com/fabric8io/kubernetes-client">https://github.com/fabric8io/kubernetes-client</link>) which is a fluent DSL able to
|
||||
communicate using <literal>http</literal> protocol to the REST API of Kubernetes Server.</simpara>
|
||||
</partintro>
|
||||
<chapter xml:id="_kubernetes_profile_autoconfiguration">
|
||||
<title>Kubernetes Profile Autoconfiguration</title>
|
||||
<simpara>When the application runs as a pod inside Kubernetes a Spring profile named <literal>kubernetes</literal> will automatically get activated.
|
||||
This allows the developer to customize the configuration, to define beans that will be applied when the Spring Boot application is deployed
|
||||
within the Kubernetes platform <emphasis role="strong">(e.g. different dev and prod configuration)</emphasis>.</simpara>
|
||||
</chapter>
|
||||
</part>
|
||||
<part xml:id="_pod_health_indicator">
|
||||
<title>Pod Health Indicator</title>
|
||||
<partintro>
|
||||
<simpara>Spring Boot uses <link xl:href="https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpoint.java">HealthIndicator</link> to expose info about the health of an application.
|
||||
That makes it really useful for exposing health related information to the user and are also a good fit for use as <link xl:href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/">readiness probes</link>.</simpara>
|
||||
<simpara>The Kubernetes health indicator which is part of the core module exposes the following info:</simpara>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>pod name, ip address, namespace, service account, node name and its ip address</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>flag that indicates if the Spring Boot application is internal or external to Kubernetes</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</partintro>
|
||||
</part>
|
||||
<part xml:id="_leader_election">
|
||||
<title>Leader Election</title>
|
||||
<partintro>
|
||||
<simpara><TBD></simpara>
|
||||
</partintro>
|
||||
</part>
|
||||
<part xml:id="_security_configurations_inside_kubernetes">
|
||||
<title>Security Configurations inside Kubernetes</title>
|
||||
<chapter xml:id="_namespace">
|
||||
<title>Namespace</title>
|
||||
<simpara>Most of the components provided in this project need to know the namespace. For Kubernetes (1.3+) the namespace is made available to pod as part of the service account secret and automatically detected by the client.
|
||||
For earlier version it needs to be specified as an env var to the pod. A quick way to do this is:</simpara>
|
||||
<literallayout class="monospaced">env:
|
||||
- name: "KUBERNETES_NAMESPACE"
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: "metadata.namespace"</literallayout>
|
||||
</chapter>
|
||||
<chapter xml:id="_service_account">
|
||||
<title>Service Account</title>
|
||||
<simpara>For distros of Kubernetes that support more fine-grained role-based access within the cluster, you need to make sure a pod that runs with spring-cloud-kubernetes has access to the Kubernetes API.
|
||||
For any service accounts you assign to a deployment/pod, you need to make sure it has the correct roles. For example, you can add <literal>cluster-reader</literal> permissions to your <literal>default</literal> service account depending on the project you’re in:</simpara>
|
||||
</chapter>
|
||||
</part>
|
||||
<part xml:id="_examples_2">
|
||||
<title>Examples</title>
|
||||
<partintro>
|
||||
<simpara>List of examples using these projects:</simpara>
|
||||
<simpara><TBD></simpara>
|
||||
</partintro>
|
||||
</part>
|
||||
<part xml:id="_other_resources">
|
||||
<title>Other Resources</title>
|
||||
<chapter xml:id="_building">
|
||||
<title>Building</title>
|
||||
<section xml:id="_basic_compile_and_test">
|
||||
<title>Basic Compile and Test</title>
|
||||
<simpara>To build the source you will need to install JDK 1.7.</simpara>
|
||||
<simpara>Spring Cloud uses Maven for most build-related activities, and you
|
||||
should be able to get off the ground quite quickly by cloning the
|
||||
project you are interested in and typing</simpara>
|
||||
<screen>$ ./mvnw install</screen>
|
||||
<note>
|
||||
<simpara>You can also install Maven (>=3.3.3) yourself and run the <literal>mvn</literal> command
|
||||
in place of <literal>./mvnw</literal> in the examples below. If you do that you also
|
||||
might need to add <literal>-P spring</literal> if your local Maven settings do not
|
||||
contain repository declarations for spring pre-release artifacts.</simpara>
|
||||
</note>
|
||||
<note>
|
||||
<simpara>Be aware that you might need to increase the amount of memory
|
||||
available to Maven by setting a <literal>MAVEN_OPTS</literal> environment variable with
|
||||
a value like <literal>-Xmx512m -XX:MaxPermSize=128m</literal>. We try to cover this in
|
||||
the <literal>.mvn</literal> configuration, so if you find you have to do it to make a
|
||||
build succeed, please raise a ticket to get the settings added to
|
||||
source control.</simpara>
|
||||
</note>
|
||||
<simpara>For hints on how to build the project look in <literal>.travis.yml</literal> if there
|
||||
is one. There should be a "script" and maybe "install" command. Also
|
||||
look at the "services" section to see if any services need to be
|
||||
running locally (e.g. mongo or rabbit). Ignore the git-related bits
|
||||
that you might find in "before_install" since they’re related to setting git
|
||||
credentials and you already have those.</simpara>
|
||||
<simpara>The projects that require middleware generally include a
|
||||
<literal>docker-compose.yml</literal>, so consider using
|
||||
<link xl:href="http://compose.docker.io/">Docker Compose</link> to run the middeware servers
|
||||
in Docker containers. See the README in the
|
||||
<link xl:href="https://github.com/spring-cloud-samples/scripts">scripts demo
|
||||
repository</link> for specific instructions about the common cases of mongo,
|
||||
rabbit and redis.</simpara>
|
||||
<note>
|
||||
<simpara>If all else fails, build with the command from <literal>.travis.yml</literal> (usually
|
||||
<literal>./mvnw install</literal>).</simpara>
|
||||
</note>
|
||||
</section>
|
||||
<section xml:id="_documentation">
|
||||
<title>Documentation</title>
|
||||
<simpara>The spring-cloud-build module has a "docs" profile, and if you switch
|
||||
that on it will try to build asciidoc sources from
|
||||
<literal>src/main/asciidoc</literal>. As part of that process it will look for a
|
||||
<literal>README.adoc</literal> and process it by loading all the includes, but not
|
||||
parsing or rendering it, just copying it to <literal>${main.basedir}</literal>
|
||||
(defaults to <literal>$../../../..</literal>, i.e. the root of the project). If there are
|
||||
any changes in the README it will then show up after a Maven build as
|
||||
a modified file in the correct place. Just commit it and push the change.</simpara>
|
||||
</section>
|
||||
<section xml:id="_working_with_the_code">
|
||||
<title>Working with the code</title>
|
||||
<simpara>If you don’t have an IDE preference we would recommend that you use
|
||||
<link xl:href="http://www.springsource.com/developer/sts">Spring Tools Suite</link> or
|
||||
<link xl:href="http://eclipse.org">Eclipse</link> when working with the code. We use the
|
||||
<link xl:href="http://eclipse.org/m2e/">m2eclipse</link> eclipse plugin for maven support. Other IDEs and tools
|
||||
should also work without issue as long as they use Maven 3.3.3 or better.</simpara>
|
||||
<section xml:id="_importing_into_eclipse_with_m2eclipse">
|
||||
<title>Importing into eclipse with m2eclipse</title>
|
||||
<simpara>We recommend the <link xl:href="http://eclipse.org/m2e/">m2eclipse</link> eclipse plugin when working with
|
||||
eclipse. If you don’t already have m2eclipse installed it is available from the "eclipse
|
||||
marketplace".</simpara>
|
||||
<note>
|
||||
<simpara>Older versions of m2e do not support Maven 3.3, so once the
|
||||
projects are imported into Eclipse you will also need to tell
|
||||
m2eclipse to use the right profile for the projects. If you
|
||||
see many different errors related to the POMs in the projects, check
|
||||
that you have an up to date installation. If you can’t upgrade m2e,
|
||||
add the "spring" profile to your <literal>settings.xml</literal>. Alternatively you can
|
||||
copy the repository settings from the "spring" profile of the parent
|
||||
pom into your <literal>settings.xml</literal>.</simpara>
|
||||
</note>
|
||||
</section>
|
||||
<section xml:id="_importing_into_eclipse_without_m2eclipse">
|
||||
<title>Importing into eclipse without m2eclipse</title>
|
||||
<simpara>If you prefer not to use m2eclipse you can generate eclipse project metadata using the
|
||||
following command:</simpara>
|
||||
<screen>$ ./mvnw eclipse:eclipse</screen>
|
||||
<simpara>The generated eclipse projects can be imported by selecting <literal>import existing projects</literal>
|
||||
from the <literal>file</literal> menu.</simpara>
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
<chapter xml:id="_contributing">
|
||||
<title>Contributing</title>
|
||||
<simpara>Spring Cloud is released under the non-restrictive Apache 2.0 license,
|
||||
and follows a very standard Github development process, using Github
|
||||
tracker for issues and merging pull requests into master. If you want
|
||||
to contribute even something trivial please do not hesitate, but
|
||||
follow the guidelines below.</simpara>
|
||||
<section xml:id="_sign_the_contributor_license_agreement">
|
||||
<title>Sign the Contributor License Agreement</title>
|
||||
<simpara>Before we accept a non-trivial patch or pull request we will need you to sign the
|
||||
<link xl:href="https://cla.pivotal.io/sign/spring">Contributor License Agreement</link>.
|
||||
Signing the contributor’s agreement does not grant anyone commit rights to the main
|
||||
repository, but it does mean that we can accept your contributions, and you will get an
|
||||
author credit if we do. Active contributors might be asked to join the core team, and
|
||||
given the ability to merge pull requests.</simpara>
|
||||
</section>
|
||||
<section xml:id="_code_of_conduct">
|
||||
<title>Code of Conduct</title>
|
||||
<simpara>This project adheres to the Contributor Covenant <link xl:href="https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc">code of
|
||||
conduct</link>. By participating, you are expected to uphold this code. Please report
|
||||
unacceptable behavior to <link xl:href="mailto:spring-code-of-conduct@pivotal.io">spring-code-of-conduct@pivotal.io</link>.</simpara>
|
||||
</section>
|
||||
<section xml:id="_code_conventions_and_housekeeping">
|
||||
<title>Code Conventions and Housekeeping</title>
|
||||
<simpara>None of these is essential for a pull request, but they will all help. They can also be
|
||||
added after the original pull request but before a merge.</simpara>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>Use the Spring Framework code format conventions. If you use Eclipse
|
||||
you can import formatter settings using the
|
||||
<literal>eclipse-code-formatter.xml</literal> file from the
|
||||
<link xl:href="https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml">Spring
|
||||
Cloud Build</link> project. If using IntelliJ, you can use the
|
||||
<link xl:href="http://plugins.jetbrains.com/plugin/6546">Eclipse Code Formatter
|
||||
Plugin</link> to import the same file.</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>Make sure all new <literal>.java</literal> files to have a simple Javadoc class comment with at least an
|
||||
<literal>@author</literal> tag identifying you, and preferably at least a paragraph on what the class is
|
||||
for.</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>Add the ASF license header comment to all new <literal>.java</literal> files (copy from existing files
|
||||
in the project)</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>Add yourself as an <literal>@author</literal> to the .java files that you modify substantially (more
|
||||
than cosmetic changes).</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>Add some Javadocs and, if you change the namespace, some XSD doc elements.</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>A few unit tests would help a lot as well — someone has to do it.</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>If no-one else is using your branch, please rebase it against the current master (or
|
||||
other target branch in the main project).</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>When writing a commit message please follow <link xl:href="http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html">these conventions</link>,
|
||||
if you are fixing an existing issue please add <literal>Fixes gh-XXXX</literal> at the end of the commit
|
||||
message (where XXXX is the issue number).</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
</chapter>
|
||||
</part>
|
||||
<part xml:id="_appendix_compendium_of_configuration_properties">
|
||||
<title>Appendix: Compendium of Configuration Properties</title>
|
||||
<partintro>
|
||||
|
||||
Reference in New Issue
Block a user