Skip to content

Allow referencing individual fields of a 1password item #69

@lhriley

Description

@lhriley

Summary

When writing a OnePasswordItem definition, it would be helpful to reference individual fields of a 1password item rather than the entire item as a whole.

Use cases

For example, consider the setting of certain environment variables across several applications where may have different names, but require the same value.

App 1:

APP1_MY_VAR="foo-bar-baz"

App 2:

APP2_MY_VAR="foo-bar-baz"

Proposed solution

Create a new OnePassword kind (or modify the existing kind: OnePasswordItem) to allow referencing individual fields:

apiVersion: onepassword.com/v1
kind: OnePasswordFields
metadata:
  name: <item_name> #this name will also be used for naming the generated kubernetes secret
spec:
  itemFields:
    <k8s secret key name>: "vaults/<vault_id_or_title>/items/<item_id_or_title>/fields/<field>" 
    APP1_MY_VAR: "vaults/<vault_id_or_title>/items/<item_id_or_title>/fields/<field>" 
    APP2_MY_VAR: "vaults/<vault_id_or_title>/items/<item_id_or_title>/fields/<field>"

For example:

apiVersion: onepassword.com/v1
kind: OnePasswordFields
metadata:
  name: my-secret-app1
spec:
  itemFields:
    APP1_MY_VAR: "vaults/myVault/items/myItem/fields/token"
apiVersion: onepassword.com/v1
kind: OnePasswordFields
metadata:
  name: my-secret-app2
spec:
  itemFields:
    APP2_MY_VAR: "vaults/myVault/items/myItem/fields/token"

would produce the following secrets:

apiVersion: v1
kind: Secret
metadata:
  name: my-secret-app1
  namespace: default
type: Opaque
data:
  APP1_MY_VAR: "foo-bar-baz"
apiVersion: v1
kind: Secret
metadata:
  name: my-secret-app2
  namespace: default
type: Opaque
data:
  APP2_MY_VAR: "foo-bar-baz"

Is there a workaround to accomplish this today?

Not using the onepassword-operator that I'm aware of. You could create multiple secrets from multiple vault items, and then individually reference the secrets created by the operator in each deployment, etc. This would create significant extra code, and be difficult to maintain.

References & Prior Work

None that I'm specifically aware of. This issue is similar, but appears to target mounting multiple items within a single k8s secret: #59

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedCommunity contributions are welcome.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions