run Mangoszero in kubernetes

  sre

项目主页:https://github.com/solipsist01/MangosZero
准备工作:玩过mangoszero、kubernetes集群、准备pv/storageclass
先在各节点拉取下镜像:
solipsist01/mangoszero
稍微创建下资源:

ns:

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

service web:

kind: Service
apiVersion: v1
metadata:
  name: web
spec:
  ports:
  - name: nginx
    port: 80
    targetPort: 80
    protocol: TCP
  selector:
    name: nginx

ingrees:

kind: Ingress
apiVersion: extensions/v1beta1
metadata: 
    name: wow-web
    namespace: wow-vanilla
    annotations:
        kubernetes.io/ingress.class: traefik
spec:
    rules:
    -   host: wow.yourdm.com
        http:
            paths:
            -   backend:
                    serviceName: web
                    servicePort: 80
                path: /

service mangos-server:

kind: Service
apiVersion: v1
metadata:
  name: mangos-server
spec:
  type: NodePort
  ports:
  - name: mangos
    port: 8085
    nodePort: 30001
    targetPort: 8085
    protocol: TCP
  - name: realmd
    port: 3724
    nodePort: 30002
    targetPort: 3724
    protocol: TCP
  selector:
    name: mangos

service mysql:

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

mangos pvc:

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

deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mangos-server
spec:
  replicas: 1
  selector:
    matchLabels:
      name: nginx
      name: mangos
      name: mysql
  template:
    metadata:
      labels:
        name: nginx
        name: mangos
        name: mysql
    spec:
      containers:
      - name: mangoszero
        image: solipsist01/mangoszero
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
          name: nginx
          protocol: TCP
        - containerPort: 3306
          name: mysql
          protocol: TCP
        - containerPort: 3724
          name: realmd
          protocol: TCP
        - containerPort: 8085
          name: mangosd
          protocol: TCP
        env:
          - name: MYSQL_ROOT_PASSWORD
            value: mangos
        volumeMounts:
        - name: mangos-config
          mountPath: /config
      volumes:
       - name: mangos-config
         persistentVolumeClaim:
           claimName: mangos-config            

创建完成后,发现运行有报错:

Could not find configuration file /config/wowconfig/realmd.conf.
Could not find configuration file /config/wowconfig/mangosd.conf.

我们在pvc里面创建两个配置文件:

realmd.conf

[RealmdConf]
ConfVersion=2010062001
LoginDatabaseInfo      = "127.0.0.1;3306;root;mangos;realmd"
LogsDir                = "/config/realmdlogs"
PidFile                = ""

MaxPingTime            = 30
RealmServerPort        = 3724
BindIP                 = "0.0.0.0"

LogLevel               = 0
LogTime                = 0
LogFile                = "realm-list.log"
LogTimestamp           = 0
LogFileLevel           = 0
LogColors              = "13 7 11 9"

UseProcessors          = 0
ProcessPriority        = 1
WaitAtStartupError     = 0
RealmsStateUpdateDelay = 20

WrongPass.MaxCount     = 3
WrongPass.BanTime      = 300
WrongPass.BanType      = 0

mangosd.conf

[MangosdConf]
ConfVersion=2017021100
RealmID                      = 1
DataDir                      = "/mangos"
LogsDir                      = "/config/mangoslogs"
LoginDatabaseInfo            = "127.0.0.1;3306;root;mangos;realmd"
WorldDatabaseInfo            = "127.0.0.1;3306;root;mangos;mangos0"
CharacterDatabaseInfo        = "127.0.0.1;3306;root;mangos;character0"
LoginDatabaseConnections     = 1
WorldDatabaseConnections     = 1
CharacterDatabaseConnections = 1
MaxPingTime                  = 5
WorldServerPort              = 8085
BindIP                       = "0.0.0.0"

UseProcessors                     = 0
ProcessPriority                   = 1
Compression                       = 1
PlayerLimit                       = 100
SaveRespawnTimeImmediately        = 1
MaxOverspeedPings                 = 2
GridUnload                        = 1
LoadAllGridsOnMaps                = ""
GridCleanUpDelay                  = 300000
MapUpdateInterval                 = 100
MapUpdateThreads                  = 2
ChangeWeatherInterval             = 600000
PlayerSave.Interval               = 900000
PlayerSave.Stats.MinLevel         = 0
PlayerSave.Stats.SaveOnlyOnLogout = 1
vmap.enableLOS                    = 1
vmap.enableHeight                 = 1
vmap.ignoreSpellIds               = "7720"
vmap.enableIndoorCheck            = 1
DetectPosCollision                = 1
TargetPosRecalculateRange         = 1.5
mmap.enabled                      = 1
mmap.ignoreMapIds                 = ""
UpdateUptimeInterval              = 10
MaxCoreStuckTime                  = 0
AddonChannel                      = 1
CleanCharacterDB                  = 1

