diff --git a/.github/workflows/update-kube-stack-version.yml b/.github/workflows/update-kube-stack-version.yml index d7d69ebccb..20157afd01 100644 --- a/.github/workflows/update-kube-stack-version.yml +++ b/.github/workflows/update-kube-stack-version.yml @@ -36,7 +36,7 @@ jobs: - name: Run update script id: update-script run: | - echo "Running kube-stack-version update script..." + echo "Running version update script (kube-stack-version and helm-version)..." python scripts/update_kube_stack_version.py echo "Script completed successfully" @@ -60,19 +60,22 @@ jobs: uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.GITHUB_TOKEN }} - commit-message: 'chore: update kube-stack-version' - title: 'chore: update kube-stack-version' + commit-message: 'chore: update kube-stack-version and helm-version' + title: 'chore: update kube-stack-version and helm-version' body: | - This PR automatically updates the `kube-stack-version` in `docset.yml` based on the latest version from the elastic-agent repository. + 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. **Changes:** - - Updated `kube-stack-version` to the latest value from elastic-agent repository + - Updated `kube-stack-version` to the latest value from the Kibana repository + - Updated `helm-version` to the latest value from the Elastic Agent repository **Generated by:** [Update Kube Stack Version workflow](https://github.com/${{ github.repository }}/actions/workflows/update-kube-stack-version.yml) This is an automated update. Please review the changes before merging. branch: update-kube-stack-version delete-branch: true + team-reviewers: | + ingest-docs labels: | automated chore @@ -91,7 +94,7 @@ jobs: git diff HEAD -- docset.yml >> $GITHUB_STEP_SUMMARY echo '```' >> $GITHUB_STEP_SUMMARY else - echo "ℹ️ **No changes needed** - kube-stack-version is already up to date" >> $GITHUB_STEP_SUMMARY + echo "ℹ️ **No changes needed** - kube-stack-version and helm-version are already up to date" >> $GITHUB_STEP_SUMMARY fi - name: Summary @@ -102,5 +105,5 @@ jobs: if [ "${{ steps.check-changes.outputs.has_changes }}" == "true" ]; then echo "✅ **PR Created** - Changes detected and pull request created" >> $GITHUB_STEP_SUMMARY else - echo "ℹ️ **No changes needed** - kube-stack-version is already up to date" >> $GITHUB_STEP_SUMMARY + echo "ℹ️ **No changes needed** - kube-stack-version and helm-version are already up to date" >> $GITHUB_STEP_SUMMARY fi diff --git a/docset.yml b/docset.yml index c20f8cd18e..21d968a5ed 100644 --- a/docset.yml +++ b/docset.yml @@ -296,6 +296,8 @@ subs: models-app: "Trained Models" agent-builder: "Elastic Agent Builder" kube-stack-version: 0.10.5 + helm-version: 3.15.4 ece-docker-images-8: 8.18.8 ece-docker-images-9: 9.0.8 + diff --git a/scripts/update_kube_stack_version.py b/scripts/update_kube_stack_version.py index 213904fe00..bafd940cd4 100755 --- a/scripts/update_kube_stack_version.py +++ b/scripts/update_kube_stack_version.py @@ -1,13 +1,15 @@ #!/usr/bin/env python3 """ -Script to update the kube-stack-version in docset.yml based on the version -from the Kibana repository. +Script to update the kube-stack-version and helm-version in docset.yml based on +versions from the Kibana and Elastic Agent repositories. This script: 1. Retrieves the latest semver from the Kibana repository 2. Reads the constants.ts file from that Kibana version 3. Extracts the OTEL_KUBE_STACK_VERSION value -4. Updates the kube-stack-version in docset.yml +4. Fetches the go.mod file from the Elastic Agent repository +5. Extracts the Helm version from go.mod +6. Updates both kube-stack-version and helm-version in docset.yml """ import re @@ -143,6 +145,64 @@ def extract_kube_stack_version(content: str) -> str: return version +def fetch_elastic_agent_gomod() -> str: + """ + Fetch the content of the go.mod file from the Elastic Agent repository with retry logic. + + Returns: + str: The content of the go.mod file + + Raises: + Exception: If unable to fetch the file content after retries + """ + url = "https://raw.githubusercontent.com/elastic/elastic-agent/refs/heads/main/go.mod" + max_retries = 3 + retry_delay = 2 # seconds + + for attempt in range(max_retries): + try: + print(f"Fetching go.mod from Elastic Agent repository (attempt {attempt + 1}/{max_retries})") + response = requests.get(url, timeout=30) + response.raise_for_status() + + print("Successfully fetched go.mod from Elastic Agent repository") + return response.text + + except requests.RequestException as e: + if attempt < max_retries - 1: + print(f"Attempt {attempt + 1} failed: {e}") + print(f"Retrying in {retry_delay} seconds...") + time.sleep(retry_delay) + retry_delay *= 2 # Exponential backoff + else: + raise Exception(f"Failed to fetch go.mod file after {max_retries} attempts: {e}") + + +def extract_helm_version(content: str) -> str: + """ + Extract the Helm version from the go.mod file content. + + Args: + content (str): The content of the go.mod file + + Returns: + str: The Helm version (e.g., '3.15.4') + + Raises: + Exception: If the Helm version pattern is not found + """ + # Pattern to match helm.sh/helm/v3 vX.Y.Z + pattern = r'helm\.sh/helm/v3\s+v([\d.]+)' + + match = re.search(pattern, content) + if not match: + raise Exception("Helm version pattern not found in go.mod file") + + version = match.group(1) + print(f"Extracted Helm version: {version}") + return version + + def update_docset_yml(kube_stack_version: str, docset_path: Path) -> None: """ 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: raise Exception(f"Failed to update docset.yml: {e}") +def update_helm_version(helm_version: str, docset_path: Path) -> None: + """ + Update the helm-version in the docset.yml file. + + Args: + helm_version (str): The new version to set + docset_path (Path): Path to the docset.yml file + + Raises: + Exception: If unable to update the file + """ + try: + # Read the current docset.yml content + with open(docset_path, 'r', encoding='utf-8') as file: + content = file.read() + + # Pattern to match helm-version: (with 2 spaces at the beginning) + pattern = r'( helm-version:\s*)([^\s\n]+)' + + # Replace the version + new_content = re.sub(pattern, rf'\g<1>{helm_version}', content) + + if new_content == content: + # Check if the version is already correct + current_match = re.search(pattern, content) + if current_match and current_match.group(2) == helm_version: + print(f"helm-version is already set to {helm_version}") + return + else: + raise Exception("helm-version pattern not found in docset.yml") + + # Write the updated content back to the file + with open(docset_path, 'w', encoding='utf-8') as file: + file.write(new_content) + + print(f"Successfully updated helm-version to {helm_version} in docset.yml") + + except Exception as e: + raise Exception(f"Failed to update docset.yml: {e}") + + def main(): """Main function to orchestrate the update process.""" try: - print("Starting kube-stack-version update process...") + print("Starting version update process...") # Get the script directory and project root script_dir = Path(__file__).parent @@ -210,11 +311,25 @@ def main(): print("\n3. Extracting OTEL_KUBE_STACK_VERSION...") kube_stack_version = extract_kube_stack_version(constants_content) - # Step 4: Update docset.yml - print("\n4. Updating docset.yml...") + # Step 4: Fetch go.mod content from Elastic Agent repository + print("\n4. Fetching go.mod file content from Elastic Agent repository...") + gomod_content = fetch_elastic_agent_gomod() + + # Step 5: Extract Helm version + print("\n5. Extracting Helm version...") + helm_version = extract_helm_version(gomod_content) + + # Step 6: Update docset.yml with kube-stack-version + print("\n6. Updating kube-stack-version in docset.yml...") update_docset_yml(kube_stack_version, docset_path) - print(f"\n✅ Successfully updated kube-stack-version to {kube_stack_version}") + # Step 7: Update docset.yml with helm-version + print("\n7. Updating helm-version in docset.yml...") + update_helm_version(helm_version, docset_path) + + print(f"\n✅ Successfully updated:") + print(f" - kube-stack-version to {kube_stack_version}") + print(f" - helm-version to {helm_version}") except Exception as e: print(f"\n❌ Error: {e}") diff --git a/solutions/observability/get-started/opentelemetry/quickstart/ech/k8s.md b/solutions/observability/get-started/opentelemetry/quickstart/ech/k8s.md index 0607a721e8..3501f013f3 100644 --- a/solutions/observability/get-started/opentelemetry/quickstart/ech/k8s.md +++ b/solutions/observability/get-started/opentelemetry/quickstart/ech/k8s.md @@ -22,6 +22,10 @@ Learn how to set up the EDOT Collector and EDOT SDKs in a Kubernetes environment :::{include} ../../_snippets/guided-instructions.md ::: +## Prerequisites + +To use the OpenTelemetry Kube Stack Chart, you need Helm version 3.9+ up to and including {{helm-version}}. + ## Manual installation Follow these steps to deploy the EDOT Collector and EDOT OTel SDKs in Kubernetes with ECH. diff --git a/solutions/observability/get-started/opentelemetry/quickstart/self-managed/k8s.md b/solutions/observability/get-started/opentelemetry/quickstart/self-managed/k8s.md index ed605e25f4..76b4c04205 100644 --- a/solutions/observability/get-started/opentelemetry/quickstart/self-managed/k8s.md +++ b/solutions/observability/get-started/opentelemetry/quickstart/self-managed/k8s.md @@ -22,6 +22,10 @@ Learn how to set up the EDOT Collector and EDOT SDKs in a Kubernetes environment :::{include} ../../_snippets/guided-instructions.md ::: +## Prerequisites + +To use the OpenTelemetry Kube Stack Chart, you need Helm version 3.9+ up to and including {{helm-version}}. + ## Manual installation Follow these steps to deploy the EDOT Collector and EDOT OTel SDKs in Docker. diff --git a/solutions/observability/get-started/opentelemetry/quickstart/serverless/k8s.md b/solutions/observability/get-started/opentelemetry/quickstart/serverless/k8s.md index d09678b6d5..6dc31050f5 100644 --- a/solutions/observability/get-started/opentelemetry/quickstart/serverless/k8s.md +++ b/solutions/observability/get-started/opentelemetry/quickstart/serverless/k8s.md @@ -22,6 +22,10 @@ Learn how to set up the EDOT Collector and EDOT SDKs in a Kubernetes environment :::{include} ../../_snippets/guided-instructions.md ::: +## Prerequisites + +To use the OpenTelemetry Kube Stack Chart, you need Helm version 3.9+ up to and including {{helm-version}}. + ## Manual installation Follow these steps to deploy the EDOT Collector and EDOT OTel SDKs in Kubernetes.