Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Kubernetes Secret from an encrypted dotenv file results in stringData instead of data #260

Open
tomklapka opened this issue Jul 15, 2024 · 4 comments
Labels
kind:bug Something isn't working

Comments

@tomklapka
Copy link

Create a Kubernetes Secret from an encrypted dotenv file ganerates a secret with stringData content e.g.:

apiVersion: viaduct.ai/v1
kind: ksops
metadata:
  name: secret-generator
  annotations:
    config.kubernetes.io/function: |
      exec:
        path: ksops
secretFrom:
  - metadata:
      name: xyz-secrets
      annotations:
        kustomize.config.k8s.io/behavior: merge
        kustomize.config.k8s.io/needs-hash: "true"
    envs:
      - .secrets.enc.env

But Kustomize SecretGenerator generates secret with data content:
Also in Kustomize doc (https://kubernetes.io/docs/tasks/configmap-secret/managing-secret-using-kustomize/) is a following note: The stringData field for a Secret does not work well with server-side apply.

It makes sense to me keeping up with Kustomize.

kustomize v5.3.0
kops v4.3.2

@dosubot dosubot bot added the kind:bug Something isn't working label Jul 15, 2024
Copy link

dosubot bot commented Jul 15, 2024

Hey @tomklapka! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this together!

To ensure that the generated Kubernetes Secret from an encrypted dotenv file uses data instead of stringData when using Kustomize SecretGenerator with KSOPS, you can use the secretFrom field in your secret-generator.yaml configuration. Here is an example configuration:

apiVersion: viaduct.ai/v1
kind: ksops
metadata:
  name: example-secret-generator
  annotations:
    config.kubernetes.io/function: |
      exec:
        path: ksops
secretFrom:
- metadata:
    name: secret-name
  envs:
  - ./secret.enc.env

This configuration will generate a Kubernetes Secret using the data field instead of stringData [1][2].

To continue talking to Dosu, mention @dosu.

@tomklapka
Copy link
Author

@dosu It's not true, check my secret generator code once again

@viaduct-ai viaduct-ai deleted a comment from dosubot bot Aug 8, 2024
@devstein
Copy link
Collaborator

devstein commented Aug 8, 2024

Hey @tomklapka is this still an issue? Happy to help with workarounds

@luong-komorebi
Copy link

luong-komorebi commented Aug 26, 2024

I can confirm that this issue is still there

@devstein may I ask what the work around would be ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants