Just augmenting this thread for those that find it (since I had a couple questions on this topic, recently)… In K8s, you can leverage initContainers to seed the data volume prior to initial launch of the Gateway container [in the pod].
Here is an example deployment that leverages an init container to seed the data volume with files from the image:
# Ignition K8s Example Deployment
---
# Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: ignition-deployment
spec:
selector:
matchLabels:
app: ignition-app
strategy:
type: Recreate
template:
metadata:
labels:
app: ignition-app
spec:
initContainers:
- name: seed-volume
image: inductiveautomation/ignition:8.1.17
resources:
limits:
memory: "256Mi"
cpu: "1000m"
command:
- sh
- -c
- >
if [ ! -f /data/.ignition-seed-complete ]; then
touch /data/.ignition-seed-complete ;
cp -dpR /usr/local/bin/ignition/data/* /data/ ;
fi
volumeMounts:
- mountPath: /data
name: ignition-data
containers:
- name: ignition
image: inductiveautomation/ignition:8.1.17
resources:
limits:
memory: "2048Mi"
cpu: "1000m"
args:
- -n
- Ignition-k8s
- -m
- "2048"
env:
- name: ACCEPT_IGNITION_EULA
value: "Y"
- name: GATEWAY_ADMIN_PASSWORD_FILE
value: /run/secrets/gateway-admin/password
- name: IGNITION_EDITION
value: standard
ports:
- name: ignition-web
containerPort: 8088
volumeMounts:
- mountPath: /usr/local/bin/ignition/data
name: ignition-data
- mountPath: /run/secrets/gateway-admin
name: gateway-admin
readOnly: true
readinessProbe:
exec:
command:
- health-check.sh
- -t
- "3"
initialDelaySeconds: 60
periodSeconds: 10
failureThreshold: 10
timeoutSeconds: 3
volumes:
- name: ignition-data
persistentVolumeClaim:
claimName: ignition-pv-claim
- name: gateway-admin
secret:
secretName: gateway-admin
---
# Secret (which you wouldn't normally just have hanging out here in your deployment yaml)
apiVersion: v1
kind: Secret
metadata:
name: gateway-admin
type: Opaque
data:
password: UEBzc3cwcmQ=
---
# Service
apiVersion: v1
kind: Service
metadata:
name: ignition-lb
spec:
selector:
app: ignition-app
type: LoadBalancer
ports:
- name: http
port: 8088
targetPort: 8088
---
# PersistentVolume
apiVersion: v1
kind: PersistentVolume
metadata:
name: ignition-pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 10Gi
hostPath:
path: "${PWD}/ignition-data"
accessModes: # ideally we want ReadWriteOncePod, but still in alpha?
- ReadWriteOnce
---
# PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ignition-pv-claim
spec:
storageClassName: manual
resources:
requests:
storage: 3Gi
accessModes:
- ReadWriteOnce
This is designed to be run from a folder on your host system with a fresh (and empty, initially) ignition-data
subfolder. I use envsubst
to substitute the current working directory. So you could deploy this with, for example:
$ kubectl create ns k8s-testing
$ kubectl config set-context --current --namespace=k8s-testing
$ envsubst < ignition-app.yaml | kubectl apply -f -
Keep in mind that this is just an example deployment that you can test locally, not a production-ready configuration.
Here’s a little video to check out with this too, in the event that moving pictures>pictures>words.
k8s-testing-2.mp4