add: prod k8s

main
ycz008 2023-08-18 11:42:14 +08:00
parent 8328f016a5
commit d6d3cc170e
3 changed files with 195 additions and 21 deletions

View File

@ -56,6 +56,9 @@ metadata:
spec: spec:
serviceName: nacos serviceName: nacos
replicas: 3 replicas: 3
selector:
matchLabels:
app: nacos
template: template:
metadata: metadata:
labels: labels:
@ -138,24 +141,3 @@ spec:
value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg==" value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg=="
- name: NACOS_AUTH_IDENTITY_VALUE - name: NACOS_AUTH_IDENTITY_VALUE
value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg==" value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg=="
selector:
matchLabels:
app: nacos
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nacos
spec:
rules:
- host: nacos.beaconfireinc.com
http:
paths:
- path: /nacos
pathType: Prefix
backend:
service:
name: nacos
port:
name: server

View File

@ -0,0 +1,49 @@
apiVersion: v1
kind: ReplicationController
metadata:
name: mysql
labels:
name: mysql
spec:
replicas: 1
selector:
name: mysql
template:
metadata:
labels:
name: mysql
spec:
containers:
- name: mysql
image: mysql:8.0.33
ports:
- containerPort: 3306
volumeMounts:
- name: nacos-mysql-data
mountPath: /var/lib/mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: "---------"
- name: MYSQL_DATABASE
value: "nacos"
- name: MYSQL_USER
value: "nacos"
- name: MYSQL_PASSWORD
value: "Nacos@2099"
volumes:
- name: nacos-mysql-data
hostPath:
path: /data/nacos/mysql
---
apiVersion: v1
kind: Service
metadata:
name: mysql
labels:
name: mysql
spec:
ports:
- port: 3306
targetPort: 3306
selector:
name: mysql

View File

@ -0,0 +1,143 @@
apiVersion: v1
kind: Service
metadata:
name: nacos-public
labels:
app: nacos
spec:
type: NodePort
selector:
app: nacos
ports:
- port: 8848
name: server
targetPort: 8848
nodePort: 30848
- port: 9848
name: client-rpc
targetPort: 9848
nodePort: 30948
---
apiVersion: v1
kind: Service
metadata:
name: nacos
labels:
app: nacos
spec:
type: ClusterIP
selector:
app: nacos
ports:
- port: 8848
name: server
targetPort: 8848
- port: 9848
name: client-rpc
targetPort: 9848
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nacos-cm
data:
mysql.host: "mysql"
mysql.db.name: "nacos"
mysql.port: "3306"
mysql.user: "root"
mysql.password: "Admin@2099"
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: nacos
spec:
serviceName: nacos
replicas: 3
selector:
matchLabels:
app: nacos
template:
metadata:
labels:
app: nacos
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- nacos
topologyKey: "kubernetes.io/hostname"
containers:
- name: nacos
imagePullPolicy: Always
image: nacos/nacos-server:v2.2.2
resources:
requests:
memory: "2Gi"
cpu: "500m"
ports:
- containerPort: 8848
name: client
- containerPort: 9848
name: client-rpc
- containerPort: 9849
name: raft-rpc
- containerPort: 7848
name: old-raft-rpc
env:
- name: NACOS_REPLICAS
value: "3"
- name: MYSQL_SERVICE_HOST
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.host
- name: MYSQL_SERVICE_DB_NAME
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.db.name
- name: MYSQL_SERVICE_PORT
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.port
- name: MYSQL_SERVICE_USER
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.user
- name: MYSQL_SERVICE_PASSWORD
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.password
- name: MYSQL_SERVICE_DB_PARAM
value: "characterEncoding=utf8&connectTimeout=10000&socketTimeout=30000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true"
- name: SPRING_DATASOURCE_PLATFORM
value: "mysql"
- name: MODE
value: "cluster"
- name: NACOS_SERVER_PORT
value: "8848"
- name: PREFER_HOST_MODE
value: "hostname"
- name: NACOS_SERVERS
value: "nacos-0.nacos.base.svc:8848 nacos-1.nacos.base.svc:8848 nacos-2.nacos.base.svc:8848"
- name: NACOS_AUTH_ENABLE
value: "true"
- name: NACOS_AUTH_TOKEN
value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg=="
- name: NACOS_AUTH_IDENTITY_KEY
value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg=="
- name: NACOS_AUTH_IDENTITY_VALUE
value: "SSBhbSB0aGUgc3RhZmYgb2Ygd3d3LmJlYWNvbmZpcmVpbmMuY29tCg=="