Compile a catalog
Compile and push a cluster catalog from local machine to update dependencies.
Requirements
-
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.
-
An existing Cluster in Lieutenant.
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. |
-
Set Lieutenant API URL
COMMODORE_API_URL=https://syn.example.com (1)
1 Replace with the URL of your Lieutenant instance -
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. -
Setup the
.env
file for CommodoreLieutenant 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 commandcommodore fetch-token
in variableLIEUTENANT_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.
Compilation
-
Get the Cluster ID from Lieutenant.
commodore catalog list -v
-
Set the cluster ID and prepare directory.
export CLUSTER_ID = <target-cluster-name-from-above> dir=$(mktemp -d) pushd "${dir}"
-
Compile the catalog and display a diff.
commodore catalog compile $CLUSTER_ID
-
Compile the catalog and push.
commodore catalog compile $CLUSTER_ID --push --interactive
popd
rm -rf "${dir}"