[优化] 优化K8S部署脚本

This commit is contained in:
PandaX
2024-03-25 14:28:37 +08:00
parent 0b0dbeab4f
commit 0cba8765c8
2 changed files with 172 additions and 149 deletions

View File

@@ -27,92 +27,9 @@ roleRef:
kind: ClusterRole kind: ClusterRole
name: cluster-admin name: cluster-admin
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: pandax name: pandax
namespace: pandax namespace: pandax
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/version: 1.0.0
name: emqx
namespace: pandax
spec:
ports:
- port: 1883
protocol: TCP
targetPort: 1883
- port: 8083
protocol: TCP
targetPort: 8083
- port: 8084
protocol: TCP
targetPort: 8084
- port: 8883
protocol: TCP
targetPort: 8883
- port: 18083
protocol: TCP
targetPort: 18083
selector:
app: emqx
app.kubernetes.io/version: 1.0.0
type: LoadBalancer
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/version: 1.0.0
name: mysql
namespace: pandax
spec:
ports:
- port: 3306
protocol: TCP
targetPort: mysql
selector:
app: mysql
app.kubernetes.io/version: 1.0.0
type: LoadBalancer
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/version: 1.0.0
name: redis
namespace: pandax
spec:
ports:
- port: 6379
protocol: TCP
targetPort: redis
selector:
app: redis
app.kubernetes.io/version: 1.0.0
type: LoadBalancer
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/version: 1.0.0
name: tdengine
namespace: pandax
spec:
ports:
- port: 6030
protocol: TCP
targetPort: 6030
- port: 6041
protocol: TCP
targetPort: 6041
selector:
app: tdengine
app.kubernetes.io/version: 1.0.0
type: LoadBalancer
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@@ -136,20 +53,25 @@ spec:
app.kubernetes.io/version: 1.0.0 app.kubernetes.io/version: 1.0.0
spec: spec:
containers: containers:
- image: emqx/emqx:5.1.0 - image: emqx/emqx:5.1.0
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
name: emqx name: emqx
ports: ports:
- containerPort: 1883 - name: emqx-1883
protocol: TCP containerPort: 1883
- containerPort: 8083 protocol: TCP
protocol: TCP - name: emqx-8083
- containerPort: 8084 containerPort: 8083
protocol: TCP protocol: TCP
- containerPort: 8883 - name: emqx-8084
protocol: TCP containerPort: 8084
- containerPort: 18083 protocol: TCP
protocol: TCP - name: emqx-8883
containerPort: 8883
protocol: TCP
- name: emqx-18083
containerPort: 18083
protocol: TCP
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@@ -173,23 +95,23 @@ spec:
app.kubernetes.io/version: 1.0.0 app.kubernetes.io/version: 1.0.0
spec: spec:
containers: containers:
- env: - env:
- name: MYSQL_ROOT_PASSWORD - name: MYSQL_ROOT_PASSWORD
value: pandax value: pandax
image: mysql:8.0.23 image: mysql:8.0.23
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
name: mysql
ports:
- containerPort: 3306
name: mysql name: mysql
protocol: TCP ports:
volumeMounts: - containerPort: 3306
- mountPath: /var/lib/mysql name: mysql
name: mysql-data protocol: TCP
volumeMounts:
- mountPath: /var/lib/mysql
name: mysql-data
volumes: volumes:
- name: mysql-data - name: mysql-data
hostPath: hostPath:
path: ./mysql/data path: /root/data/mysql/data
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@@ -213,28 +135,28 @@ spec:
app.kubernetes.io/version: 1.0.0 app.kubernetes.io/version: 1.0.0
spec: spec:
containers: containers:
- env: - env:
- name: requirepass - name: requirepass
value: pandax value: pandax
image: redis:7.0.12 image: redis:7.0.12
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
name: redis
ports:
- containerPort: 3306
name: redis name: redis
protocol: TCP ports:
volumeMounts: - containerPort: 3306
- mountPath: /data name: redis
name: redis-data protocol: TCP
- mountPath: /logs volumeMounts:
name: mysql-log - mountPath: /data
name: redis-data
- mountPath: /logs
name: redis-log
volumes: volumes:
- name: redis-data - name: redis-data
hostPath: hostPath:
path: ./redis/data path: /root/data/redis/data
- name: redis-log - name: redis-log
hostPath: hostPath:
path: ./redis/logs path: /root/data/redis/logs
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@@ -258,11 +180,104 @@ spec:
app.kubernetes.io/version: 1.0.0 app.kubernetes.io/version: 1.0.0
spec: spec:
containers: containers:
- image: tdengine/tdengine:3.0.4.2 - image: tdengine/tdengine:3.0.4.2
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
name: tdengine name: tdengine
ports: ports:
- containerPort: 6030 - name: td-6030
protocol: TCP containerPort: 6030
- containerPort: 6041 protocol: TCP
protocol: TCP - name: td-6041
containerPort: 6041
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/version: 1.0.0
name: emqx
namespace: pandax
spec:
ports:
- name: emqx-1883
port: 1883
protocol: TCP
targetPort: 1883
- name: emqx-8083
port: 8083
protocol: TCP
targetPort: 8083
- name: emqx-8084
port: 8084
protocol: TCP
targetPort: 8084
- name: emqx-8883
port: 8883
protocol: TCP
targetPort: 8883
- name: emqx-18083
port: 18083
protocol: TCP
targetPort: 18083
selector:
app: emqx
app.kubernetes.io/version: 1.0.0
type: LoadBalancer
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/version: 1.0.0
name: redis
namespace: pandax
spec:
ports:
- name: redis
port: 6379
protocol: TCP
targetPort: redis
selector:
app: redis
app.kubernetes.io/version: 1.0.0
type: LoadBalancer
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/version: 1.0.0
name: tdengine
namespace: pandax
spec:
ports:
- name: td-6030
port: 6030
protocol: TCP
targetPort: 6030
- name: td-6041
port: 6041
protocol: TCP
targetPort: 6041
selector:
app: tdengine
app.kubernetes.io/version: 1.0.0
type: LoadBalancer
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/version: 1.0.0
name: mysql
namespace: pandax
spec:
ports:
- port: 3306
protocol: TCP
targetPort: mysql
selector:
app: mysql
app.kubernetes.io/version: 1.0.0
type: LoadBalancer

View File

@@ -11,18 +11,23 @@ spec:
- port: 7788 - port: 7788
protocol: TCP protocol: TCP
targetPort: 7788 targetPort: 7788
name: px-7788
- port: 9001 - port: 9001
protocol: TCP protocol: TCP
targetPort: 9001 targetPort: 9001
name: px-9001
- port: 9002 - port: 9002
protocol: TCP protocol: TCP
targetPort: 9002 targetPort: 9002
name: px-9002
- port: 9003 - port: 9003
protocol: TCP protocol: TCP
targetPort: tcp9003 targetPort: tcp9003
name: px-tcp9003
- port: 9003 - port: 9003
protocol: UDP protocol: UDP
targetPort: udp9003 targetPort: udp9003
name: px-udp9003
selector: selector:
app.kubernetes.io/name: pandax app.kubernetes.io/name: pandax
app.kubernetes.io/version: 1.0.0 app.kubernetes.io/version: 1.0.0
@@ -107,18 +112,21 @@ spec:
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
name: pandax name: pandax
ports: ports:
- containerPort: 7788 - name: px-7788
containerPort: 7788
protocol: TCP protocol: TCP
- containerPort: 9001 - name: px-9001
containerPort: 9001
protocol: TCP protocol: TCP
- containerPort: 9002 - name: px-9002
containerPort: 9002
protocol: TCP protocol: TCP
- containerPort: 9003 - name: px-tcp9003
containerPort: 9003
protocol: TCP protocol: TCP
name: tcp9003
- containerPort: 9003 - containerPort: 9003
protocol: UDP protocol: UDP
name: udp9003 name: px-udp9003
serviceAccountName: pandax serviceAccountName: pandax
--- ---
apiVersion: apps/v1 apiVersion: apps/v1