From 8bfc73452ed3f9ba269e301021389638300b9b2d Mon Sep 17 00:00:00 2001 From: JesusPerez Date: Tue, 31 Aug 2021 10:34:06 +0100 Subject: [PATCH] chore: full update content, links, yaml,etc --- README.md | 143 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 127 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 88896bf..08ad54d 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,11 @@ Fork me on GitHub -## Declarative [UpCloud](https://upcloud.com) Go API with YAML +## Declarative & command-line interface for [UpCloud](https://upcloud.com) resources -This was created to: +This was created since December 2020 to: +- to use YAML config definition files for resources and services - create,delete,start,stop [UpCloud servers](https://upcloud.com/products/cloud-servers/). - modify, delete [UpCloud storages](https://upcloud.com/products/maxiops-storage/). - Run commands with **ssh** in [UpCloud servers](https://upcloud.com/products/cloud-servers/). @@ -28,19 +29,26 @@ It clearly does not try to replace tools like [Terraform](https://www.terraform. - resources lists in **json** - prototyping ... +- As a provider tool for other **LibreClouds** [Klouds](https://rlung.librecloud.online/LibreCloud/Klouds#klouds) tools: [CloudMandala](https://rlung.librecloud.online/LibreCloud/CloudMandala#cloudmandala) and [Zteron](https://rlung.librecloud.online/LibreCloud/CloudMandala#cloudmandala) +Since March 2021 [UpCloud](https://github.com/UpCloudLtd) made available a [UpCloud CLI - upctl](https://github.com/UpCloudLtd/upcloud-cli#upcloud-cli---upctl) to allow resources control from command line. +[UpClapi](https://rlung.librecloud.online/LibreCloud/Upclapi#upclapi) was create to be used with a [Declarative](https://en.wikipedia.org/wiki/Declarative_programming) approach to manage infrastructures although some tasks can be solved with imperative command calls, resources relationship and their dependencies should be set and declared somewhere at least for monitoring,management,etc. + +Both developments ([upctl](https://github.com/UpCloudLtd/upcloud-cli#upcloud-cli---upctl) and [upclapi](https://rlung.librecloud.online/LibreCloud/Upclapi#upclapi)) use [Official UpCloudLtd GO API](https://github.com/UpCloudLtd/upcloud-go-api) extensively. + +> [UpClapi](https://rlung.librecloud.online/LibreCloud/Upclapi#upclapi) is used as a tool to provision and manage **UpCloud** ressources for **LibreClouds** [Klouds](https://rlung.librecloud.online/LibreCloud/Klouds#klouds) with [CloudMandala](https://rlung.librecloud.online/LibreCloud/CloudMandala#cloudmandala) and [Zteron](https://rlung.librecloud.online/LibreCloud/CloudMandala#cloudmandala) as major tools. ## Requirements for build -- Go `1.11+` -- Go Modules +- Go `1.16+` +- Go Modules defined in [go.mod](https://rlung.librecloud.online/LibreCloud/Upclapi/src/branch/master/go.mod) ## Build from source - Clone this repository and go to folder: ```bash -git clone https://github.com/JesusPerez/upclapi.git -cd upclapi +git clone https://rlung.librecloud.online/LibreCloud/Upclapi.git +cd Upclapi ``` - Build: @@ -65,6 +73,12 @@ export UPCLOUD_USERNAME="api-username" export UPCLOUD_PASSWORD="api-password" ``` +As an alternative this can be set as in an enviroment file with paths: + /etc/upcloud/.env or /usr/local/etc/upcloud/.env + +Another alternative is to use default [UpCloud CLI - upctl](https://github.com/UpCloudLtd/upcloud-cli#quick-start) config set path: +$HOME/.config/upctl.yaml + If creadentials are not found, this message will be displayed: ```txt @@ -73,7 +87,7 @@ or Auth info: Password must be specified ``` -As an option it is possible to encrypt sensitive informations like: +As a more secure option it is possible to encrypt sensitive informations like: - Credentials (username/password) - Data config file in yaml @@ -86,12 +100,13 @@ go run ./... --help ``` ```txt +Usage of upclapi: -c string command to run [ - createserver, infoserver, restartserver, startserver, stopserver, deleteserver, + createserver, infoserver, restartserver, startserver, stopserver, modifyserver, deleteserver, infofloatip, movefloatip, modifyip, - infotags, addtags, deletetags - deletestorage, modifystorage, + infotags, addtags, deletetags (use -t keep to keep storages) + liststorages, fixstorage (-t size | part0 | part1 | final), deletestorage, modifystorage, createstorageimage (-t title), inventory, pubhosts, prvhosts runssh, runcmd ] (default "infoserver") @@ -100,11 +115,13 @@ go run ./... --help -f string path to data file (default "datacfg.yaml") -id string - server uuid + resource name or uuid -kdr string use coder -o string - output format + output format (json|yaml) + -t string + target item for command ``` - Create Server @@ -167,6 +184,101 @@ make show_coverage ## YAML Config Example ```yaml +# Controller to manage and monitor +cntrllrs: + - cldPath: relative-path-for-controller + host: hostname + masterPath: '' + sshaccess: + host: hostname + keyPath: '' + password: '' + port: 22 + user: ssh-user + utype: key +domainName: domain-name +floatIP: '' +group: group-name +group_path: relative-group-path +hostPrefix: hostprefix- +mainName: main-name +# UpCloud as provider +provider: upcloud +resolvDNS: '' +servers: + # Apps to install + - apps: + - critical: no + liveness: '' + name: none + path: '' + req: '' + target: '' + arch: linux_amd64 + backup: + - '' + clients: + - '' + cluster: + role: role-tag + hostname: hostname + loginUser: + sshKeys: + - '' + metadata: 1 + networks: + - access: utility + family: IPv4 + source_ip_filtering: yes + - access: public + family: IPv4 + source_ip_filtering: yes + # If use SDN + - access: private + family: IPv4 + ipaddress: 'ip-for-sdn' + network: "sdn-uuid" + source_ip_filtering: no + # UpCloud server plan + plan: "1xCPU-1GB" + rules: + - '' + sshAccess: + host: hostname + keyPath: '' + password: '' + port: 22 + user: "ssh-user" + utype: key + storages: + - action: clone + size: 20 + # this can be used to create partitions + finalSize: 20 + makefs: "" + partSizes: '' + source: source-name + storage: UUID-for-source-image + tier: maxiops + title: Title-for-this-storage + tags: + - cd + - ci + timeZone: UTC + title: titls-of-this-host + # Tasks & Services to install,maintain,monitor, etc. + tsksrvcs: + - critical: no + liveness: '' + name: sysconfig + path: '' + req: '' + target: '' + useFloatIP: false + userData: '' + # UpCloud Zone + zone: es-mad1 + floatIP: float-ip-for-servers # "hostname" should start with hostPrefix or comment/remove this setting hostPrefix: prefix-for-severs @@ -193,7 +305,6 @@ servers: loginUser: sshKeys: # ssh-rsa public keys to add - ssh-rsa .... - plan: "1xCPU-1GB" # UpCloud Plan if is using an UpCloud "Simple Plan" metaData: 1 timeZone: "UTC" @@ -203,8 +314,8 @@ servers: # List of Storage Devices, at least one storageDevices: - action: clone # UpCloud Storage Action - title: "Ubuntu Server 20.04 LTS (Focal Fossa)" - storage: "01000000-0000-4000-8000-000030200200" # UpCloud Storage UUID + title: "storage-title" + storage: "UpCloud Storage UUID" size: 25 # Volume Size in GB tier: maxiops # If this sever can use floatIP set to 1 @@ -215,7 +326,7 @@ servers: family: IPv4 - access: public # only if is need it family: IPv4 - - access: private # if is going to use SDN + - access: private # if is going to use SDN or remove family: IPv4 network: UUID-SDN-NETWORK ipaddress: SDN-ip-address-or-use-SDN-DHCP