UNPKG

@adp-psych/container-tools

Version:

Tools for using containers for psychology experiments

100 lines (92 loc) 2.78 kB
/* * Copyright (C) 2021, 2022 Anthony Di Pietro * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ /** * @file Installs [ExternalDNS](https://github.com/kubernetes-sigs/external-dns) * to a [Kubernetes](https://kubernetes.io/) cluster * using [Helm](https://helm.sh/). * * @module module:install-external-dns * @requires console-exec * @author Anthony Di Pietro <anthony.dipietro@research.uwa.edu.au> * @copyright © 2021, 2022 Anthony Di Pietro * @license AGPL-3.0-or-later */ const { addRepository, updateRepositories, upgradeInstall, } = require('./helm.js'); /** * The name of the repository containing the Helm chart. * * @constant {String} * @static * @access protected */ const REPOSITORY_NAME = 'bitnami'; /** * The URL of the repository containing the Helm chart. * * @constant {String} * @static * @access protected */ const REPOSITORY_URL = 'https://charts.bitnami.com/bitnami'; /** * Installs/upgrades external-dns using Helm. * * @static * @access protected * @param {String} version - The version of external-dns to install. * @param {String} apiToken - The DigitalOcean API token. * @example * // Installs/upgrades external-dns to version 6.7.2. * helmUpgradeExternalDns('6.7.2', 'abc'); */ const upgradeExternalDns = async (version, apiToken) => { await upgradeInstall('external-dns', 'bitnami/external-dns', [ `--version=${version}`, '--set', 'rbac.create=true', '--set', 'rbac.apiVersion=v1', '--set', 'policy=sync', '--set', 'triggerLoopOnEvent=true', '--set', 'provider=digitalocean', '--set', `digitalocean.apiToken=${apiToken}`, ]); }; /** * Installs/upgrades external-dns using Helm. * * @static * @param {String} version - The version of external-dns to install. * @param {String} apiToken - The DigitalOcean API token. * @example * // Installs/upgrades external-dns to version 6.7.2. * installExternalDns('6.7.2', 'abc'); */ const installExternalDns = async (version, apiToken) => { await addRepository(REPOSITORY_NAME, REPOSITORY_URL); await updateRepositories(); await upgradeExternalDns(version, apiToken); }; module.exports = installExternalDns;