full-external-secret.yaml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. {% raw %}
  2. apiVersion: external-secrets.io/v1beta1
  3. kind: ExternalSecret
  4. metadata:
  5. name: "hello-world"
  6. # labels and annotations are copied over to the
  7. # secret that will be created
  8. labels:
  9. acme.org/owned-by: "q-team"
  10. annotations:
  11. acme.org/sha: 1234
  12. spec:
  13. # Optional, SecretStoreRef defines the default SecretStore to use when fetching the secret data.
  14. secretStoreRef:
  15. name: aws-store
  16. kind: SecretStore # or ClusterSecretStore
  17. # RefreshPolicy determines how the ExternalSecret should be refreshed.
  18. # - CreatedOnce: Creates the Secret only if it does not exist and does not update it afterward
  19. # - Periodic: (default) Synchronizes the Secret at intervals specified by refreshInterval
  20. # - OnChange: Only synchronizes when the ExternalSecret's metadata or specification changes
  21. refreshPolicy: Periodic
  22. # RefreshInterval is the amount of time before the values reading again from the SecretStore provider
  23. # Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h" (from time.ParseDuration)
  24. # May be set to zero to fetch and create it once
  25. refreshInterval: "1h"
  26. # the target describes the secret that shall be created
  27. # there can only be one target per ExternalSecret
  28. target:
  29. # The secret name of the resource
  30. # Defaults to .metadata.name of the ExternalSecret
  31. # It is immutable
  32. name: application-config
  33. # Specifies the ExternalSecret ownership details in the created Secret. Options:
  34. # - Owner: (default) Creates the Secret and sets .metadata.ownerReferences. If the ExternalSecret is deleted, the Secret will also be deleted.
  35. # - Merge: Does not create the Secret but merges data fields into the existing Secret (expects the Secret to already exist).
  36. # - Orphan: Creates the Secret but does not set .metadata.ownerReferences. If the Secret already exists, it will be updated.
  37. # - None: Does not create or update the Secret (reserved for future use with injector).
  38. creationPolicy: Merge
  39. # Specifies what happens to the Secret when data fields are deleted from the provider (e.g., Vault, AWS Parameter Store). Options:
  40. # - Retain: (default) Retains the Secret if all Secret data fields have been deleted from the provider.
  41. # - Delete: Removes the Secret if all Secret data fields from the provider are deleted.
  42. # - Merge: Removes keys from the Secret but not the Secret itself.
  43. deletionPolicy: Retain
  44. # Specify a blueprint for the resulting Kind=Secret
  45. template:
  46. type: kubernetes.io/dockerconfigjson # or TLS...
  47. metadata:
  48. annotations: {}
  49. labels: {}
  50. # Use inline templates to construct your desired config file that contains your secret
  51. data:
  52. config.yml: |
  53. database:
  54. connection: postgres://{{ .username }}:{{ .password }}@{{ .database_host }}:5432/payments
  55. # Uses an existing template from configmap
  56. # Secret is fetched, merged and templated within the referenced configMap data
  57. # It does not update the configmap, it creates a secret with: data["alertmanager.yml"] = ...result...
  58. templateFrom:
  59. - configMap:
  60. name: application-config-tmpl
  61. items:
  62. - key: config.yml
  63. # Data defines the connection between the Kubernetes Secret keys and the Provider data
  64. data:
  65. - secretKey: username
  66. remoteRef:
  67. key: database-credentials
  68. version: v1
  69. property: username
  70. decodingStrategy: None # can be None, Base64, Base64URL or Auto
  71. # define the source of the secret. Can be a SecretStore or a Generator kind
  72. sourceRef:
  73. # point to a SecretStore that should be used to fetch a secret.
  74. # must be defined if no spec.secretStoreRef is defined.
  75. storeRef:
  76. name: aws-secretstore
  77. kind: ClusterSecretStore
  78. # Used to fetch all properties from the Provider key
  79. # If multiple dataFrom are specified, secrets are merged in the specified order
  80. # Can be defined using sourceRef.generatorRef or extract / find
  81. # Both use cases are exemplified below
  82. dataFrom:
  83. - sourceRef:
  84. generatorRef:
  85. apiVersion: generators.external-secrets.io/v1alpha1
  86. kind: ECRAuthorizationToken
  87. name: "my-ecr"
  88. #Or
  89. dataFrom:
  90. - extract:
  91. key: database-credentials
  92. version: v1
  93. property: data
  94. conversionStrategy: Default
  95. decodingStrategy: Auto
  96. rewrite:
  97. - regexp:
  98. source: "exp-(.*?)-ression"
  99. target: "rewriting-${1}-with-groups"
  100. - find:
  101. path: path-to-filter
  102. name:
  103. regexp: ".*foobar.*"
  104. tags:
  105. foo: bar
  106. conversionStrategy: Unicode
  107. decodingStrategy: Base64
  108. rewrite:
  109. - regexp:
  110. source: "foo"
  111. target: "bar"
  112. status:
  113. # refreshTime is the time and date the external secret was fetched and
  114. # the target secret updated
  115. refreshTime: "2019-08-12T12:33:02Z"
  116. # Standard condition schema
  117. conditions:
  118. # ExternalSecret ready condition indicates the secret is ready for use.
  119. # This is defined as:
  120. # - The target secret exists
  121. # - The target secret has been refreshed within the last refreshInterval
  122. # - The target secret content is up-to-date based on any target templates
  123. - type: Ready
  124. status: "True" # False if last refresh was not successful
  125. reason: "SecretSynced"
  126. message: "Secret was synced"
  127. lastTransitionTime: "2019-08-12T12:33:02Z"
  128. {% endraw %}