Mounting secrets as filesΒΆ

Follow the steps below to a mount secrets as a file in your microservice:

  1. Add your file to hasura secrets.

    # Format:
    # hasura secret update <secret-key> -f <file-path>
    $ hasura secret update credvalue.json -f ~/creds/credvalue.json
    
  2. Modify the k8s.yaml of your microservice (microservices/<microservice-name>/k8s.yaml) to mount this secret as a file, instead of as an evironment variable.

    ...
    spec:
      containers:
      - name: app
        image: my-image
        volumeMounts:
        - name: foo
          mountPath: "/etc/foo"
          readOnly: true
      volumes:
      - name: foo
        secret:
          secretName: hasura-secrets
          items:
          - key: credvalue.json
            path: credvalue.json
    
  3. Your file will be available inside the microservice container as /etc/foo/credvalue.json.