Skip to content

Commit 20b57f9

Browse files
authored
[*] update Makefile for v2.x, resolves #121 (#122)
[*] update `Makefile` for v2.x, resolves #121
1 parent af86f88 commit 20b57f9

File tree

2 files changed

+35
-96
lines changed

2 files changed

+35
-96
lines changed

Makefile

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,15 @@ vip-manager: *.go */*.go
88
install:
99
install -d $(DESTDIR)/usr/bin
1010
install vip-manager $(DESTDIR)/usr/bin/vip-manager
11-
install -d $(DESTDIR)/lib/systemd/system
12-
install package/scripts/init-systemd.service $(DESTDIR)/lib/systemd/system/vip-manager.service
13-
install -d $(DESTDIR)/etc/init.d/
14-
install package/scripts/init-systemv.sh $(DESTDIR)/etc/init.d/vip-manager
1511
install -d $(DESTDIR)/etc/default
1612
install vipconfig/vip-manager.yml $(DESTDIR)/etc/default/vip-manager.yml
1713

1814
DESTDIR=tmp
1915

20-
.PHONY: package package/changelog.yml
21-
22-
package: package-deb package-rpm
23-
24-
package-deb: vip-manager package/changelog.yml
25-
nfpm package --config package/nfpm.yml --packager deb
26-
27-
package-rpm: vip-manager package/changelog.yml
28-
nfpm package --config package/nfpm.yml --packager rpm
29-
30-
package/changelog.yml:
31-
chglog init --config-file package/chglog.yml --deb-distribution unstable --deb-urgency low --output $@
16+
package:
17+
goreleaser release --snapshot --skip-publish --rm-dist
3218

3319
clean:
34-
rm -f vip-manager
35-
rm -f vip-manager*.deb
36-
rm -f vip-manager*.rpm
37-
rm -fr $(DESTDIR)
38-
rm -f package/changelog.yml
20+
$(RM) vip-manager
21+
$(RM) -r dist
22+
$(RM) -r $(DESTDIR)

README.md

Lines changed: 30 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -13,65 +13,61 @@ Manages a virtual IP based on state kept in etcd or Consul. Monitors state in et
1313
## Table of Contents
1414
- [Prerequisites](#prerequisites)
1515
- [Building](#building)
16-
- [Installing from package](#Installing-from-package)
17-
- [Installing from source](#installing-by-hand)
16+
- [Installing from package](#installing-from-package)
17+
- [Installing from source](#installing-from-source)
1818
- [Environment prerequisites](#environment-prerequisites)
19-
- [PostgreSQL prerequisites](#PostgreSQL-prerequisites)
20-
- [Configuration](#Configuration)
21-
- [Migrating configuration from releases before v1.0](#migrating-configuration-from-releases-before-v10)
22-
- [Migration for Service Files using Environment Variables](#Migration-for-Service-Files-using-Environment-Variables)
23-
- [Migration for Service Files using YAML config files](#Migration-for-Service-Files-using-YAML-config-files)
24-
- [Configuration - Hetzner](#Configuration---Hetzner)
25-
- [Credential File - Hetzmer](#Credential-File---Hetzner)
26-
- [Debugging](#Debugging)
27-
- [Author](#Author)
19+
- [PostgreSQL prerequisites](#postgresql-prerequisites)
20+
- [Configuration](#configuration)
21+
- [Configuration - Hetzner](#configuration---hetzner)
22+
- [Credential File - Hetzmer](#credential-file---hetzner)
23+
- [Debugging](#debugging)
24+
- [Author](#author)
2825

2926
## Prerequisites
3027

3128
- `go` >= 1.19
32-
- `make`
33-
- [`nfpm`](https://github.com/goreleaser/nfpm) for building .rpm and .deb packages
34-
- [`chglog`](https://github.com/goreleaser/chglog) for changelog and packaging
29+
- `make` (optional)
30+
- `goreleaser` (optional)
3531

3632
## Building
3733
1. clone this repo
3834
```
3935
git clone https://github.com/cybertec-postgresql/vip-manager.git
4036
```
41-
2. get the (optional) requirements
37+
2. Build the binary using `make` or `go build`.
38+
5. To build your own packages (.deb, .rpm, .zip, etc.), run
4239
```
43-
# packaging:
44-
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest
45-
# changelog, also packaging:
46-
go get github.com/goreleaser/chglog/cmd/chglog
40+
make package
4741
```
48-
3. (optionally) set PATH to find those dependencies
42+
or
4943
```
50-
PATH="$HOME/go/bin:$PATH"
44+
goreleaser release --snapshot --skip-publish --rm-dist
5145
```
52-
4. Build the binary using `make`.
53-
5. To build your own .deb or .rpm, run `make package`, which will generate a .deb and .rpm package.
5446

5547
## Installing from package
5648
You can download .rpm or .deb packages here, on the [Releases](https://github.com/cybertec-postgresql/vip-manager/releases) page.
5749
On Debian and Ubuntu, the universe repositories should provide you with vip-manager, though the version may be not as recent.
58-
> NB! Our .deb is probably not compatible with the one from those repositories, do not try to install them side-by-side.
50+
> **Warning**<br>
51+
> Our packages are probably not compatible with the one from those repositories, do not try to install them side-by-side.
5952
6053
## Installing from source
6154

6255
- Follow the steps to [build](#building) vip-manager.
6356
- Run `DESTDIR=/tmp make install` to copy the binary, service files and config file into the destination of your choice.
6457
- Edit config to your needs, then run `systemctl daemon-reload`, then `systemctl start vip-manager`.
58+
59+
> **Note**<br>
6560
> systemd will only pick the service files up if you chose a `DESTDIR` so that it can find it. Usually `DESTDIR=''` should work.
6661
6762
## Environment prerequisites
6863

6964
When vip-manager is in charge of registering and deregistering the VIP locally, it needs superuser privileges to do so.
7065
This is not required when vip-manager is used to manage a VIP through some API, e.g. Hetzner Robot API or Hetzner Cloud API.
7166

67+
> **Note**<br>
7268
> At some point it would be great to reduce this requirement to only the `CAP_NET_RAW` and `CAP_NET_ADMIN` capabilities, which could be added by a superuser to the vip-manager binary _once_.
7369
> Right now, this is not possible since vip-manager launches plain shell commands to register and deregister virtual IP addresses locally (at least on linux), so the whole user would need these privileges.
74-
> When vip-manager is eventually taught to directly use a library that directly uses the linux kernel's API to register/deregister the VIP, the capabilities set for the binary will suffice.
70+
> When vip-manager is eventually taught to directly use a library that directly uses the Linux kernel's API to register/deregister the VIP, the capabilities set for the binary will suffice.
7571
7672
## PostgreSQL prerequisites
7773

@@ -98,8 +94,9 @@ sysctl -p
9894

9995
The configuration can be passed to the executable through argument flags, environment variables or through a YAML config file. Run `vip-manager --help` to see the available flags.
10096

97+
> **Note**<br>
10198
> The location of the YAML config file can be specified with the --config flag.
102-
> An exemplary config file is installed into `/etc/default/vip-manager_default.yml` or is available in the vipconfig directory in the repository of the software.
99+
> An exemplary config file is installed into `/etc/default/vip-manager.yml` or is available in the vipconfig directory in the repository of the software.
103100
104101
Configuration is now (from release v1.0 on) handled using the [`viper`](https://github.com/spf13/viper) library.
105102
This means that environment variables, command line flags, and config files can be used to configure vip-manager.
@@ -108,15 +105,12 @@ When using different configuration sources simultaneously, this is the precedenc
108105
- env
109106
- config
110107

108+
> **Note**<br>
111109
> So flags always overwrite env variables and entries from the config file. Env variables overwrite the config file entries.
112110
113-
All flags and file entries are written in lower case. To make longer multi-word flags and entries readable, they are separated by dashes.
114-
115-
> e.g. `retry-num`
116-
117-
If you put a flag or file entry into uppercase and replace dashes with underscores, you end up with the format of environment variables. To avoid overlapping configuration with other applications, the env variables are additionall prefixed with `VIP_`.
111+
All flags and file entries are written in lower case. To make longer multi-word flags and entries readable, they are separated by dashes, e.g. `retry-num`.
118112

119-
> e.g. `VIP_RETRY_NUM`
113+
If you put a flag or file entry into uppercase and replace dashes with underscores, you end up with the format of environment variables. To avoid overlapping configuration with other applications, the env variables are additionall prefixed with `VIP_`, e.g. `VIP_RETRY_NUM`.
120114

121115
This is a list of all avaiable configuration items:
122116

@@ -142,51 +136,11 @@ This is a list of all avaiable configuration items:
142136
`verbose` | `VIP_VERBOSE` | no | true | Enable more verbose logging. Currently only the manager-type=hetzner provides additional logs.
143137

144138

145-
### Migrating configuration from releases before v1.0
146-
As stated above, the configuration method has been changed from v1.0 onwards.
147-
The breaking changes with regards to config handling are thus:
148-
- Config flags are no longer prefixed with a single dash `-`, but in POSIX style with double dashes `--`.
149-
- Some config keys have received new names, but the value handling has not changed.
150-
151-
However, some consideration has been made to ease migration:
152-
- The old key names in VIP_* environment variables and in YAML config files are mapped to the new keys, a deprecation warning will be emitted for each old key that is used.
153-
- If both old and new key names are used and have different values, vip-manager will exit; If both values are identical, the duplication will be ignored.
154-
155-
This means that migration should be pretty straight forward.
156-
157-
#### Migration for Service Files using Environment Variables
158-
> These Service Files have been published in releases <v0.4 and on Debian/Ubuntu in release v0.6 as well.
159-
In the "ENV style" Service Files, configuration was loaded in through an environment file and the values of the environment variables where shimmed in place of the flag values:
160-
```bash
161-
ExecStart=/usr/bin/vip-manager -ip="${VIP_IP}" -mask="${VIP_MASK}" -iface="${VIP_IFACE}" -key="${VIP_KEY}" -host="${VIP_HOST}" -type="${VIP_TYPE}" -endpoint="${VIP_ENDPOINT}"
162-
```
163-
164-
As a result, these Service Files should be replaced by ones that specify no flags at all:
165-
```bash
166-
ExecStart=/usr/bin/vip-manager
167-
```
168-
169-
Since the environment variables are still there, the vip-manager (>=v1.0) will pick them up itself. It will pick up the old keys and use only emit log messages indicating the deprecation of those keys.
170-
> You could even consider another shim, that will take the environment variables using old keys, get their values and assign them to environment variables using the new keys. Then unset the old keys and you will no longer see deprecation messages.
171-
172-
#### Migration for Service Files using YAML config files:
173-
> These Service FIles have been published in release v0.6
174-
In these "config file style" Service Files, the yaml configuration file was passed as a flag to the vip-manager.
175-
```bash
176-
ExecStart=/usr/bin/vip-manager -config=/etc/default/vip-manager.yml
177-
```
178-
179-
Because the old keys in the YAML config files will be remapped to new keys, all that needs to be done is to add a single dash (`sed -i 's/-config/--config/'`):
180-
```bash
181-
ExecStart=/usr/bin/vip-manager --config=/etc/default/vip-manager.yml
182-
```
183-
184139
## Configuration - Hetzner
185-
To use vip-manager with Hetzner Robot API you need a Credential file, set hosting_type to `hetzner` and your Floating-IP must be added on all Servers.
140+
To use vip-manager with Hetzner Robot API you need a Credential file, set `hosting_type` to `hetzner` in `/etc/default/vip-manager.yml`
141+
and your Floating-IP must be added on all Servers.
186142
The Floating-IP (VIP) will not be added or removed on the current Master node interface, Hetzner will route it to the current one.
187143

188-
Set `hosting_type` to `hetzner` in `/etc/default/vip-manager.yml`
189-
190144
### Credential File - Hetzner
191145
Add the File `/etc/hetzner` with your Username and Password
192146
```
@@ -202,7 +156,8 @@ Either:
202156
* set `verbose` to `true` in `/etc/default/vip-manager.yml`
203157
* set `VIP_VERBOSE=true`
204158

205-
(currently only supported for `hetzner`)
159+
> **Note**<br>
160+
> Currently only supported for `hetzner`
206161
207162
## Author
208163

0 commit comments

Comments
 (0)