一:deployment资源模板
apiVersion: apps/v1
kind: Deployment
metadata:
name: ${depName}
namespace: ${namespace}
spec:
replicas: ${replicas}
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 30%
selector:
matchLabels:
app: ${depName}
template:
metadata:
labels:
app: ${depName}
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: host-label
operator: In
values:
- "normal"
imagePullSecrets:
- name: artifact-registry-key
containers:
- image: 10.100.10.10:8081/${repoPath}/${imageName}:${imageTag}
name: ${appName}
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: "2"
memory: 4Gi
limits:
cpu: "3"
memory: 6Gi
ports:
- containerPort: ${appPort}
envFrom:
- configMapRef:
name: ${cmName}
env: #传参
- name: SERVICE_NAME
value: "${svcName}"
readinessProbe:
tcpSocket:
port: ${appPort}
initialDelaySeconds: 60 # 容器启动后多久开始探测
timeoutSeconds: 2 # 表示容器必须在2s内做出相应反馈给probe,否则视为探测失败
periodSeconds: 30 # 探测周期,每30s探测一次
successThreshold: 1 # 连续探测1次成功表示成功
failureThreshold: 3 # 连续探测3次失败表示失败
livenessProbe:
tcpSocket:
port: ${appPort}
initialDelaySeconds: 60 # 容器启动后多久开始探测
timeoutSeconds: 2 # 表示容器必须在2s内做出相应反馈给probe,否则视为探测失败
periodSeconds: 30 # 探测周期,每30s探测一次
successThreshold: 1 # 连续探测1次成功表示成功
failureThreshold: 3 # 连续探测3次失败表示失败
startupProbe: #应用启动探测
tcpSocket: #
port: ${appPort} #探测端口
initialDelaySeconds: 60 # 容器启动后多久开始探测
timeoutSeconds: 2 # 表示容器必须在2s内做出相应反馈给probe,否则视为探测失败
periodSeconds: 30 # 探测周期,每30s探测一次
successThreshold: 1 # 连续探测1次成功表示成功
failureThreshold: 3 # 连续探测3次失败表示失败
二:SVC资源模板
apiVersion: v1
kind: Service
metadata:
name: ${svcName}
namespace: ${namespace}
labels:
name: ${svcName}
springbootadmin: enabled
annotations:
#service.kubernetes.io/loadbalance-id: lb-**** #lb获取ingressIP的ID,IP动态变化
service.kubernetes.io/qcloud-loadbalancer-internal-subnetid: subnet-**** #分配ingressIP的网段
service.kubernetes.io/tke-existed-lbid: lb-**** #lb获取ingressIP的ID,IP非动态变化
spec:
type: ${svcType}
ports:
- protocol: "TCP"
port: ${svcPort}
targetPort: ${appPort}
selector:
app: ${depName}
三:configMap资源模板
kind: ConfigMap
apiVersion: v1
metadata:
name: ${cmName}
namespace: ${namespace}
data:
JAVA_OPTS: >-
-server -Xmx2048m -Xms512m -Xmn512m -Xss512k
-XX:+DisableExplicitGC -XX:+AggressiveOpts -XX:+UseBiasedLocking
-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled
-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70
-XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/work/log
-Xloggc:/tmp/work/log/heap_trace.txt
PARAMS: >-
--address.shared.tools.pns=http://............
..........
..........