k8s编排文件
This commit is contained in:
parent
2adf026f0b
commit
e178a14737
|
|
@ -0,0 +1,419 @@
|
|||
# ConfigMap 用于存储环境变量
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: gns-config
|
||||
namespace: gns
|
||||
data:
|
||||
MYSQL_DATABASE: "gitlink_notification"
|
||||
---
|
||||
# Redis Deployment
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: gns-redis
|
||||
namespace: gns
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: gns-redis
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: gns-redis
|
||||
spec:
|
||||
containers:
|
||||
- name: gns-redis
|
||||
image: redis:5.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: TZ
|
||||
value: "Asia/Shanghai"
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
volumeMounts:
|
||||
- name: redis-data
|
||||
mountPath: /data
|
||||
- name: redis-logs
|
||||
mountPath: /logs
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: gns-config
|
||||
volumes:
|
||||
- name: redis-data
|
||||
hostPath:
|
||||
path: /data/gitlink-notification-system/docker-data/redis/data
|
||||
- name: redis-logs
|
||||
hostPath:
|
||||
path: /data/gitlink-notification-system/docker-data/redis/logs
|
||||
|
||||
---
|
||||
# Redis Service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: gns-redis
|
||||
namespace: gns
|
||||
spec:
|
||||
selector:
|
||||
app: gns-redis
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 6379
|
||||
targetPort: 6379
|
||||
type: ClusterIP
|
||||
---
|
||||
# Zookeeper Deployment
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: gns-zookeeper
|
||||
namespace: gns
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: gns-zookeeper
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: gns-zookeeper
|
||||
spec:
|
||||
containers:
|
||||
- name: gns-zookeeper
|
||||
image: confluentinc/cp-zookeeper:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: ZOOKEEPER_CLIENT_PORT
|
||||
value: "2181"
|
||||
- name: ZOOKEEPER_TICK_TIME
|
||||
value: "2000"
|
||||
ports:
|
||||
- containerPort: 2181
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: gns-config
|
||||
volumes:
|
||||
- name: zookeeper-data
|
||||
hostPath:
|
||||
path: /data/gitlink-notification-system/docker-data/zookeeper
|
||||
|
||||
---
|
||||
# Zookeeper Service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: gns-zookeeper
|
||||
namespace: gns
|
||||
spec:
|
||||
selector:
|
||||
app: gns-zookeeper
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 2181
|
||||
targetPort: 2181
|
||||
type: ClusterIP
|
||||
---
|
||||
# Kafka1 Deployment
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: gns-kafka1
|
||||
namespace: gns
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: gns-kafka1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: gns-kafka1
|
||||
spec:
|
||||
containers:
|
||||
- name: gns-kafka1
|
||||
image: confluentinc/cp-kafka:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: KAFKA_BROKER_ID
|
||||
value: "1"
|
||||
- name: KAFKA_ZOOKEEPER_CONNECT
|
||||
value: "gns-zookeeper:2181"
|
||||
- name: KAFKA_ADVERTISED_LISTENERS
|
||||
value: "PLAINTEXT://gns-kafka1:9092,PLAINTEXT_HOST://localhost:29092"
|
||||
- name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
|
||||
value: "PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT"
|
||||
- name: KAFKA_INTER_BROKER_LISTENER_NAME
|
||||
value: "PLAINTEXT"
|
||||
- name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
|
||||
value: "1"
|
||||
ports:
|
||||
- containerPort: 9092
|
||||
- containerPort: 29092
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: gns-config
|
||||
volumes:
|
||||
- name: kafka-data
|
||||
hostPath:
|
||||
path: /data/gitlink-notification-system/docker-data/kafka/gns_kafka1/lib
|
||||
- name: kafka-logs
|
||||
hostPath:
|
||||
path: /data/gitlink-notification-system/docker-data/kafka/gns_kafka1/logs
|
||||
- name: kafka-conf
|
||||
hostPath:
|
||||
path: /data/gitlink-notification-system/docker-data/kafka/gns_kafka1/conf
|
||||
|
||||
---
|
||||
# Kafka1 Service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: gns-kafka1
|
||||
namespace: gns
|
||||
spec:
|
||||
selector:
|
||||
app: gns-kafka1
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 9092
|
||||
targetPort: 9092
|
||||
name: kafka1-9092
|
||||
- protocol: TCP
|
||||
port: 29092
|
||||
targetPort: 29092
|
||||
name: kafka1-29092
|
||||
type: ClusterIP
|
||||
---
|
||||
# Kafka2 Deployment
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: gns-kafka2
|
||||
namespace: gns
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: gns-kafka2
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: gns-kafka2
|
||||
spec:
|
||||
containers:
|
||||
- name: gns-kafka2
|
||||
image: confluentinc/cp-kafka:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: KAFKA_BROKER_ID
|
||||
value: "2"
|
||||
- name: KAFKA_ZOOKEEPER_CONNECT
|
||||
value: "gns-zookeeper:2181"
|
||||
- name: KAFKA_ADVERTISED_LISTENERS
|
||||
value: "PLAINTEXT://gns-kafka2:9092,PLAINTEXT_HOST://localhost:39092"
|
||||
- name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
|
||||
value: "PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT"
|
||||
- name: KAFKA_INTER_BROKER_LISTENER_NAME
|
||||
value: "PLAINTEXT"
|
||||
- name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
|
||||
value: "1"
|
||||
ports:
|
||||
- containerPort: 9092
|
||||
- containerPort: 39092
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: gns-config
|
||||
volumes:
|
||||
- name: kafka-data
|
||||
hostPath:
|
||||
path: /data/gitlink-notification-system/docker-data/kafka/gns_kafka2/lib
|
||||
- name: kafka-logs
|
||||
hostPath:
|
||||
path: /data/gitlink-notification-system/docker-data/kafka/gns_kafka2/logs
|
||||
- name: kafka-conf
|
||||
hostPath:
|
||||
path: /data/gitlink-notification-system/docker-data/kafka/gns_kafka2/conf
|
||||
|
||||
---
|
||||
# Kafka2 Service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: gns-kafka2
|
||||
namespace: gns
|
||||
spec:
|
||||
selector:
|
||||
app: gns-kafka2
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 9092
|
||||
targetPort: 9092
|
||||
name: kafka2-9092
|
||||
- protocol: TCP
|
||||
port: 39092
|
||||
targetPort: 39092
|
||||
name: kafka2-29092
|
||||
type: ClusterIP
|
||||
---
|
||||
# GNS Reader Deployment
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: gns-reader
|
||||
namespace: gns
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: gns-reader
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: gns-reader
|
||||
spec:
|
||||
containers:
|
||||
- name: gns-reader
|
||||
image: gitlink/gns-reader:1.0.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: NACOS_OPTS
|
||||
value: "--nacos_ip=gitlink-nacos.microservices.svc --nacos_port=8848 --nacos_username=nacos --nacos_password=nacos"
|
||||
- name: TZ
|
||||
value: "Asia/Shanghai"
|
||||
ports:
|
||||
- containerPort: 8081
|
||||
volumeMounts:
|
||||
- name: logs
|
||||
mountPath: /data/logs
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: gns-config
|
||||
volumes:
|
||||
- name: logs
|
||||
hostPath:
|
||||
path: /data/gitlink-notification-system/docker-data/gitlink
|
||||
---
|
||||
# GNS Reader Service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: gns-reader
|
||||
namespace: gns
|
||||
spec:
|
||||
selector:
|
||||
app: gns-reader
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 8081
|
||||
targetPort: 8081
|
||||
type: ClusterIP
|
||||
---
|
||||
# GNS Writer Deployment
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: gns-writer
|
||||
namespace: gns
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: gns-writer
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: gns-writer
|
||||
spec:
|
||||
containers:
|
||||
- name: gns-writer
|
||||
image: gitlink/gns-writer:1.0.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: NACOS_OPTS
|
||||
value: "--nacos_ip=gitlink-nacos.microservices.svc --nacos_port=8848 --nacos_username=nacos --nacos_password=nacos"
|
||||
- name: TZ
|
||||
value: "Asia/Shanghai"
|
||||
ports:
|
||||
- containerPort: 8082
|
||||
volumeMounts:
|
||||
- name: logs
|
||||
mountPath: /data/logs
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: gns-config
|
||||
volumes:
|
||||
- name: logs
|
||||
hostPath:
|
||||
path: /data/gitlink-notification-system/docker-data/gitlink
|
||||
|
||||
---
|
||||
# GNS Writer Service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: gns-writer
|
||||
namespace: gns
|
||||
spec:
|
||||
selector:
|
||||
app: gns-writer
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 8082
|
||||
targetPort: 8082
|
||||
type: ClusterIP
|
||||
---
|
||||
# GNS Executor Deployment
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: gns-executor
|
||||
namespace: gns
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: gns-executor
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: gns-executor
|
||||
spec:
|
||||
containers:
|
||||
- name: gns-executor
|
||||
image: gitlink/gns-executor:1.0.0
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: NACOS_OPTS
|
||||
value: "--nacos_ip=gitlink-nacos.microservices.svc --nacos_port=8848 --nacos_username=nacos --nacos_password=nacos"
|
||||
- name: TZ
|
||||
value: "Asia/Shanghai"
|
||||
ports:
|
||||
- containerPort: 8083
|
||||
volumeMounts:
|
||||
- name: logs
|
||||
mountPath: /data/logs
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: gns-config
|
||||
volumes:
|
||||
- name: logs
|
||||
hostPath:
|
||||
path: /data/gitlink-notification-system/docker-data/gitlink
|
||||
|
||||
---
|
||||
# GNS Executor Service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: gns-executor
|
||||
namespace: gns
|
||||
spec:
|
||||
selector:
|
||||
app: gns-executor
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 8083
|
||||
targetPort: 8083
|
||||
type: ClusterIP
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: gns-mysql-pv
|
||||
namespace: gns
|
||||
spec:
|
||||
capacity:
|
||||
storage: 10Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: "gns-mysql-pv" # 确保这个 storageClassName 与 PVC 中的匹配
|
||||
hostPath:
|
||||
path: "/data/gitlink-notification-system/docker-data/mysql"
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
# PersistentVolumeClaim 用于存储卷
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: gns-mysql-pvc
|
||||
namespace: gns
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: "gns-mysql-pv"
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
---
|
||||
# Secret 用于存储敏感信息
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: gns-secret
|
||||
namespace: gns
|
||||
type: Opaque
|
||||
data:
|
||||
MYSQL_ROOT_PASSWORD: "Z2l0TGlOa184Mjc="
|
||||
MYSQL_USER: "Z2l0bGluaw=="
|
||||
MYSQL_PASSWORD: "Z2lUbGluSzBeODI3"
|
||||
#---
|
||||
## gns-mysql-pv 用于存储 MySQL 数据
|
||||
#apiVersion: v1
|
||||
#kind: PersistentVolume
|
||||
#metadata:
|
||||
# name: gns-mysql-pv
|
||||
# namespace: gns
|
||||
#spec:
|
||||
# capacity:
|
||||
# storage: 10Gi
|
||||
# accessModes:
|
||||
# - ReadWriteOnce
|
||||
# storageClassName: "gns-mysql-pv" # 确保这个 storageClassName 与 PVC 中的匹配
|
||||
# hostPath:
|
||||
# path: "/data/gitlink-notification-system/docker-data/mysql"
|
||||
#---
|
||||
## PersistentVolumeClaim 用于存储卷
|
||||
#apiVersion: v1
|
||||
#kind: PersistentVolumeClaim
|
||||
#metadata:
|
||||
# name: gns-mysql-pvc
|
||||
# namespace: gns
|
||||
#spec:
|
||||
# accessModes:
|
||||
# - ReadWriteOnce
|
||||
# storageClassName: "gns-mysql-pv"
|
||||
# resources:
|
||||
# requests:
|
||||
# storage: 10Gi
|
||||
---
|
||||
# MySQL Deployment
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: gns-mysql
|
||||
namespace: gns
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: gns-mysql
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: gns-mysql
|
||||
spec:
|
||||
containers:
|
||||
- name: gns-mysql
|
||||
image: mysql:5.7
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: MYSQL_ROOT_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: gns-secret
|
||||
key: MYSQL_ROOT_PASSWORD
|
||||
- name: MYSQL_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: gns-secret
|
||||
key: MYSQL_USER
|
||||
- name: MYSQL_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: gns-secret
|
||||
key: MYSQL_PASSWORD
|
||||
- name: MYSQL_DATABASE
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: gns-config
|
||||
key: MYSQL_DATABASE
|
||||
- name: TZ
|
||||
value: "Asia/Shanghai"
|
||||
ports:
|
||||
- containerPort: 3306
|
||||
volumeMounts:
|
||||
- name: mysql-data
|
||||
mountPath: /var/lib/mysql
|
||||
- name: sql-scripts
|
||||
mountPath: /docker-entrypoint-initdb.d
|
||||
command: ["/entrypoint.sh"]
|
||||
args: ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci","--bind-address=0.0.0.0"]
|
||||
volumes:
|
||||
- name: mysql-data
|
||||
hostPath:
|
||||
path: /data/gitlink-notification-system/docker-data/mysql
|
||||
type: DirectoryOrCreate
|
||||
- name: sql-scripts
|
||||
hostPath:
|
||||
path: /data/gitlink-notification-system/db
|
||||
---
|
||||
# MySQL Service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: gns-mysql-service
|
||||
namespace: gns
|
||||
spec:
|
||||
selector:
|
||||
app: gns-mysql
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 3306
|
||||
targetPort: 3306
|
||||
type: ClusterIP
|
||||
Loading…
Reference in New Issue