diff --git a/deploy/helm/README.md b/deploy/helm/README.md new file mode 100644 index 0000000000..69564ea60a --- /dev/null +++ b/deploy/helm/README.md @@ -0,0 +1,19 @@ +# Deploy StreamPark on k8s + +### 1. create template + +```shell +helm template streampark/ -n default -f streampark/values.yaml --output-dir ./result +``` + +### 2. apply + +```shell +kubectl apply -f result/streampark/templates +``` + +### 3. open WebUI + +http://${host}:10000 + +#### [more detail](streampark/templates/NOTES.txt) diff --git a/deploy/helm/streampark/templates/ingress.yaml b/deploy/helm/streampark/templates/ingress.yaml index 5c9ca778cf..e4b99d23ce 100644 --- a/deploy/helm/streampark/templates/ingress.yaml +++ b/deploy/helm/streampark/templates/ingress.yaml @@ -15,23 +15,27 @@ # limitations under the License. # {{- if .Values.ingress.enabled }} -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ include "streampark.name" . }} + namespace: {{ .Release.Namespace }} labels: {{- include "streampark.labels" . | nindent 4 }} annotations: - nginx.ingress.kubernetes.io/configuration-snippet: {{ .Values.nginx.ingress.kubernetes.configurationSnippet }} - nginx.ingress.kubernetes.io/proxy-body-size: {{ .Values.nginx.ingress.kubernetes.proxyBbodySize }} - nginx.ingress.kubernetes.io/rewrite-target: {{ .Values.nginx.ingress.kubernetes.rewriteTarget }} + {{- with .Values.ingress.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} spec: rules: - host: {{ .Values.ingress.host }} http: paths: - - backend: - serviceName: {{ .Values.service.name }} - servicePort: {{ .Values.spec.name }} - path: {{ .Values.ingress.path }} + - backend: + service: + name: {{ .Values.service.name }} + port: + name: {{ .Values.spec.name }} + path: {{ .Values.ingress.path }} + pathType: {{ .Values.ingress.pathType }} {{- end }} diff --git a/deploy/helm/streampark/templates/streampark.yml b/deploy/helm/streampark/templates/streampark.yml index 5d7bcb9164..fa8a5d4df7 100755 --- a/deploy/helm/streampark/templates/streampark.yml +++ b/deploy/helm/streampark/templates/streampark.yml @@ -22,7 +22,7 @@ metadata: labels: {{- include "streampark.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicaCount}} + replicas: {{ .Values.spec.replicaCount }} selector: matchLabels: {{- include "streampark.selectorLabels" . | nindent 6 }} @@ -57,11 +57,10 @@ spec: containerPort: {{ .Values.spec.containerPort }} protocol: TCP env: - - name: TZ - value: {{ .Values.timezone }} + {{- toYaml .Values.spec.container.env | nindent 12 }} securityContext: privileged: false - command: ["bash","-c","bash bin/startup.sh"] + command: ["bash","-c","bash ./bin/streampark.sh start_docker"] {{- if .Values.spec.livenessProbe.enabled }} livenessProbe: exec: @@ -83,11 +82,10 @@ spec: failureThreshold: {{ .Values.spec.readinessProbe.failureThreshold }} {{- end }} volumeMounts: - - name: volume-docker - mountPath: /var/run/docker.sock - readOnly: true - name: streampark-default-config-volume - mountPath: /streampark/conf + mountPath: /usr/local/service/streampark/conf + resources: + {{- toYaml .Values.spec.resources | nindent 12 }} volumes: - name: streampark-default-config-volume configMap: @@ -109,9 +107,6 @@ spec: path: spy.properties - key: ValidationMessages.properties path: ValidationMessages.properties - - name: volume-docker - hostPath: - path: /var/run/docker.sock - type: "" + diff --git a/deploy/helm/streampark/values.yaml b/deploy/helm/streampark/values.yaml index 915811c036..a8e4392475 100644 --- a/deploy/helm/streampark/values.yaml +++ b/deploy/helm/streampark/values.yaml @@ -18,18 +18,40 @@ # When enabled RBAC is only created for said namespaces, otherwise it is done for the cluster scope. # watchNamespaces: ["streampark"] -timezone: "Asia/Shanghai" - image: repository: "apache/streampark" pullPolicy: "IfNotPresent" - tag: "2.2.0-SNAPSHOT" + tag: "2.1.1" pullSecret: "" rbac: create: true spec: + container: + env: [ + { + name: TZ, + value: "Asia/Shanghai" + }, + { + name: DOCKER_HOST, + value: "tcp://localhost:2375" + }, + { + name: LANG, + value: en_US.UTF-8 + }, + { + name: LANGUAGE, + value: en_US:en + }, + { + name: LC_ALL, + value: en_US.UTF-8 + } + ] + replicaCount: 1 containerPort: 10000 name: rest @@ -42,7 +64,17 @@ spec: tolerations: [ ] ## Affinity is a group of affinity scheduling rules. If specified, the pod's scheduling constraints. ## More info: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#affinity-v1-core - resources: { } + resources: { + limits: { + memory: "1Gi", + cpu: "1" + }, + requests: { + memory: "1Gi", + cpu: "1" + } + } + # resources: # limits: # memory: "2Gi" @@ -72,10 +104,18 @@ spec: successThreshold: "1" ingress: - enabled: false + enabled: true host: "streampark.apache.org" - path: "/streampark" - annotations: {} + path: "/streampark(/|$)(.*)" + pathType: "ImplementationSpecific" + annotations: { + nginx.ingress.kubernetes.io/rewrite-target: "/$2", + nginx.ingress.kubernetes.io/proxy-body-size: "1024m", + ## fix swagger 404: https://github.com/springdoc/springdoc-openapi/issues/1741 + ## add rewrite ^/v3/(.*)$ /streampark/v3/$1 redirect; + nginx.ingress.kubernetes.io/configuration-snippet: 'rewrite ^(/streampark)$ $1/ permanent;', + kubernetes.io/ingress.class: "nginx" + } service: ## type determines how the Service is exposed. Defaults to ClusterIP. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer @@ -96,9 +136,3 @@ streamParkServiceAccount: annotations: {} name: "streampark" -nginx: - ingress: - kubernetes: - configurationSnippet: "rewrite ^(/streampark)$ $1/ permanent;" - proxyBbodySize: "1024m" - rewriteTarget: "/$2" diff --git a/streampark-console/streampark-console-service/src/main/assembly/bin/streampark.sh b/streampark-console/streampark-console-service/src/main/assembly/bin/streampark.sh index 84d2247f97..7e7c31545c 100755 --- a/streampark-console/streampark-console-service/src/main/assembly/bin/streampark.sh +++ b/streampark-console/streampark-console-service/src/main/assembly/bin/streampark.sh @@ -622,11 +622,12 @@ main() { echo_r "Unknown command: $1" echo_w "Usage: streampark.sh ( commands ... )" echo_w "commands:" - echo_w " start \$conf Start StreamPark with application config." + echo_w " start \$conf Start StreamPark with application config." echo_w " stop Stop StreamPark, wait up to 3 seconds and then use kill -KILL if still running" + echo_w " start_docker start in docker or k8s mode" echo_w " status StreamPark status" echo_w " debug StreamPark start with debug mode,start debug mode, like: bash streampark.sh debug 10002" - echo_w " restart \$conf restart StreamPark with application config." + echo_w " restart \$conf restart StreamPark with application config." exit 0 ;; esac diff --git a/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/helper/KubernetesDeploymentHelper.scala b/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/helper/KubernetesDeploymentHelper.scala index dc23a0f2a8..8e622fe048 100644 --- a/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/helper/KubernetesDeploymentHelper.scala +++ b/streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/helper/KubernetesDeploymentHelper.scala @@ -58,7 +58,13 @@ object KubernetesDeploymentHelper extends Logger { def getDeploymentStatusChanges(nameSpace: String, deploymentName: String): Boolean = { Try { val pods = getPods(nameSpace, deploymentName) - pods.head.getStatus.getContainerStatuses.head.getLastState.getTerminated != null + val podStatus = pods.head.getStatus + podStatus.getPhase match { + case "Unknown" => return true + case "Failed" => return true + case "Pending" => return false + case _ => podStatus.getContainerStatuses.head.getLastState.getTerminated != null + } }.getOrElse(true) }