List Lieutenant clusters

Compile and push a cluster catalog from local machine to update dependencies.

Requirements

  • A working commodore command.

  • Access to a running Lieutenant instance. See the next section for details on how to connect to Lieutenant instances with OIDC or long-lived tokens.

  • jq

Prepare Commodore

The following snippet sets up needed environment variables in your current working directory.

You can skip this section if you have already defined the required environment variables.
  1. Set Lieutenant API URL

    COMMODORE_API_URL=https://syn.example.com (1)
    1 Replace with the URL of your Lieutenant instance
  2. Determine whether the Lieutenant instance uses OIDC authentication:

    curl ${COMMODORE_API_URL}

    If the response contains field oidc, the Lieutenant API instance uses OIDC authentication. Otherwise, please check with your Project Syn administrators for details on how to authenticate against the Lieutenant API.

  3. Setup the .env file for Commodore

    Lieutenant instance using OIDC token
    cat << EOF > .env
    LIEUTENANT_AUTH="Authorization:Bearer \$(commodore fetch-token)"
    LIEUTENANT_URL="${COMMODORE_API_URL}"
    COMMODORE_API_URL="${COMMODORE_API_URL}"
    EOF
    For some how-tos, you’ll need to source the .env file. In those cases, the command commodore fetch-token in variable LIEUTENANT_AUTH will be executed at the time you source the .env file. You may need to re-source the file when following a longer guide as the OIDC token will usually have a lifetime of only a few minutes.
    Lieutenant instance using long-lived Kubernetes token
    # Assuming "syn-synfra" is the user for the cluster hosting the Lieutenant API in your kubeconfig
    LIEUTENANT_TOKEN=$(kubectl config view -o jsonpath='{.users[?(@.name == "syn-synfra")].user.token}'  --raw)
    LIEUTENANT_URL="the-public-lieutenant-API-URL"
    
    cat << EOF > .env
    LIEUTENANT_AUTH="Authorization:Bearer ${LIEUTENANT_TOKEN}"
    LIEUTENANT_URL="${LIEUTENANT_URL}"
    COMMODORE_API_TOKEN="${LIEUTENANT_TOKEN}"
    COMMODORE_API_URL="${LIEUTENANT_URL}"
    EOF

    Commodore will automatically load environment variables from file .env in the working directory. When you’re just compiling a cluster catalog, you don’t need to source the file.

List clusters

List all clusters known to Lieutenant
commodore catalog list
List all clusters for a specific tenant
TENANT_ID=t-tenant-id-1234 (1)
commodore catalog list -t $TENANT_ID
1 Replace with the Tenant ID for which you want to list clusters
List all clusters with fact distribution set to openshift4
commodore catalog list -ojson | jq -r '.[] | select(.facts.distribution == "openshift4") | .id'
List all clusters with fact cloud set to cloudscale
commodore catalog list -ojson | jq -r '.[] | select(.facts.cloud == "cloudscale") | .id'
List all clusters with K8s version < 1.24 (requires recent Steward)
commodore catalog list -ojson | \
  jq -r '.[] | select(.dynamicFacts.kubernetesVersion.minor//"0"|tonumber < 24) | .id'

Clusters which don’t have a reported K8s version as a dynamic fact will be listed. To change this behavior, replace //"0" with //"24" in the jq expression.