Skip to content

Commit

Permalink
Flink k8s operator improvements (#162)
Browse files Browse the repository at this point in the history
* test

* test

* removed unnecessaryn file

* bumped download-artifacts

* fix

* test

* test

* fix

* potential fix

* test

* fixes

* fix

* test
  • Loading branch information
pielas authored Sep 10, 2024
1 parent 9ab7cf4 commit f298115
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 44 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/helm-test-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: packageAll
run: helm package ${{env.CHART_SRC_DIR}} -d dist --version "${{steps.setVersion.outputs.version}}"
- name: Store target
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: helm-build
path: "dist/${{env.NAME}}-${{steps.setVersion.outputs.version}}.tgz"
Expand All @@ -66,7 +66,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: helm-build
path: dist
Expand All @@ -91,7 +91,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: helm-build
path: dist
Expand All @@ -116,7 +116,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: helm-build
path: dist
Expand Down Expand Up @@ -145,7 +145,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: helm-build
path: dist
Expand All @@ -169,7 +169,7 @@ jobs:
runs-on: ubuntu-latest
needs: [ build, test-flink, test-streaming-lite-postgres, test-streaming-lite-hsql, test-request-response ]
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: helm-build
path: dist
Expand All @@ -180,7 +180,7 @@ jobs:
runs-on: ubuntu-latest
needs: [ build, test-flink, test-streaming-lite-postgres, test-streaming-lite-hsql, test-request-response ]
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: helm-build
path: dist
Expand Down
17 changes: 11 additions & 6 deletions src/templates/flink-k8s-operator/delete-flink-deployments.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{{- if and (hasKey .Values "enterprise.flinkK8sOperatorDeploymentManager") .Values.enterprise.flinkK8sOperatorDeploymentManager.enabled }}
{{- if not (and (hasKey .Values.enterprise.flinkK8sOperatorDeploymentManager "keepFlinkDeploymentsOnUninstall") (.Values.enterprise.flinkK8sOperatorDeploymentManager.keepFlinkDeploymentsOnUninstall)) }}
{{- $originalContext := . -}}
{{- with .Values.enterprise -}}
{{- with .flinkK8sOperatorDeploymentManager -}}
{{- if .enabled }}
{{- if not (and (hasKey . "keepFlinkDeploymentsOnUninstall") (.keepFlinkDeploymentsOnUninstall)) }}
apiVersion: batch/v1
kind: Job
metadata:
name: delete-flinkdeployments
labels:
{{ include "nussknacker.labels" . | nindent 4 }}
{{ include "nussknacker.labels" $originalContext | nindent 4 }}
annotations:
"helm.sh/hook": pre-delete
"helm.sh/hook-weight": "0"
Expand All @@ -14,9 +17,9 @@ spec:
template:
metadata:
labels:
{{ include "nussknacker.labels" . | nindent 8 }}
{{ include "nussknacker.labels" $originalContext | nindent 8 }}
spec:
serviceAccountName: {{ include "nussknacker.serviceAccountName" . }}
serviceAccountName: {{ include "nussknacker.serviceAccountName" $originalContext }}
containers:
- name: delete-flinkdeployments
image: bitnami/kubectl:latest
Expand All @@ -25,7 +28,7 @@ spec:
- /bin/sh
- -c
- |
kubectl delete flinkdeployments --all -n {{ .Release.Namespace }}
kubectl delete flinkdeployments --all -n {{ $originalContext.Release.Namespace }}
resources:
limits:
cpu: "100m"
Expand All @@ -37,3 +40,5 @@ spec:
backoffLimit: 1
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{{- if and (hasKey .Values "enterprise.flinkK8sOperatorDeploymentManager") .Values.enterprise.flinkK8sOperatorDeploymentManager.enabled }}
{{- $originalContext := . -}}
{{- with .Values.enterprise -}}
{{- with .flinkK8sOperatorDeploymentManager -}}
{{- if .enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ default "flink-deployment-creator" .Values.enterprise.flinkK8sOperatorDeploymentManager.flinkDeploymentCreatorRole }}
name: {{ default "flink-deployment-creator" .flinkDeploymentCreatorRole }}
labels:
{{ include "nussknacker.labels" . | nindent 4 }}
{{ include "nussknacker.labels" $originalContext | nindent 4 }}
rules:
- apiGroups: ["flink.apache.org"]
resources: ["flinkdeployments"]
verbs: ["create", "delete", "list", "update", "get"]
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
{{- if and (hasKey .Values "enterprise.flinkK8sOperatorDeploymentManager") .Values.enterprise.flinkK8sOperatorDeploymentManager.enabled }}
{{- $originalContext := . -}}
{{- with .Values.enterprise -}}
{{- with .flinkK8sOperatorDeploymentManager -}}
{{- if .enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ default "flink-deployment-creator" .Values.enterprise.flinkK8sOperatorDeploymentManager.flinkDeploymentCreatorRole }}-rolebinding
name: {{ default "flink-deployment-creator" .flinkDeploymentCreatorRole }}-rolebinding
labels:
{{ include "nussknacker.labels" . | nindent 4 }}
{{- include "nussknacker.labels" $originalContext | nindent 4 }}
subjects:
- kind: ServiceAccount
name: {{ include "nussknacker.serviceAccountName" . }}
name: {{ include "nussknacker.serviceAccountName" $originalContext }}
roleRef:
kind: Role
name: {{ default "flink-deployment-creator" .Values.enterprise.flinkK8sOperatorDeploymentManager.flinkDeploymentCreatorRole }}
name: {{ default "flink-deployment-creator" .flinkDeploymentCreatorRole }}
apiGroup: rbac.authorization.k8s.io
{{- end }}
{{- end }}
{{- end }}
11 changes: 8 additions & 3 deletions src/templates/flink-k8s-operator/flink-operator-role.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{{- if and (hasKey .Values "enterprise.flinkK8sOperatorDeploymentManager") .Values.enterprise.flinkK8sOperatorDeploymentManager.enabled }}
{{- $originalContext := . -}}
{{- with .Values.enterprise -}}
{{- with .flinkK8sOperatorDeploymentManager -}}
{{- if .enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ default "flink-operator" .Values.enterprise.flinkK8sOperatorDeploymentManager.flinkOperatorRole }}
name: {{ default "flink-operator" .flinkOperatorRole }}
labels:
{{ include "nussknacker.labels" . | nindent 4 }}
{{ include "nussknacker.labels" $originalContext | nindent 4 }}
rules:
- apiGroups: [""]
resources: ["pods"]
Expand All @@ -15,4 +18,6 @@ rules:
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["create", "get", "list", "watch", "update", "delete"]
{{- end }}
{{- end }}
{{- end }}
15 changes: 10 additions & 5 deletions src/templates/flink-k8s-operator/flink-operator-rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
{{- if and (hasKey .Values "enterprise.flinkK8sOperatorDeploymentManager") .Values.enterprise.flinkK8sOperatorDeploymentManager.enabled }}
{{- $originalContext := . -}}
{{- with .Values.enterprise -}}
{{- with .flinkK8sOperatorDeploymentManager -}}
{{- if .enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ default "flink-operator" .Values.enterprise.flinkK8sOperatorDeploymentManager.flinkOperatorRole }}-rolebinding
name: {{ default "flink-operator" .flinkOperatorRole }}-rolebinding
labels:
{{ include "nussknacker.labels" . | nindent 4 }}
{{- include "nussknacker.labels" $originalContext | nindent 4 }}
subjects:
- kind: ServiceAccount
name: {{ default "flink-service-account" .Values.enterprise.flinkK8sOperatorDeploymentManager.flinkServiceAccount }}
name: {{ default "flink-service-account" .flinkServiceAccount }}
roleRef:
kind: Role
name: {{ default "flink-operator" .Values.enterprise.flinkK8sOperatorDeploymentManager.flinkOperatorRole }}
name: {{ default "flink-operator" .flinkOperatorRole }}
apiGroup: rbac.authorization.k8s.io
{{- end }}
{{- end }}
{{- end }}
11 changes: 8 additions & 3 deletions src/templates/flink-k8s-operator/flink-service-account.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{{- if and (hasKey .Values "enterprise.flinkK8sOperatorDeploymentManager") .Values.enterprise.flinkK8sOperatorDeploymentManager.enabled }}
{{- $originalContext := . -}}
{{- with .Values.enterprise -}}
{{- with .flinkK8sOperatorDeploymentManager -}}
{{- if .enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ default "flink-service-account" .Values.enterprise.flinkK8sOperatorDeploymentManager.flinkServiceAccount }}
name: {{ default "flink-service-account" .flinkServiceAccount }}
labels:
{{ include "nussknacker.labels" . | nindent 4 }}
{{ include "nussknacker.labels" $originalContext | nindent 4 }}
{{- end -}}
{{- end -}}
{{- end -}}
19 changes: 13 additions & 6 deletions src/templates/flink-k8s-operator/jar-shared-volume-pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
{{- if and (hasKey .Values "enterprise.flinkK8sOperatorDeploymentManager") .Values.enterprise.flinkK8sOperatorDeploymentManager.enabled }}
{{- $originalContext := . -}}
{{- with .Values.enterprise -}}
{{- with .flinkK8sOperatorDeploymentManager -}}
{{- if .enabled }}
{{- with .jobJarStorage -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.enterprise.flinkK8sOperatorDeploymentManager.jobJarStorage.pvcName }}
{{- if and (hasKey .Values.enterprise.flinkK8sOperatorDeploymentManager.jobJarStorage "keepAfterUninstall") .Values.enterprise.flinkK8sOperatorDeploymentManager.jobJarStorage.keepAfterUninstall }}
name: {{ .pvcName }}
{{- if and (hasKey . "keepAfterUninstall") .keepAfterUninstall }}
annotations:
"helm.sh/resource-policy": keep
{{- end }}
labels:
{{ include "nussknacker.labels" . | nindent 4 }}
{{ include "nussknacker.labels" $originalContext | nindent 4 }}
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: {{ default "1Gi" .Values.enterprise.flinkK8sOperatorDeploymentManager.jobJarStorage.pvcSize }}
{{- with .Values.enterprise.flinkK8sOperatorDeploymentManager.jobJarStorage.pvcStorageClassName }}
storage: {{ default "1Gi" .pvcSize }}
{{- with .pvcStorageClassName }}
storageClassName: {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
19 changes: 13 additions & 6 deletions src/templates/flink-k8s-operator/job-state-shared-volume-pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
{{- if and (hasKey .Values "enterprise.flinkK8sOperatorDeploymentManager") .Values.enterprise.flinkK8sOperatorDeploymentManager.enabled }}
{{- $originalContext := . -}}
{{- with .Values.enterprise -}}
{{- with .flinkK8sOperatorDeploymentManager -}}
{{- if .enabled }}
{{- with .jobStateStorage -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.enterprise.flinkK8sOperatorDeploymentManager.jobStateStorage.pvcName }}
{{- if and (hasKey .Values.enterprise.flinkK8sOperatorDeploymentManager.jobStateStorage "keepAfterUninstall") .Values.enterprise.flinkK8sOperatorDeploymentManager.jobStateStorage.keepAfterUninstall }}
name: {{ .pvcName }}
{{- if and (hasKey . "keepAfterUninstall") .keepAfterUninstall }}
annotations:
"helm.sh/resource-policy": keep
{{- end }}
labels:
{{ include "nussknacker.labels" . | nindent 4 }}
{{ include "nussknacker.labels" $originalContext | nindent 4 }}
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: {{ default "1Gi" .Values.enterprise.flinkK8sOperatorDeploymentManager.jobStateStorage.pvcSize }}
{{- with .Values.enterprise.flinkK8sOperatorDeploymentManager.jobStateStorage.pvcStorageClassName }}
storage: {{ default "1Gi" .pvcSize }}
{{- with .pvcStorageClassName }}
storageClassName: {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

0 comments on commit f298115

Please sign in to comment.