full-external-secret.yaml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. {% raw %}
  2. apiVersion: external-secrets.io/v1
  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: "1h0m0s"
  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. # Labels and annotations to set on the Secret.
  49. # When a template is defined, these replace the default behavior
  50. # of copying labels and annotations from the ExternalSecret.
  51. # Set to an empty map ({}) to prevent any labels or annotations from being copied.
  52. annotations: {}
  53. labels: {}
  54. # The finalizers will be added to the Secret.
  55. # It is expected that finalizers will be deleted with custom cleanup functionality.
  56. # This is required when another chart depends on the Secret, and it is needed to prevent the Secret from being deleted too early.
  57. finalizers: []
  58. # Use inline templates to construct your desired config file that contains your secret
  59. data:
  60. config.yml: |
  61. database:
  62. connection: postgres://{{ .username }}:{{ .password }}@{{ .database_host }}:5432/payments
  63. # Uses an existing template from configmap
  64. # Secret is fetched, merged and templated within the referenced configMap data
  65. # It does not update the configmap, it creates a secret with: data["alertmanager.yml"] = ...result...
  66. templateFrom:
  67. - configMap:
  68. name: application-config-tmpl
  69. items:
  70. - key: config.yml
  71. # Data defines the connection between the Kubernetes Secret keys and the Provider data
  72. data:
  73. - secretKey: username
  74. remoteRef:
  75. key: database-credentials
  76. version: v1
  77. property: username
  78. decodingStrategy: None # can be None, Base64, Base64URL or Auto
  79. # define the source of the secret. Can be a SecretStore or a Generator kind
  80. sourceRef:
  81. # point to a SecretStore that should be used to fetch a secret.
  82. # must be defined if no spec.secretStoreRef is defined.
  83. storeRef:
  84. name: aws-secretstore
  85. kind: ClusterSecretStore
  86. # Used to fetch all properties from the Provider key
  87. # If multiple dataFrom are specified, secrets are merged in the specified order
  88. # Can be defined using sourceRef.generatorRef or extract / find
  89. # Both use cases are exemplified below
  90. dataFrom:
  91. - sourceRef:
  92. generatorRef:
  93. apiVersion: generators.external-secrets.io/v1alpha1
  94. kind: ECRAuthorizationToken
  95. name: "my-ecr"
  96. #Or
  97. dataFrom:
  98. - extract:
  99. key: database-credentials
  100. version: v1
  101. property: data
  102. conversionStrategy: Default
  103. decodingStrategy: Auto
  104. rewrite:
  105. - regexp:
  106. source: "exp-(.*?)-ression"
  107. target: "rewriting-${1}-with-groups"
  108. - find:
  109. path: path-to-filter
  110. name:
  111. regexp: ".*foobar.*"
  112. tags:
  113. foo: bar
  114. conversionStrategy: Unicode
  115. decodingStrategy: Base64
  116. rewrite:
  117. - regexp:
  118. source: "foo"
  119. target: "bar"
  120. status:
  121. # refreshTime is the time and date the external secret was fetched and
  122. # the target secret updated
  123. refreshTime: "2019-08-12T12:33:02Z"
  124. # Standard condition schema
  125. conditions:
  126. # ExternalSecret ready condition indicates the secret is ready for use.
  127. # This is defined as:
  128. # - The target secret exists
  129. # - The target secret has been refreshed within the last refreshInterval
  130. # - The target secret content is up-to-date based on any target templates
  131. - type: Ready
  132. status: "True" # False if last refresh was not successful
  133. reason: "SecretSynced"
  134. message: "Secret was synced"
  135. lastTransitionTime: "2019-08-12T12:33:02Z"
  136. {% endraw %}