<p>I am trying to create a Keycloak deployment having its configuration imported from a local file located at <code>./import/realm.json</code>.</p>
<p>Folder structure:</p>
<ul>
<li><code>keycloak-deploy.yml</code></li>
<li><code>import/realm.json</code></li>
</ul>
<p>However, when applying the deployment I get this error:</p>
<pre><code> FATAL [org.keycloak.services] (ServerService Thread Pool -- 59) Error during startup: java.lang.RuntimeException: java.io.FileNotFoundException: /import/realm.json (No such file or directory)
</code></pre>
<p>This is the deployment (<code>keycloak-deploy.yml</code>) I'm trying to create:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: keycloak-deployment
  name: keycloak-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: keycloak-deployment
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: keycloak-deployment
    spec:
      containers:
      - image: jboss/keycloak:latest
        name: keycloak
        env:
          - name: KEYCLOAK_USER
            value: admin
          - name: KEYCLOAK_PASSWORD
            value: superSecret
          - name: KEYCLOAK_IMPORT
            value: /import/realm.json
        ports:
          - containerPort: 8081
        readinessProbe:
          httpGet:
            path: /auth/realms/master
            port: 8081
        resources: {}
status: {}
</code></pre>
<p>I'm a beginner with Kubernetes so any help is apreciated, thanks !</p>

happy songs
<p>I followed what was said in the comments (thanks @Andrew Skorkin). It worked like this:</p>
<ul>
<li>deployment &amp; service:</li>
</ul>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: keycloak-deployment
  name: keycloak-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: keycloak-deployment
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: keycloak-deployment
    spec:
      containers:
      - image: jboss/keycloak:latest
        name: keycloak
        env:
          - name: KEYCLOAK_USER
            value: admin
          - name: KEYCLOAK_PASSWORD
            value: superSecret
          - name: KEYCLOAK_IMPORT
            value: /import/realm.json
        ports:
          - name: http
            containerPort: 8081
        volumeMounts:
          - name: keycloak-volume
            mountPath: /import
        readinessProbe:
          httpGet:
            path: /auth/realms/master
            port: 8081
          initialDelaySeconds: 30
          timeoutSeconds: 30
        resources: {}
      volumes:
        - name: keycloak-volume
          configMap:
            name: keycloak-configmap
status: {}
---
apiVersion: v1
kind: Service
metadata:
  name: keycloak-service
spec:
  selector:
    app: keycloak-service
  ports:
    - protocol: TCP
      port: 8081
      targetPort: 8081
</code></pre>
<ul>
<li>config map:</li>
</ul>
<pre><code>apiVersion: v1
data:
  realm.json: |
    {json_content}
kind: ConfigMap
metadata:
  name: keycloak-configmap
</code></pre>
<p><code>json_content</code> contains the realm.json data. I exported the data from a working keycloak instance (made with docker-compose).</p>
