使用microk8s部署Factorio,记录一下配置文件
安装 microk8s
1 2 3 4 5 6 7 8
| sudo apt update sudo apt install snapd sudo snap install microk8s --classic microk8s status --wait-ready microk8s enable dashboard dns registry istio microk8s kubectl get all --all-namespaces microk8s dashboard-proxy sudo snap alias microk8s.kubectl kubectl
|
配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| apiVersion: apps/v1 kind: Deployment metadata: name: factorio spec: replicas: 1 selector: matchLabels: app: factorio template: metadata: labels: app: factorio spec: containers: - name: factorio image: factoriotools/factorio ports: - containerPort: 34197 protocol: UDP - containerPort: 27015 protocol: TCP volumeMounts: - name: factorio-volume mountPath: /factorio restartPolicy: Always volumes: - name: factorio-volume hostPath: path: /opt/factorio
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| apiVersion: v1 kind: Service metadata: name: factorio spec: selector: app: factorio type: NodePort ports: - name: udp protocol: UDP port: 34197 targetPort: 34197 nodePort: 30002 - name: tcp protocol: TCP port: 27015 targetPort: 27015 nodePort: 30001
|
nodePort端口外部可访问 其范围是 30000 到 32767
常用命令
1 2 3 4 5 6 7 8 9
| kubectl apply -f .\xxx.yaml microk8s.kubectl get deployments microk8s.kubectl get pods microk8s.kubectl get services microk8s.kubectl delete services myapp2 microk8s.kubectl create deployment nginx --image=nginx microk8s.kubectl expose deployments/nginx --type="NodePort" --port=80 --name=myapp5 microk8s.kubectl describe svc myapp5 microk8s.kubectl port-forward nginx-xxxxxxx-xxxx --address 0.0.0.0 8081:8080
|
二进制方式启动
1 2
| ./bin/x64/factorio --config ~/factorio/config/config.ini --port 34197 --start-server ~/factorio/saves/test1.zip --server-settings ~/factorio/data/server-settings.json
|
设置游戏管理员
- 在服务端输入
/promote 玩家名字
- 在启动服务器命令时加上 –server-adminlist +管理员名单json文件的路径
例如:
- -server-adminlist /usr/local/games/factorio/data/server-adminlist.json
具体的adminlist.json文件内容的写法和白名单的example一样
参考
https://kubernetes.io/zh-cn/docs/concepts/services-networking/service/
https://github.com/factoriotools/factorio-docker
https://microk8s.io/#install-microk8s
https://wiki.factorio.com/Command_line_parameters