gopaddle-io / configurator

Synchronize and Version Control ConfigMaps & Secrets across Deployment Rollouts.
Other
113 stars 45 forks source link

CustomSecret breaks the data format while creating Secrets #54

Closed renugadevi-2613 closed 3 years ago

renugadevi-2613 commented 3 years ago

Describe the bug If we provide stringData in customSecret spec, it creates customSecret with the given field and values. But while creating the secrets from the customSecret, configurator adds stringData values into 'data' field instead of 'stringData' field and the content is added as base64 instead of plain text.

To Reproduce Steps to reproduce the behavior:

  1. create a customSecret with stringData field
  2. apply the yaml
  3. it creates a secret. get the yaml of the secert you can see stringData added into Data field in secret. (note:- stringData added to Data in base64 format)
juliohm1978 commented 3 years ago

Hi @renugadevi-2613. I think I'm not understanding this entirely. Has this been fixed already?

With this CCM...

apiVersion: "configurator.gopaddle.io/v1alpha1"
kind: CustomSecret
metadata:
 name: secrettest
 namespace: test
spec:
  secretName: testsecret
  type: bootstrap.kubernetes.io/token
  stringData:
    auth-extra-groups: "system:bootstrappers:kubeadm:default-node-token"
    expiration: "2020-09-13T04:39:10Z"
    token-id: "5emitj"
    token-secret: "kq4gihvszzgn1p0r"
    usage-bootstrap-authentication: "true"
    usage-bootstrap-signing: "true"
  secretAnnotations:
    name: "sa-name"

... Configurator creates the following Secret

apiVersion: v1
data:
  auth-extra-groups: YzNsemRHVnRPbUp2YjNSemRISmhjSEJsY25NNmEzVmlaV0ZrYlRwa1pXWmhkV3gwTFc1dlpHVXRkRzlyWlc0PQ==
  expiration: TWpBeU1DMHdPUzB4TTFRd05Eb3pPVG94TUZvPQ==
  token-id: TldWdGFYUnE=
  token-secret: a3E0Z2lodnN6emduMXAwcg==
  usage-bootstrap-authentication: dHJ1ZQ==
  usage-bootstrap-signing: dHJ1ZQ==
kind: Secret
metadata:
  annotations:
    name: sa-name
  creationTimestamp: "2021-10-21T16:16:38Z"
  labels:
    customSecretName: secrettest
    latest: "true"
    name: testsecret
  name: testsecret-ocmhj
  namespace: test
  ownerReferences:
  - apiVersion: configurator.gopaddle.io/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: CustomSecret
    name: secrettest
    uid: 89c3c9a0-f859-43c5-8323-6bdfb9eee35c
  resourceVersion: "635"
  uid: 49465024-2af7-4226-aaa2-2dc095074b5f
type: bootstrap.kubernetes.io/token

with all values in data already base64 encoded.

renugadevi-2613 commented 3 years ago

Hi @juliohm1978 Regarding the secrets and the stringData, what you pointed out is correct. Kube is converting the stringData and plain text to data in base64. So we can close this issue #54 - as no change.