feat: add chart source
This commit is contained in:
8
templates/NOTES.txt
Normal file
8
templates/NOTES.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
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 }}{{ .path }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
62
templates/_helpers.tpl
Normal file
62
templates/_helpers.tpl
Normal file
@@ -0,0 +1,62 @@
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "chart.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 "chart.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 "chart.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "chart.labels" -}}
|
||||
helm.sh/chart: {{ include "chart.chart" . }}
|
||||
{{ include "chart.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "chart.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "chart.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "chart.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "chart.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
163
templates/configmap.yaml
Normal file
163
templates/configmap.yaml
Normal file
@@ -0,0 +1,163 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{.Release.Name}}-nginx-config
|
||||
data:
|
||||
default.conf: |
|
||||
server {
|
||||
listen 8080;
|
||||
server_name {{ if .Values.ingress.enabled }}{{ (index .Values.ingress.hosts 0).host }}{{ else }}_{{ end }};
|
||||
|
||||
root /app/dist;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /health {
|
||||
return 200 "ok";
|
||||
}
|
||||
|
||||
location /app/uploads/ {
|
||||
alias /app/uploads/;
|
||||
autoindex off;
|
||||
access_log off;
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, must-revalidate";
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://{{.Release.Name}}-backend.{{.Release.Namespace}}.svc.cluster.local/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Authorization $http_authorization;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{.Release.Name}}-application-config
|
||||
data:
|
||||
application.yml: |
|
||||
server:
|
||||
port: {{ .Values.backend.service.port }}
|
||||
tomcat:
|
||||
threads:
|
||||
max: 50
|
||||
min-spare: 5
|
||||
|
||||
jwt:
|
||||
secret: ${JWT_SECRET}
|
||||
issuer: ${JWT_ISSUER}
|
||||
subject: ${JWT_SUBJECT}
|
||||
expire: ${JWT_EXPIRE}
|
||||
|
||||
upload:
|
||||
dir: ${UPLOAD_DIR}
|
||||
|
||||
spring:
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 50MB
|
||||
datasource:
|
||||
driver-class-name: org.postgresql.Driver
|
||||
url: jdbc:postgresql://{{.Release.Name}}-postgresql.{{.Release.Namespace}}.svc.cluster.local:5432/postgres
|
||||
username: ${DB_USER_NAME}
|
||||
password: ${DB_USER_PWD}
|
||||
hikari:
|
||||
maximum-pool-size: 5
|
||||
minimum-idle: 2
|
||||
|
||||
jackson:
|
||||
time-zone: Asia/Shanghai
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
|
||||
mail:
|
||||
protocol: smtps
|
||||
port: ${MAIL_PORT}
|
||||
default-encoding: utf-8
|
||||
host: ${MAIL_HOST}
|
||||
username: ${MAIL_USERNAME}
|
||||
password: ${MAIL_USER_PWD}
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
auth: true
|
||||
ssl:
|
||||
enable: true
|
||||
required: true
|
||||
protocols: TLSv1.2
|
||||
connectiontimeout: 5000
|
||||
timeout: 5000
|
||||
writetimeout: 5000
|
||||
debug: true
|
||||
|
||||
mybatis-plus:
|
||||
global-config:
|
||||
db-config:
|
||||
table-prefix: ""
|
||||
id-type: auto
|
||||
configuration:
|
||||
map-underscore-to-camel-case: false
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
logging:
|
||||
level:
|
||||
org:
|
||||
springframework:
|
||||
security: DEBUG
|
||||
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: blog-db-sql
|
||||
data:
|
||||
init.sql: |
|
||||
SET client_min_messages TO warning;
|
||||
CREATE TABLE "articles" (
|
||||
"id" bigserial,
|
||||
"title" varchar(50) NOT NULL,
|
||||
"cover" varchar(255) DEFAULT '{{.Values.web.default.cover}}',
|
||||
"content" text,
|
||||
"published" date DEFAULT CURRENT_DATE,
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
CREATE TABLE "news" (
|
||||
"id" bigserial,
|
||||
"title" varchar(50) NOT NULL,
|
||||
"cover" varchar(255) DEFAULT '{{.Values.web.default.cover}}',
|
||||
"content" text,
|
||||
"published" date DEFAULT CURRENT_DATE,
|
||||
"related" varchar(255),
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
CREATE TABLE "users" (
|
||||
"id" bigserial,
|
||||
"name" varchar(50) NOT NULL,
|
||||
"profile" varchar(255) NOT NULL DEFAULT '{{.Values.web.default.avatar}}',
|
||||
"account" varchar(255) NOT NULL UNIQUE,
|
||||
"password" varchar(255) NOT NULL,
|
||||
"ip" varchar(50),
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
CREATE TABLE "comments" (
|
||||
"id" bigserial,
|
||||
"content" varchar(255) NOT NULL,
|
||||
"published" date DEFAULT CURRENT_DATE,
|
||||
"u_id" int8,
|
||||
"a_id" int8 NOT NULL,
|
||||
PRIMARY KEY ("id"),
|
||||
CONSTRAINT fk_comments_articles FOREIGN KEY ("a_id") REFERENCES "articles" ("id"),
|
||||
CONSTRAINT fk_comments_users FOREIGN KEY ("u_id") REFERENCES "users" ("id")
|
||||
);
|
||||
|
||||
196
templates/deployment.yaml
Normal file
196
templates/deployment.yaml
Normal file
@@ -0,0 +1,196 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{.Release.Name}}-web
|
||||
namespace: {{.Release.Namespace}}
|
||||
labels:
|
||||
app.kubernetes.io/component: web
|
||||
{{- include "chart.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.web.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/component: web
|
||||
{{- include "chart.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/component: web
|
||||
{{- include "chart.labels" . | nindent 8 }}
|
||||
annotations:
|
||||
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
|
||||
checksum/config-map: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
|
||||
spec:
|
||||
securityContext:
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
readOnlyRootFilesystem: true
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
containers:
|
||||
- name: {{.Release.Name}}-web
|
||||
{{- with .Values.web.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
image: "{{ .Values.web.image.repository }}:{{ .Values.web.image.tag | default .Chart.AppVersion }}"
|
||||
imagePullPolicy: "{{ .Values.imagePullPolicy | default "Always" }}"
|
||||
ports:
|
||||
- name: web
|
||||
containerPort: {{ .Values.web.service.port }}
|
||||
protocol: TCP
|
||||
{{- with .Values.web.livenessProbe }}
|
||||
livenessProbe:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.web.readinessProbe }}
|
||||
readinessProbe:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.web.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: web-uploads
|
||||
mountPath: /app/uploads
|
||||
- name: nginx-config
|
||||
mountPath: /etc/nginx/conf.d
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: web-uploads
|
||||
persistentVolumeClaim:
|
||||
claimName: {{.Release.Name}}-uploads
|
||||
- name: nginx-config
|
||||
configMap:
|
||||
name: {{.Release.Name}}-nginx-config
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{.Release.Name}}-backend
|
||||
namespace: {{.Release.Namespace}}
|
||||
labels:
|
||||
app.kubernetes.io/component: backend
|
||||
{{- include "chart.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/component: backend
|
||||
{{- include "chart.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
|
||||
checksum/config-map: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
|
||||
labels:
|
||||
app.kubernetes.io/component: backend
|
||||
{{- include "chart.labels" . | nindent 8 }}
|
||||
spec:
|
||||
securityContext:
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
readOnlyRootFilesystem: true
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
containers:
|
||||
- name: {{.Release.Name}}-backend
|
||||
{{- with .Values.backend.securityContext }}
|
||||
securityContext:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag | default .Chart.AppVersion }}"
|
||||
imagePullPolicy: "{{ .Values.imagePullPolicy | default "Always" }}"
|
||||
env:
|
||||
- name: UPLOAD_DIR
|
||||
value: /app/uploads
|
||||
- name: SPRING_CONFIG_LOCATION
|
||||
value: /app/applicaton.yml
|
||||
- name: JWT_SECRET
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-backend
|
||||
key: JWT_SECRET
|
||||
- name: JWT_ISSUER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-backend
|
||||
key: JWT_ISSUER
|
||||
- name: JWT_SUBJECT
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-backend
|
||||
key: JWT_SUBJECT
|
||||
- name: JWT_EXPIRE
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-backend
|
||||
key: JWT_EXPIRE
|
||||
- name: DB_USER_NAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-backend
|
||||
key: DB_USER_NAME
|
||||
- name: DB_USER_PWD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-backend
|
||||
key: DB_USER_PWD
|
||||
- name: MAIL_PORT
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-backend
|
||||
key: MAIL_PORT
|
||||
- name: MAIL_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-backend
|
||||
key: MAIL_HOST
|
||||
- name: MAIL_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-backend
|
||||
key: MAIL_USERNAME
|
||||
- name: MAIL_USER_PWD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: blog-backend
|
||||
key: MAIL_USER_PWD
|
||||
ports:
|
||||
- name: backend
|
||||
containerPort: {{ .Values.backend.service.port }}
|
||||
protocol: TCP
|
||||
{{- with .Values.backend.livenessProbe }}
|
||||
livenessProbe:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.readinessProbe }}
|
||||
readinessProbe:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.backend.resources }}
|
||||
resources:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: web-uploads
|
||||
mountPath: /app/uploads
|
||||
- name: blog-application
|
||||
mountPath: /app/application.yml
|
||||
subPath: application.yml
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
volumes:
|
||||
- name: web-uploads
|
||||
persistentVolumeClaim:
|
||||
claimName: {{.Release.Name}}-uploads
|
||||
- name: blog-application
|
||||
configMap:
|
||||
name: {{.Release.Name}}-application-config
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
|
||||
43
templates/ingress.yaml
Normal file
43
templates/ingress.yaml
Normal file
@@ -0,0 +1,43 @@
|
||||
{{- if .Values.ingress.enabled -}}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{.Release.Name}}
|
||||
labels:
|
||||
{{- include "chart.labels" . | nindent 4 }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with .Values.ingress.className }}
|
||||
ingressClassName: {{ . }}
|
||||
{{- end }}
|
||||
{{- 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: {{ .path }}
|
||||
{{- with .pathType }}
|
||||
pathType: {{ . }}
|
||||
{{- end }}
|
||||
backend:
|
||||
service:
|
||||
name: {{ include "chart.fullname" $ }}-web
|
||||
port:
|
||||
number: 80
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
15
templates/pvc.yaml
Normal file
15
templates/pvc.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: {{.Release.Name}}-uploads
|
||||
labels:
|
||||
{{- include "chart.labels" . | nindent 4 }}
|
||||
spec:
|
||||
accessModes:
|
||||
- {{ .Values.web.persistence.accessMode | quote }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.web.persistence.size | quote }}
|
||||
{{- if .Values.web.persistence.storageClassName }}
|
||||
storageClassName: {{ .Values.web.persistence.storageClassName }}
|
||||
{{- end }}
|
||||
13
templates/secret.yaml
Normal file
13
templates/secret.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: blog-backend
|
||||
labels:
|
||||
{{- include "chart.labels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: backend
|
||||
data:
|
||||
{{- if .Values.secrets }}
|
||||
{{- range $key, $value := .Values.secrets }}
|
||||
{{ $key | quote }}: {{ $value | toString | b64enc | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
34
templates/service.yaml
Normal file
34
templates/service.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{.Release.Name}}-web
|
||||
labels:
|
||||
{{- include "chart.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.web.service.type }}
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: {{ .Values.web.service.port }}
|
||||
protocol: TCP
|
||||
name: web
|
||||
selector:
|
||||
app.kubernetes.io/component: web
|
||||
{{- include "chart.selectorLabels" . | nindent 4 }}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{.Release.Name}}-backend
|
||||
labels:
|
||||
{{- include "chart.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.backend.service.type }}
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: {{ .Values.backend.service.port }}
|
||||
protocol: TCP
|
||||
name: backend
|
||||
selector:
|
||||
app.kubernetes.io/component: backend
|
||||
{{- include "chart.selectorLabels" . | nindent 4 }}
|
||||
Reference in New Issue
Block a user