Skip to content
Icon

argo Helm Release Health

Profile Avatar

Icon 1 5 Troubleshooting Commands

Icon 1 Last updated 13 weeks ago

Icon 1 Contributed by stewartshea



Troubleshooting Commands

List all available FluxCD Helmreleases in Namespace argo

What does it do?

This command retrieves information about a specific Kubernetes resource within a specific namespace and context. It is a way to access and view details about the specified resource in a particular environment or cluster.

Command
kubectl get HelmRelease.helm.toolkit.fluxcd.io -n argo --context gke_runwhen-nonprod-sandbox_us-central1_sandbox-cluster-1-cluster
IconCopy to clipboard Copied to clipboard

Learn more

This multi-line content is auto-generated and used for educational purposes. Copying and pasting the multi-line text might not function as expected.

# First, let's list all the resources in a specific namespace within a context

# Replace ${RESOURCE_NAME} with the name of the resource you want to retrieve, such as pods, deployments, services, etc.
# Replace ${NAMESPACE} with the name of the namespace where the resource is located
# Replace ${CONTEXT} with the name of the Kubernetes context you want to use

kubectl get ${RESOURCE_NAME} -n ${NAMESPACE} --context ${CONTEXT}
Helpful Links

Fetch Installed FluxCD Helmrelease Versions in Namespace argo

What does it do?

This command uses kubectl to retrieve specific information about a resource in a particular namespace, using JSONPath to format the output, and specifying a context for the command to run in. The "|| true" part at the end ensures that the command will return a successful status code even if it encounters an error.

Command
kubectl get HelmRelease.helm.toolkit.fluxcd.io -n argo -o=jsonpath="{range .items[*]}{'\nName: '}{@.metadata.name}{'\nlastAppliedRevision:'}{@.status.lastAppliedRevision}{'\nlastAttemptedRevision:'}{@.status.lastAttemptedRevision}{'\n---'}{end}" --context gke_runwhen-nonprod-sandbox_us-central1_sandbox-cluster-1-cluster || true
IconCopy to clipboard Copied to clipboard

Learn more

This multi-line content is auto-generated and used for educational purposes. Copying and pasting the multi-line text might not function as expected.

# This command uses kubectl to get information about a specific resource in a given namespace and outputs it in a custom format.
# Replace ${RESOURCE_NAME} with the name of the Kubernetes resource you want to get information about, e.g., pod, deployment, etc.
# Replace ${NAMESPACE} with the name of the Kubernetes namespace where the resource is located.
# Replace ${CONTEXT} with the name of the Kubernetes context to use.

kubectl get ${RESOURCE_NAME} -n ${NAMESPACE} \
  -o=jsonpath="{range .items[*]}{'\nName: '}{@.metadata.name}{'\nlastAppliedRevision:'}{@.status.lastAppliedRevision}{'\nlastAttemptedRevision:'}{@.status.lastAttemptedRevision}{'\n---'}{end}" \
  --context ${CONTEXT} || true

By breaking down the command into multiple lines and providing helpful comments, newer or less experienced devops engineers can better understand what each part of the command does and how to customize it for their specific needs.
Helpful Links

Fetch Mismatched FluxCD HelmRelease Version in Namespace argo

What does it do?

This command retrieves the specified Kubernetes resource in the specified namespace and context, outputs it as JSON, and then filters the results to display only the items that have a different last applied revision from the last attempted revision, along with their name and revision information.

Command
kubectl get HelmRelease.helm.toolkit.fluxcd.io -n argo -o json --context gke_runwhen-nonprod-sandbox_us-central1_sandbox-cluster-1-cluster | jq -r '.items[] | select(.status.lastAppliedRevision!=.status.lastAttemptedRevision) | "Name: " + .metadata.name + " Last Attempted Version: " + .status.lastAttemptedRevision + " Last Applied Revision: " + .status.lastAppliedRevision'
IconCopy to clipboard Copied to clipboard

Learn more

This multi-line content is auto-generated and used for educational purposes. Copying and pasting the multi-line text might not function as expected.

# Use kubectl to get the resource with a specific name in a specific namespace, output as JSON, using a specific context
kubectl get ${RESOURCE_NAME} -n ${NAMESPACE} -o json --context ${CONTEXT} \

