run mangosone in kubernetes

  sre

主页

先在各节点拉取3个镜像:
ssorriaux/mangosone-database-mysql:latest ssorriaux/mangosone-server:latest ssorriaux/mangosone-realmd
先获取镜像内数据库,并导入到本地:

ns

apiVersion: v1
kind: Namespace
metadata:
  name: wow-tbc

Deployment mysql

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mangosone-mysql
  template:
    metadata:
      labels:
        app: mangosone-mysql
    spec:
      containers:
      - name: mangosone-mysql
        image: ssorriaux/mangosone-database-mysql:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 3306
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: QWERTY123

mysql Service

kind: Service
apiVersion: v1
metadata:
  name: mysql
spec:
  type: NodePort
  ports:
  - name: mysql
    port: 3306
    nodePort: 30004
    targetPort: 3306
    protocol: TCP
  selector:
    app: mangosone-mysql

数据库处理

连接30004端口,导出三个库。
导出后删除mysql的Deployment与Service,并在本地数据库导入。

创建mangos pvc:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mangos-map
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: "30Gi"
  volumeName: 
  storageClassName: nfs

创建完成后,将maps的4个目录复制进去

Deployment mangosone-server

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mangosone-server
  labels:
    app: mangosone-server
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mangosone-server
  template:
    metadata:
      labels:
        app: mangosone-server
    spec:
      containers:
      - name: mangosone-server
        image: ssorriaux/mangosone-server:latest
        env:
        - name: LOGIN_DATABASE_INFO
          value: 192.168.2.144;3306;root;QWERTY123.;tbc_realmd
        - name: WORLD_DATABASE_INFO
          value: 192.168.2.144;3306;root;QWERTY123.;tbc_mangos
        - name: CHARACTER_DATABASE_INFO
          value: 192.168.2.144;3306;root;QWERTY123.;tbc_character
        ports:
        - name: "mangos-server"
          containerPort: 8085
        volumeMounts:
        - name: mangos-map
          mountPath: /etc/mangos
        volumes:
        - name: mangos-map
          persistentVolumeClaim:
            claimName: mangos-map
        livenessProbe:
          tcpSocket:
            port: 8085
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 5
        readinessProbe:
          tcpSocket:
            port: 8085
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 5

service 8085

apiVersion: v1
kind: Service
metadata:
  name: mangosone-server
  labels:
    app: mangosone-server
spec:
  ports:
  - name: mangos-server
    port: 8085
  clusterIP: None
  selector:
    app: mangosone-server

realmd Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mangosone-realmd
  labels:
    app: mangosone-realmd
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mangosone-realmd
  template:
    metadata:
      labels:
        app: mangosone-realmd
    spec:
      containers:
      - name: mangosone-realmd
        image: ssorriaux/mangosone-realmd:latest
        env:
        - name: LOGIN_DATABASE_INFO
          value: 192.168.2.144;3306;root;QWERTY123.;tbc_realmd
        ports:
        - name: "mangos-realmd"
          containerPort: 3724
        livenessProbe:
          tcpSocket:
            port: 3724
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 5
        readinessProbe:
          tcpSocket:
            port: 3724
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 5

service 3724

apiVersion: v1
kind: Service
metadata:
  name: mangosone-realmd
  labels:
    app: mangosone-realmd
spec:
  ports:
  - name: mangos-realmd
    port: 3724
  clusterIP: None
  selector:
    app: mangosone-realmd

LEAVE A COMMENT

Captcha Code