Skip to content

Commit

Permalink
add goinception (#20)
Browse files Browse the repository at this point in the history
* add goinception

* add maintainers and home

* ci

* fix blank lines
  • Loading branch information
LeoQuote authored May 27, 2022
1 parent f569ad4 commit bfe0444
Show file tree
Hide file tree
Showing 8 changed files with 334 additions and 0 deletions.
22 changes: 22 additions & 0 deletions charts/goinception/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
9 changes: 9 additions & 0 deletions charts/goinception/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: goinception
version: 0.1.0
home: https://github.com/hanchuanchuan/goInception
maintainers:
- name: LeoQuote
- name: AceAttorney
15 changes: 15 additions & 0 deletions charts/goinception/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
1. Get the application URL by running these commands:
{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "goinception.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 svc -w {{ include "goinception.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "goinception.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
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 "goinception.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 port-forward $POD_NAME 8080:80
{{- end }}
32 changes: 32 additions & 0 deletions charts/goinception/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "goinception.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 "goinception.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 "goinception.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
15 changes: 15 additions & 0 deletions charts/goinception/templates/configMap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.configMap.enabled -}}
kind: ConfigMap
apiVersion: v1
metadata:
name: goinception-config
labels:
app.kubernetes.io/name: {{ include "goinception.name" . }}
helm.sh/chart: {{ include "goinception.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.configMap.data }}
data:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
73 changes: 73 additions & 0 deletions charts/goinception/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "goinception.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "goinception.name" . }}
helm.sh/chart: {{ include "goinception.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "goinception.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "goinception.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
initContainers:
- name: override-configs
image: busybox:1.28
{{- with .Values.initEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
command: ['sh', '-c',
'sed "s/BACKUP_PASSWORD_PLACEHOLDER/${BACKUP_PASSWORD}/g" /etc/goinception-template/config.toml.template > /etc/goinception/config.toml']
volumeMounts:
- name: goinception-config-volume
mountPath: /etc/goinception
- name: goinception-config-template
mountPath: /etc/goinception-template
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: goinception
containerPort: 4000
protocol: TCP
livenessProbe:
tcpSocket:
port: goinception
resources:
{{- toYaml .Values.resources | nindent 12 }}
command:
- "/usr/local/bin/dumb-init"
- "/goInception"
- "--config=/etc/goinception/config.toml"
volumeMounts:
- name: goinception-config-volume
mountPath: /etc/goinception
volumes:
- name: goinception-config-volume
emptyDir: {}
- name: goinception-config-template
configMap:
name: goinception-config
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
19 changes: 19 additions & 0 deletions charts/goinception/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "goinception.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "goinception.name" . }}
helm.sh/chart: {{ include "goinception.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.targetPort }}
protocol: TCP
name: goinception
selector:
app.kubernetes.io/name: {{ include "goinception.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
149 changes: 149 additions & 0 deletions charts/goinception/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Default values for goinception.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository: hanchuanchuan/goinception
tag: latest
pullPolicy: IfNotPresent

nameOverride: ""
fullnameOverride: ""

service:
type: ClusterIP
port: 4000
targetPort: 4000

initEnv:
- name: BACKUP_PASSWORD
value: "my-password"
# - name: xxx
# value: xxx

resources: {}

configMap:
enabled: true
data:
config.toml.template: |-
host="0.0.0.0"
advertise_address=""
port=4000
[inc]
check_autoincrement_datatype=true
check_autoincrement_init_value=true
check_autoincrement_name=true
check_column_comment=true
check_column_default_value=true
check_column_position_change=true
check_column_type_change=true
check_dml_limit=true
check_dml_orderby=true
check_dml_where=true
check_identifier=true
check_index_prefix=true
check_insert_field=true
check_primary_key=true
check_table_comment=true
check_timestamp_default=true
check_timestamp_count=false
enable_autoincrement_unsigned=true
enable_blob_type=true
enable_column_charset=true
enable_drop_database=true
enable_drop_table=true
enable_enum_set_bit=false
enable_fingerprint=true
enable_foreign_key=false
enable_json_type=true
enable_identifer_keyword=false
enable_not_innodb=false
enable_nullable=false
enable_null_index_name=false
enable_orderby_rand=true
enable_partition_table=true
enable_pk_columns_only_int=true
enable_select_star=false
enable_set_charset=true
enable_set_collation=false
enable_set_engine=false
max_char_length=0
max_insert_rows=0
max_keys=5
max_key_parts=5
max_update_rows=5000
max_primary_key_parts=1
max_allowed_packet=33554432
merge_alter_table=true
check_float_double=true
support_charset="utf8,utf8mb4"
support_collation="utf8_general_ci,utf8mb4_general_ci"
backup_host="archery-mysql"
backup_port=3306
backup_user="root"
backup_password="BACKUP_PASSWORD_PLACEHOLDER"
#安全更新是否开启.
#-1表示不做操作,基于远端数据库[默认值]
#0表示关闭安全更新
#1表示开启安全更新
sql_safe_updates=0
#lang="en-US"
lang="zh-CN"
#是否记录全量日志
general_log=false
#开启统计功能
enable_sql_statistic=true
[inc_level]
er_cant_set_engine=2
er_cant_set_collation=2
er_table_must_have_comment=2
er_column_have_no_comment=2
er_table_must_have_pk=2
er_index_name_idx_prefix=1
er_index_name_uniq_prefix=1
er_autoinc_unsigned=2
er_alter_table_once=2
er_pk_too_many_parts=2
[osc]
osc_on=false
osc_min_table_size=16
osc_print_none=false
osc_bin_dir="/usr/local/bin"
[ghost]
ghost_on=false
ghost_allow_on_master=true
ghost_assume_rbr=true
ghost_chunk_size=1000
ghost_concurrent_rowcount=true
ghost_cut_over="atomic"
ghost_cut_over_lock_timeout_seconds=3
ghost_default_retries=60
ghost_heartbeat_interval_millis=500
ghost_max_lag_millis=1500
ghost_approve_renamed_columns=true
ghost_exponential_backoff_max_interval=64
ghost_dml_batch_size=10
[log]
# Log level: debug, info, warn, error, fatal.
level="error"
# Log format, one of json, text, console.
format="console"
# 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

nodeSelector: {}

tolerations: []

affinity: {}

0 comments on commit bfe0444

Please sign in to comment.