diff --git a/charts/scalar-manager/.helmignore b/charts/scalar-manager/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/scalar-manager/.helmignore @@ -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/ diff --git a/charts/scalar-manager/Chart.yaml b/charts/scalar-manager/Chart.yaml new file mode 100644 index 00000000..71d6c933 --- /dev/null +++ b/charts/scalar-manager/Chart.yaml @@ -0,0 +1,23 @@ +apiVersion: v2 +name: scalar-manager +description: Scalar Manager +type: application +version: 2.0.0-SNAPSHOT +appVersion: 2.0.0-SNAPSHOT +deprecated: false +icon: https://scalar-labs.com/wp-content/themes/scalar/assets/img/logo_scalar.svg +keywords: + - scalar-manager + - scalardb-cluster + - scalardl-ledger + - scalardl-auditor + - scalar-admin-for-kubernetes +home: https://scalar-labs.com/ +sources: + - https://github.com/scalar-labs/scalar-manager-api + - https://github.com/scalar-labs/scalar-manager-web +maintainers: + - name: Takanori Yokoyama + email: takanori.yokoyama@scalar-labs.com + - name: Plenty Su + email: plenty.su@scalar-labs.com diff --git a/charts/scalar-manager/README.md b/charts/scalar-manager/README.md new file mode 100644 index 00000000..a11926e8 --- /dev/null +++ b/charts/scalar-manager/README.md @@ -0,0 +1,50 @@ +# scalar-manager + +![Version: 2.0.0-SNAPSHOT](https://img.shields.io/badge/Version-2.0.0--SNAPSHOT-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.0.0-SNAPSHOT](https://img.shields.io/badge/AppVersion-2.0.0--SNAPSHOT-informational?style=flat-square) + +Scalar Manager +Current chart version is `2.0.0-SNAPSHOT` + +**Homepage:** + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| api.grafanaKubernetesServiceLabelName | string | `"app.kubernetes.io/name"` | | +| api.grafanaKubernetesServiceLabelValue | string | `"grafana"` | | +| api.grafanaKubernetesServicePortName | string | `"http-web"` | | +| api.helmScalarAdminForKubernetesChartName | string | `"scalar-admin-for-kubernetes"` | | +| api.helmScalarAdminForKubernetesChartVersion | string | `"1.0.0"` | | +| api.helmScalarRepositoryName | string | `"scalar-labs"` | | +| api.helmScalarRepositoryUrl | string | `"https://scalar-labs.github.io/helm-charts"` | | +| api.image.pullPolicy | string | `"IfNotPresent"` | | +| api.image.repository | string | `"ghcr.io/scalar-labs/scalar-manager-api"` | | +| api.image.tag | string | `""` | | +| api.lokiKubernetesServiceLabelName | string | `"app"` | | +| api.lokiKubernetesServiceLabelValue | string | `"loki"` | | +| api.lokiKubernetesServicePortName | string | `"http-metrics"` | | +| api.pausedStateRetentionMaxNumber | string | `"100"` | | +| api.pausedStateRetentionStorage | string | `"configmap"` | | +| api.prometheusKubernetesServiceLabelName | string | `"app"` | | +| api.prometheusKubernetesServiceLabelValue | string | `"kube-prometheus-stack-prometheus"` | | +| api.prometheusKubernetesServicePortName | string | `"http-web"` | | +| fullnameOverride | string | `""` | | +| imagePullSecrets[0].name | string | `"reg-docker-secrets"` | | +| nameOverride | string | `""` | | +| nodeSelector | object | `{}` | | +| podAnnotations | object | `{}` | | +| podLabels | object | `{}` | | +| podSecurityContext | object | `{}` | | +| replicaCount | int | `1` | | +| resources | object | `{}` | | +| securityContext | object | `{}` | | +| service.port | int | `80` | | +| service.type | string | `"LoadBalancer"` | | +| serviceAccount.automount | bool | `true` | | +| serviceAccount.create | bool | `true` | | +| serviceAccount.name | string | `""` | | +| tolerations | list | `[]` | | +| web.image.pullPolicy | string | `"IfNotPresent"` | | +| web.image.repository | string | `"ghcr.io/scalar-labs/scalar-manager-web"` | | +| web.image.tag | string | `""` | | diff --git a/charts/scalar-manager/README.md.gotmpl b/charts/scalar-manager/README.md.gotmpl new file mode 100644 index 00000000..e41d4ff6 --- /dev/null +++ b/charts/scalar-manager/README.md.gotmpl @@ -0,0 +1,12 @@ +{{ template "chart.header" . }} + +{{ template "chart.versionBadge" . }} {{ template "chart.typeBadge" . }} {{ template "chart.appVersionBadge" . }} + +{{ template "chart.description" . }} +Current chart version is `{{ template "chart.version" . }}` + +**Homepage:** + +{{ template "chart.requirementsSection" . }} + +{{ template "chart.valuesSection" . }} diff --git a/charts/scalar-manager/templates/_helpers.tpl b/charts/scalar-manager/templates/_helpers.tpl new file mode 100644 index 00000000..b3d9dd53 --- /dev/null +++ b/charts/scalar-manager/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "scalar-manager.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 "scalar-manager.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 "scalar-manager.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "scalar-manager.labels" -}} +helm.sh/chart: {{ include "scalar-manager.chart" . }} +{{ include "scalar-manager.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "scalar-manager.selectorLabels" -}} +app.kubernetes.io/name: {{ include "scalar-manager.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "scalar-manager.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "scalar-manager.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/scalar-manager/templates/scalar-manager/clusterrole.yaml b/charts/scalar-manager/templates/scalar-manager/clusterrole.yaml new file mode 100644 index 00000000..c988e9e2 --- /dev/null +++ b/charts/scalar-manager/templates/scalar-manager/clusterrole.yaml @@ -0,0 +1,10 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "scalar-manager.fullname" . }} + labels: + {{- include "scalar-manager.labels" . | nindent 4 }} +rules: + - apiGroups: ["", "apps", "batch", "rbac.authorization.k8s.io"] + resources: ["pods", "deployments", "services", "namespaces", "configmaps", "secrets", "cronjobs", "serviceaccounts", "roles", "rolebindings", "jobs"] + verbs: ["get", "list", "create", "patch", "delete", "update"] diff --git a/charts/scalar-manager/templates/scalar-manager/clusterrolebinding.yaml b/charts/scalar-manager/templates/scalar-manager/clusterrolebinding.yaml new file mode 100644 index 00000000..fb1b66f2 --- /dev/null +++ b/charts/scalar-manager/templates/scalar-manager/clusterrolebinding.yaml @@ -0,0 +1,15 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "scalar-manager.fullname" . }} + labels: + {{- include "scalar-manager.labels" . | nindent 4 }} +subjects: + - kind: ServiceAccount + name: {{ include "scalar-manager.fullname" . }} + namespace: {{ .Release.Namespace }} + apiGroup: "" +roleRef: + kind: ClusterRole + name: {{ include "scalar-manager.fullname" . }} + apiGroup: rbac.authorization.k8s.io diff --git a/charts/scalar-manager/templates/scalar-manager/configmap.yaml b/charts/scalar-manager/templates/scalar-manager/configmap.yaml new file mode 100644 index 00000000..d58dac26 --- /dev/null +++ b/charts/scalar-manager/templates/scalar-manager/configmap.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "scalar-manager.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/app: {{ include "scalar-manager.fullname" . }} + {{- include "scalar-manager.labels" . | nindent 4 }} +data: + managed-clusters: "[]" + paused-states: "[]" + paused-states-updated-at: "0" diff --git a/charts/scalar-manager/templates/scalar-manager/deployment.yaml b/charts/scalar-manager/templates/scalar-manager/deployment.yaml new file mode 100644 index 00000000..6f847fed --- /dev/null +++ b/charts/scalar-manager/templates/scalar-manager/deployment.yaml @@ -0,0 +1,101 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "scalar-manager.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "scalar-manager.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "scalar-manager.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/scalar-manager/configmap.yaml") . | sha256sum }} + {{- if .Values.podAnnotations }} + {{- toYaml .Values.podAnnotations | nindent 8 }} + {{- end }} + labels: + {{- include "scalar-manager.selectorLabels" . | nindent 8 }} + {{- if .Values.podLabels }} + {{- toYaml .Values.podLabels | nindent 8 }} + {{- end }} + spec: + restartPolicy: Always + serviceAccountName: {{ include "scalar-manager.serviceAccountName" . }} + automountServiceAccountToken: {{ .Values.serviceAccount.automount }} + terminationGracePeriodSeconds: 90 + containers: + - name: {{ .Chart.Name }}-api + image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag | default .Chart.AppVersion }}" + resources: + {{- toYaml .Values.resources | nindent 12 }} + ports: + - containerPort: 8080 + imagePullPolicy: {{ .Values.api.image.pullPolicy }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + env: + - name: GRAFANA_KUBERNETES_SERVICE_LABEL_NAME + value: {{ .Values.api.grafanaKubernetesServiceLabelName | quote }} + - name: GRAFANA_KUBERNETES_SERVICE_LABEL_VALUE + value: {{ .Values.api.grafanaKubernetesServiceLabelValue | quote }} + - name: GRAFANA_KUBERNETES_SERVICE_PORT_NAME + value: {{ .Values.api.grafanaKubernetesServicePortName | quote }} + - name: PROMETHEUS_KUBERNETES_SERVICE_LABEL_NAME + value: {{ .Values.api.prometheusKubernetesServiceLabelName | quote }} + - name: PROMETHEUS_KUBERNETES_SERVICE_LABEL_VALUE + value: {{ .Values.api.prometheusKubernetesServiceLabelValue | quote }} + - name: PROMETHEUS_KUBERNETES_SERVICE_PORT_NAME + value: {{ .Values.api.prometheusKubernetesServicePortName | quote }} + - name: LOKI_KUBERNETES_SERVICE_LABEL_NAME + value: {{ .Values.api.lokiKubernetesServiceLabelName | quote }} + - name: LOKI_KUBERNETES_SERVICE_LABEL_VALUE + value: {{ .Values.api.lokiKubernetesServiceLabelValue | quote }} + - name: LOKI_KUBERNETES_SERVICE_PORT_NAME + value: {{ .Values.api.lokiKubernetesServicePortName | quote }} + - name: HELM_SCALAR_REPOSITORY_NAME + value: {{ .Values.api.helmScalarRepositoryName | quote }} + - name: HELM_SCALAR_REPOSITORY_URL + value: {{ .Values.api.helmScalarRepositoryUrl | quote }} + - name: HELM_SCALAR_ADMIN_FOR_KUBERNETES_CHART_NAME + value: {{ .Values.api.helmScalarAdminForKubernetesChartName | quote }} + - name : HELM_SCALAR_ADMIN_FOR_KUBERNETES_CHART_VERSION + value: {{ .Values.api.helmScalarAdminForKubernetesChartVersion | quote }} + - name: CONFIG_MAP_LABEL_NAME + value: "app.kubernetes.io/app" + - name: CONFIG_MAP_LABEL_VALUE + value: {{ include "scalar-manager.fullname" . | quote }} + - name: PAUSED_STATE_RETENTION_STORAGE + value: {{ .Values.api.pausedStateRetentionStorage | quote }} + - name: PAUSED_STATE_RETENTION_MAX_NUMBER + value: {{ .Values.api.pausedStateRetentionMaxNumber | quote }} + - name: {{ .Chart.Name }}-web + image: "{{ .Values.web.image.repository }}:{{ .Values.web.image.tag | default .Chart.AppVersion }}" + resources: + {{- toYaml .Values.resources | nindent 12 }} + ports: + - containerPort: 3000 + imagePullPolicy: {{ .Values.web.image.pullPolicy }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- 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/scalar-manager/templates/scalar-manager/service.yaml b/charts/scalar-manager/templates/scalar-manager/service.yaml new file mode 100644 index 00000000..eea2cf3d --- /dev/null +++ b/charts/scalar-manager/templates/scalar-manager/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "scalar-manager.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "scalar-manager.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - protocol: TCP + name: web + port: {{ .Values.service.port }} + targetPort: 3000 + selector: + {{- include "scalar-manager.selectorLabels" . | nindent 4 }} diff --git a/charts/scalar-manager/templates/scalar-manager/serviceaccount.yaml b/charts/scalar-manager/templates/scalar-manager/serviceaccount.yaml new file mode 100644 index 00000000..c1a96476 --- /dev/null +++ b/charts/scalar-manager/templates/scalar-manager/serviceaccount.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "scalar-manager.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "scalar-manager.labels" . | nindent 4 }} diff --git a/charts/scalar-manager/values.schema.json b/charts/scalar-manager/values.schema.json new file mode 100644 index 00000000..58130444 --- /dev/null +++ b/charts/scalar-manager/values.schema.json @@ -0,0 +1,155 @@ +{ + "$schema": "http://json-schema.org/schema#", + "type": "object", + "properties": { + "api": { + "type": "object", + "properties": { + "grafanaKubernetesServiceLabelName": { + "type": "string" + }, + "grafanaKubernetesServiceLabelValue": { + "type": "string" + }, + "grafanaKubernetesServicePortName": { + "type": "string" + }, + "helmScalarAdminForKubernetesChartName": { + "type": "string" + }, + "helmScalarAdminForKubernetesChartVersion": { + "type": "string" + }, + "helmScalarRepositoryName": { + "type": "string" + }, + "helmScalarRepositoryUrl": { + "type": "string" + }, + "image": { + "type": "object", + "properties": { + "pullPolicy": { + "type": "string" + }, + "repository": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "lokiKubernetesServiceLabelName": { + "type": "string" + }, + "lokiKubernetesServiceLabelValue": { + "type": "string" + }, + "lokiKubernetesServicePortName": { + "type": "string" + }, + "pausedStateRetentionMaxNumber": { + "type": "string" + }, + "pausedStateRetentionStorage": { + "type": "string" + }, + "prometheusKubernetesServiceLabelName": { + "type": "string" + }, + "prometheusKubernetesServiceLabelValue": { + "type": "string" + }, + "prometheusKubernetesServicePortName": { + "type": "string" + } + } + }, + "fullnameOverride": { + "type": "string" + }, + "imagePullSecrets": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + } + } + }, + "nameOverride": { + "type": "string" + }, + "nodeSelector": { + "type": "object" + }, + "podAnnotations": { + "type": "object" + }, + "podLabels": { + "type": "object" + }, + "podSecurityContext": { + "type": "object" + }, + "replicaCount": { + "type": "integer" + }, + "resources": { + "type": "object" + }, + "securityContext": { + "type": "object" + }, + "service": { + "type": "object", + "properties": { + "port": { + "type": "integer" + }, + "type": { + "type": "string" + } + } + }, + "serviceAccount": { + "type": "object", + "properties": { + "automount": { + "type": "boolean" + }, + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + } + } + }, + "tolerations": { + "type": "array" + }, + "web": { + "type": "object", + "properties": { + "image": { + "type": "object", + "properties": { + "pullPolicy": { + "type": "string" + }, + "repository": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + } +} diff --git a/charts/scalar-manager/values.yaml b/charts/scalar-manager/values.yaml new file mode 100644 index 00000000..a3c1fc33 --- /dev/null +++ b/charts/scalar-manager/values.yaml @@ -0,0 +1,89 @@ +# Default values for scalar-manager. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 + +nameOverride: "" + +fullnameOverride: "" + +podAnnotations: {} + +podLabels: {} + +podSecurityContext: + {} + # fsGroup: 2000 + +securityContext: + {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +nodeSelector: {} + +tolerations: [] + +service: + type: LoadBalancer + port: 80 + +serviceAccount: + # Specifies whether a service account should be created + create: true + + # Automatically mount a ServiceAccount's API credentials? + automount: true + + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +api: + image: + repository: ghcr.io/scalar-labs/scalar-manager-api + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + grafanaKubernetesServiceLabelName: "app.kubernetes.io/name" + grafanaKubernetesServiceLabelValue: "grafana" + grafanaKubernetesServicePortName: "http-web" + prometheusKubernetesServiceLabelName: "app" + prometheusKubernetesServiceLabelValue: "kube-prometheus-stack-prometheus" + prometheusKubernetesServicePortName: "http-web" + lokiKubernetesServiceLabelName: "app" + lokiKubernetesServiceLabelValue: "loki" + lokiKubernetesServicePortName: "http-metrics" + helmScalarRepositoryName: "scalar-labs" + helmScalarRepositoryUrl: "https://scalar-labs.github.io/helm-charts" + helmScalarAdminForKubernetesChartName: "scalar-admin-for-kubernetes" + helmScalarAdminForKubernetesChartVersion: "1.0.0" + pausedStateRetentionStorage: "configmap" + pausedStateRetentionMaxNumber: "100" + +web: + image: + repository: ghcr.io/scalar-labs/scalar-manager-web + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: + - name: reg-docker-secrets + +resources: + {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi