Skip to content

Commit be928c6

Browse files
Add helm version automation (#4142)
<!-- Thank you for contributing to the Elastic Docs! πŸŽ‰ Use this template to help us efficiently review your contribution. --> ## Summary <!-- Describe what your PR changes or improves. If your PR fixes an issue, link it here. If your PR does not fix an issue, describe the reason you are making the change. --> This enhances the Kubernetes chart docs automation to add the Helm version (latest tested). Fixes #4143 ## Generative AI disclosure <!-- To help us ensure compliance with the Elastic open source and documentation guidelines, please answer the following: --> 1. Did you use a generative AI (GenAI) tool to assist in creating this contribution? - [X] Yes - [ ] No <!-- 2. If you answered "Yes" to the previous question, please specify the tool(s) and model(s) used (e.g., Google Gemini, OpenAI ChatGPT-4, etc.). Tool(s) and model(s) used: Cursor 2 and Claude 4.5 Opus. --> --------- Co-authored-by: Roger Coll <[email protected]>
1 parent 8f86bce commit be928c6

File tree

6 files changed

+146
-14
lines changed

6 files changed

+146
-14
lines changed

β€Ž.github/workflows/update-kube-stack-version.ymlβ€Ž

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Run update script
3737
id: update-script
3838
run: |
39-
echo "Running kube-stack-version update script..."
39+
echo "Running version update script (kube-stack-version and helm-version)..."
4040
python scripts/update_kube_stack_version.py
4141
echo "Script completed successfully"
4242
@@ -60,19 +60,22 @@ jobs:
6060
uses: peter-evans/create-pull-request@v7
6161
with:
6262
token: ${{ secrets.GITHUB_TOKEN }}
63-
commit-message: 'chore: update kube-stack-version'
64-
title: 'chore: update kube-stack-version'
63+
commit-message: 'chore: update kube-stack-version and helm-version'
64+
title: 'chore: update kube-stack-version and helm-version'
6565
body: |
66-
This PR automatically updates the `kube-stack-version` in `docset.yml` based on the latest version from the elastic-agent repository.
66+
This PR automatically updates the `kube-stack-version` and `helm-version` in `docset.yml` based on the latest versions from the Kibana and Elastic Agent repositories.
6767
6868
**Changes:**
69-
- Updated `kube-stack-version` to the latest value from elastic-agent repository
69+
- Updated `kube-stack-version` to the latest value from the Kibana repository
70+
- Updated `helm-version` to the latest value from the Elastic Agent repository
7071
7172
**Generated by:** [Update Kube Stack Version workflow](https://github.com/${{ github.repository }}/actions/workflows/update-kube-stack-version.yml)
7273
7374
This is an automated update. Please review the changes before merging.
7475
branch: update-kube-stack-version
7576
delete-branch: true
77+
team-reviewers: |
78+
ingest-docs
7679
labels: |
7780
automated
7881
chore
@@ -91,7 +94,7 @@ jobs:
9194
git diff HEAD -- docset.yml >> $GITHUB_STEP_SUMMARY
9295
echo '```' >> $GITHUB_STEP_SUMMARY
9396
else
94-
echo "ℹ️ **No changes needed** - kube-stack-version is already up to date" >> $GITHUB_STEP_SUMMARY
97+
echo "ℹ️ **No changes needed** - kube-stack-version and helm-version are already up to date" >> $GITHUB_STEP_SUMMARY
9598
fi
9699
97100
- name: Summary
@@ -102,5 +105,5 @@ jobs:
102105
if [ "${{ steps.check-changes.outputs.has_changes }}" == "true" ]; then
103106
echo "βœ… **PR Created** - Changes detected and pull request created" >> $GITHUB_STEP_SUMMARY
104107
else
105-
echo "ℹ️ **No changes needed** - kube-stack-version is already up to date" >> $GITHUB_STEP_SUMMARY
108+
echo "ℹ️ **No changes needed** - kube-stack-version and helm-version are already up to date" >> $GITHUB_STEP_SUMMARY
106109
fi

β€Ždocset.ymlβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ subs:
296296
models-app: "Trained Models"
297297
agent-builder: "Elastic Agent Builder"
298298
kube-stack-version: 0.10.5
299+
helm-version: 3.15.4
299300
ece-docker-images-8: 8.18.8
300301
ece-docker-images-9: 9.0.8
301302

303+

β€Žscripts/update_kube_stack_version.pyβ€Ž

Lines changed: 122 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#!/usr/bin/env python3
22
"""
3-
Script to update the kube-stack-version in docset.yml based on the version
4-
from the Kibana repository.
3+
Script to update the kube-stack-version and helm-version in docset.yml based on
4+
versions from the Kibana and Elastic Agent repositories.
55
66
This script:
77
1. Retrieves the latest semver from the Kibana repository
88
2. Reads the constants.ts file from that Kibana version
99
3. Extracts the OTEL_KUBE_STACK_VERSION value
10-
4. Updates the kube-stack-version in docset.yml
10+
4. Fetches the go.mod file from the Elastic Agent repository
11+
5. Extracts the Helm version from go.mod
12+
6. Updates both kube-stack-version and helm-version in docset.yml
1113
"""
1214

1315
import re
@@ -143,6 +145,64 @@ def extract_kube_stack_version(content: str) -> str:
143145
return version
144146

145147

148+
def fetch_elastic_agent_gomod() -> str:
149+
"""
150+
Fetch the content of the go.mod file from the Elastic Agent repository with retry logic.
151+
152+
Returns:
153+
str: The content of the go.mod file
154+
155+
Raises:
156+
Exception: If unable to fetch the file content after retries
157+
"""
158+
url = "https://raw.githubusercontent.com/elastic/elastic-agent/refs/heads/main/go.mod"
159+
max_retries = 3
160+
retry_delay = 2 # seconds
161+
162+
for attempt in range(max_retries):
163+
try:
164+
print(f"Fetching go.mod from Elastic Agent repository (attempt {attempt + 1}/{max_retries})")
165+
response = requests.get(url, timeout=30)
166+
response.raise_for_status()
167+
168+
print("Successfully fetched go.mod from Elastic Agent repository")
169+
return response.text
170+
171+
except requests.RequestException as e:
172+
if attempt < max_retries - 1:
173+
print(f"Attempt {attempt + 1} failed: {e}")
174+
print(f"Retrying in {retry_delay} seconds...")
175+
time.sleep(retry_delay)
176+
retry_delay *= 2 # Exponential backoff
177+
else:
178+
raise Exception(f"Failed to fetch go.mod file after {max_retries} attempts: {e}")
179+
180+
181+
def extract_helm_version(content: str) -> str:
182+
"""
183+
Extract the Helm version from the go.mod file content.
184+
185+
Args:
186+
content (str): The content of the go.mod file
187+
188+
Returns:
189+
str: The Helm version (e.g., '3.15.4')
190+
191+
Raises:
192+
Exception: If the Helm version pattern is not found
193+
"""
194+
# Pattern to match helm.sh/helm/v3 vX.Y.Z
195+
pattern = r'helm\.sh/helm/v3\s+v([\d.]+)'
196+
197+
match = re.search(pattern, content)
198+
if not match:
199+
raise Exception("Helm version pattern not found in go.mod file")
200+
201+
version = match.group(1)
202+
print(f"Extracted Helm version: {version}")
203+
return version
204+
205+
146206
def update_docset_yml(kube_stack_version: str, docset_path: Path) -> None:
147207
"""
148208
Update the kube-stack-version in the docset.yml file.
@@ -184,10 +244,51 @@ def update_docset_yml(kube_stack_version: str, docset_path: Path) -> None:
184244
raise Exception(f"Failed to update docset.yml: {e}")
185245

186246

247+
def update_helm_version(helm_version: str, docset_path: Path) -> None:
248+
"""
249+
Update the helm-version in the docset.yml file.
250+
251+
Args:
252+
helm_version (str): The new version to set
253+
docset_path (Path): Path to the docset.yml file
254+
255+
Raises:
256+
Exception: If unable to update the file
257+
"""
258+
try:
259+
# Read the current docset.yml content
260+
with open(docset_path, 'r', encoding='utf-8') as file:
261+
content = file.read()
262+
263+
# Pattern to match helm-version: <value> (with 2 spaces at the beginning)
264+
pattern = r'( helm-version:\s*)([^\s\n]+)'
265+
266+
# Replace the version
267+
new_content = re.sub(pattern, rf'\g<1>{helm_version}', content)
268+
269+
if new_content == content:
270+
# Check if the version is already correct
271+
current_match = re.search(pattern, content)
272+
if current_match and current_match.group(2) == helm_version:
273+
print(f"helm-version is already set to {helm_version}")
274+
return
275+
else:
276+
raise Exception("helm-version pattern not found in docset.yml")
277+
278+
# Write the updated content back to the file
279+
with open(docset_path, 'w', encoding='utf-8') as file:
280+
file.write(new_content)
281+
282+
print(f"Successfully updated helm-version to {helm_version} in docset.yml")
283+
284+
except Exception as e:
285+
raise Exception(f"Failed to update docset.yml: {e}")
286+
287+
187288
def main():
188289
"""Main function to orchestrate the update process."""
189290
try:
190-
print("Starting kube-stack-version update process...")
291+
print("Starting version update process...")
191292

192293
# Get the script directory and project root
193294
script_dir = Path(__file__).parent
@@ -210,11 +311,25 @@ def main():
210311
print("\n3. Extracting OTEL_KUBE_STACK_VERSION...")
211312
kube_stack_version = extract_kube_stack_version(constants_content)
212313

213-
# Step 4: Update docset.yml
214-
print("\n4. Updating docset.yml...")
314+
# Step 4: Fetch go.mod content from Elastic Agent repository
315+
print("\n4. Fetching go.mod file content from Elastic Agent repository...")
316+
gomod_content = fetch_elastic_agent_gomod()
317+
318+
# Step 5: Extract Helm version
319+
print("\n5. Extracting Helm version...")
320+
helm_version = extract_helm_version(gomod_content)
321+
322+
# Step 6: Update docset.yml with kube-stack-version
323+
print("\n6. Updating kube-stack-version in docset.yml...")
215324
update_docset_yml(kube_stack_version, docset_path)
216325

217-
print(f"\nβœ… Successfully updated kube-stack-version to {kube_stack_version}")
326+
# Step 7: Update docset.yml with helm-version
327+
print("\n7. Updating helm-version in docset.yml...")
328+
update_helm_version(helm_version, docset_path)
329+
330+
print(f"\nβœ… Successfully updated:")
331+
print(f" - kube-stack-version to {kube_stack_version}")
332+
print(f" - helm-version to {helm_version}")
218333

219334
except Exception as e:
220335
print(f"\n❌ Error: {e}")

β€Žsolutions/observability/get-started/opentelemetry/quickstart/ech/k8s.mdβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Learn how to set up the EDOT Collector and EDOT SDKs in a Kubernetes environment
2222
:::{include} ../../_snippets/guided-instructions.md
2323
:::
2424

25+
## Prerequisites
26+
27+
To use the OpenTelemetry Kube Stack Chart, you need Helm version 3.9+ up to and including {{helm-version}}.
28+
2529
## Manual installation
2630

2731
Follow these steps to deploy the EDOT Collector and EDOT OTel SDKs in Kubernetes with ECH.

β€Žsolutions/observability/get-started/opentelemetry/quickstart/self-managed/k8s.mdβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Learn how to set up the EDOT Collector and EDOT SDKs in a Kubernetes environment
2222
:::{include} ../../_snippets/guided-instructions.md
2323
:::
2424

25+
## Prerequisites
26+
27+
To use the OpenTelemetry Kube Stack Chart, you need Helm version 3.9+ up to and including {{helm-version}}.
28+
2529
## Manual installation
2630

2731
Follow these steps to deploy the EDOT Collector and EDOT OTel SDKs in Docker.

β€Žsolutions/observability/get-started/opentelemetry/quickstart/serverless/k8s.mdβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Learn how to set up the EDOT Collector and EDOT SDKs in a Kubernetes environment
2222
:::{include} ../../_snippets/guided-instructions.md
2323
:::
2424

25+
## Prerequisites
26+
27+
To use the OpenTelemetry Kube Stack Chart, you need Helm version 3.9+ up to and including {{helm-version}}.
28+
2529
## Manual installation
2630

2731
Follow these steps to deploy the EDOT Collector and EDOT OTel SDKs in Kubernetes.

0 commit comments

Comments
Β (0)