This is an automated email from the ASF dual-hosted git repository.

azagrebin pushed a commit to branch release-1.11
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.11 by this push:
     new a352b1d  [FLINK-15794][Kubernetes] Generate the Kubernetes default 
image version
a352b1d is described below

commit a352b1d5b8ea8659d325f64b8a1767a17792a500
Author: Niels Basjes <ni...@basjes.nl>
AuthorDate: Thu May 28 15:44:27 2020 +0200

    [FLINK-15794][Kubernetes] Generate the Kubernetes default image version
    
    The default image used by Kubernetes is 'flink:latest' which causes version 
compatibility problems
    if the latest it not exactly the same as what you are using.
    The commit derives the default value from the actual Flink and Scala 
version,
    which the running Flink was built with (i.e. no longer latest).
    The latest tag is used only for snapshot versions until we have snapshot 
builds for docker images.
    
    This closes #11245.
---
 .../generated/kubernetes_config_configuration.html      |  4 ++--
 docs/ops/deployment/docker.md                           |  5 +++++
 docs/ops/deployment/docker.zh.md                        |  5 +++++
 docs/ops/deployment/kubernetes.md                       |  8 ++++----
 docs/ops/deployment/kubernetes.zh.md                    |  8 ++++----
 .../configuration/KubernetesConfigOptions.java          | 17 +++++++++++++++--
 6 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/docs/_includes/generated/kubernetes_config_configuration.html 
b/docs/_includes/generated/kubernetes_config_configuration.html
index 6b19cec..f757edc 100644
--- a/docs/_includes/generated/kubernetes_config_configuration.html
+++ b/docs/_includes/generated/kubernetes_config_configuration.html
@@ -34,9 +34,9 @@
         </tr>
         <tr>
             <td><h5>kubernetes.container.image</h5></td>
-            <td style="word-wrap: break-word;">"flink:latest"</td>
+            <td style="word-wrap: break-word;">The default value depends on 
the actually running version. In general it looks like 
"flink:&lt;FLINK_VERSION&gt;-scala_&lt;SCALA_VERSION&gt;"</td>
             <td>String</td>
-            <td>Image to use for Flink containers.</td>
+            <td>Image to use for Flink containers. The specified image must be 
based upon the same Apache Flink and Scala versions as used by the application. 
Visit https://hub.docker.com/_/flink?tab=tags for the images provided by the 
Flink project.</td>
         </tr>
         <tr>
             <td><h5>kubernetes.container.image.pull-policy</h5></td>
diff --git a/docs/ops/deployment/docker.md b/docs/ops/deployment/docker.md
index a32bdad..59526cb 100644
--- a/docs/ops/deployment/docker.md
+++ b/docs/ops/deployment/docker.md
@@ -46,6 +46,11 @@ For example, you can use the following aliases:
 * `flink:latest` → `flink:<latest-flink>-scala_<latest-scala>`
 * `flink:1.11` → `flink:1.11.<latest-flink-1.11>-scala_2.11`
 
+<span class="label label-info">Note</span> It is recommended to always use an 
explicit version tag of the docker image that specifies both the needed Flink 
and Scala
+versions (for example `flink:1.11-scala_2.12`).
+This will avoid some class conflicts that can occur if the Flink and/or Scala 
versions used in the application are different
+from the versions provided by the docker image.
+
 <span class="label label-info">Note</span> Prior to Flink 1.5 version, Hadoop 
dependencies were always bundled with Flink.
 You can see that certain tags include the version of Hadoop, e.g. (e.g. 
`-hadoop28`).
 Beginning with Flink 1.5, image tags that omit the Hadoop version correspond 
to Hadoop-free releases of Flink
diff --git a/docs/ops/deployment/docker.zh.md b/docs/ops/deployment/docker.zh.md
index ab2f4a5..eb1ef37 100644
--- a/docs/ops/deployment/docker.zh.md
+++ b/docs/ops/deployment/docker.zh.md
@@ -46,6 +46,11 @@ For example, you can use the following aliases:
 * `flink:latest` → `flink:<latest-flink>-scala_<latest-scala>`
 * `flink:1.11` → `flink:1.11.<latest-flink-1.11>-scala_2.11`
 
+<span class="label label-info">Note</span>It is recommended to always use an 
explicit version tag of the docker image that specifies both the needed Flink 
and Scala
+versions (for example `flink:1.11-scala_2.12`).
+This will avoid some class conflicts that can occur if the Flink and/or Scala 
versions used in the application are different
+from the versions provided by the docker image.
+
 <span class="label label-info">Note</span> Prior to Flink 1.5 version, Hadoop 
dependencies were always bundled with Flink.
 You can see that certain tags include the version of Hadoop, e.g. (e.g. 
`-hadoop28`).
 Beginning with Flink 1.5, image tags that omit the Hadoop version correspond 
to Hadoop-free releases of Flink
diff --git a/docs/ops/deployment/kubernetes.md 
b/docs/ops/deployment/kubernetes.md
index 1d3ee95..6dbb2df 100644
--- a/docs/ops/deployment/kubernetes.md
+++ b/docs/ops/deployment/kubernetes.md
@@ -310,7 +310,7 @@ spec:
     spec:
       containers:
       - name: jobmanager
-        image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest{% endif %}
+        image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest # The 
'latest' tag contains the latest released version of Flink for a specific Scala 
version. Do not use the 'latest' tag in production as it will break your setup 
automatically when a new version is released.{% endif %}
         args: ["jobmanager"]
         ports:
         - containerPort: 6123
@@ -360,7 +360,7 @@ spec:
     spec:
       containers:
       - name: taskmanager
-        image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest{% endif %}
+        image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest # The 
'latest' tag contains the latest released version of Flink for a specific Scala 
version. Do not use the 'latest' tag in production as it will break your setup 
automatically when a new version is released.{% endif %}
         args: ["taskmanager"]
         ports:
         - containerPort: 6122
@@ -406,7 +406,7 @@ spec:
       restartPolicy: OnFailure
       containers:
         - name: jobmanager
-          image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest{% endif %}
+          image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest # The 
'latest' tag contains the latest released version of Flink for a specific Scala 
version. Do not use the 'latest' tag in production as it will break your setup 
automatically when a new version is released.{% endif %}
           env:
           args: ["standalone-job", "--job-classname", "com.job.ClassName", 
<optional arguments>, <job arguments>] # optional arguments: ["--job-id", "<job 
id>", "--fromSavepoint", "/path/to/savepoint", "--allowNonRestoredState"]
           ports:
@@ -462,7 +462,7 @@ spec:
     spec:
       containers:
       - name: taskmanager
-        image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest{% endif %}
+        image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest # The 
'latest' tag contains the latest released version of Flink for a specific Scala 
version. Do not use the 'latest' tag in production as it will break your setup 
automatically when a new version is released.{% endif %}
         env:
         args: ["taskmanager"]
         ports:
diff --git a/docs/ops/deployment/kubernetes.zh.md 
b/docs/ops/deployment/kubernetes.zh.md
index deff204..f57135d 100644
--- a/docs/ops/deployment/kubernetes.zh.md
+++ b/docs/ops/deployment/kubernetes.zh.md
@@ -310,7 +310,7 @@ spec:
     spec:
       containers:
       - name: jobmanager
-        image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest{% endif %}
+        image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest # The 
'latest' tag contains the latest released version of Flink for a specific Scala 
version. Do not use the 'latest' tag in production as it will break your setup 
automatically when a new version is released.{% endif %}
         args: ["jobmanager"]
         ports:
         - containerPort: 6123
@@ -360,7 +360,7 @@ spec:
     spec:
       containers:
       - name: taskmanager
-        image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest{% endif %}
+        image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest # The 
'latest' tag contains the latest released version of Flink for a specific Scala 
version. Do not use the 'latest' tag in production as it will break your setup 
automatically when a new version is released.{% endif %}
         args: ["taskmanager"]
         ports:
         - containerPort: 6122
@@ -406,7 +406,7 @@ spec:
       restartPolicy: OnFailure
       containers:
         - name: jobmanager
-          image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest{% endif %}
+          image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest # The 
'latest' tag contains the latest released version of Flink for a specific Scala 
version. Do not use the 'latest' tag in production as it will break your setup 
automatically when a new version is released.{% endif %}
           env:
           args: ["standalone-job", "--job-classname", "com.job.ClassName", 
<optional arguments>, <job arguments>] # optional arguments: ["--job-id", "<job 
id>", "--fromSavepoint", "/path/to/savepoint", "--allowNonRestoredState"]
           ports:
@@ -462,7 +462,7 @@ spec:
     spec:
       containers:
       - name: taskmanager
-        image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest{% endif %}
+        image: flink:{% if site.is_stable 
%}{{site.version}}-scala{{site.scala_version_suffix}}{% else %}latest # The 
'latest' tag contains the latest released version of Flink for a specific Scala 
version. Do not use the 'latest' tag in production as it will break your setup 
automatically when a new version is released.{% endif %}
         env:
         args: ["taskmanager"]
         ports:
diff --git 
a/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/configuration/KubernetesConfigOptions.java
 
b/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/configuration/KubernetesConfigOptions.java
index 0c4303f..8ed7352 100644
--- 
a/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/configuration/KubernetesConfigOptions.java
+++ 
b/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/configuration/KubernetesConfigOptions.java
@@ -19,10 +19,13 @@
 package org.apache.flink.kubernetes.configuration;
 
 import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.annotation.docs.Documentation;
 import org.apache.flink.configuration.ConfigOption;
 import org.apache.flink.configuration.ExternalResourceOptions;
+import org.apache.flink.runtime.util.EnvironmentInformation;
 
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import static org.apache.flink.configuration.ConfigOptions.key;
@@ -137,11 +140,14 @@ public class KubernetesConfigOptions {
                .withDescription("The cluster-id, which should be no more than 
45 characters, is used for identifying " +
                        "a unique Flink cluster. If not set, the client will 
automatically generate it with a random ID.");
 
+       @Documentation.OverrideDefault("The default value depends on the 
actually running version. In general it looks like 
\"flink:<FLINK_VERSION>-scala_<SCALA_VERSION>\"")
        public static final ConfigOption<String> CONTAINER_IMAGE =
                key("kubernetes.container.image")
                .stringType()
-               .defaultValue("flink:latest")
-               .withDescription("Image to use for Flink containers.");
+               .defaultValue(getDefaultFlinkImage())
+               .withDescription("Image to use for Flink containers. " +
+                       "The specified image must be based upon the same Apache 
Flink and Scala versions as used by the application. " +
+                       "Visit https://hub.docker.com/_/flink?tab=tags for the 
images provided by the Flink project.");
 
        /**
         * The following config options need to be set according to the image.
@@ -229,6 +235,13 @@ public class KubernetesConfigOptions {
                        .withDescription("If configured, Flink will add 
\"resources.limits.<config-key>\" and \"resources.requests.<config-key>\" " +
                                "to the main container of TaskExecutor and set 
the value to the value of " + 
ExternalResourceOptions.EXTERNAL_RESOURCE_AMOUNT.key() + ".");
 
+       private static String getDefaultFlinkImage() {
+               // The default container image that ties to the exact needed 
versions of both Flink and Scala.
+               boolean snapshot = 
EnvironmentInformation.getVersion().toLowerCase(Locale.ENGLISH).contains("snapshot");
+               String tag = snapshot ? "latest" : 
EnvironmentInformation.getVersion() + "-scala_" + 
EnvironmentInformation.getScalaVersion();
+               return "flink:" + tag;
+       }
+
        /**
         * The flink rest service exposed type.
         */

Reply via email to