初始提交
This commit is contained in:
0
py-deploy/applications/.gitkeep
Normal file
0
py-deploy/applications/.gitkeep
Normal file
44
py-deploy/bin/mexec
Normal file
44
py-deploy/bin/mexec
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASEDIR=$(cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd)
|
||||
SSH_KEY=${BASEDIR}/$(ls ${BASEDIR} | egrep '.pem$' | head -n 1)
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
>&2 echo "Execute command on each host."
|
||||
>&2 echo "Usage: $0 <cmd> | $0 -f <file>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NOMASTER=0
|
||||
if [ "$1" == "--no-master" ]; then
|
||||
NOMASTER=1
|
||||
shift
|
||||
fi
|
||||
|
||||
if [ "$1" == "-f" ]; then
|
||||
file=$2
|
||||
else
|
||||
cmd="$@"
|
||||
fi
|
||||
|
||||
user=$(whoami)
|
||||
N=0
|
||||
for host in $(cat ${BASEDIR}/hosts | grep -v "^#" | awk '{print $1}')
|
||||
do
|
||||
if [ "${NOMASTER}" == "1" ] && cat ${BASEDIR}/hosts | grep "master" | grep ${host} >/dev/null
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
N=$(expr ${N} + 1)
|
||||
if [ "x${cmd}" != "x" ]; then
|
||||
exe_cmd=$(echo "${cmd}" | sed "s/\${N}/${N}/")
|
||||
echo "${user}@${host}> ${exe_cmd}"
|
||||
echo "${exe_cmd}" | ssh -T ${host}
|
||||
else
|
||||
echo "${user}@${host}> ${file}"
|
||||
${file}> ssh -T ${host}
|
||||
fi
|
||||
echo "(exit $?)"
|
||||
echo ""
|
||||
done
|
||||
21
py-deploy/bin/mscp
Normal file
21
py-deploy/bin/mscp
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASEDIR=$(cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd)
|
||||
SSH_KEY=${BASEDIR}/$(ls ${BASEDIR} | egrep '.pem$' | head -n 1)
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Copy file to all hosts"
|
||||
echo "Usage: $0 <source> <target>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for host in $(cat ${BASEDIR}/hosts | grep -v "^#" | awk '{print $1}')
|
||||
do
|
||||
if ifconfig | grep inet | grep "${host}" >/dev/null ; then
|
||||
# skip current host
|
||||
continue
|
||||
fi
|
||||
|
||||
#scp -i ${SSH_KEY} -r $1 ${host}:$2
|
||||
scp -r $1 ${host}:$2
|
||||
done
|
||||
19
py-deploy/bin/ssh
Normal file
19
py-deploy/bin/ssh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASEDIR=$(cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd)
|
||||
SSH_KEY=${BASEDIR}/$(ls ${BASEDIR} | egrep '.pem$' | head -n 1)
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
>&2 echo "Usage: $0 <hostname>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
host=$1
|
||||
user=$(whoami)
|
||||
for h in $(cat ${BASEDIR}/hosts | grep -v "^#" | egrep "\\s+${host}(\\s+.*)*$" | awk '{print $1}')
|
||||
do
|
||||
host=${h}
|
||||
break
|
||||
done
|
||||
|
||||
ssh -i ${SSH_KEY} ${host}
|
||||
72
py-deploy/global.json
Normal file
72
py-deploy/global.json
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"namespace": "a",
|
||||
"imageSecret": "harbor",
|
||||
"domain": "a.notesync.cn",
|
||||
"superDomain": "b.notesync.cn",
|
||||
"tssDomain": "c.notesync.cn",
|
||||
"ingressClassName": "nginx",
|
||||
"deployments": [
|
||||
{
|
||||
"name": "nginx01",
|
||||
"image": "nginx:nginx01",
|
||||
"replicas": 2,
|
||||
"resources": {
|
||||
"limits": {
|
||||
"cpu": "0.2",
|
||||
"memory": "256Mi"
|
||||
},
|
||||
"requests": {
|
||||
"cpu": "0.1",
|
||||
"memory": "128Mi"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "nginx02",
|
||||
"image": "nginx:nginx02",
|
||||
"replicas": 2,
|
||||
"resources": {
|
||||
"limits": {
|
||||
"cpu": "0.2",
|
||||
"memory": "256Mi"
|
||||
},
|
||||
"requests": {
|
||||
"cpu": "0.1",
|
||||
"memory": "128Mi"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "gateway",
|
||||
"image": "backend:gateway",
|
||||
"replicas": 2,
|
||||
"resources": {
|
||||
"limits": {
|
||||
"cpu": "2",
|
||||
"memory": "4G"
|
||||
},
|
||||
"requests": {
|
||||
"cpu": "1",
|
||||
"memory": "2G"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "auth",
|
||||
"image": "backend:auth",
|
||||
"replicas": 2,
|
||||
"resources": {
|
||||
"limits": {
|
||||
"cpu": "2",
|
||||
"memory": "4G"
|
||||
},
|
||||
"requests": {
|
||||
"cpu": "1",
|
||||
"memory": "2G"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
3
py-deploy/hosts
Normal file
3
py-deploy/hosts
Normal file
@@ -0,0 +1,3 @@
|
||||
192.168.100.4 k8s1
|
||||
192.168.100.5 k8s2
|
||||
192.168.100.6 k8s3
|
||||
262
py-deploy/k8s
Normal file
262
py-deploy/k8s
Normal file
@@ -0,0 +1,262 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import json
|
||||
import jinja2
|
||||
import os
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
|
||||
|
||||
def generate_global_configmap_yaml(json_data):
|
||||
template_global_configmap_dir='template/'
|
||||
global_configmap_dir='applications/'
|
||||
template_global_configmaps = ['nginx.yaml','backend.yaml']
|
||||
for global_configmap in template_global_configmaps:
|
||||
template_global_config_file=f'{template_global_configmap_dir}{global_configmap}'
|
||||
with open(template_global_config_file,'r') as file:
|
||||
template = jinja2.Template(file.read())
|
||||
rendered_yaml = template.render(
|
||||
namespace=json_data['namespace'],
|
||||
)
|
||||
global_configmap_file=f'{global_configmap_dir}{global_configmap}'
|
||||
with open(global_configmap_file, 'w') as global_file:
|
||||
global_file.write(rendered_yaml)
|
||||
|
||||
|
||||
|
||||
def generate_configmap_yaml(json_data, app):
|
||||
template_global_configmap_dir='template/'
|
||||
global_configmap_dir='applications/'
|
||||
template_app_configmap_file=f'{template_global_configmap_dir}{app}''/configmap.yaml'
|
||||
|
||||
if not os.path.exists(template_app_configmap_file):
|
||||
print(f"{template_app_configmap_file} does have configmap. exiting.")
|
||||
return
|
||||
|
||||
app_configmap_path=f'applications/{app}'
|
||||
if not os.path.isdir(app_configmap_path):
|
||||
os.makedirs(app_configmap_path)
|
||||
|
||||
app_configmap_file=f'{app_configmap_path}''/configmap.yaml'
|
||||
with open(template_app_configmap_file,'r') as template_app_configmap:
|
||||
template = jinja2.Template(template_app_configmap.read())
|
||||
superDomain = ["tmuyun-h5"]
|
||||
if app in superDomain:
|
||||
rendered_yaml = template.render(
|
||||
namespace=json_data['namespace'],
|
||||
superDomain=json_data['superDomain'],
|
||||
name=app
|
||||
)
|
||||
else:
|
||||
rendered_yaml = template.render(
|
||||
namespace=json_data['namespace'],
|
||||
domain=json_data['domain'],
|
||||
name=app
|
||||
)
|
||||
with open(app_configmap_file,'w') as app_configmap:
|
||||
app_configmap.write(rendered_yaml)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def generate_deployment_yaml(json_data, app):
|
||||
|
||||
app_template = 'template/%s/deployment.yaml' % app
|
||||
if os.path.exists(app_template):
|
||||
pass
|
||||
else:
|
||||
print("%s 文件不存在" %app_template)
|
||||
exit(1)
|
||||
|
||||
|
||||
with open(app_template, 'r') as file:
|
||||
template = jinja2.Template(file.read())
|
||||
|
||||
superApp=["tmuyun-h5"]
|
||||
superGateway=["tmy-gateway"]
|
||||
tssApp=["tss-api"]
|
||||
|
||||
for deployment in json_data['deployments']:
|
||||
|
||||
namespace=json_data['namespace'],
|
||||
imageSecret=json_data['imageSecret'],
|
||||
deployment_name=deployment['name'],
|
||||
image=deployment['image'],
|
||||
replicas=deployment['replicas'],
|
||||
limits_cpu=deployment['resources']['limits']['cpu'],
|
||||
limits_memory=deployment['resources']['limits']['memory'],
|
||||
requests_cpu=deployment['resources']['requests']['cpu'],
|
||||
requests_memory=deployment['resources']['requests']['memory'],
|
||||
domain=json_data['domain'],
|
||||
superDomain=json_data['superDomain'],
|
||||
ingressClassName=json_data['ingressClassName']
|
||||
|
||||
|
||||
if app != deployment['name']:
|
||||
continue
|
||||
else:
|
||||
if app in superApp:
|
||||
rendered_yaml = template.render(
|
||||
namespace=json_data['namespace'],
|
||||
imageSecret=json_data['imageSecret'],
|
||||
deployment_name=deployment['name'],
|
||||
image=deployment['image'],
|
||||
replicas=deployment['replicas'],
|
||||
limits_cpu=deployment['resources']['limits']['cpu'],
|
||||
limits_memory=deployment['resources']['limits']['memory'],
|
||||
requests_cpu=deployment['resources']['requests']['cpu'],
|
||||
requests_memory=deployment['resources']['requests']['memory'],
|
||||
superDomain=json_data['superDomain'],
|
||||
ingressClassName=json_data['ingressClassName']
|
||||
)
|
||||
elif app in superGateway:
|
||||
rendered_yaml = template.render(
|
||||
namespace=json_data['namespace'],
|
||||
imageSecret=json_data['imageSecret'],
|
||||
deployment_name=deployment['name'],
|
||||
image=deployment['image'],
|
||||
replicas=deployment['replicas'],
|
||||
limits_cpu=deployment['resources']['limits']['cpu'],
|
||||
limits_memory=deployment['resources']['limits']['memory'],
|
||||
requests_cpu=deployment['resources']['requests']['cpu'],
|
||||
requests_memory=deployment['resources']['requests']['memory'],
|
||||
superDomain=json_data['superDomain'],
|
||||
domain=json_data['domain'],
|
||||
ingressClassName=json_data['ingressClassName']
|
||||
)
|
||||
elif app in tssApp:
|
||||
rendered_yaml = template.render(
|
||||
namespace=json_data['namespace'],
|
||||
imageSecret=json_data['imageSecret'],
|
||||
deployment_name=deployment['name'],
|
||||
image=deployment['image'],
|
||||
replicas=deployment['replicas'],
|
||||
limits_cpu=deployment['resources']['limits']['cpu'],
|
||||
limits_memory=deployment['resources']['limits']['memory'],
|
||||
requests_cpu=deployment['resources']['requests']['cpu'],
|
||||
requests_memory=deployment['resources']['requests']['memory'],
|
||||
tssDomain=json_data['tssDomain'],
|
||||
ingressClassName=json_data['ingressClassName']
|
||||
)
|
||||
else:
|
||||
rendered_yaml = template.render(
|
||||
namespace=json_data['namespace'],
|
||||
imageSecret=json_data['imageSecret'],
|
||||
deployment_name=deployment['name'],
|
||||
image=deployment['image'],
|
||||
replicas=deployment['replicas'],
|
||||
limits_cpu=deployment['resources']['limits']['cpu'],
|
||||
limits_memory=deployment['resources']['limits']['memory'],
|
||||
requests_cpu=deployment['resources']['requests']['cpu'],
|
||||
requests_memory=deployment['resources']['requests']['memory'],
|
||||
domain=json_data['domain'],
|
||||
ingressClassName=json_data['ingressClassName']
|
||||
)
|
||||
|
||||
app_dir = 'applications/%s' %app
|
||||
if not os.path.isdir(app_dir):
|
||||
os.makedirs(app_dir)
|
||||
print("%s 目录已创建" %app_dir)
|
||||
|
||||
app_deployment = app_dir+'/deployment.yaml'
|
||||
|
||||
with open(app_deployment, 'w') as file:
|
||||
file.write(rendered_yaml)
|
||||
print("Generated %s" %app_deployment)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def before_apply():
|
||||
front_configmap='applications/nginx.yaml'
|
||||
backend_config='applications/tmly.yaml'
|
||||
|
||||
cmd_front='kubectl apply -f %s' %front_configmap
|
||||
cmd_backend='kubectl apply -f %s' %backend_config
|
||||
subprocess.run(cmd_front,shell=True)
|
||||
subprocess.run(cmd_backend,shell=True)
|
||||
|
||||
|
||||
def delete_after():
|
||||
front_configmap='applications/nginx.yaml'
|
||||
backend_config='applications/tmly.yaml'
|
||||
|
||||
cmd_front='kubectl delete -f %s' %front_configmap
|
||||
cmd_backend='kubectl delete -f %s' %backend_config
|
||||
subprocess.run(cmd_front,shell=True)
|
||||
subprocess.run(cmd_backend,shell=True)
|
||||
|
||||
def apply(app):
|
||||
app_configmap='applications/%s/configmap.yaml'%app
|
||||
app_deployment='applications/%s/deployment.yaml' %app
|
||||
cmd_configmap='kubectl apply -f %s' %app_configmap
|
||||
cmd_deployment = 'kubectl apply -f %s' %app_deployment
|
||||
|
||||
if os.path.exists(app_configmap):
|
||||
subprocess.run(cmd_configmap,shell=True)
|
||||
|
||||
subprocess.run(cmd_deployment,shell=True)
|
||||
|
||||
|
||||
|
||||
def delete(app):
|
||||
app_configmap='applications/%s/configmap.yaml'%app
|
||||
app_deployment='applications/%s/deployment.yaml' %app
|
||||
cmd_configmap='kubectl delete -f %s' %app_configmap
|
||||
cmd_deployment = 'kubectl delete -f %s' %app_deployment
|
||||
|
||||
subprocess.run(cmd_deployment,shell=True)
|
||||
|
||||
if os.path.exists(app_configmap):
|
||||
subprocess.run(cmd_configmap,shell=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open('global.json', 'r') as file:
|
||||
json_data = json.load(file)
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description="D")
|
||||
parser.add_argument("action",type=str,help="config,build,apply,delete")
|
||||
parser.add_argument("apps",type=str,help="app name or -")
|
||||
args = parser.parse_args()
|
||||
|
||||
action = args.action
|
||||
apps = args.apps
|
||||
_app = []
|
||||
|
||||
# generate_global_configmap_yaml(json_data)
|
||||
|
||||
if apps == '-':
|
||||
for app in json_data['deployments']:
|
||||
_app.append(app['name'])
|
||||
else:
|
||||
_app.append(apps)
|
||||
|
||||
# generate configmap
|
||||
if action == 'config':
|
||||
generate_global_configmap_yaml(json_data)
|
||||
for app in _app:
|
||||
generate_configmap_yaml(json_data,app)
|
||||
|
||||
# generate deployment
|
||||
if action == 'build':
|
||||
for app in _app:
|
||||
generate_deployment_yaml(json_data,app)
|
||||
|
||||
# apply configmap,deployment
|
||||
if action == 'apply':
|
||||
before_apply()
|
||||
for app in _app:
|
||||
apply(app)
|
||||
|
||||
# delete deployment,configmap
|
||||
if action == 'delete':
|
||||
for app in _app:
|
||||
delete(app)
|
||||
# delete_after()
|
||||
|
||||
74
py-deploy/template/auth/deployment.yaml
Normal file
74
py-deploy/template/auth/deployment.yaml
Normal file
@@ -0,0 +1,74 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ deployment_name }}
|
||||
namespace: {{ namespace }}
|
||||
spec:
|
||||
replicas: {{ replicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ deployment_name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: {{ deployment_name }}
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ deployment_name }}
|
||||
env:
|
||||
- name: SERVICE_NAME
|
||||
value: {{ deployment_name }}
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
image: {{ image }}
|
||||
imagePullPolicy: IfNotPresent
|
||||
lifecycle:
|
||||
preStop:
|
||||
exec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- /saas/tmy3-config/pre-Stop.sh
|
||||
resources:
|
||||
limits:
|
||||
cpu: {{ limits_cpu }}
|
||||
memory: {{ limits_memory }}
|
||||
requests:
|
||||
cpu: {{ requests_cpu }}
|
||||
memory: {{ requests_memory }}
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
tcpSocket:
|
||||
port: 8080
|
||||
timeoutSeconds: 1
|
||||
volumeMounts:
|
||||
- mountPath: /etc/localtime
|
||||
name: localtime
|
||||
- mountPath: /saas/tmy3-config/logback-spring.xml
|
||||
name: tmly
|
||||
subPath: logback-spring.xml
|
||||
- mountPath: /saas/tmy3-config/pre-Stop.sh
|
||||
name: tmly
|
||||
subPath: pre-Stop.sh
|
||||
- mountPath: /saas/run-env.sh
|
||||
name: tmly
|
||||
subPath: run-env.sh
|
||||
imagePullSecrets:
|
||||
- name: {{ imageSecret }}
|
||||
volumes:
|
||||
- hostPath:
|
||||
path: /etc/localtime
|
||||
type: ''
|
||||
name: localtime
|
||||
- configMap:
|
||||
defaultMode: 420
|
||||
name: tmly
|
||||
name: tmly
|
||||
280
py-deploy/template/backend.yaml
Normal file
280
py-deploy/template/backend.yaml
Normal file
@@ -0,0 +1,280 @@
|
||||
apiVersion: v1
|
||||
data:
|
||||
pre-Stop.sh: |-
|
||||
#!/bin/sh
|
||||
curl -X PUT "10.22.3.100:8848/nacos/v1/ns/instance?serviceName=${SERVICE_NAME}&ip=${POD_IP}&port=8080&enabled=false"
|
||||
sleep 30
|
||||
curl -X POST http://127.0.0.1:8080/actuator/shutdown
|
||||
|
||||
|
||||
logback-spring.xml: |-
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="false">
|
||||
<property name="FILE_LOG_PATTERN" value="%d %p %mdc{trace_id} %mdc{span_id} %t %logger{60}: %m%n"/>
|
||||
<contextName>logback-spring</contextName>
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${FILE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
</configuration>
|
||||
|
||||
run-env.sh: |-
|
||||
#!/bin/sh
|
||||
export ENV="prod"
|
||||
export JAVA_MAX_MEM_RATIO="70"
|
||||
JAVA_OPTIONS="-Dserver.port=8080"
|
||||
JAVA_OPTIONS="${JAVA_OPTIONS} -Dspring.profiles.active=${ENV}"
|
||||
JAVA_OPTIONS="${JAVA_OPTIONS} -Duser.timezone=GMT+8"
|
||||
JAVA_OPTIONS="${JAVA_OPTIONS} -Dlogging.config=/saas/tmy3-config/logback-spring.xml"
|
||||
JAVA_OPTIONS="${JAVA_OPTIONS} -Dspring.cloud.nacos.config.server-addr=http://10.22.3.100:8848"
|
||||
JAVA_OPTIONS="${JAVA_OPTIONS} -Dspring.cloud.nacos.config.namespace=454ddf7f-f1cd-436e-970b-7e5d807e0c0a"
|
||||
JAVA_OPTIONS="${JAVA_OPTIONS} -Dspring.cloud.nacos.config.group=a"
|
||||
JAVA_OPTIONS="${JAVA_OPTIONS} -Dsentinel.nacos.address=10.22.3.100"
|
||||
|
||||
canal.properties: |-
|
||||
#################################################
|
||||
######### common argument #############
|
||||
#################################################
|
||||
# tcp bind ip
|
||||
canal.ip =
|
||||
# register ip to zookeeper
|
||||
canal.register.ip =
|
||||
canal.port = 11111
|
||||
canal.metrics.pull.port = 11112
|
||||
# canal instance user/passwd
|
||||
# canal.user = canal
|
||||
# canal.passwd = E3619321C1A937C46A0D8BD1DAC39F93B27D4458
|
||||
|
||||
# canal admin config
|
||||
#canal.admin.manager = 127.0.0.1:8089
|
||||
canal.admin.port = 11110
|
||||
canal.admin.user = admin
|
||||
canal.admin.passwd = 4ACFE3202A5FF5CF467898FC58AAB1D615029441
|
||||
# admin auto register
|
||||
#canal.admin.register.auto = true
|
||||
#canal.admin.register.cluster =
|
||||
#canal.admin.register.name =
|
||||
|
||||
canal.zkServers =
|
||||
# flush data to zk
|
||||
canal.zookeeper.flush.period = 1000
|
||||
canal.withoutNetty = false
|
||||
# tcp, kafka, rocketMQ, rabbitMQ
|
||||
#canal.serverMode = rabbitMQ
|
||||
canal.serverMode = tcp
|
||||
# flush meta cursor/parse position to file
|
||||
canal.file.data.dir = ${canal.conf.dir}
|
||||
canal.file.flush.period = 1000
|
||||
## memory store RingBuffer size, should be Math.pow(2,n)
|
||||
canal.instance.memory.buffer.size = 16384
|
||||
## memory store RingBuffer used memory unit size , default 1kb
|
||||
canal.instance.memory.buffer.memunit = 1024
|
||||
## meory store gets mode used MEMSIZE or ITEMSIZE
|
||||
canal.instance.memory.batch.mode = MEMSIZE
|
||||
canal.instance.memory.rawEntry = true
|
||||
|
||||
## detecing config
|
||||
canal.instance.detecting.enable = false
|
||||
#canal.instance.detecting.sql = insert into retl.xdual values(1,now()) on duplicate key update x=now()
|
||||
canal.instance.detecting.sql = select 1
|
||||
canal.instance.detecting.interval.time = 3
|
||||
canal.instance.detecting.retry.threshold = 3
|
||||
canal.instance.detecting.heartbeatHaEnable = false
|
||||
|
||||
# support maximum transaction size, more than the size of the transaction will be cut into multiple transactions delivery
|
||||
canal.instance.transaction.size = 1024
|
||||
# mysql fallback connected to new master should fallback times
|
||||
canal.instance.fallbackIntervalInSeconds = 60
|
||||
|
||||
# network config
|
||||
canal.instance.network.receiveBufferSize = 16384
|
||||
canal.instance.network.sendBufferSize = 16384
|
||||
canal.instance.network.soTimeout = 30
|
||||
|
||||
# binlog filter config
|
||||
canal.instance.filter.druid.ddl = true
|
||||
canal.instance.filter.query.dcl = false
|
||||
canal.instance.filter.query.dml = false
|
||||
canal.instance.filter.query.ddl = false
|
||||
canal.instance.filter.table.error = false
|
||||
canal.instance.filter.rows = false
|
||||
canal.instance.filter.transaction.entry = false
|
||||
canal.instance.filter.dml.insert = false
|
||||
canal.instance.filter.dml.update = false
|
||||
canal.instance.filter.dml.delete = false
|
||||
|
||||
# binlog format/image check
|
||||
canal.instance.binlog.format = ROW,STATEMENT,MIXED
|
||||
canal.instance.binlog.image = FULL,MINIMAL,NOBLOB
|
||||
|
||||
# binlog ddl isolation
|
||||
canal.instance.get.ddl.isolation = false
|
||||
|
||||
# parallel parser config
|
||||
canal.instance.parser.parallel = true
|
||||
## concurrent thread number, default 60% available processors, suggest not to exceed Runtime.getRuntime().availableProcessors()
|
||||
canal.instance.parser.parallelThreadSize = 16
|
||||
## disruptor ringbuffer size, must be power of 2
|
||||
canal.instance.parser.parallelBufferSize = 256
|
||||
|
||||
# table meta tsdb info
|
||||
canal.instance.tsdb.enable = false
|
||||
canal.instance.tsdb.dir = ${canal.file.data.dir:../conf}/${canal.instance.destination:}
|
||||
canal.instance.tsdb.url = jdbc:h2:${canal.instance.tsdb.dir}/h2;CACHE_SIZE=1000;MODE=MYSQL;
|
||||
canal.instance.tsdb.dbUsername = canal
|
||||
canal.instance.tsdb.dbPassword = canal
|
||||
# dump snapshot interval, default 24 hour
|
||||
canal.instance.tsdb.snapshot.interval = 24
|
||||
# purge snapshot expire , default 360 hour(15 days)
|
||||
canal.instance.tsdb.snapshot.expire = 360
|
||||
|
||||
#################################################
|
||||
######### destinations #############
|
||||
#################################################
|
||||
canal.destinations = example
|
||||
# conf root dir
|
||||
canal.conf.dir = ../conf
|
||||
# auto scan instance dir add/remove and start/stop instance
|
||||
canal.auto.scan = true
|
||||
canal.auto.scan.interval = 5
|
||||
# set this value to 'true' means that when binlog pos not found, skip to latest.
|
||||
# WARN: pls keep 'false' in production env, or if you know what you want.
|
||||
canal.auto.reset.latest.pos.mode = false
|
||||
|
||||
canal.instance.tsdb.spring.xml = classpath:spring/tsdb/h2-tsdb.xml
|
||||
#canal.instance.tsdb.spring.xml = classpath:spring/tsdb/mysql-tsdb.xml
|
||||
|
||||
canal.instance.global.mode = spring
|
||||
canal.instance.global.lazy = false
|
||||
canal.instance.global.manager.address = ${canal.admin.manager}
|
||||
#canal.instance.global.spring.xml = classpath:spring/memory-instance.xml
|
||||
canal.instance.global.spring.xml = classpath:spring/file-instance.xml
|
||||
#canal.instance.global.spring.xml = classpath:spring/default-instance.xml
|
||||
|
||||
##################################################
|
||||
######### MQ Properties #############
|
||||
##################################################
|
||||
# aliyun ak/sk , support rds/mq
|
||||
canal.aliyun.accessKey =
|
||||
canal.aliyun.secretKey =
|
||||
canal.aliyun.uid=
|
||||
|
||||
canal.mq.flatMessage = true
|
||||
canal.mq.canalBatchSize = 50
|
||||
canal.mq.canalGetTimeout = 100
|
||||
# Set this value to "cloud", if you want open message trace feature in aliyun.
|
||||
canal.mq.accessChannel = local
|
||||
|
||||
canal.mq.database.hash = true
|
||||
canal.mq.send.thread.size = 30
|
||||
canal.mq.build.thread.size = 8
|
||||
|
||||
##################################################
|
||||
######### Kafka #############
|
||||
##################################################
|
||||
kafka.bootstrap.servers = 127.0.0.1:9092
|
||||
kafka.acks = all
|
||||
kafka.compression.type = none
|
||||
kafka.batch.size = 16384
|
||||
kafka.linger.ms = 1
|
||||
kafka.max.request.size = 1048576
|
||||
kafka.buffer.memory = 33554432
|
||||
kafka.max.in.flight.requests.per.connection = 1
|
||||
kafka.retries = 0
|
||||
|
||||
kafka.kerberos.enable = false
|
||||
kafka.kerberos.krb5.file = "../conf/kerberos/krb5.conf"
|
||||
kafka.kerberos.jaas.file = "../conf/kerberos/jaas.conf"
|
||||
|
||||
##################################################
|
||||
######### RocketMQ #############
|
||||
##################################################
|
||||
rocketmq.producer.group = test
|
||||
rocketmq.enable.message.trace = false
|
||||
rocketmq.customized.trace.topic =
|
||||
rocketmq.namespace =
|
||||
rocketmq.namesrv.addr = 127.0.0.1:9876
|
||||
rocketmq.retry.times.when.send.failed = 0
|
||||
rocketmq.vip.channel.enabled = false
|
||||
rocketmq.tag =
|
||||
|
||||
##################################################
|
||||
######### RabbitMQ #############
|
||||
##################################################
|
||||
rabbitmq.host = 10.200.77.130:5672
|
||||
rabbitmq.virtual.host = canal
|
||||
rabbitmq.exchange = tmy_sync_exachage
|
||||
rabbitmq.username = guest
|
||||
rabbitmq.password = guest
|
||||
rabbitmq.deliveryMode = 1
|
||||
|
||||
instance.properties: |-
|
||||
#################################################
|
||||
## mysql serverId , v1.0.26+ will autoGen
|
||||
# canal.instance.mysql.slaveId=1
|
||||
canal.instance.mysql.slaveId=80250
|
||||
|
||||
# enable gtid use true/false
|
||||
canal.instance.gtidon=false
|
||||
|
||||
# position info
|
||||
canal.instance.master.address=10.200.80.221:3306
|
||||
canal.instance.master.journal.name=
|
||||
canal.instance.master.position=
|
||||
canal.instance.master.timestamp=
|
||||
canal.instance.master.gtid=
|
||||
|
||||
# rds oss binlog
|
||||
canal.instance.rds.accesskey=
|
||||
canal.instance.rds.secretkey=
|
||||
canal.instance.rds.instanceId=
|
||||
|
||||
# table meta tsdb info
|
||||
canal.instance.tsdb.enable=true
|
||||
#canal.instance.tsdb.url=jdbc:mysql://127.0.0.1:3306/canal_tsdb
|
||||
#canal.instance.tsdb.dbUsername=canal
|
||||
#canal.instance.tsdb.dbPassword=canal
|
||||
|
||||
#canal.instance.standby.address =
|
||||
#canal.instance.standby.journal.name =
|
||||
#canal.instance.standby.position =
|
||||
#canal.instance.standby.timestamp =
|
||||
#canal.instance.standby.gtid=
|
||||
|
||||
# username/password
|
||||
canal.instance.dbUsername=tmy3
|
||||
canal.instance.dbPassword=3evCV2!ivx
|
||||
canal.instance.connectionCharset = UTF-8
|
||||
# enable druid Decrypt database password
|
||||
canal.instance.enableDruid=false
|
||||
#canal.instance.pwdPublicKey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALK4BUxdDltRRE5/zXpVEVPUgunvscYFtEip3pmLlhrWpacX7y7GCMo2/JM6LeHmiiNdH1FWgGCpUfircSwlWKUCAwEAAQ==
|
||||
|
||||
# table regex
|
||||
|
||||
canal.instance.filter.regex=uc.sys_user,uc.sys_tenant,uc.sys_group,uc.sys_group_user,product.tenant_site,product.tenant_channel
|
||||
#l.instance.filter.regex table black regex
|
||||
#canal.instance.filter.black.regex=mysql\\.slave_.*
|
||||
# table field filter(format: schema1.tableName1:field1/field2,schema2.tableName2:field1/field2)
|
||||
#canal.instance.filter.field=test1.t_product:id/subject/keywords,test2.t_company:id/name/contact/ch
|
||||
# table field black filter(format: schema1.tableName1:field1/field2,schema2.tableName2:field1/field2)
|
||||
#canal.instance.filter.black.field=test1.t_product:subject/product_image,test2.t_company:id/name/contact/ch
|
||||
|
||||
# mq config
|
||||
canal.mq.topic=canal
|
||||
# dynamic topic route by schema or table regex
|
||||
#canal.mq.dynamicTopic=uc.sys_user,uc.sys_tenant,uc.sys_group,uc.sys_group_user,product.tenant_site,product.tenant_channel
|
||||
canal.mq.partition=0
|
||||
# hash partition config
|
||||
#canal.mq.partitionsNum=3
|
||||
#canal.mq.partitionHash=test.table:id^name,.*\\..*
|
||||
#canal.mq.dynamicTopicPartitionNum=test.*:4,mycanal:6
|
||||
#################################################
|
||||
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: backend
|
||||
namespace: {{ namespace }}
|
||||
141
py-deploy/template/gateway/deployment.yaml
Normal file
141
py-deploy/template/gateway/deployment.yaml
Normal file
@@ -0,0 +1,141 @@
|
||||
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ deployment_name }}
|
||||
namespace: {{ namespace }}
|
||||
spec:
|
||||
replicas: {{ replicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ deployment_name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: {{ deployment_name }}
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ deployment_name }}
|
||||
env:
|
||||
- name: SERVICE_NAME
|
||||
value: {{ deployment_name }}
|
||||
- name: POD_IP
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: status.podIP
|
||||
image: {{ image }}
|
||||
imagePullPolicy: IfNotPresent
|
||||
lifecycle:
|
||||
preStop:
|
||||
exec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- /saas/tmy3-config/pre-Stop.sh
|
||||
resources:
|
||||
limits:
|
||||
cpu: {{ limits_cpu }}
|
||||
memory: {{ limits_memory }}
|
||||
requests:
|
||||
cpu: {{ requests_cpu }}
|
||||
memory: {{ requests_memory }}
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
tcpSocket:
|
||||
port: 8080
|
||||
timeoutSeconds: 1
|
||||
volumeMounts:
|
||||
- mountPath: /etc/localtime
|
||||
name: localtime
|
||||
- mountPath: /saas/tmy3-config/logback-spring.xml
|
||||
name: tmly
|
||||
subPath: logback-spring.xml
|
||||
- mountPath: /saas/tmy3-config/pre-Stop.sh
|
||||
name: tmly
|
||||
subPath: pre-Stop.sh
|
||||
- mountPath: /saas/run-env.sh
|
||||
name: tmly
|
||||
subPath: run-env.sh
|
||||
imagePullSecrets:
|
||||
- name: {{ imageSecret }}
|
||||
volumes:
|
||||
- hostPath:
|
||||
path: /etc/localtime
|
||||
type: ''
|
||||
name: localtime
|
||||
- configMap:
|
||||
defaultMode: 420
|
||||
name: tmly
|
||||
name: tmly
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ deployment_name }}
|
||||
namespace: {{ namespace }}
|
||||
spec:
|
||||
ports:
|
||||
- name: server-port
|
||||
port: 8080
|
||||
targetPort: 8080
|
||||
selector:
|
||||
app: {{ deployment_name }}
|
||||
type: ClusterIP
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/rewrite-target: /$2
|
||||
nginx.ingress.kubernetes.io/enable-cors: 'true'
|
||||
nginx.ingress.kubernetes.io/cors-allow-origin: '*'
|
||||
nginx.ingress.kubernetes.io/cors-allow-methods: 'GET,PUT,POST'
|
||||
name: {{ deployment_name }}
|
||||
namespace: {{ namespace }}
|
||||
spec:
|
||||
ingressClassName: {{ ingressClassName }}
|
||||
rules:
|
||||
- host: {{ domain }}
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: {{ deployment_name }}
|
||||
port:
|
||||
number: 8080
|
||||
path: /tmy3/tmy3api(/|$)(.*)
|
||||
pathType: ImplementationSpecific
|
||||
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/rewrite-target: /$2
|
||||
nginx.ingress.kubernetes.io/enable-cors: 'true'
|
||||
nginx.ingress.kubernetes.io/cors-allow-origin: '*'
|
||||
nginx.ingress.kubernetes.io/cors-allow-methods: 'GET,PUT,POST'
|
||||
name: super-{{ deployment_name }}
|
||||
namespace: {{ namespace }}
|
||||
spec:
|
||||
ingressClassName: {{ ingressClassName }}
|
||||
rules:
|
||||
- host: {{ superDomain }}
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: {{ deployment_name }}
|
||||
port:
|
||||
number: 8080
|
||||
path: /tmy3/tmy3api(/|$)(.*)
|
||||
pathType: ImplementationSpecific
|
||||
90
py-deploy/template/nginx.yaml
Normal file
90
py-deploy/template/nginx.yaml
Normal file
@@ -0,0 +1,90 @@
|
||||
apiVersion: v1
|
||||
data:
|
||||
nginx.conf: >-
|
||||
user root;
|
||||
worker_processes 1;
|
||||
|
||||
#error_log logs/error.log;
|
||||
#error_log logs/error.log notice;
|
||||
#error_log logs/error.log info;
|
||||
|
||||
#pid logs/nginx.pid;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 65535;
|
||||
multi_accept on;
|
||||
use epoll;
|
||||
}
|
||||
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
# '$status $body_bytes_sent "$http_referer" '
|
||||
# '"$http_user_agent" "$http_x_forwarded_for"';
|
||||
# access_log off;
|
||||
#access_log logs/access.log main;
|
||||
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
|
||||
#keepalive_timeout 0;
|
||||
keepalive_timeout 300;
|
||||
|
||||
|
||||
ssi on;
|
||||
ssi_silent_errors on;
|
||||
ssi_types text/shtml;
|
||||
server_names_hash_bucket_size 1280;
|
||||
client_max_body_size 300M;
|
||||
client_header_buffer_size 32m;
|
||||
large_client_header_buffers 4 32m;
|
||||
|
||||
server_tokens off; #隐藏版本号
|
||||
ignore_invalid_headers on;
|
||||
recursive_error_pages on;
|
||||
server_name_in_redirect off;
|
||||
#gzip模块设置,使用 gzip 压缩可以降低网站带宽消耗,同时提升访问速度。
|
||||
gzip on; #开启gzip
|
||||
gzip_min_length 1k; #最小压缩大小
|
||||
gzip_buffers 4 16k; #压缩缓冲区
|
||||
gzip_http_version 1.1; #压缩版本
|
||||
gzip_comp_level 5; #压缩等级
|
||||
gzip_types text/javascript text/plain application/x-javascript text/css application/xml application/json image/jpeg image/png application/javascript image/gif;
|
||||
|
||||
map $http_x_forwarded_for $clientRealIp {
|
||||
"" $remote_addr;
|
||||
~^(?P<firstAddr>[0-9\.]+),?.*$ $firstAddr;
|
||||
}
|
||||
|
||||
# 将日志格式修改为如下格式:
|
||||
log_format main '{"@timestamp":"$time_iso8601",'
|
||||
'"host":"$server_addr",'
|
||||
'"service":"nginx-web",'
|
||||
'"trace":"$upstream_http_ctx_transaction_id",'
|
||||
'"log":"log",'
|
||||
'"clientip":"$remote_addr",'
|
||||
'"remote_user":"$remote_user",'
|
||||
'"request":"$request",'
|
||||
'"request_body":"$request_body",'
|
||||
'"http_user_agent":"$http_user_agent",'
|
||||
'"size":$body_bytes_sent,'
|
||||
'"responsetime":$request_time,'
|
||||
'"upstreamtime":"$upstream_response_time",'
|
||||
'"upstreamhost":"$upstream_addr",'
|
||||
'"http_host":"$host",'
|
||||
'"url":"$uri",'
|
||||
'"domain":"$host",'
|
||||
'"xff":"$http_x_forwarded_for",'
|
||||
'"referer":"$http_referer",'
|
||||
'"status":"$status"}';
|
||||
include conf.d/*.conf;
|
||||
}
|
||||
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: nginx
|
||||
namespace: {{ namespace }}
|
||||
28
py-deploy/template/nginx01/configmap.yaml
Normal file
28
py-deploy/template/nginx01/configmap.yaml
Normal file
@@ -0,0 +1,28 @@
|
||||
apiVersion: v1
|
||||
data:
|
||||
{{ name }}.conf: >-
|
||||
server {
|
||||
listen 80;
|
||||
server_name {{ superDomain }};
|
||||
access_log /storage/nginx_logs/{{ name }}_access.log main;
|
||||
error_log /storage/nginx_logs/{{ name }}_error.log;
|
||||
location /nginx01 {
|
||||
if ($request_filename ~* .*\.(?:htm|html)$) {
|
||||
add_header Cache-Control "no-cache";
|
||||
}
|
||||
alias /storage/{{ name }};
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /nginx01/index.html;
|
||||
}
|
||||
error_page 404 /404.html;
|
||||
location = /404.html {
|
||||
}
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
}
|
||||
}
|
||||
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: configmap-{{ name }}
|
||||
namespace: {{ namespace }}
|
||||
95
py-deploy/template/nginx01/deployment.yaml
Normal file
95
py-deploy/template/nginx01/deployment.yaml
Normal file
@@ -0,0 +1,95 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ deployment_name }}
|
||||
namespace: {{ namespace }}
|
||||
spec:
|
||||
replicas: {{ replicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ deployment_name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: {{ deployment_name }}
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ deployment_name }}
|
||||
image: {{ image }}
|
||||
imagePullPolicy: IfNotPresent
|
||||
resources:
|
||||
limits:
|
||||
cpu: {{ limits_cpu }}
|
||||
memory: {{ limits_memory }}
|
||||
requests:
|
||||
cpu: {{ requests_cpu }}
|
||||
memory: {{ requests_memory }}
|
||||
ports:
|
||||
- containerPort: 80
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
tcpSocket:
|
||||
port: 80
|
||||
timeoutSeconds: 1
|
||||
volumeMounts:
|
||||
- mountPath: /etc/localtime
|
||||
name: localtime
|
||||
- mountPath: /usr/local/nginx/conf/nginx.conf
|
||||
name: nginx
|
||||
subPath: nginx.conf
|
||||
- mountPath: /usr/local/nginx/conf/conf.d/{{ deployment_name }}.conf
|
||||
name: {{ deployment_name }}
|
||||
subPath: {{ deployment_name }}.conf
|
||||
imagePullSecrets:
|
||||
- name: {{ imageSecret }}
|
||||
volumes:
|
||||
- hostPath:
|
||||
path: /etc/localtime
|
||||
type: ''
|
||||
name: localtime
|
||||
- configMap:
|
||||
defaultMode: 420
|
||||
name: nginx
|
||||
name: nginx
|
||||
- configMap:
|
||||
defaultMode: 420
|
||||
name: configmap-{{ deployment_name }}
|
||||
name: {{ deployment_name }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ deployment_name }}
|
||||
namespace: {{ namespace }}
|
||||
spec:
|
||||
ports:
|
||||
- name: server-port
|
||||
port: 80
|
||||
targetPort: 80
|
||||
selector:
|
||||
app: {{ deployment_name }}
|
||||
type: ClusterIP
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ deployment_name }}
|
||||
namespace: {{ namespace }}
|
||||
spec:
|
||||
ingressClassName: {{ ingressClassName }}
|
||||
rules:
|
||||
- host: {{ superDomain }}
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: {{ deployment_name }}
|
||||
port:
|
||||
number: 80
|
||||
path: /nginx01
|
||||
pathType: ImplementationSpecific
|
||||
28
py-deploy/template/nginx02/configmap.yaml
Normal file
28
py-deploy/template/nginx02/configmap.yaml
Normal file
@@ -0,0 +1,28 @@
|
||||
apiVersion: v1
|
||||
data:
|
||||
{{ name }}.conf: >-
|
||||
server {
|
||||
listen 80;
|
||||
server_name {{ superDomain }};
|
||||
access_log /storage/nginx_logs/{{ name }}_access.log main;
|
||||
error_log /storage/nginx_logs/{{ name }}_error.log;
|
||||
location /nginx02 {
|
||||
if ($request_filename ~* .*\.(?:htm|html)$) {
|
||||
add_header Cache-Control "no-cache";
|
||||
}
|
||||
alias /storage/{{ name }};
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /nginx02/index.html;
|
||||
}
|
||||
error_page 404 /404.html;
|
||||
location = /404.html {
|
||||
}
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
}
|
||||
}
|
||||
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: configmap-{{ name }}
|
||||
namespace: {{ namespace }}
|
||||
95
py-deploy/template/nginx02/deployment.yaml
Normal file
95
py-deploy/template/nginx02/deployment.yaml
Normal file
@@ -0,0 +1,95 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ deployment_name }}
|
||||
namespace: {{ namespace }}
|
||||
spec:
|
||||
replicas: {{ replicas }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ deployment_name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: {{ deployment_name }}
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ deployment_name }}
|
||||
image: {{ image }}
|
||||
imagePullPolicy: IfNotPresent
|
||||
resources:
|
||||
limits:
|
||||
cpu: {{ limits_cpu }}
|
||||
memory: {{ limits_memory }}
|
||||
requests:
|
||||
cpu: {{ requests_cpu }}
|
||||
memory: {{ requests_memory }}
|
||||
ports:
|
||||
- containerPort: 80
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
tcpSocket:
|
||||
port: 80
|
||||
timeoutSeconds: 1
|
||||
volumeMounts:
|
||||
- mountPath: /etc/localtime
|
||||
name: localtime
|
||||
- mountPath: /usr/local/nginx/conf/nginx.conf
|
||||
name: nginx
|
||||
subPath: nginx.conf
|
||||
- mountPath: /usr/local/nginx/conf/conf.d/{{ deployment_name }}.conf
|
||||
name: {{ deployment_name }}
|
||||
subPath: {{ deployment_name }}.conf
|
||||
imagePullSecrets:
|
||||
- name: {{ imageSecret }}
|
||||
volumes:
|
||||
- hostPath:
|
||||
path: /etc/localtime
|
||||
type: ''
|
||||
name: localtime
|
||||
- configMap:
|
||||
defaultMode: 420
|
||||
name: nginx
|
||||
name: nginx
|
||||
- configMap:
|
||||
defaultMode: 420
|
||||
name: configmap-{{ deployment_name }}
|
||||
name: {{ deployment_name }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ deployment_name }}
|
||||
namespace: {{ namespace }}
|
||||
spec:
|
||||
ports:
|
||||
- name: server-port
|
||||
port: 80
|
||||
targetPort: 80
|
||||
selector:
|
||||
app: {{ deployment_name }}
|
||||
type: ClusterIP
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ deployment_name }}
|
||||
namespace: {{ namespace }}
|
||||
spec:
|
||||
ingressClassName: {{ ingressClassName }}
|
||||
rules:
|
||||
- host: {{ superDomain }}
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: {{ deployment_name }}
|
||||
port:
|
||||
number: 80
|
||||
path: /nginx02
|
||||
pathType: ImplementationSpecific
|
||||
Reference in New Issue
Block a user