<p>I'm new to openshift and Kubernetes too (coming from Docker swarm world). and I'm looking to create secrets in openshift using definition file. these secrets are generated from a file. to give an example of what I'm trying to do let's say I have a file "apache.conf" and I want to add that file to containers as a secret mounted as a volume. In swarm I can just write the following in the stack file:</p>

<pre><code>my-service:
 secrets:
  - source: my-secret
    target: /home/myuser/
    mode: 0700
secrets:
 my-secret:
   file: /from/host/apache.conf
</code></pre>

<p>In openshift I'm looking to have something similar like:</p>

<pre><code>apiVersion: v1
kind: Secret
metadata:
- name: my-secret
  files:
    - "/from/host/apache.conf"
type: Opaque 
</code></pre>

<p>The only way I've found that I can do something similar is by using <a href="https://kubectl.docs.kubernetes.io/pages/app_management/secrets_and_configmaps.html" rel="nofollow noreferrer">kustomize</a> and <a href="https://github.com/adnovum/kustomize-openshift" rel="nofollow noreferrer">according to this post</a> using Kustomize with openshift is cumbersome. is there a better way for creating secrets from a file? </p>

tkyass
<p>No you can't</p>

<p>The reason is that the object Secret is stored in the etcd database and is not bound to any host. Therefore, the object doesn't understand the path.
You can create the secret from a file using the cli, and then the content will be saved in the Secret object.</p>

<p><code>oc create secret generic my-secret --from-file=fil1=pullsecret_private.json</code></p>
