Overview
vendir is a tool that allows you to declaratively define a set of data resources in a consistent structure.
An analogy for describing vendir is git submodules on steroids.
Theory
- Know what vendir is and how it fits into the
Carveltoolchain.
- Review the
vendirdocumentation
Practical
- Know how to use vendir for obtaining upstream dependencies.
Pre-requisites
If you intend on completing the tutorial section there are some pre-requisites.
- Linux environment with admin permissions
if using a Windows Laptop, the suggestion is to have either WSL installed or have available a Hyper-V Linux VM.
Tutorial
Prior to starting the tutorial, you need to have the Carvel toolchain installed and available locally. Full installation instructions are available over at carvel.dev .
- Install Carvel
wget -O- https://carvel.dev/install.sh | sudo bash
wget -O- https://carvel.dev/install.sh | sudo bash
- Install
helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- Install
kustomize
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
sudo mv kustomize /usr/local/bin/
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
sudo mv kustomize /usr/local/bin/
- Install
yq
# https://github.com/mikefarah/yq/releases
YQ_VERSION="v4.24.2"
YQ_URL="https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"
YQ_URL_CHECKSUMS="https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/checksums"
curl \
--location \
--insecure \
--output yq_linux_amd64 \
${YQ_URL} \
&& curl \
--location \
--insecure \
--output yq.checksums \
"${YQ_URL_CHECKSUMS}" \
&& chmod +x yq_linux_amd64 \
&& echo "$(grep "yq_linux_amd64 " yq.checksums | tr -s ' ' | cut -d ' ' -f 19) yq_linux_amd64" | sha256sum --check \
&& sudo mv yq_linux_amd64 /usr/local/bin/yq \
&& yq --version \
&& rm yq.checksums
# https://github.com/mikefarah/yq/releases
YQ_VERSION="v4.24.2"
YQ_URL="https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"
YQ_URL_CHECKSUMS="https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/checksums"
curl \
--location \
--insecure \
--output yq_linux_amd64 \
${YQ_URL} \
&& curl \
--location \
--insecure \
--output yq.checksums \
"${YQ_URL_CHECKSUMS}" \
&& chmod +x yq_linux_amd64 \
&& echo "$(grep "yq_linux_amd64 " yq.checksums | tr -s ' ' | cut -d ' ' -f 19) yq_linux_amd64" | sha256sum --check \
&& sudo mv yq_linux_amd64 /usr/local/bin/yq \
&& yq --version \
&& rm yq.checksums
vendir reads from a single configuration file named vendir.yml. Full information about all supported configuration options is available in the specification
.
- Create an example
vendir.ymlfile as follows:
cat <<- _EOF_ > "vendir.yml"
apiVersion: vendir.k14s.io/v1alpha1
kind: Config
minimumRequiredVersion: 0.12.0
directories:
- path: vendor
contents:
- path: custom-repo-custom-version
helmChart:
name: contour
version: "1.2.1"
repository:
url: https://charts.bitnami.com/bitnami
_EOF_
cat <<- _EOF_ > "vendir.yml"
apiVersion: vendir.k14s.io/v1alpha1
kind: Config
minimumRequiredVersion: 0.12.0
directories:
- path: vendor
contents:
- path: custom-repo-custom-version
helmChart:
name: contour
version: "1.2.1"
repository:
url: https://charts.bitnami.com/bitnami
_EOF_
Now that the configuration file has been created, execute the utility now to pull down the dependencies.
- Run
vendir
vendir sync
The tool will automatically create a lock file in the current directory, take a look at it now.
- Inspect the lock file
cat vendir.lock.yml
cat vendir.lock.yml
As defined in the configuration file, the downloaded contents are stored in the vendor directory.
- Inspect the contents of the
vendordirectory
tree -a vendor
tree -a vendor
tree /F vendor
The basic vendir tutorial is now complete!
For a longer form tutorial check out how vendir fits into a carvel package the hard way