# Pipe the result to jq to filter and format the output
| jq -r '.items[] 
  | select(.status.lastAppliedRevision!=.status.lastAttemptedRevision) 
  | "Name: " + .metadata.name 
  + " Last Attempted Version: " + .status.lastAttemptedRevision 
  + " Last Applied Revision: " + .status.lastAppliedRevision'

In this multi-line command, we break down the process of fetching and processing data on Kubernetes resources in a more understandable way. By adding comments, newer or less experienced devops engineers can better understand what each part of the command does.
Helpful Links

Fetch FluxCD HelmRelease Error Messages in Namespace argo

What does it do?

This command retrieves a list of specific resources in a specified namespace, and then filters out the items that have a status condition of 'False'. It then outputs the name of the resource and its corresponding status condition message, with a line of dashes separating each resource. After executing the command, it will return a success status regardless of whether any resources were found or not.

Command
kubectl get HelmRelease.helm.toolkit.fluxcd.io -n argo -o=jsonpath="{range .items[?(@.status.conditions[].status=='False')]}{'-----\nName: '}{@.metadata.name}{'\n'}{@.status.conditions[*].message}{'\n'}{end}" --context gke_runwhen-nonprod-sandbox_us-central1_sandbox-cluster-1-cluster || true
IconCopy to clipboard Copied to clipboard

Learn more

This multi-line content is auto-generated and used for educational purposes. Copying and pasting the multi-line text might not function as expected.

# This command is used to retrieve specific resource information from a Kubernetes cluster.

# Replace `${RESOURCE_NAME}` with the name of the Kubernetes resource you want to query.
# Replace `${NAMESPACE}` with the namespace in which the resource resides.
# Replace `${CONTEXT}` with the context of the Kubernetes cluster you want to use.

# The following command retrieves the specified resource using kubectl and outputs the result in a custom format.
kubectl get ${RESOURCE_NAME} -n ${NAMESPACE} -o=jsonpath="{range .items[?(@.status.conditions[].status=='False')]}{'-----\nName: '}{@.metadata.name}{'\n'}{@.status.conditions[*].message}{'\n'}{end}" --context ${CONTEXT}

# In case the command fails (e.g., due to the resource not existing), the `|| true` statement ensures that the overall exit status of the command is successful, allowing it to continue without causing an error.
Helpful Links

Check for Available Helm Chart Updates in Namespace argo

What does it do?

This command retrieves information about Helm releases in a Kubernetes cluster, including chart details and available updates for the charts. It then prints out a summary for each release, including the installed version and whether an update is available.

Command
namespace="argo" context="gke_runwhen-nonprod-sandbox_us-central1_sandbox-cluster-1-cluster"; helm_releases=$(kubectl get HelmRelease.helm.toolkit.fluxcd.io -n "$namespace" --context "$context" -o json | jq -r '.items[] | .metadata.name'); echo "$helm_releases" | while IFS= read -r release; do chart_details=$(kubectl get HelmRelease.helm.toolkit.fluxcd.io "$release" -n "$namespace" --context "$context" -o json | jq -r '.spec.chart.spec // empty'); if [[ -n "$chart_details" ]]; then chart_kind=$(echo "$chart_details" | jq -r '.sourceRef.kind // empty'); chart_name=$(echo "$chart_details" | jq -r '.chart // empty'); chart_source_name=$(echo "$chart_details" | jq -r '.sourceRef.name // empty'); chart_namespace=$(echo "$chart_details" | jq -r '.sourceRef.namespace // empty'); chart_version=$(echo "$chart_details" | jq -r '.version // "N/A"'); if [[ "$chart_kind" == "HelmRepository" && -n "$chart_name" && -n "$chart_namespace" ]]; then repo_url=$(kubectl get helmrepositories.source.toolkit.fluxcd.io "$chart_source_name" -n "$chart_namespace" --context "$context" -o json | jq -r '.spec.url // empty'); if [[ -n "$repo_url" ]]; then temp_repo_name="$chart_source_name-temp-$release"; add_repo=$(helm repo add "$temp_repo_name" "$repo_url"); available_chart_version=$(helm search repo "$temp_repo_name"/"$chart_name" --version ">$chart_version" --output json | jq -r '.[].version'); if [[ -n "$available_chart_version" ]]; then sorted_versions=($(echo "${available_chart_version[@]}" | tr ' ' '\n' | sort -V)); available_version=${sorted_versions[-1]}; version_update_available="True"; else available_version="N/A"; version_update_available="False"; fi; remove_repo=$(helm repo remove "$temp_repo_name"); else available_version="N/A"; version_update_available="False"; fi; else available_version="N/A"; version_update_available="False"; fi; else chart_name="N/A"; chart_namespace="N/A"; chart_version="N/A"; available_version="N/A"; version_update_available="False"; fi; echo "Release: $release | Chart: $chart_namespace/$chart_name | Installed Version: $chart_version | Available Update: $version_update_available | Available Version: $available_version"; done
IconCopy to clipboard Copied to clipboard

Learn more

This multi-line content is auto-generated and used for educational purposes. Copying and pasting the multi-line text might not function as expected.

# Set the namespace and context variables for use in the command
namespace="${NAMESPACE}"
context="${CONTEXT}"

# Get a list of helm releases in the specified namespace and context
helm_releases=$(kubectl get ${RESOURCE_NAME} -n "$namespace" --context "$context" -o json | jq -r '.items[] | .metadata.name')

# Iterate through each helm release
echo "$helm_releases" | while IFS= read -r release; do

  # Get details about the helm chart for the current release
  chart_details=$(kubectl get ${RESOURCE_NAME} "$release" -n "$namespace" --context "$context" -o json | jq -r '.spec.chart.spec // empty')

  # Check if the chart details exist
  if [[ -n "$chart_details" ]]; then

    # Extract specific details such as kind, name, namespace, version
    chart_kind=$(echo "$chart_details" | jq -r '.sourceRef.kind // empty')
    chart_name=$(echo "$chart_details" | jq -r '.chart // empty')
    chart_source_name=$(echo "$chart_details" | jq -r '.sourceRef.name // empty')
    chart_namespace=$(echo "$chart_details" | jq -r '.sourceRef.namespace // empty')
    chart_version=$(echo "$chart_details" | jq -r '.version // "N/A"')

    # Check if the chart kind is HelmRepository and relevant information exists
    if [[ "$chart_kind" == "HelmRepository" && -n "$chart_name" && -n "$chart_namespace" ]]; then

      # Get the repository URL for the chart
      repo_url=$(kubectl get helmrepositories.source.toolkit.fluxcd.io "$chart_source_name" -n "$chart_namespace" --context "$context" -o json | jq -r '.spec.url // empty')

      # If the repository URL exists, proceed with checking for available updates
      if [[ -n "$repo_url" ]]; then

        # Add the temporary repo for the chart to check available versions
        temp_repo_name="$chart_source_name-temp-$release"
        add_repo=$(helm repo add "$temp_repo_name" "$repo_url")

        # Check for the latest available version of the chart
        available_chart_version=$(helm search repo "$temp_repo_name"/"$chart_name" --version ">$chart_version" --output json | jq -r '.[].version')

        # If there is an available version, update the available_version variable
        if [[ -n "$available_chart_version" ]]; then
          sorted_versions=($(echo "\${available_chart_version[@]}" | tr ' ' '\n' | sort -V))
          available_version=${sorted_versions[-1]}
          version_update_available="True"
        else
          available_version="N/A"
          version_update_available="False"
        fi

        # Remove the temporary repo
        remove_repo=$(helm repo remove "$temp_repo_name")

      else
        available_version="N/A"
        version_update_available="False"
      fi

    else
      available_version="N/A"
      version_update_available="False"
    fi

  else 
    chart_name="N/A"
    chart_namespace="N/A"
    chart_version="N/A"
    available_version="N/A"
    version_update_available="False"
  fi

  # Display the release, chart details, and update information
  echo "Release: $release | Chart: $chart_namespace/$chart_name | Installed Version: $chart_version | Available Update: $version_update_available | Available Version: $available_version"

done
Helpful Links