adobe / rules_gitops

This repository contains rules for continuous, GitOps driven Kubernetes deployments.
Apache License 2.0
173 stars 43 forks source link

Configmap creation from .env file doesn't(?) work #82

Open kczulko opened 2 years ago

kczulko commented 2 years ago

Description of the problem / feature request:

When I'm creating configmap from *.env file it is being placed under files section, rather than envs section of kustomize.yaml.

Feature requests: what underlying problem are you trying to solve with this feature?

I'm trying to apply any env parameters to my container (particularly it's a postgres now) running on the local kubernetes cluster.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Create env file with e.g. following content:

POSTGRES_DB=orders
POSTGRES_USER=root
POSTGRES_PASSWORD=password
POSTGRES_HOST_AUTH_METHOD=trust

What operating system are you running Bazel on?

NixOs

What's the output of bazel info release?

release 4.1.0- (@non-git)

If bazel info release returns "development version" or "(@non-git)", tell us how you built Bazel.

This is my pinned nixpkgs version. It's an ongoing PR made by my college, which fixed environment variables issue when using bazel at nixos.

pkgs = import (fetchTarball "https://github.com/nixos/nixpkgs/archive/d624ab2cdc957c6b4673de246cdd0e49030dc67e.tar.gz") {};

Snippet of the WORKSPACE file that includes rules_gitops rules.

##################################################
# rules_gitops
##################################################

rules_gitops_version = "01b16044b3ae3384d03a75f58d45218091ad1ba5"

http_archive(
    name = "com_adobe_rules_gitops",
    # sha256 = "4921c8f7fab5f16240f39bc67b10a1dce9f7c63eda54ceb7b97b88251ad7bdaf",
    strip_prefix = "rules_gitops-%s" % rules_gitops_version,
    urls = ["https://github.com/adobe/rules_gitops/archive/%s.zip" % rules_gitops_version],
)

load("@com_adobe_rules_gitops//gitops:deps.bzl", "rules_gitops_dependencies")

rules_gitops_dependencies()

load("@com_adobe_rules_gitops//gitops:repositories.bzl", "rules_gitops_repositories")

rules_gitops_repositories()

Have you found anything relevant by searching the web?

Yes, kustomization doc which mentions envs section: https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/

Any other information, logs, or outputs that you want to share?

This dummy patch fixes my problem: image

.show output WITHOUT the fix (I thought that changing file extension to .properties would help somehow...):

INFO: Build completed successfully, 1 total action
apiVersion: v1
data:
  app.properties: |-
    POSTGRES_DB=orders
    POSTGRES_USER=root
    POSTGRES_PASSWORD=password
    POSTGRES_HOST_AUTH_METHOD=trust
kind: ConfigMap
metadata:
  name: postgresql-config
  namespace: default
---

.show output WITH my dummy fix:

INFO: Build completed successfully, 3 total actions
apiVersion: v1
data:
  POSTGRES_DB: orders
  POSTGRES_HOST_AUTH_METHOD: trust
  POSTGRES_PASSWORD: password
  POSTGRES_USER: root
kind: ConfigMap
metadata:
  name: postgresql-config
  namespace: default
---
michaelschiff commented 2 years ago

Hey @kczulko thanks for pointing this out! Can you update this issue with your sample BUILD file so we can reproduce?