Upgraded to use the Spark 2.4.0 image

This commit is contained in:
Yinan Li 2018-11-04 09:39:39 -08:00
parent 0d2df329df
commit b575f307ad
14 changed files with 56 additions and 44 deletions

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
# #
ARG SPARK_IMAGE=gcr.io/spark-operator/spark:v2.3.1 ARG SPARK_IMAGE=gcr.io/spark-operator/spark:v2.4.0
FROM golang:1.10.2-alpine as builder FROM golang:1.10.2-alpine as builder
ARG DEP_VERSION="0.4.1" ARG DEP_VERSION="0.4.1"

View File

@ -10,7 +10,7 @@ The easiest way to build without worrying about dependencies is to just build th
$ docker build -t <image-tag> . $ docker build -t <image-tag> .
``` ```
The operator image is built upon a base Spark image that defaults to `gcr.io/spark-operator/spark:v2.3.1`. If you want to use your own Spark image (e.g., an image with a different version of Spark or some custom dependencies), specify the argument `SPARK_IMAGE` as the following example shows: The operator image is built upon a base Spark image that defaults to `gcr.io/spark-operator/spark:v2.4.0`. If you want to use your own Spark image (e.g., an image with a different version of Spark or some custom dependencies), specify the argument `SPARK_IMAGE` as the following example shows:
```bash ```bash
$ docker build --build-arg SPARK_IMAGE=<your Spark image> -t <image-tag> . $ docker build --build-arg SPARK_IMAGE=<your Spark image> -t <image-tag> .

View File

@ -138,7 +138,7 @@ spec:
labels: labels:
version: 2.3.0 version: 2.3.0
memory: 512m memory: 512m
image: gcr.io/ynli-k8s/spark:v2.3.0 image: gcr.io/ynli-k8s/spark:v2.4.0
mainApplicationFile: local:///opt/spark/examples/jars/spark-examples_2.11-2.3.0.jar mainApplicationFile: local:///opt/spark/examples/jars/spark-examples_2.11-2.3.0.jar
mainClass: org.apache.spark.examples.SparkPi mainClass: org.apache.spark.examples.SparkPi
mode: cluster mode: cluster

View File

@ -68,7 +68,7 @@ metadata:
spec: spec:
type: Scala type: Scala
mode: cluster mode: cluster
image: gcr.io/spark/spark:v2.3.0 image: gcr.io/spark/spark:v2.4.0
mainClass: org.apache.spark.examples.SparkPi mainClass: org.apache.spark.examples.SparkPi
mainApplicationFile: local:///opt/spark/examples/jars/spark-examples_2.11-2.3.0.jar mainApplicationFile: local:///opt/spark/examples/jars/spark-examples_2.11-2.3.0.jar
``` ```
@ -420,7 +420,7 @@ and currently requires building a custom Docker image from the Spark master bran
The operator supports using the Spark metric system to expose metrics to a variety of sinks. Particularly, it is able to automatically configure the metric system to expose metrics to [Prometheus](https://prometheus.io/). Specifically, the field `.spec.monitoring` specifies how application monitoring is handled and particularly how metrics are to be reported. The metric system is configured through the configuration file `metrics.properties`, which gets its content from the field `.spec.monitoring.metricsProperties`. The content of [metrics.properties](../spark-docker/conf/metrics.properties) will be used by default if `.spec.monitoring.metricsProperties` is not specified. You can choose to enable or disable reporting driver and executor metrics using the fields `.spec.monitoring.exposeDriverMetrics` and `.spec.monitoring.exposeExecutorMetrics`, respectively. The operator supports using the Spark metric system to expose metrics to a variety of sinks. Particularly, it is able to automatically configure the metric system to expose metrics to [Prometheus](https://prometheus.io/). Specifically, the field `.spec.monitoring` specifies how application monitoring is handled and particularly how metrics are to be reported. The metric system is configured through the configuration file `metrics.properties`, which gets its content from the field `.spec.monitoring.metricsProperties`. The content of [metrics.properties](../spark-docker/conf/metrics.properties) will be used by default if `.spec.monitoring.metricsProperties` is not specified. You can choose to enable or disable reporting driver and executor metrics using the fields `.spec.monitoring.exposeDriverMetrics` and `.spec.monitoring.exposeExecutorMetrics`, respectively.
Further, the field `.spec.monitoring.prometheus` specifies how metrics are exposed to Prometheus using the [Prometheus JMX exporter](https://github.com/prometheus/jmx_exporter). When `.spec.monitoring.prometheus` is specified, the operator automatically configures the JMX exporter to run as a Java agent. The only required field of `.spec.monitoring.prometheus` is `jmxExporterJar`, which specified the path to the Prometheus JMX exporter Java agent jar in the container. If you use the image `gcr.io/spark-operator/spark:v2.3.1-gcs-prometheus`, the jar is located at `/prometheus/jmx_prometheus_javaagent-0.3.1.jar`. The field `.spec.monitoring.prometheus.port` specifies the port the JMX exporter Java agent binds to and defaults to `8090` if not specified. The field `.spec.monitoring.prometheus.configuration` specifies the content of the configuration to be used with the JMX exporter. The content of [prometheus.yaml](../spark-docker/conf/prometheus.yaml) will be used by default if `.spec.monitoring.prometheus.configuration` is not specified. Further, the field `.spec.monitoring.prometheus` specifies how metrics are exposed to Prometheus using the [Prometheus JMX exporter](https://github.com/prometheus/jmx_exporter). When `.spec.monitoring.prometheus` is specified, the operator automatically configures the JMX exporter to run as a Java agent. The only required field of `.spec.monitoring.prometheus` is `jmxExporterJar`, which specified the path to the Prometheus JMX exporter Java agent jar in the container. If you use the image `gcr.io/spark-operator/spark:v2.4.0-gcs-prometheus`, the jar is located at `/prometheus/jmx_prometheus_javaagent-0.3.1.jar`. The field `.spec.monitoring.prometheus.port` specifies the port the JMX exporter Java agent binds to and defaults to `8090` if not specified. The field `.spec.monitoring.prometheus.configuration` specifies the content of the configuration to be used with the JMX exporter. The content of [prometheus.yaml](../spark-docker/conf/prometheus.yaml) will be used by default if `.spec.monitoring.prometheus.configuration` is not specified.
Below is an example that shows how to configure the metric system to expose metrics to Prometheus using the Prometheus JMX exporter. Note that the JMX exporter Java agent jar is listed as a dependency and will be downloaded to where `.spec.dep.jarsDownloadDir` points to in Spark 2.3.x, which is `/var/spark-data/spark-jars` by default. Things will be different in Spark 2.4 as dependencies will be downloaded to the local working directory instead in Spark 2.4. A complete example can be found in [examples/spark-pi-prometheus.yaml](../examples/spark-pi-prometheus.yaml). Below is an example that shows how to configure the metric system to expose metrics to Prometheus using the Prometheus JMX exporter. Note that the JMX exporter Java agent jar is listed as a dependency and will be downloaded to where `.spec.dep.jarsDownloadDir` points to in Spark 2.3.x, which is `/var/spark-data/spark-jars` by default. Things will be different in Spark 2.4 as dependencies will be downloaded to the local working directory instead in Spark 2.4. A complete example can be found in [examples/spark-pi-prometheus.yaml](../examples/spark-pi-prometheus.yaml).
@ -512,7 +512,7 @@ spec:
template: template:
type: Scala type: Scala
mode: cluster mode: cluster
image: gcr.io/spark/spark:v2.3.0 image: gcr.io/spark/spark:v2.4.0
mainClass: org.apache.spark.examples.SparkPi mainClass: org.apache.spark.examples.SparkPi
mainApplicationFile: local:///opt/spark/examples/jars/spark-examples_2.11-2.3.0.jar mainApplicationFile: local:///opt/spark/examples/jars/spark-examples_2.11-2.3.0.jar
driver: driver:

View File

@ -22,10 +22,10 @@ metadata:
spec: spec:
type: Scala type: Scala
mode: cluster mode: cluster
image: "gcr.io/spark-operator/spark:v2.3.1-gcs-prometheus" image: "gcr.io/spark-operator/spark:v2.4.0-gcs-prometheus"
imagePullPolicy: Always imagePullPolicy: Always
mainClass: org.apache.spark.examples.SparkPi mainClass: org.apache.spark.examples.SparkPi
mainApplicationFile: "local:///opt/spark/examples/jars/spark-examples_2.11-2.3.1.jar" mainApplicationFile: "local:///opt/spark/examples/jars/spark-examples_2.11-2.4.0.jar"
deps: deps:
jars: jars:
- http://central.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.3.1/jmx_prometheus_javaagent-0.3.1.jar - http://central.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.3.1/jmx_prometheus_javaagent-0.3.1.jar
@ -34,14 +34,14 @@ spec:
coreLimit: "200m" coreLimit: "200m"
memory: "512m" memory: "512m"
labels: labels:
version: 2.3.1 version: 2.4.0
serviceAccount: spark serviceAccount: spark
executor: executor:
cores: 1 cores: 1
instances: 1 instances: 1
memory: "512m" memory: "512m"
labels: labels:
version: 2.3.1 version: 2.4.0
monitoring: monitoring:
exposeDriverMetrics: true exposeDriverMetrics: true
exposeExecutorMetrics: true exposeExecutorMetrics: true

View File

@ -25,21 +25,21 @@ spec:
template: template:
type: Scala type: Scala
mode: cluster mode: cluster
image: "gcr.io/spark-operator/spark:v2.3.1" image: "gcr.io/spark-operator/spark:v2.4.0"
imagePullPolicy: Always imagePullPolicy: Always
mainClass: org.apache.spark.examples.SparkPi mainClass: org.apache.spark.examples.SparkPi
mainApplicationFile: "local:///opt/spark/examples/jars/spark-examples_2.11-2.3.1.jar" mainApplicationFile: "local:///opt/spark/examples/jars/spark-examples_2.11-2.4.0.jar"
driver: driver:
cores: 0.1 cores: 0.1
coreLimit: "200m" coreLimit: "200m"
memory: "512m" memory: "512m"
labels: labels:
version: 2.3.1 version: 2.4.0
serviceAccount: spark serviceAccount: spark
executor: executor:
cores: 1 cores: 1
instances: 1 instances: 1
memory: "512m" memory: "512m"
labels: labels:
version: 2.3.1 version: 2.4.0
restartPolicy: Never restartPolicy: Never

View File

@ -22,10 +22,10 @@ metadata:
spec: spec:
type: Scala type: Scala
mode: cluster mode: cluster
image: "gcr.io/spark-operator/spark:v2.3.1" image: "gcr.io/spark-operator/spark:v2.4.0"
imagePullPolicy: Always imagePullPolicy: Always
mainClass: org.apache.spark.examples.SparkPi mainClass: org.apache.spark.examples.SparkPi
mainApplicationFile: "local:///opt/spark/examples/jars/spark-examples_2.11-2.3.1.jar" mainApplicationFile: "local:///opt/spark/examples/jars/spark-examples_2.11-2.4.0.jar"
volumes: volumes:
- name: "test-volume" - name: "test-volume"
hostPath: hostPath:
@ -36,7 +36,7 @@ spec:
coreLimit: "200m" coreLimit: "200m"
memory: "512m" memory: "512m"
labels: labels:
version: 2.3.1 version: 2.4.0
serviceAccount: spark serviceAccount: spark
volumeMounts: volumeMounts:
- name: "test-volume" - name: "test-volume"
@ -46,7 +46,7 @@ spec:
instances: 1 instances: 1
memory: "512m" memory: "512m"
labels: labels:
version: 2.3.1 version: 2.4.0
volumeMounts: volumeMounts:
- name: "test-volume" - name: "test-volume"
mountPath: "/tmp" mountPath: "/tmp"

View File

@ -25,7 +25,7 @@ spec:
type: Python type: Python
pythonVersion: "2" pythonVersion: "2"
mode: cluster mode: cluster
image: "gcr.io/spark-operator/spark-py:v2.4.0-SNAPSHOT" image: "gcr.io/spark-operator/spark-py:v2.4.0"
imagePullPolicy: Always imagePullPolicy: Always
mainApplicationFile: local:///opt/spark/examples/src/main/python/pyfiles.py mainApplicationFile: local:///opt/spark/examples/src/main/python/pyfiles.py
arguments: arguments:

View File

@ -21,13 +21,13 @@ metadata:
namespace: spark-operator namespace: spark-operator
labels: labels:
app.kubernetes.io/name: sparkoperator app.kubernetes.io/name: sparkoperator
app.kubernetes.io/version: v2.3.1-v1alpha1 app.kubernetes.io/version: v2.4.0-v1alpha1
spec: spec:
replicas: 1 replicas: 1
selector: selector:
matchLabels: matchLabels:
app.kubernetes.io/name: sparkoperator app.kubernetes.io/name: sparkoperator
app.kubernetes.io/version: v2.3.1-v1alpha1 app.kubernetes.io/version: v2.4.0-v1alpha1
strategy: strategy:
type: Recreate type: Recreate
template: template:
@ -38,14 +38,14 @@ spec:
prometheus.io/path: "/metrics" prometheus.io/path: "/metrics"
labels: labels:
app.kubernetes.io/name: sparkoperator app.kubernetes.io/name: sparkoperator
app.kubernetes.io/version: v2.3.1-v1alpha1 app.kubernetes.io/version: v2.4.0-v1alpha1
initializers: initializers:
pending: [] pending: []
spec: spec:
serviceAccountName: sparkoperator serviceAccountName: sparkoperator
containers: containers:
- name: sparkoperator - name: sparkoperator
image: gcr.io/spark-operator/spark-operator:v2.3.1-v1alpha1-latest image: gcr.io/spark-operator/spark-operator:v2.4.0-v1alpha1-latest
imagePullPolicy: Always imagePullPolicy: Always
command: ["/usr/bin/spark-operator"] command: ["/usr/bin/spark-operator"]
ports: ports:

View File

@ -21,20 +21,20 @@ metadata:
namespace: spark-operator namespace: spark-operator
labels: labels:
app.kubernetes.io/name: sparkoperator app.kubernetes.io/name: sparkoperator
app.kubernetes.io/version: v2.3.1-v1alpha1 app.kubernetes.io/version: v2.4.0-v1alpha1
spec: spec:
replicas: 1 replicas: 1
selector: selector:
matchLabels: matchLabels:
app.kubernetes.io/name: sparkoperator app.kubernetes.io/name: sparkoperator
app.kubernetes.io/version: v2.3.1-v1alpha1 app.kubernetes.io/version: v2.4.0-v1alpha1
strategy: strategy:
type: Recreate type: Recreate
template: template:
metadata: metadata:
labels: labels:
app.kubernetes.io/name: sparkoperator app.kubernetes.io/name: sparkoperator
app.kubernetes.io/version: v2.3.1-v1alpha1 app.kubernetes.io/version: v2.4.0-v1alpha1
initializers: initializers:
pending: [] pending: []
spec: spec:
@ -45,7 +45,7 @@ spec:
secretName: spark-webhook-certs secretName: spark-webhook-certs
containers: containers:
- name: sparkoperator - name: sparkoperator
image: gcr.io/spark-operator/spark-operator:v2.3.1-v1alpha1-latest image: gcr.io/spark-operator/spark-operator:v2.4.0-v1alpha1-latest
imagePullPolicy: Always imagePullPolicy: Always
volumeMounts: volumeMounts:
- name: webhook-certs - name: webhook-certs
@ -64,20 +64,20 @@ metadata:
namespace: spark-operator namespace: spark-operator
labels: labels:
app.kubernetes.io/name: sparkoperator app.kubernetes.io/name: sparkoperator
app.kubernetes.io/version: v2.3.1-v1alpha1 app.kubernetes.io/version: v2.4.0-v1alpha1
spec: spec:
backoffLimit: 3 backoffLimit: 3
template: template:
metadata: metadata:
labels: labels:
app.kubernetes.io/name: sparkoperator app.kubernetes.io/name: sparkoperator
app.kubernetes.io/version: v2.3.1-v1alpha1 app.kubernetes.io/version: v2.4.0-v1alpha1
spec: spec:
serviceAccountName: sparkoperator serviceAccountName: sparkoperator
restartPolicy: Never restartPolicy: Never
containers: containers:
- name: main - name: main
image: gcr.io/spark-operator/spark-operator:v2.3.1-v1alpha1-latest image: gcr.io/spark-operator/spark-operator:v2.4.0-v1alpha1-latest
imagePullPolicy: Always imagePullPolicy: Always
command: ["/usr/bin/gencerts.sh", "-p"] command: ["/usr/bin/gencerts.sh", "-p"]
--- ---
@ -93,4 +93,4 @@ spec:
name: webhook name: webhook
selector: selector:
app.kubernetes.io/name: sparkoperator app.kubernetes.io/name: sparkoperator
app.kubernetes.io/version: v2.3.1-v1alpha1 app.kubernetes.io/version: v2.4.0-v1alpha1

View File

@ -21,27 +21,27 @@ metadata:
namespace: spark-operator namespace: spark-operator
labels: labels:
app.kubernetes.io/name: sparkoperator app.kubernetes.io/name: sparkoperator
app.kubernetes.io/version: v2.3.1-v1alpha1 app.kubernetes.io/version: v2.4.0-v1alpha1
spec: spec:
replicas: 1 replicas: 1
selector: selector:
matchLabels: matchLabels:
app.kubernetes.io/name: sparkoperator app.kubernetes.io/name: sparkoperator
app.kubernetes.io/version: v2.3.1-v1alpha1 app.kubernetes.io/version: v2.4.0-v1alpha1
strategy: strategy:
type: Recreate type: Recreate
template: template:
metadata: metadata:
labels: labels:
app.kubernetes.io/name: sparkoperator app.kubernetes.io/name: sparkoperator
app.kubernetes.io/version: v2.3.1-v1alpha1 app.kubernetes.io/version: v2.4.0-v1alpha1
initializers: initializers:
pending: [] pending: []
spec: spec:
serviceAccountName: sparkoperator serviceAccountName: sparkoperator
containers: containers:
- name: sparkoperator - name: sparkoperator
image: gcr.io/spark-operator/spark-operator:v2.3.1-v1alpha1-latest image: gcr.io/spark-operator/spark-operator:v2.4.0-v1alpha1-latest
imagePullPolicy: Always imagePullPolicy: Always
command: ["/usr/bin/spark-operator"] command: ["/usr/bin/spark-operator"]
args: args:

View File

@ -18,6 +18,7 @@ package config
import ( import (
"fmt" "fmt"
"sort"
"strings" "strings"
"testing" "testing"
@ -57,13 +58,22 @@ func TestFindTolerations(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
assert.Equal(t, 2, len(tolerations)) assert.Equal(t, 2, len(tolerations))
assert.Equal(t, "Key1", tolerations[0].Key) if tolerations[0].Key == "Key1" {
assert.Equal(t, "Value", tolerations[0].Value) assert.Equal(t, "Value", tolerations[0].Value)
assert.Equal(t, "Equal", string(tolerations[0].Operator)) assert.Equal(t, "Equal", string(tolerations[0].Operator))
assert.Equal(t, "NoEffect", string(tolerations[0].Effect)) assert.Equal(t, "NoEffect", string(tolerations[0].Effect))
assert.Equal(t, "Key2", tolerations[1].Key) assert.Equal(t, "Key2", tolerations[1].Key)
assert.Equal(t, "Exists", string(tolerations[1].Operator)) assert.Equal(t, "Exists", string(tolerations[1].Operator))
assert.Equal(t, "NoSchedule", string(tolerations[1].Effect)) assert.Equal(t, "NoSchedule", string(tolerations[1].Effect))
} else {
assert.Equal(t, "Key1", tolerations[1].Key)
assert.Equal(t, "Value", tolerations[1].Value)
assert.Equal(t, "Equal", string(tolerations[1].Operator))
assert.Equal(t, "NoEffect", string(tolerations[1].Effect))
assert.Equal(t, "Key2", tolerations[0].Key)
assert.Equal(t, "Exists", string(tolerations[0].Operator))
assert.Equal(t, "NoSchedule", string(tolerations[0].Effect))
}
} }
func TestGetTolerationAnnotations(t *testing.T) { func TestGetTolerationAnnotations(t *testing.T) {
@ -137,6 +147,7 @@ func TestGetDriverTolerationConfOptions(t *testing.T) {
} }
assert.Equal(t, 2, len(options)) assert.Equal(t, 2, len(options))
sort.Strings(options)
assert.True(t, strings.HasPrefix(options[0], fmt.Sprintf("%s%s%s=", SparkDriverAnnotationKeyPrefix, assert.True(t, strings.HasPrefix(options[0], fmt.Sprintf("%s%s%s=", SparkDriverAnnotationKeyPrefix,
TolerationsAnnotationPrefix, "toleration1"))) TolerationsAnnotationPrefix, "toleration1")))
assert.True(t, strings.HasPrefix(options[1], fmt.Sprintf("%s%s%s=", SparkDriverAnnotationKeyPrefix, assert.True(t, strings.HasPrefix(options[1], fmt.Sprintf("%s%s%s=", SparkDriverAnnotationKeyPrefix,
@ -172,6 +183,7 @@ func TestGetExecutorTolerationConfOptions(t *testing.T) {
} }
assert.Equal(t, 2, len(options)) assert.Equal(t, 2, len(options))
sort.Strings(options)
assert.True(t, strings.HasPrefix(options[0], fmt.Sprintf("%s%s%s=", SparkExecutorAnnotationKeyPrefix, assert.True(t, strings.HasPrefix(options[0], fmt.Sprintf("%s%s%s=", SparkExecutorAnnotationKeyPrefix,
TolerationsAnnotationPrefix, "toleration1"))) TolerationsAnnotationPrefix, "toleration1")))
assert.True(t, strings.HasPrefix(options[1], fmt.Sprintf("%s%s%s=", SparkExecutorAnnotationKeyPrefix, assert.True(t, strings.HasPrefix(options[1], fmt.Sprintf("%s%s%s=", SparkExecutorAnnotationKeyPrefix,

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
# #
ARG SPARK_IMAGE=gcr.io/spark-operator/spark:v2.3.1 ARG SPARK_IMAGE=gcr.io/spark-operator/spark:v2.4.0
FROM ${SPARK_IMAGE} FROM ${SPARK_IMAGE}
# Setup dependencies for Google Cloud Storage access. # Setup dependencies for Google Cloud Storage access.

View File

@ -12,5 +12,5 @@ Prerequisites:
e2e tests are written as Go test. All go test techniques apply (e.g. picking what to run, timeout length). Let's say I want to run all tests in "test/e2e/": e2e tests are written as Go test. All go test techniques apply (e.g. picking what to run, timeout length). Let's say I want to run all tests in "test/e2e/":
```bash ```bash
$ go test -v ./test/e2e/ --kubeconfig "$HOME/.kube/config" --operator-image=gcr.io/spark-operator/spark-operator:v2.3.1-v1alpha1-latest $ go test -v ./test/e2e/ --kubeconfig "$HOME/.kube/config" --operator-image=gcr.io/spark-operator/spark-operator:v2.4.0-v1alpha1-latest
``` ```