LogSQL                       = 1
PidFile                      = "/mangos/mangos.pid"
LogLevel                     = 3
LogTime                      = 0
LogFile                      = "world-server.log"
LogTimestamp                 = 0
LogFileLevel                 = 3
LogFilter_TransportMoves     = 1
LogFilter_CreatureMoves      = 1
LogFilter_VisibilityChanges  = 1
LogFilter_Weather            = 1
LogFilter_DbStrictedCheck    = 1
LogFilter_Pathfinding        = 1
LogFilter_MapsLoading        = 1
LogFilter_EventAiDev         = 1
LogFilter_PeriodicAffects    = 0
LogFilter_PlayerMoves        = 1
LogFilter_SQLText            = 1
LogFilter_AIAndMovegens      = 0
LogFilter_PlayerStats        = 0
LogFilter_Damage             = 0
LogFilter_Combat             = 0
LogFilter_SpellCast          = 0
LogWhispers                  = 1
WorldLogFile                 = "world-packets.log"
WorldLogTimestamp            = 0
DBErrorLogFile               = "world-database.log"
ElunaErrorLogFile            = "ElunaErrors.log"
EventAIErrorLogFile          = "world-eventai.log"
CharLogFile                  = "world-characters.log"
CharLogTimestamp             = 0
CharLogDump                  = 0
GmLogFile                    = "world-gamemaster.log"
GmLogTimestamp               = 0
GmLogPerAccount              = 0
RaLogFile                    = "world-remote-access.log"
WardenLogFile                = "warden.log"
WardenLogTimestamp           = 0
LogColors                    = "13 7 11 9"
SD3ErrorLogFile              = "scriptdev3-errors.log"

GameType                                  = 1
RealmZone                                 = 1
DBC.Locale                                = 255
DeclinedNames                             = 0
StrictPlayerNames                         = 0
StrictCharterNames                        = 0
StrictPetNames                            = 0
MinPlayerName                             = 2
MinCharterName                            = 2
MinPetName                                = 2
CharactersCreatingDisabled                = 0
CharactersPerAccount                      = 50
CharactersPerRealm                        = 10
SkipCinematics                            = 0
MaxPlayerLevel                            = 60
StartPlayerLevel                          = 1
StartPlayerMoney                          = 0
MaxHonorPoints                            = 75000
StartHonorPoints                          = 0
MinHonorKills                             = 15
MaintenanceDay                            = 3
InstantLogout                             = 1
MountCost                                 = 100000
TrainMountCost                            = 900000
MinTrainMountLevel                        = 40
EpicMountCost                             = 1000000
TrainEpicMountCost                        = 9000000
MinTrainEpicMountLevel                    = 60
AllFlightPaths                            = 0
InstantFlightPaths                        = 0
AlwaysMaxSkillForLevel                    = 0
ActivateWeather                           = 1
CastUnstuck                               = 1
MaxSpellCastsInChain                      = 20
RabbitDay                                 = 0
Instance.IgnoreLevel                      = 0
Instance.IgnoreRaid                       = 0
Instance.ResetTimeHour                    = 4
Instance.UnloadDelay                      = 1800000
Quests.LowLevelHideDiff                   = 4
Quests.HighLevelHideDiff                  = 7
Quests.IgnoreRaid                         = 0
Guild.EventLogRecordsCount                = 100
TimerBar.Fatigue.GMLevel                  = 4
TimerBar.Fatigue.Max                      = 60
TimerBar.Breath.GMLevel                   = 4
TimerBar.Breath.Max                       = 60
TimerBar.Fire.GMLevel                     = 4
TimerBar.Fire.Max                         = 1
MaxPrimaryTradeSkill                      = 2
TradeSkill.GMIgnore.MaxPrimarySkillsCount = 4
TradeSkill.GMIgnore.Level                 = 4
TradeSkill.GMIgnore.Skill                 = 4
MinPetitionSigns                          = 9
MaxGroupXPDistance                        = 74
MailDeliveryDelay                         = 3600
MassMailer.SendPerTick                    = 10
PetUnsummonAtMount                        = 0
Event.Announce                            = 0
BeepAtStart                               = 1
ShowProgressBars                          = 1
WaitAtStartupError                        = 10
PlayerCommands                            = 0
Motd                                      = "Welcome to Mangos Zero"
AutoBroadcast                             = 0

