pre { background: #333; white-space: pre; word-wrap: break-word; overflow: auto; }

Hopr ytt Template Guide

A guide on how to use ytt Templates when configuring and deploying Hopr sidecars

NAME                        READY   STATUS    RESTARTS   AGEhopr-p2p-6d4687599c-w9p9b   4/4     Running   0          60s
Chat icon
Transcript

Not sure what ytt is? Not sure how to use ytt templates? You've come to the right place!

Purpose

  • What is ytt?
  • Installation of ytt
  • Leveraging HOPR's ytt Template

ytt Templates?

ytt is an open source tool that is a part of the Carvel suite. It is a tool that understands YAML structure and can be used for templating, combining, and patching YAML content. ytt gives the ability to set values that you can use across configs, and also gives us (Hopr) the ability to make a standard configuration YAML available for our customers to utilize. While not necessary for installation of XTRA, it is a fast and convenient way of configuring the YAML files needed to run XTRA sidecar in your environment while eliminating the woes of text-based templating.

Side note: The artifacts in this guide show considerations for Kubernetes environments, but any container runtime or container orchestration environment can be used to deploy XTRA.

XTRA & ytt

In order to successfully deploy XTRA in your Kubernetes environment, there are Kubernetes manifest that has to be setup in your Kubernetes cluster. Those manifest include: namespace configuration, envoy configmap configuration, docker configuration file secret, hopr license secret, persistent maid volume, XTRA deployment manifest, as well as, services and communication endpoints configurations.

This can be overwhelming for even the most seasoned configuration veterans.

In comes ytt templating

ytt templates allows you to use our premade configuration files with values you set that are specific to your environment.

Example: Creating a namespace for your Kubernetes cluster

HOPR will provide you with a ytt template that looks like:

---
apiVersion: v1
kind: Namespace
metadata:
  namespace: #@ data.values.namespace

You will be able to set the name of the namespace by replacing the value for namespace in the vars file, that looks like:

#@data/values
---
namespace: hopr-p2p

Next Steps:

In order to use ytt templates, ytt has to be installed in your environment.

Installing ytt

Installation of ytt is straightforward:

You can access install scripts provided by Carvel available for all Carvel Tools.Note: The following command will install Carvel's suite of tools.

wget -O- https://carvel.dev/install.sh > install.sh
sudo bash install.sh

You can also access specific downloads on their GitHub page:

Note: For our purposes, you will only need to install ytt.

https://github.com/carvel-dev/ytt/releases

For more information on ytt installation, visit Carvel's ytt page [here].(https://carvel.dev/ytt/docs/v0.44.0/install/)

Once you have installed ytt, you can start leveraging HOPR's ytt template.

Leveraging Hopr's ytt Template

HOPR's ytt template can be found here:

Verify you have a templ.yaml file and a vars file:

Example: hopr-p2p.templ.yaml and vars.yaml

The templ.yaml file is created by HOPR and can be leveraged by setting values specific to your environment in the vars.yaml file

A vars.yaml file

#@data/values
---
create_namespace: false
namespace: hopr-p2p

app_port: 8000
node_port: 30002
listener_port: 18000

Once the vars.yaml file is set, run the following command to output the YAML files for your XTRA deployment:

ytt -f .

This can be paired with the kubectl apply command to apply the YAML files directly to your Kubernetes cluster:

ytt -f. | kubectl apply -f-

Email icon

Still need help?

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris eget urna nisi. Etiam vehicula scelerisque pretium.
Contact support