Compare commits
2 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
0d93c9ea67 | |
|
|
587290f1fb |
|
|
@ -63,6 +63,11 @@ jobs:
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
# This ensures that for a git tag like "v0.1.0",
|
||||||
|
# an image tag "0.1.0" is generated.
|
||||||
|
# It will also generate "latest" for the most recent semver tag.
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
|
|
|
||||||
|
|
@ -37,3 +37,7 @@ Thumbs.db
|
||||||
# Helm
|
# Helm
|
||||||
!charts/iperf3-monitor/.helmignore
|
!charts/iperf3-monitor/.helmignore
|
||||||
charts/iperf3-monitor/charts/
|
charts/iperf3-monitor/charts/
|
||||||
|
|
||||||
|
# Rendered Kubernetes manifests (for local testing)
|
||||||
|
rendered-manifests.yaml
|
||||||
|
rendered-manifests-updated.yaml
|
||||||
|
|
|
||||||
|
|
@ -72,12 +72,23 @@ Proceed with modifications only if the exporter controller is defined.
|
||||||
{{- /*
|
{{- /*
|
||||||
Ensure the container image tag is set, defaulting to Chart.AppVersion if empty,
|
Ensure the container image tag is set, defaulting to Chart.AppVersion if empty,
|
||||||
as the common library validation requires it during 'helm template'.
|
as the common library validation requires it during 'helm template'.
|
||||||
|
|
||||||
|
NOTE: BJW-S common library typically handles defaulting image.tag to Chart.appVersion
|
||||||
|
if image.tag is empty or null in values. The custom logic below prepending "v"
|
||||||
|
is specific to this chart and might be redundant if the common library's default
|
||||||
|
is preferred. For now, we keep it as it was the reason for previous errors if tag was not set.
|
||||||
|
However, if common library handles it, this block could be removed and image.tag in values.yaml set to "" or null.
|
||||||
|
Forcing the tag to be set (even if to chart.appVersion) ensures the common library doesn't complain.
|
||||||
|
The issue encountered during `helm template` earlier (empty output) was resolved by
|
||||||
|
explicitly setting the tag (e.g. via --set or by ensuring values.yaml has it).
|
||||||
|
The common library's internal validation likely needs *a* tag to be present in the values passed to it,
|
||||||
|
even if that tag is derived from AppVersion. This block ensures that.
|
||||||
*/}}
|
*/}}
|
||||||
{{- $exporterContainerCfg := get $exporterControllerConfig.containers "exporter" -}}
|
{{- $exporterContainerCfg := get $exporterControllerConfig.containers "exporter" -}}
|
||||||
{{- if $exporterContainerCfg -}}
|
{{- if $exporterContainerCfg -}}
|
||||||
{{- if not $exporterContainerCfg.image.tag -}}
|
{{- if not $exporterContainerCfg.image.tag -}}
|
||||||
{{- if $chart.AppVersion -}}
|
{{- if $chart.AppVersion -}}
|
||||||
{{- $_ := set $exporterContainerCfg.image "tag" (printf "v%s" $chart.AppVersion) -}}
|
{{- $_ := set $exporterContainerCfg.image "tag" (printf "%s" $chart.AppVersion) -}} # Removed "v" prefix
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
{{- fail (printf "Error: Container image tag is not specified for controller '%s', container '%s', and Chart.AppVersion is also empty." $exporterControllerKey "exporter") -}}
|
{{- fail (printf "Error: Container image tag is not specified for controller '%s', container '%s', and Chart.AppVersion is also empty." $exporterControllerKey "exporter") -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,8 @@ controllers:
|
||||||
# -- Annotations for the exporter pod.
|
# -- Annotations for the exporter pod.
|
||||||
annotations: {}
|
annotations: {}
|
||||||
# -- Labels for the exporter pod.
|
# -- Labels for the exporter pod.
|
||||||
labels: {} # The common library will add its own default labels.
|
labels:
|
||||||
|
app.kubernetes.io/component: exporter # Ensure pods get the component label for service selection
|
||||||
# -- Node selector for scheduling exporter pods.
|
# -- Node selector for scheduling exporter pods.
|
||||||
nodeSelector: {}
|
nodeSelector: {}
|
||||||
# -- Tolerations for scheduling exporter pods.
|
# -- Tolerations for scheduling exporter pods.
|
||||||
|
|
|
||||||
|
|
@ -92,16 +92,18 @@ def discover_iperf_servers():
|
||||||
|
|
||||||
logging.info(f"Discovering iperf3 servers with label '{label_selector}' in namespace '{namespace}'")
|
logging.info(f"Discovering iperf3 servers with label '{label_selector}' in namespace '{namespace}'")
|
||||||
|
|
||||||
ret = v1.list_pod_for_all_namespaces(label_selector=label_selector, watch=False)
|
# Use list_namespaced_pod to query only the specified namespace
|
||||||
|
ret = v1.list_namespaced_pod(namespace=namespace, label_selector=label_selector, watch=False)
|
||||||
|
|
||||||
servers = []
|
servers = []
|
||||||
for item in ret.items:
|
for item in ret.items:
|
||||||
|
# No need to filter by namespace here as the API call is already namespaced
|
||||||
if item.status.pod_ip and item.status.phase == 'Running':
|
if item.status.pod_ip and item.status.phase == 'Running':
|
||||||
servers.append({
|
servers.append({
|
||||||
'ip': item.status.pod_ip,
|
'ip': item.status.pod_ip,
|
||||||
'node_name': item.spec.node_name # Node where the iperf server pod is running
|
'node_name': item.spec.node_name # Node where the iperf server pod is running
|
||||||
})
|
})
|
||||||
logging.info(f"Discovered {len(servers)} iperf3 server pods.")
|
logging.info(f"Discovered {len(servers)} iperf3 server pods in namespace '{namespace}'.")
|
||||||
return servers
|
return servers
|
||||||
except config.ConfigException as e:
|
except config.ConfigException as e:
|
||||||
logging.error(f"Kubernetes config error: {e}. Is the exporter running in a cluster with RBAC permissions?")
|
logging.error(f"Kubernetes config error: {e}. Is the exporter running in a cluster with RBAC permissions?")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue