Skip to content

Commit fd675f0

Browse files
synaretephlogistonjohn
authored andcommitted
config: pass pod name namespace and ip via env
Allow samba-operator to discover self settings by passing explicit environment variables. Needed in order to detect cluster-type (via pod's annotations) when running over OpenShift. Signed-off-by: Shachar Sharon <[email protected]>
1 parent 00a0031 commit fd675f0

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

config/manager-full/auth_proxy_patch.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,16 @@ spec:
2929
args:
3030
- "--metrics-addr=127.0.0.1:8080"
3131
- "--enable-leader-election"
32+
env:
33+
- name: SAMBA_OP_POD_NAME
34+
valueFrom:
35+
fieldRef:
36+
fieldPath: metadata.name
37+
- name: SAMBA_OP_POD_NAMESPACE
38+
valueFrom:
39+
fieldRef:
40+
fieldPath: metadata.namespace
41+
- name: SAMBA_OP_POD_IP
42+
valueFrom:
43+
fieldRef:
44+
fieldPath: status.podIP

internal/conf/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ type OperatorConfig struct {
6767
// operator should run metrics-exporter container within samba-server pod.
6868
// Valid values are "enabled", "disabled" or empty string (default).
6969
MetricsExporterMode string `mapstructure:"metrics-exporter-mode"`
70+
// PodName is a (string) which defines the currnt operator pod name.
71+
PodName string `mapstructure:"pod-name"`
72+
// PodNamespace is a (string) which defines the currnt operator namespace.
73+
PodNamespace string `mapstructure:"pod-namespace"`
74+
// PodIP is a (string) which defines the currnt pod cluster-ip.
75+
PodIP string `mapstructure:"pod-ip"`
7076
}
7177

7278
// Validate the OperatorConfig returning an error if the config is not
@@ -113,6 +119,9 @@ func NewSource() *Source {
113119
v.SetDefault("smbd-port", d.SmbdPort)
114120
v.SetDefault("service-account-name", d.ServiceAccountName)
115121
v.SetDefault("metrics-exporter-mode", d.MetricsExporterMode)
122+
v.SetDefault("pod-name", d.PodName)
123+
v.SetDefault("pod-namespace", d.PodNamespace)
124+
v.SetDefault("pod-ip", d.PodIP)
116125
return &Source{v: v}
117126
}
118127

0 commit comments

Comments
 (0)