diff --git a/charts/hive-metastore/Chart.yaml b/charts/hive-metastore/Chart.yaml new file mode 100644 index 0000000..a56ab18 --- /dev/null +++ b/charts/hive-metastore/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v2 +name: hive-metastore +description: |- + Helm chart to deploy [hive-metastore](https://hive.apache.org/). +type: application +version: 0.0.1 +appVersion: 2.3.9-2.10.1 +home: https://github.com/slamdev/helm-charts/tree/master/charts/hive-metastore +icon: https://hive.apache.org/images/hive_logo_medium.jpg +maintainers: + - name: slamdev + email: valentin.fedoskin@gmail.com diff --git a/charts/hive-metastore/README.md b/charts/hive-metastore/README.md new file mode 100644 index 0000000..ed8fc58 --- /dev/null +++ b/charts/hive-metastore/README.md @@ -0,0 +1,46 @@ +# hive-metastore + +![Version: 0.0.1](https://img.shields.io/badge/Version-0.0.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.3.9-2.10.1](https://img.shields.io/badge/AppVersion-2.3.9--2.10.1-informational?style=flat-square) + +Helm chart to deploy [hive-metastore](https://hive.apache.org/). + +**Homepage:** + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| slamdev | valentin.fedoskin@gmail.com | | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | affinity for scheduler pod assignment | +| env | list | `[]` | additional environment variables for the deployment | +| fullnameOverride | string | `""` | full name of the chart. | +| hiveSiteXml | string | `"\n\n\n"` | | +| image.pullPolicy | string | `"IfNotPresent"` | image pull policy | +| image.repository | string | `"slamdev/apache-hive"` | image repository | +| image.tag | string | `""` | image tag (chart's appVersion value will be used if not set) | +| imagePullSecrets | list | `[]` | image pull secret for private images | +| ingress.annotations | object | `{}` | ingress annotations | +| ingress.enabled | bool | `false` | enables Ingress for hive-metastore | +| ingress.hosts | list | `[]` | ingress accepted hostnames | +| ingress.tls | list | `[]` | ingress TLS configuration | +| nameOverride | string | `""` | override name of the chart | +| nodeSelector | object | `{}` | node for scheduler pod assignment | +| podSecurityContext | object | `{}` | specifies security settings for a pod | +| replicaCount | int | `1` | number of replicas for flux-notifier deployment. | +| resources | object | `{}` | custom resource configuration | +| schematool.dbType | string | `"postgres"` | schematool database type | +| schematool.enabled | bool | `false` | run schematool as int container | +| securityContext | object | `{}` | specifies security settings for a container | +| service.port | int | `9083` | service port | +| service.type | string | `"ClusterIP"` | service type | +| serviceAccount.annotations | object | `{}` | annotations to add to the service account | +| serviceAccount.create | bool | `false` | specifies whether a service account should be created | +| serviceAccount.name | string | `nil` | the name of the service account to use; if not set and create is true, a name is generated using the fullname template | +| tolerations | list | `[]` | tolerations for scheduler pod assignment | +| volumeMounts | list | `[]` | additional volume mounts | +| volumes | list | `[]` | additional volumes | diff --git a/charts/hive-metastore/templates/NOTES.txt b/charts/hive-metastore/templates/NOTES.txt new file mode 100644 index 0000000..4dee950 --- /dev/null +++ b/charts/hive-metastore/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "hive-metastore.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "hive-metastore.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "hive-metastore.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "hive-metastore.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/hive-metastore/templates/_helpers.tpl b/charts/hive-metastore/templates/_helpers.tpl new file mode 100644 index 0000000..688a8aa --- /dev/null +++ b/charts/hive-metastore/templates/_helpers.tpl @@ -0,0 +1,70 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "hive-metastore.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 "hive-metastore.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 "hive-metastore.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "hive-metastore.labels" -}} +helm.sh/chart: {{ include "hive-metastore.chart" . }} +{{ include "hive-metastore.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "hive-metastore.selectorLabels" -}} +app.kubernetes.io/name: {{ include "hive-metastore.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "hive-metastore.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "hive-metastore.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} + +{{/* +Create the tag for the docker image to use +*/}} +{{- define "hive-metastore.tag" -}} +{{- .Values.image.tag | default .Chart.AppVersion -}} +{{- end -}} diff --git a/charts/hive-metastore/templates/configmap.yaml b/charts/hive-metastore/templates/configmap.yaml new file mode 100644 index 0000000..9a51e23 --- /dev/null +++ b/charts/hive-metastore/templates/configmap.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "hive-metastore.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "hive-metastore.labels" . | nindent 4 }} +data: + hive-site.xml: | + {{ .Values.hiveSiteXml | nindent 4 }} diff --git a/charts/hive-metastore/templates/deployment.yaml b/charts/hive-metastore/templates/deployment.yaml new file mode 100644 index 0000000..a541fff --- /dev/null +++ b/charts/hive-metastore/templates/deployment.yaml @@ -0,0 +1,116 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "hive-metastore.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "hive-metastore.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "hive-metastore.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "hive-metastore.selectorLabels" . | nindent 8 }} + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "hive-metastore.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + initContainers: + - name: expand-configs + image: tempire/alpine-perl:3.14.0 + command: + - sh + args: + - -c + - cp /tmp/hive-site.xml /opt/hive-configs/ && perl -pi -e 's/\${env:([_A-Z0-9]+)}/$ENV{$1}/g' /opt/hive-configs/hive-site.xml + {{- with .Values.env }} + env: + {{- toYaml . | nindent 12 }} + {{- end }} + volumeMounts: + - name: hive-config-map + mountPath: /tmp/hive-site.xml + subPath: hive-site.xml + - name: hive-configs + mountPath: /opt/hive-configs + {{- if .Values.schematool.enabled -}} + - name: schematool + image: "{{ .Values.image.repository }}:{{ include "hive-metastore.tag" . }}" + command: + - sh + args: + - -c + - schematool -dbType {{ .Values.schematool.dbType }} -initSchema || true + env: + - name: HIVE_CONF_DIR + value: /opt/hive-configs + volumeMounts: + - name: hive-configs + mountPath: /opt/hive-configs + {{- end -}} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ include "hive-metastore.tag" . }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - --service + - metastore + ports: + - name: thrift + containerPort: 9083 + protocol: TCP + livenessProbe: + tcpSocket: + port: thrift + readinessProbe: + tcpSocket: + port: thrift + startupProbe: + tcpSocket: + port: thrift + resources: + {{- toYaml .Values.resources | nindent 12 }} + env: + - name: HIVE_CONF_DIR + value: /opt/hive-configs + {{- with .Values.env }} + {{- toYaml . | nindent 12 }} + {{- end }} + volumeMounts: + - name: hive-configs + mountPath: /opt/hive-configs + {{- with .Values.volumeMounts }} + {{- toYaml . | nindent 12 }} + {{- end }} + volumes: + - name: hive-configs + emptyDir: {} + - name: hive-config-map + configMap: + name: {{ include "hive-metastore.fullname" . }} + {{- with .Values.volumes }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/hive-metastore/templates/ingress.yaml b/charts/hive-metastore/templates/ingress.yaml new file mode 100644 index 0000000..b2fd26a --- /dev/null +++ b/charts/hive-metastore/templates/ingress.yaml @@ -0,0 +1,53 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "hive-metastore.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: extensions/v1beta1 +{{- else if semverCompare "<1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: networking.k8s.io/v1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "hive-metastore.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + {{- if semverCompare "<1.19-0" $.Capabilities.KubeVersion.GitVersion }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- else }} + pathType: Prefix + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/hive-metastore/templates/service.yaml b/charts/hive-metastore/templates/service.yaml new file mode 100644 index 0000000..6e2009c --- /dev/null +++ b/charts/hive-metastore/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "hive-metastore.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "hive-metastore.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: thrift + protocol: TCP + name: thrift + selector: + {{- include "hive-metastore.selectorLabels" . | nindent 4 }} diff --git a/charts/hive-metastore/templates/serviceaccount.yaml b/charts/hive-metastore/templates/serviceaccount.yaml new file mode 100644 index 0000000..a77ac4a --- /dev/null +++ b/charts/hive-metastore/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "hive-metastore.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "hive-metastore.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end -}} diff --git a/charts/hive-metastore/values.yaml b/charts/hive-metastore/values.yaml new file mode 100644 index 0000000..22db2f3 --- /dev/null +++ b/charts/hive-metastore/values.yaml @@ -0,0 +1,105 @@ +image: + # image.repository -- image repository + repository: slamdev/apache-hive + # image.tag -- image tag (chart's appVersion value will be used if not set) + tag: "" + # image.pullPolicy -- image pull policy + pullPolicy: IfNotPresent + +# imagePullSecrets -- image pull secret for private images +imagePullSecrets: [] +# nameOverride -- override name of the chart +nameOverride: "" +# fullnameOverride -- full name of the chart. +fullnameOverride: "" + +serviceAccount: + # serviceAccount.create -- specifies whether a service account should be created + create: false + # serviceAccount.annotations -- annotations to add to the service account + annotations: {} + # serviceAccount.name -- the name of the service account to use; if not set and create is true, a name is generated using the fullname template + name: + +# podSecurityContext -- specifies security settings for a pod +podSecurityContext: {} + # fsGroup: 2000 + +# securityContext -- specifies security settings for a container +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + # service.type -- service type + type: ClusterIP + # service.port -- service port + port: 9083 + +ingress: + # ingress.enabled -- enables Ingress for hive-metastore + enabled: false + # ingress.annotations -- ingress annotations + annotations: {} + # kubernetes.io/ingress.class: hive-metastore + # kubernetes.io/tls-acme: "true" + # ingress.hosts -- ingress accepted hostnames + hosts: [] + # - host: chart-example.local + # paths: [] + # ingress.tls -- ingress TLS configuration + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +# replicaCount -- number of replicas for flux-notifier deployment. +replicaCount: 1 + +# resources -- custom resource configuration +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +# nodeSelector -- node for scheduler pod assignment +nodeSelector: {} + +# tolerations -- tolerations for scheduler pod assignment +tolerations: [] + +# affinity -- affinity for scheduler pod assignment +affinity: {} + +# volumeMounts -- additional volume mounts +volumeMounts: [] + # - name: cache + # mountPath: /data + +# volumes -- additional volumes +volumes: [] + # - name: cache + # emptyDir: {} + +# env -- additional environment variables for the deployment +env: [] + # - name: SAMPLE + # value: text + +hiveSiteXml: | + + + + +schematool: + # schematool.enabled -- run schematool as int container + enabled: false + # schematool.dbType -- schematool database type + dbType: postgres