Skip to content

Conversation

@gamer22026
Copy link

@gamer22026 gamer22026 commented Dec 23, 2025

The chart was rendering etcd secret and setting APISIX_ETCD_PASSWORD env var from secret in the deployment even if etcd was not being used.

@gamer22026
Copy link
Author

Code Explanation

File: ./etcd-secret.yaml

Line 1:

{{- if and (or (and .Values.etcd.enabled .Values.etcd.auth.rbac.create) (and (not .Values.etcd.enabled) .Values.externalEtcd.user)) (or (and .Values.apisix.deployment.role_traditional (eq .Values.apisix.deployment.role_traditional.config_provider "etcd")) (and .Values.apisix.deployment.role_data_plane (eq .Values.apisix.deployment.role_data_plane.config_provider "etcd")) (and .Values.apisix.deployment.role_control_plane (eq .Values.apisix.deployment.role_control_plane.config_provider "etcd"))) }}

Explanation:
This line is a Helm template conditional directive. It acts as a guard to decide whether the entire Secret resource defined in this file should be rendered.

The condition evaluates to true (and thus generates the Secret) if:

  1. ETCD Auth is needed: Either the in-chart ETCD is enabled with RBAC (etcd.enabled AND etcd.auth.rbac.create) OR an external ETCD user is provided (externalEtcd.user).
    AND
  2. APISIX uses ETCD: The APISIX deployment role (Traditional, Data Plane, or Control Plane) is explicitly configured to use "etcd" as its config_provider.

File: ./deployment.yaml

Line 95:

{{- if and (or (and .Values.etcd.enabled .Values.etcd.auth.rbac.create) (and (not .Values.etcd.enabled) .Values.externalEtcd.user)) (or (and .Values.apisix.deployment.role_traditional (eq .Values.apisix.deployment.role_traditional.config_provider "etcd")) (and (not .Values.apisix.deployment.role_traditional) (or (and .Values.apisix.deployment.role_data_plane (eq .Values.apisix.deployment.role_data_plane.config_provider "etcd")) (and .Values.apisix.deployment.role_control_plane (eq .Values.apisix.deployment.role_control_plane.config_provider "etcd"))))) }}

Explanation:
This line uses the same logic as the secret file but is applied within the Deployment spec. It controls whether the APISIX_ETCD_PASSWORD environment variable (which would follow this line) is injected into the APISIX container.

It ensures that the application only attempts to load the ETCD password environment variable when ETCD authentication is actually configured and relevant for the current deployment mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant