-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save Jobs History on Flink #6
Changes from 8 commits
b47cc34
3f1baa8
07cd6ab
4cc9b4d
15559f5
7be14c5
1fc95d9
a3b0bb8
dcbbd35
fbc07a3
bc1a2ea
cd672be
dbbf520
c92ddc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: v2 | ||
name: flink-historyserver | ||
description: A Helm chart for Kubernetes | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 0.1.2 | ||
|
||
# This is the version number of the application being deployed. This version number should be | ||
# incremented each time you make changes to the application. Versions are not expected to | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
# It is recommended to use it with quotes. | ||
appVersion: "0.1.2" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "flink-historyserver.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "flink-historyserver.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "flink-historyserver.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "flink-historyserver.labels" -}} | ||
helm.sh/chart: {{ include "flink-historyserver.chart" . }} | ||
{{ include "flink-historyserver.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "flink-historyserver.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "flink-historyserver.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "flink-historyserver.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "flink-historyserver.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apiVersion: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
name: {{ .Release.Name }}-efs-flink-history | ||
parameters: | ||
provisioningMode: efs-ap | ||
fileSystemId: "{{- .Values.efsFileSystemId }}" | ||
provisioner: "efs.csi.aws.com" | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolume | ||
metadata: | ||
name: flink-historyserver-efs-pv | ||
spec: | ||
capacity: | ||
storage: "1Mi" | ||
volumeMode: "Filesystem" | ||
accessModes: | ||
- "ReadWriteMany" | ||
# 'persistentVolumeReclaimPolicy' means EFS volumes must be manually cleaned up when testing is done | ||
persistentVolumeReclaimPolicy: Retain | ||
ranchodeluxe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
storageClassName: {{ .Release.Name }}-efs-flink-history | ||
csi: | ||
driver: "efs.csi.aws.com" | ||
volumeHandle: "{{- .Values.efsFileSystemId }}" | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: flink-historyserver-efs-pvc | ||
spec: | ||
accessModes: | ||
- ReadWriteMany | ||
storageClassName: {{ .Release.Name }}-efs-flink-history | ||
resources: | ||
requests: | ||
storage: 1Mi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: historyserver | ||
name: historyserver | ||
spec: | ||
replicas: 1 | ||
revisionHistoryLimit: 10 | ||
ranchodeluxe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
selector: | ||
matchLabels: | ||
app: historyserver | ||
template: | ||
metadata: | ||
labels: | ||
app: historyserver | ||
spec: | ||
containers: | ||
- args: | ||
- history-server | ||
command: | ||
- /docker-entrypoint.sh | ||
env: | ||
- name: _POD_IP_ADDRESS | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: status.podIP | ||
image: flink:{{- .Values.flinkVersion }} | ||
name: flink-main-container | ||
ports: | ||
- containerPort: 8082 | ||
name: history | ||
protocol: TCP | ||
resources: | ||
ranchodeluxe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
limits: | ||
cpu: 300m | ||
memory: 1536Mi | ||
requests: | ||
cpu: 300m | ||
memory: 1536Mi | ||
startupProbe: | ||
httpGet: | ||
path: /config | ||
port: history | ||
volumeMounts: | ||
- mountPath: /opt/history/jobs | ||
name: efs-flink-history | ||
- mountPath: /opt/flink/conf | ||
name: flink-config-volume | ||
initContainers: | ||
- command: | ||
- sh | ||
- -c | ||
- chown 9999:9999 /opt/history/jobs && ls -lhd /opt/history/jobs | ||
image: busybox:1.36.1 | ||
imagePullPolicy: IfNotPresent | ||
ranchodeluxe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name: efs-mount-ownership-fix | ||
resources: {} | ||
volumeMounts: | ||
- mountPath: /opt/history/jobs | ||
name: efs-flink-history | ||
schedulerName: default-scheduler | ||
ranchodeluxe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
securityContext: | ||
fsGroup: 9999 | ||
# NOTE: this SA is set up by the flink-operator helm chart and reused here | ||
serviceAccountName: flink | ||
terminationGracePeriodSeconds: 30 | ||
ranchodeluxe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
volumes: | ||
- name: efs-flink-history | ||
persistentVolumeClaim: | ||
claimName: flink-historyserver-efs-pvc | ||
- configMap: | ||
items: | ||
- key: log4j-console.properties | ||
path: log4j-console.properties | ||
- key: flink-conf.yaml | ||
path: flink-conf.yaml | ||
# NOTE: this configmap is set up by the flink-operator helm chart and reused here | ||
name: flink-operator-config | ||
name: flink-config-volume | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: historyserver | ||
name: historyserver-rest | ||
spec: | ||
ports: | ||
- name: history | ||
port: 8082 | ||
targetPort: 8082 | ||
selector: | ||
app: historyserver | ||
type: ClusterIP | ||
status: | ||
ranchodeluxe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
loadBalancer: {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
ranchodeluxe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"required": ["efsFileSystemId"], | ||
"properties": { | ||
"efsFileSystemId": { | ||
"type": "string", | ||
"minLength": 1 | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
efsFileSystemId: "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think for schema items that we mark as required, we should not specify them here. That way, when the user tries to deploy this without those set, the schema setup will kick in and complain - I think specifying empty values here negates that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think undoing the 'required' is much cleaner than enforcing them via |
||
flinkVersion: "1.16" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.yaml | ||
ranchodeluxe marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
resource "aws_efs_file_system" "job_history" { | ||
creation_token = "${var.cluster_name}-flink-job-history" | ||
} | ||
|
||
resource "aws_efs_mount_target" "job_history" { | ||
for_each = toset(data.aws_subnets.default.ids) | ||
file_system_id = aws_efs_file_system.job_history.id | ||
subnet_id = each.value | ||
security_groups = [aws_eks_cluster.cluster.vpc_config[0].cluster_security_group_id] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
provider "kubernetes" { | ||
host = aws_eks_cluster.cluster.endpoint | ||
cluster_ca_certificate = base64decode(aws_eks_cluster.cluster.certificate_authority[0].data) | ||
token = data.aws_eks_cluster_auth.cluster.token | ||
} | ||
|
||
data "aws_eks_cluster_auth" "cluster" { | ||
name = "${aws_eks_cluster.cluster.name}" | ||
depends_on = [ | ||
aws_eks_cluster.cluster, | ||
helm_release.flink_operator | ||
] | ||
} | ||
|
||
resource "helm_release" "flink_historyserver" { | ||
name = "flink-historyserver" | ||
chart = "../../helm-charts/flink-historyserver" | ||
create_namespace = false | ||
|
||
set { | ||
name = "efsFileSystemId" | ||
value = "${aws_efs_file_system.job_history.id}" | ||
} | ||
|
||
set { | ||
name = "flinkVersion" | ||
value = "${var.flink_version}" | ||
} | ||
|
||
wait = true | ||
depends_on = [ | ||
aws_eks_cluster.cluster, | ||
helm_release.flink_operator | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that this has 'historyserver' in the name, so it gets used specifically just for this and not much more :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PersistentVolume is also not namespaced, and should get same treatment as
StorageClass
with.Release.Name
. sorry for not catching that earlier.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ranchodeluxe I think this still needs to be fixed?