title: Kubernetes - how do I extract a secret tar file?
body: <p>I have mounted two tar files as secrets. I would like to mount them to my container and then unpack the contents. The commands that created the secrets are as follows:</p>
  <pre><code>kubectl create secret generic orderer-genesis-block --from-file=./channel-artifacts/genesis.block
  
  kubectl create secret generic crypto-config --from-file=crypto-config.tar
  
  kubectl create secret generic channel-artifacts --from-file=channel-artifacts.tar
  </code></pre>
  <p>The following is what I <code>kubectl apply</code>:</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: fabric-orderer-01
  spec:
    selector:
      matchLabels:
        app: fabric-orderer-01
    replicas: 1
    template:
      metadata:
        labels:
          app: fabric-orderer-01
      spec:
        initContainers:
        - name: init-channel-artifacts
          image: busybox
          volumeMounts:
          - name: channel-artifacts
            mountPath: /hlf/channel-artifacts
          command: ['sh', '-c', 'tar -xf /hlf/channel-artifacts/channel-artifacts.tar']
        containers:
        - name: fabric-orderer-01
          image: hyperledger/fabric-orderer:1.4.9
          env:
          - name: ORDERER_CFG_PATH
            value: /hlf/
          - name: CONFIGTX_ORDERER_ADDRESSES
            value: &quot;orderer.example.com:7050&quot;
          - name: ORDERER_GENERAL_LISTENADDRESS
            value: 0.0.0.0
          - name: ORDERER_GENERAL_LISTENPORT
            value: &quot;7050&quot;
          - name: ORDERER_GENERAL_LOGLEVEL
            value: debug
          - name: ORDERER_GENERAL_LOCALMSPID
            value: OrdererMSP
          - name: ORDERER_GENERAL_GENESISMETHOD
            value: file
          - name: ORDERER_GENERAL_GENESISFILE
            value: /hlf/genesis.block
          imagePullPolicy: Always
          ports:
          - containerPort: 8080
          volumeMounts:
          - name: fabricfiles-01
            mountPath: /fabric
          - name: orderer-genesis-block
            mountPath: /hlf/
            readOnly: true
          - name: crypto-config
            mountPath: /hlf/crypto-config
            readOnly: true
          - name: channel-artifacts
            mountPath: /hlf/channel-artifacts
            readOnly: true
        volumes:
        - name: orderer-genesis-block
          secret:
            secretName: orderer-genesis-block
        - name: crypto-config
          secret:
            secretName: crypto-config
        - name: channel-artifacts
          secret:
            secretName: channel-artifacts
        - name: fabricfiles-01
          persistentVolumeClaim:
            claimName: fabric-pvc-01
  </code></pre>
  <p>My deployment succeeds, but when I <code>bash</code> into my pod, I don't see my tar files being extracted. I only see my tar files <code>/hlf/channel-artifacts/channel-artifacts.tar</code> and <code>/hlf/crypto-config/crypto-config.tar</code>. How should I go about extracting their contents?</p>