AllowTwoSide.Accounts             = 0
AllowTwoSide.Interaction.Chat     = 0
AllowTwoSide.Interaction.Channel  = 0
AllowTwoSide.Interaction.Group    = 0
AllowTwoSide.Interaction.Guild    = 0
AllowTwoSide.Interaction.Trade    = 0
AllowTwoSide.Interaction.Auction  = 0
AllowTwoSide.Interaction.Mail     = 0
AllowTwoSide.WhoList              = 0
AllowTwoSide.AddFriend            = 0
TalentsInspecting                 = 1


ThreatRadius                              = 100
Rate.Creature.Aggro                       = 1
CreatureRespawnAggroDelay                 = 5000
CreatureFamilyFleeAssistanceRadius        = 30
CreatureFamilyAssistanceRadius            = 10
CreatureFamilyAssistanceDelay             = 1500
CreatureFamilyFleeDelay                   = 7000
WorldBossLevelDiff                        = 3
Corpse.EmptyLootShow                      = 1
Corpse.Decay.NORMAL                       = 300
Corpse.Decay.RARE                         = 900
Corpse.Decay.ELITE                        = 600
Corpse.Decay.RAREELITE                    = 1200
Corpse.Decay.WORLDBOSS                    = 3600
Rate.Corpse.Decay.Looted                  = 0.5
Rate.Creature.Elite.Elite.Damage          = 1
Rate.Creature.Elite.Elite.HP              = 1
Rate.Creature.Elite.Elite.SpellDamage     = 1
Rate.Creature.Elite.RARE.Damage           = 1
Rate.Creature.Elite.RARE.HP               = 1
Rate.Creature.Elite.RARE.SpellDamage      = 1
Rate.Creature.Elite.RAREELITE.Damage      = 1
Rate.Creature.Elite.RAREELITE.HP          = 1
Rate.Creature.Elite.RAREELITE.SpellDamage = 1
Rate.Creature.Elite.WORLDBOSS.Damage      = 1
Rate.Creature.Elite.WORLDBOSS.HP          = 1
Rate.Creature.Elite.WORLDBOSS.SpellDamage = 1
Rate.Creature.Normal.Damage               = 1
Rate.Creature.Normal.HP                   = 1
Rate.Creature.Normal.SpellDamage          = 1

ListenRange.Say                           = 40
ListenRange.TextEmote                     = 40
ListenRange.Yell                          = 300

GuidReserveSize.Creature                  = 100
GuidReserveSize.GameObject                = 100

ChatFakeMessagePreventing       = 0
ChatStrictLinkChecking.Severity = 0
ChatStrictLinkChecking.Kick     = 0
ChatFlood.MessageCount          = 10
ChatFlood.MessageDelay          = 1
ChatFlood.MuteTime              = 10
Channel.SilentlyGMJoin          = 0

GM.LoginState            = 2
GM.Visible               = 2
GM.AcceptTickets         = 2
GM.TicketListSize        = 30
GM.TicketOfflineClosing  = 1
GM.Chat                  = 2
GM.WhisperingTo          = 2
GM.InGMList.Level        = 3
GM.InWhoList.Level       = 3
GM.LogTrade              = 1
GM.StartLevel            = 1
GM.LowerSecurity         = 0
GM.InvisibleAura         = 31748

Visibility.GroupMode               = 0
Visibility.Distance.Continents     = 90
Visibility.Distance.Instances      = 120
Visibility.Distance.BG             = 180
Visibility.Distance.InFlight       = 100
Visibility.Distance.Grey.Unit      = 1
Visibility.Distance.Grey.Object    = 10
Visibility.RelocationLowerLimit    = 10
Visibility.AIRelocationNotifyDelay = 1000

