Skip to main content

Factorio

Création du Namespace et du label : 

kubectl create namespace factorio
kubectl label namespace factorio istio-injection=enabled

Création du PVC : 

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: factorio-srv-01-pvc
  namespace: factorio
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: longhorn
  resources:
    requests:
      storage: 10Gi
EOF

Déployment  + Service :

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
  name: factorio-mod-list
  namespace: factorio
data:
  mod-list.json: |
    {
      "mods": [
        {
          "name": "base",
          "enabled": true
        }
      ]
    }
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: factorio-01
  namespace: factorio
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: factorio-01
  template:
    metadata:
      labels:
        app: factorio-01
    spec:
      securityContext:
        runAsUser: 845
        runAsGroup: 845
        fsGroup: 845
      containers:
        - name: factorio-01
          image: factoriotools/factorio:latest-rootless
          ports:
            - containerPort: 34197
              protocol: UDP
          env:
            - name: UPDATE_MODS_ON_START
              value: "false"
          resources:
            requests:
              memory: "1Gi"
              cpu: "1000m"
          volumeMounts:
            - name: storage-volume
              mountPath: /factorio
            - name: mod-list
              mountPath: /factorio/config/mod-list.json
              subPath: mod-list.json
      volumes:
      - name: storage-volume
        persistentVolumeClaim:
          claimName: factorio-srv-01-pvc
      - name: mod-list
        configMap:
          name: factorio-mod-list
---
apiVersion: v1
kind: Service
metadata:
  name: factorio-01
  namespace: factorio
  labels:
    expose: "true"
  annotations:
    lbipam.cilium.io/ips: "10.0.20.2"
spec:
  type: LoadBalancer
  selector:
    app: factorio-01
  ports:
    - port: 34197
      targetPort: 34197
      protocol: UDP
EOF