Rate.Health                       = 1
Rate.Mana                         = 1
Rate.Rage.Income                  = 1
Rate.Rage.Loss                    = 1
Rate.Focus                        = 1
Rate.Loyalty                      = 1
Rate.Energy                       = 1
Rate.Skill.Discovery              = 1
Rate.Drop.Item.Poor               = 1
Rate.Drop.Item.Normal             = 1
Rate.Drop.Item.Uncommon           = 1
Rate.Drop.Item.Rare               = 1
Rate.Drop.Item.Epic               = 1
Rate.Drop.Item.Legendary          = 1
Rate.Drop.Item.Artifact           = 1
Rate.Drop.Item.Referenced         = 1
Rate.Drop.Money                   = 1
Rate.XP.Kill                      = 1
Rate.XP.PetKill                   = 1
Rate.XP.Quest                     = 1
Rate.XP.Explore                   = 1
Rate.Rest.InGame                  = 1
Rate.Rest.Offline.InTavernOrCity  = 1
Rate.Rest.Offline.InWilderness    = 1
Rate.Damage.Fall                  = 1
Rate.Auction.Time                 = 1
Rate.Auction.Deposit              = 1
Rate.Auction.Cut                  = 1
Auction.Deposit.Min               = 0
Rate.Honor                        = 1
Rate.Mining.Amount                = 1
Rate.Mining.Next                  = 1
Rate.Mining.Lower                 = 50
Rate.Mining.Rare                  = 20
Rate.Mining.Darkiron              = 10
Autopooling.Mining.Enable         = 0
Rate.Mining.Autopooling           = 90
Rate.Talent                       = 1
Rate.Reputation.Gain              = 1
Rate.Reputation.LowLevel.Kill     = 0.2
Rate.Reputation.LowLevel.Quest    = 1
Rate.InstanceResetTime            = 1

SkillGain.Crafting                = 1
SkillGain.Defense                 = 1
SkillGain.Gathering               = 1
SkillGain.Weapon                  = 1

SkillChance.Orange                = 100
SkillChance.Yellow                = 75
SkillChance.Green                 = 25
SkillChance.Grey                  = 0
SkillChance.MiningSteps           = 0
SkillChance.SkinningSteps         = 0

SkillFail.Loot.Fishing            = 0
SkillFail.Gain.Fishing            = 0
SkillFail.Possible.FishingPool    = 1

DurabilityLossChance.Damage       = 0.5
DurabilityLossChance.Absorb       = 0.5
DurabilityLossChance.Parry        = 0.05
DurabilityLossChance.Block        = 0.05

Death.SicknessLevel               = 11
Death.CorpseReclaimDelay.PvP      = 1
Death.CorpseReclaimDelay.PvE      = 1
Death.Bones.World                 = 1
Death.Bones.Battleground          = 1
Death.Ghost.RunSpeed.World        = 1.0
Death.Ghost.RunSpeed.Battleground = 1.0


Battleground.CastDeserter             = 1
Battleground.QueueAnnouncer.Join      = 0
Battleground.QueueAnnouncer.Start     = 0
Battleground.ScoreStatistics          = 0
Battleground.InvitationType           = 0
BattleGround.PrematureFinishTimer     = 300000
BattleGround.PremadeGroupWaitForMatch = 0

OutdoorPvp.SIEnabled = 1
OutdoorPvp.EPEnabled = 1

Network.Threads         = 3
Network.OutKBuff        = -1
Network.OutUBuff        = 65536
Network.TcpNodelay      = 1
Network.KickOnBadPacket = 0

Console.Enable = 0

Ra.Enable      = 0
Ra.IP          = 0.0.0.0
Ra.Port        = 3443
Ra.MinLevel    = 3
Ra.Secure      = 1
Ra.Stricted    = 1

SOAP.Enabled   = 0
SOAP.IP        = 127.0.0.1
SOAP.Port      = 7878

CharDelete.Method   = 0
CharDelete.MinLevel = 0
CharDelete.KeepDays = 30

Warden.WinEnabled            = 1
Warden.OSXEnabled            = 0
Warden.NumMemChecks          = 3
Warden.NumOtherChecks        = 7
Warden.ClientResponseDelay   = 600
Warden.ClientCheckHoldOff    = 30
Warden.ClientCheckFailAction = 1
Warden.BanDuration           = 86400
Warden.DBLogLevel            = 0

Eluna.Enabled    = 1
Eluna.TraceBack  = false
Eluna.ScriptPath = "lua_scripts"

然后删除pod,继续观察:
提示找不到maps文件,将maps目录放入wowconfig的pvc中去继续观察:
提示版本不对:

根据https://github.com/solipsist01/MangosZero/blob/master/InstallWowfiles.sh的意思,我们重新解压一个maps。
将wow客户端打包进pvc,只需要在客户端根目录下执行以下即可:

./map-extractor
./vmap-extractor
./movemap-generator

切图执行比较慢,千万别中断:



数据库放在kubernetes里面,维护pvc不方便,改成调用外部db:
将wowconfig里面的database目录打包到任意服务器上:

[root@db database]# ll
total 96
drwxr-xr-x 4 911 911    32 Feb 21 20:37 Character
drwxr-xr-x 2 911 911    74 Feb 21 20:37 icons
-rw-r--r-- 1 911 911 63756 Feb 21 20:37 InstallDatabases.bat
-rwxr-xr-x 1 911 911  8430 Feb 21 20:37 InstallDatabases.sh
-rw-r--r-- 1 911 911  2255 Feb 21 20:37 LICENSE.md
-rw-r--r-- 1 911 911   980 Feb 21 20:37 make_full_WorldDB.sh
-rw-r--r-- 1 911 911  1704 Feb 21 20:37 README.md
drwxr-xr-x 4 911 911    59 Feb 21 20:37 Realm
drwxr-xr-x 3 911 911  4096 Feb 21 20:37 Tools
drwxr-xr-x 5 911 911  4096 Feb 21 20:37 Translations
drwxr-xr-x 4 911 911    32 Feb 21 20:37 World

在目标数据库上创建个root权限用户,如mangos密码123456,执行InstallDatabases.sh
一路输入用户名密码,数据库名称自选,脚本会自动合并sql版本:

再改变下wowconfig中数据库连接方式为外部连接:
mangosd.conf:

[MangosdConf]
ConfVersion=2017021100
RealmID                      = 1
#DataDir                      = "/mangos"
DataDir                      = "/config/wowmaps"
LogsDir                      = "/config/mangoslogs"
LoginDatabaseInfo            = "192.168.2.144;3306;mangos;123456;realmd"
WorldDatabaseInfo            = "192.168.2.144;3306;mangos;123456;mangos0"
CharacterDatabaseInfo        = "192.168.2.144;3306;mangos;123456;character0"

realmd.conf:

[RealmdConf]
ConfVersion=2010062001
LoginDatabaseInfo      = "192.168.2.144;3306;mangos;123456;realmd"

重启成功:

修改deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mangos-server
spec:
  replicas: 1
  selector:
    matchLabels:
      name: mangos
  template:
    metadata:
      labels:
        name: mangos
    spec:
      containers:
      - name: mangoszero
        image: solipsist01/mangoszero
        imagePullPolicy: IfNotPresent
        volumeMounts:
        - name: mangos-config
          mountPath: /config
      volumes:
       - name: mangos-config
         persistentVolumeClaim:
           claimName: mangos-config

修改service:

kind: Service
apiVersion: v1
metadata:
  name: mangos
spec:
  type: NodePort
  ports:
  - name: nginx
    port: 80
    nodePort: 30000
    targetPort: 80
    protocol: TCP
  - name: realmd
    port: 3724
    nodePort: 30001
    targetPort: 3724
    protocol: TCP
  - name: mangosd
    port: 8085
    nodePort: 30002
    targetPort: 8085
    protocol: TCP
  selector:
    name: mangos

外网访问,使用nginx tcp转发实现:
在nginx.conf增加如下配置:

        #wow realmd mangosd
        upstream realmd_3724 {
                hash remote_addr consistent;
                server 10.0.3.41:30001;
                server 10.0.3.42:30001;
                server 10.0.3.43:30001;
        }

        server {
                listen 3724;
                proxy_connect_timeout 28800;
                proxy_timeout 86400;
                proxy_pass realmd_3724;
        }
        upstream mangosd_30002 {
                hashremote_addr consistent;
                server 10.0.3.41:30002;
                server 10.0.3.42:30002;
                server 10.0.3.43:30002;
        }
        server {
                listen 30002;
                proxy_connect_timeout 28800;
                proxy_timeout 86400;
                proxy_pass mangosd_30002;
        }

2 thoughts on - run Mangoszero in kubernetes

LEAVE A COMMENT

Captcha Code