Commit Graph

148 Commits (cf9ebb3259b7c2c5264340d46c76f2ad2b0f8a39)

Author SHA1 Message Date
Kevin Messer 6c9f3d528a
feat(install): replace rpm by yum for setup_selinux (#1829)
It's a bad practice to install packages via rpm directly. It's better to install all packages with Yum/Dnf. It's also possible to install packages directly via an URL, which is the purpose of this PR.
2020-09-26 01:45:33 -07:00
Adam Farden 86d2e2a5f8
[systemd] really wait for network to come online (#1665)
Wants= is required to actually set the dependency on network-online.service
After= is required or k3s.service will be started at the same time as network-online.service

In network environments with slow DHCP, both are required to ensure valid network configuration for k3s

Signed-off-by: Adam Farden <adam@farden.cz>
2020-09-26 01:44:06 -07:00
Matthew Clive fc55904d82
Add network dependency to installed service file (#2210)
Adds the line `After=network-online.target` to the k3s systemd service
file. This applies the fix mentioned in
[this GH comment](https://github.com/rancher/k3s/issues/1626#issuecomment-642253812)
which I can confirm makes k3s networking survive reboot in Raspbian
Buster.

[It appears, in some docs I found](https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files)
that this is a recommended and usual way of specifying that we need the
target to be _completed_ before starting k3s. Using just the `Wants=`
directive doesn't work for this task, you have to add both directives
at once to do this. Quote:

> `Wants=`: This directive is similar to `Requires=`, but less strict.
> `Systemd` will attempt to start any units listed here when this unit
> is activated. If these units are not found or fail to start, the
> current unit will continue to function. This is the recommended way to
> configure most dependency relationships. **Again, this implies a
> parallel activation unless modified by other directives**

> [...]

> `After=`: The units listed in this directive will be started before
> starting the current unit. This does not imply a dependency
> relationship and **one must be established through the above
> directives if this is required.**

- _(Emphasis mine)_

Signed-off-by: Matthew Clive <arcticlight@arcticlight.me>
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2020-09-26 01:42:17 -07:00
Brad Davidson 5ad76043ac Replace unmount read loop with awk
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2020-09-11 10:33:37 -07:00
Brad Davidson 9ac113de4c
Merge pull request #2185 from rockholla/bugfix/2120
2120: fix issue with umount arg list too long on uninstall
2020-09-01 17:56:06 -07:00
Patrick Force 8b47ccc4d1 2120: fix issue with umount arg list too long on uninstall
Signed-off-by: Patrick Force <patrickforce@gmail.com>
2020-09-01 16:56:42 -06:00
Brad Davidson fd933c936f
Merge pull request #1847 from ericleu/patch_install.sh
update install.sh to respect K3S_TOKEN_FILE
2020-09-01 11:14:16 -07:00
Brad Davidson 0291bd770e Fix removal of /run directories
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2020-08-07 11:13:04 -07:00
Brad Davidson 9137c45cdb
Merge pull request #1614 from sen-subhabrata/master
install.sh: cleanup /run on uninstall
2020-08-05 11:26:21 -07:00
Josh McSavaney 265bd9848b Always validate K3S_URL.
Also move K3S_URL validation to its own function.

Signed-off-by: Josh McSavaney <mcsaucy@csh.rit.edu>
2020-07-23 17:21:55 -04:00
Josh McSavaney 9a5b7e2fc4 Pattern match for https check instead of grep
Signed-off-by: Josh McSavaney <mcsaucy@csh.rit.edu>
2020-06-30 12:45:35 -04:00
Josh McSavaney 12235fe733 Perform basic validation on K3S_URL in install.sh
This allows us to fail quickly if we're handed a schemeless or plain
HTTP URI, rather than having the agent barf when the systemd unit
starts. For an operator, this makes for a cleaner error up front and
clear messaging for how to fix the situation.

Signed-off-by: Josh McSavaney <mcsaucy@csh.rit.edu>
2020-06-25 20:23:28 -04:00
Serge van Ginderachter 921e11930e
Always keep restarting k3s process by openrc
When for some reason, k3s crashes, and can't startup again, e.g. when
the data backend is not available (dqlite crashed, database server is
offline, ...), on openrc systems, supervise-daemon will try to restart
it, as per supervise-daemon(8):

    respawn-max:

    Sets the maximum number of times a daemon will be respawned during
    a respawn period. If a daemon dies more than this number of times
    during a respawn period, will give up trying to respawn it and exit.
    The default is 10, and 0 means unlimited.

Setting respawn-max to 0, makes sure a k3s process on openrc systems will
keep trying to come online, even if the database backend is offline for a
longer period of time.

This aligns the openrc service configuration with the systemd
configuration, which has

    Restart=always
    RestartSec=5s
2020-06-19 10:47:59 +02:00
Eric Leu b966ad18da update install.sh to respect K3S_TOKEN_FILE 2020-05-31 14:48:10 -07:00
Craig Jellick ad4c542ad5
Merge pull request #1735 from stellirin/performance
[systemd] Add value to LimitNOFILE due to performance problems
2020-05-06 16:37:37 -07:00
omichaelis e629fd381d
Replace deprecated option
The option --no-deploy was deprecated by
0374c4f63d
and is now replaced in the install.sh documentation by --disable

Signed-off-by: omichaelis <38879457+oliviermichaelis@users.noreply.github.com>
2020-05-03 18:26:59 +02:00
Adam Farden b4335630b7 [systemd] Add value to LimitNOFILE due to performance problems
When k3s is installed on an OS with default high ulimits, performance
issues can be observed. This was discovered on CoreOS where the default
value is 1073741816. Symptoms include very slow file operations such
as installing a Rook/Ceph cluster will take ~6 hours instead of ~10 minutes.

A google search for 'container LimitNOFILE' will show that most major
projects set this already, including the (unused) containerd systemd unit
found in this repository at /vendor/github.com/containerd/containerd/containerd.service

k3OS is not affected becuasse the default there is already 1048576.

See description in coreos/fedora-coreos-tracker#329
2020-05-03 09:37:00 +02:00
Darren Shepherd 0efe2af1a7
Merge pull request #1637 from MaciejKucia/mattkucia/fix-install
install: Properly detect enabled selinux
2020-04-27 09:25:15 -07:00
Maciej Kucia cae65ae648 install: Properly detect enabled selinux 2020-04-13 12:13:50 +08:00
Erik Wilson dddbd16305 Use channel server for install script 2020-04-08 14:32:52 -07:00
sen-subhabrata 4006bb57d0
Fix for issue 1326, updated install.sh
Fix for issue 1326, added lines to delete /run/k3s and /run/flannel in create_uninstall() function.
2020-04-04 14:42:12 +05:30
Erik Wilson ce10c1f080 Check for k3s policy and provide install hints 2020-03-30 08:56:15 -07:00
Viet Hung Nguyen f741e8f9c5 Fix error when get version using Wget
GitHub now returns lowercase:

wget -SqO /dev/null https://github.com/rancher/k3s/releases/latest |& grep -i location

  location: https://github.com/rancher/k3s/releases/tag/v1.17.3+k3s1
2020-03-22 17:29:51 +07:00
Erik Wilson 5753dbd6ae
Merge branch 'master' into selinux-install 2020-03-13 09:51:36 -07:00
Erik Wilson 3410986357 Update install script for rpm install 2020-03-10 11:25:43 -07:00
Darren Shepherd 429e9d4966 Don't require selinux utils and require k3s_selinux
If you are installing k3s on a selinux enforcing system then we
required that you also install k3s_selinux RPM to put in the proper
policy.
2020-02-24 16:08:02 -07:00
William Johansson 37ebb93a77 Start cgroups service in OpenRC script
cgroups init script is present in Alpine Linux since 3.8.

Fixes #660
2020-01-26 19:28:36 +01:00
Erik Wilson 95689687c3 Add INSTALL_K3S_COMMIT option to installer 2019-12-24 09:58:43 -07:00
Johan Kok 51f8a1a0b9
Verify selinux status before downloading 2019-11-23 13:03:40 +01:00
Erik Wilson e810ee1678
Merge pull request #967 from erikwilson/killall-cleanup
Cleanup k3s-killall
2019-10-26 16:54:09 -07:00
Erik Wilson fecdee6fb5 Fix installs for older systemd 2019-10-26 16:18:45 -07:00
Erik Wilson ef9c1f23f0 Cleanup k3s-killall 2019-10-26 16:13:59 -07:00
Erik Wilson 33f6a4e683
Merge pull request #965 from erikwilson/systemd-service-cleanup
Cleanup systemd service file
2019-10-26 13:53:17 -07:00
Erik Wilson 36dc38f361 Cleanup systemd service file
Move command with line continuations to bottom of service file to
prevent including systemd directives.

Changes After network-online to Wants network-online for air-gap.
2019-10-26 13:11:50 -07:00
Erik Wilson e3cd52a49e Remove iptables on k3s-killall.sh 2019-10-25 03:14:11 -07:00
Erik Wilson ad4ea681ce Hide the --disable-agent flag 2019-10-24 21:51:58 -07:00
Christian Tramnitz 7b37988fb1
make match case-insensitive 2019-10-23 02:00:10 +02:00
Christian Tramnitz 06f477410b
inherit proxy settings on install
Write proxy settings into FILE_K3S_ENV on install. This should address #627
2019-10-23 01:56:19 +02:00
Erik Wilson 0e0fbea23c Uninstall/killall should clean up /var/lib/kubelet also 2019-10-17 19:11:27 -07:00
Erik Wilson bb3aca1817 Cleanup killall and uninstall 2019-10-17 15:41:39 -07:00
Joakim Roubert d982c33bfc
Merge branch 'master' into joakimr-axis_quotes 2019-10-08 07:47:07 +02:00
Joakim Roubert f0bce02a62
Update install.sh
Signed-off-by: Joakim Roubert <joakimr@axis.com>
2019-10-04 07:41:05 +02:00
Joakim Roubert 2548f3ebaa
Update install.sh
Signed-off-by: Joakim Roubert <joakimr@axis.com>
2019-10-01 08:49:01 +02:00
Joakim Roubert ce388e3788
Update install.sh
Signed-off-by: Joakim Roubert <joakimr@axis.com>
2019-09-28 14:29:49 +02:00
Joakim Roubert 2b5eff7237
Merge branch 'master' into joakimr-axis_noawk 2019-09-19 09:55:31 +02:00
Erik Wilson 76d685ae5d
Merge pull request #815 from dweomer/install/openrc
install.sh: fix openrc service depend in heredoc
2019-09-18 15:59:34 -07:00
Erik Wilson ad7b2e0a5d
Merge pull request #756 from joakimr-axis/joakimr-axis_wget
install.sh: Add wget fallback if curl isn't available
2019-09-18 15:55:42 -07:00
Jacob Blain Christen 4d5cca6b50 install.sh: fix openrc service depend in heredoc
This change sets up the correct dependency on the `network-online`
service provided by openrc.

See:
- https://github.com/OpenRC/openrc/blob/0.39.2/service-script-guide.md#be-wary-of-need-net-dependencies
- https://github.com/OpenRC/openrc/blob/0.39.2/init.d/net-online.in#L18
2019-09-18 11:22:59 -07:00
Joakim Roubert a0d2743868
Update install.sh 2019-09-03 08:15:39 +02:00
Joakim Roubert 0a67557c4a Update install.sh after review comments
Change-Id: I8acf9f0fc0115dd8a45027b1d7610b47aa7462d9
2019-09-03 08:12:22 +02:00
Joakim Roubert 98410df788
Update install.sh according to yamt's suggestion 2019-09-03 07:51:33 +02:00
Joakim Roubert e822bcafa1
Update install.sh 2019-09-03 06:36:36 +02:00
Raimund Hook 2fe5d2768b Changed SELinux error to fatal
If the install errors out on semanage not found, a file not found is
thrown as a 'file not found' for error. Updating to 'fatal' resolves
this as the script then exits as intended and throws an 'error'.
2019-08-28 15:35:56 +01:00
Erik Wilson 94167cdb4e
Merge branch 'master' into joakimr-axis_quotes 2019-08-26 09:43:34 -07:00
Joakim Roubert 6d07cb47b7
Merge branch 'master' into joakimr-axis_noawk 2019-08-26 18:43:30 +02:00
Erik Wilson cc76ca6931
Merge branch 'master' into joakimr-axis_comparison 2019-08-26 09:38:23 -07:00
Joakim Roubert b86d08a318
Merge branch 'master' into joakimr-axis_wget 2019-08-26 18:38:05 +02:00
Erik Wilson 59f0f004d0
Merge branch 'master' into master 2019-08-26 09:35:14 -07:00
Darren Shepherd 1c93798037 Check for semanage command availability 2019-08-24 23:32:11 -07:00
Joakim Roubert 76342565a2
Update install.sh 2019-08-24 08:11:08 +02:00
Joakim Roubert 7a96fbb3f8 install.sh: Cleanup of quotes
Where no variable expansion is done, " is replaced with '.
Copying content of one variable to another variable never needs quotes.
Some calls to echo and fatal need no quotes at all, but have been left
with ' to make it easier to see where the string begins and ends.
The fatal function now also sends output to stderr.

Change-Id: I2504707e5c550bc498e7663cedf58c224cd0a15b
Signed-off-by: Joakim Roubert <joakimr@axis.com>
2019-08-23 15:14:46 +02:00
Joakim Roubert db441f28b8 install.sh: Add wget fallback if curl isn't available
Reportedly, some systems don't have curl but wget. With this patch,
install.sh will use wget instead of curl if the latter is not available
on the target system.

Change-Id: I0bc78feec6d8e1dbf7fbef7c2e10833b79bdbbdc
Signed-off-by: Joakim Roubert <joakimr@axis.com>
2019-08-23 14:41:11 +02:00
Joakim Roubert 7a01e0fae3 install.sh: Use -eq instead of = for integer comparison
For integer comparison, it is recommended to use '-eq' instead of the
broader comparison '='. From the manual:

n1 -eq n2  True if the integers n1 and n2 are algebraically equal.
s1 = s2    True if the strings s1 and s2 are identical.

Change-Id: I3a92c3944a19e7a618438a9e3e304d9de5d9874f
Signed-off-by: Joakim Roubert <joakimr@axis.com>
2019-08-23 10:32:18 +02:00
Joakim Roubert 9982da1953 install.sh: Use contemporary command substitution syntax
The install.sh script currently uses a mix of the legacy backquote
syntax and the recommended contemporary $() syntax. This patch brings
consistency by replacing the occurrences of the legacy backquote ones
with the $() syntax.

Change-Id: I018f3250175064dcb22ef86a0240b2c804153641
Signed-off-by: Joakim Roubert <joakimr@axis.com>
2019-08-23 10:26:43 +02:00
Joakim Roubert 1d220e33a5 install.sh: Use built-in shell functionality instead of awk
If install.sh relies on awk, install.sh malfunctions when run on a
device with a limited environment where awk is not available. This patch
replaces the use of awk with built-in shell script functionality.

Change-Id: I071d9f565ff7ef38445a6dd0ea9692b903721601
Signed-off-by: Joakim Roubert <joakimr@axis.com>
2019-08-23 09:58:38 +02:00
Erik Wilson d8c4f3811e Fix logging for openrc 2019-08-07 23:07:16 -07:00
Erik Wilson 23501c08cb
Merge pull request #662 from cryptk/systemd-delay
Add a little extra delay between restart attempts
2019-07-27 07:57:45 -07:00
cryptk f9dd8dedc8 Add a little extra delay between restart attempts
This extra delay prevents systemd from determining that the service is restarting "too quickly".
2019-07-25 13:02:19 -05:00
Erik Wilson c443101bfc Install symlink skip or force, links ctr 2019-07-23 09:50:50 -07:00
Ray Tsang 32f1d66932 Added K3S_INSTALL_SKIP_SYMLINK flag 2019-07-19 11:27:57 -07:00
peter_he d140911b55 Fix install.sh comment typo (#638) 2019-07-15 08:37:31 -07:00
Erik Wilson deb4178459 Quote installer arguments 2019-06-18 09:45:05 -07:00
galal-hussein 8188bc62aa Add Restart=always to systemd unit 2019-05-08 02:54:40 +02:00
Erik Wilson 7ca50efb8b Add k3s-killall.sh script to installer 2019-05-01 14:27:39 -07:00
Darren Shepherd 0726ce75e9
Merge pull request #416 from galal-hussein/change_systemd_target
Change systemd unit file target to network-online.target
2019-04-30 11:24:17 -07:00
galal-hussein c30c809642 Change systemd unit file target to network-online.target 2019-04-30 01:28:58 +02:00
Darren Shepherd 8867c509ce Add ability to set architecture
The ARCH env var can be set by the install.sh caller.  This is
specifically important if you want to install arm on arm64.
2019-04-29 09:14:43 -07:00
Erik Wilson 3af2618393 Fix systemd install not starting 2019-04-26 22:13:38 -07:00
Erik Wilson fa673468ce Add INSTALL_K3S_BIN_DIR_READ_ONLY variable 2019-04-25 14:18:16 -07:00
Erik Wilson 3543ba4b56 Only start service if something changed 2019-04-25 10:06:22 -07:00
Erik Wilson 6a80350dda OpenRC install to BIN_DIR 2019-04-24 11:45:05 -07:00
Erik Wilson 100e2f6c2f Provide INSTALL_K3S_SKIP_START environment variable 2019-04-23 13:24:02 -07:00
Erik Wilson eabc1154b1 Add OpenRC support to installer 2019-04-22 19:57:21 -07:00
Erik Wilson 1bc7042bd5 Fix systemd TimeoutStartSec
Set TimeoutStartSec to 0 instead of infinity for systemd versions older
than 229.
2019-04-17 11:27:03 -07:00
Matt Keas f7e0017fed Extend systemd start timeout for slow systems
Cert generation may cause slow startup times for some systems such as
the Raspberry Pi, set the systemd service TimeoutStartSec to Infinity to
avoid startup timeouts.
2019-04-12 22:28:17 +00:00
Erik Wilson 43852f040b Fix shasum check
Airgap image checksums may accidentaly be used by the installer, be
more specific to grep only for the downloaded executable.
2019-03-29 03:55:55 +00:00
Brandon Wulf 397ae335fd Set the selinux context during the install (#228)
* Set the selinux context
2019-03-22 13:51:59 -07:00
Erik Wilson e05964d1dd Allow agent install
Modify the install script to allow defining arbitrary service names and
commands for k3s.
2019-03-07 12:45:08 -07:00
Darren Shepherd 0414f97c78 Revert "Enable systemd ready notification for k3s server"
This reverts commit c73e9187bb.
2019-03-04 13:18:20 -07:00
Erik Wilson a7640cfb90 Download latest release for install script
Check for latest release of k3s or pass a desired version as an
argument. Adds curl as a requirement and early exits if not available.
Fixes silent abort when wget is not available and `which` returns
non-zero exit code.
2019-03-01 11:16:24 -07:00
Erik Wilson c73e9187bb Enable systemd ready notification for k3s server
Disables k8s generic api server systemd ready notification and send
our own ready notification after server available and kubeconfig
available.
2019-03-01 10:47:34 -07:00
Darren Shepherd 7d1baa919b Remove wget 2019-02-26 09:19:00 -07:00
Darren Shepherd f14a1ae2de Bump to v0.1.0 2019-02-26 09:16:07 -07:00
Darren Shepherd 37caa68cce Bump to rc8 2019-02-24 12:16:20 -07:00
Darren Shepherd 6602756aea Bump scripts to rc6 2019-02-24 12:00:56 -07:00
Darren Shepherd b07727ae24 Move default config location to /etc/rancher/k3s/k3s.yaml 2019-02-19 09:53:41 -08:00
Darren Shepherd 4e2d6c9b1c Fix suffix for arm 2019-02-14 11:27:26 -07:00
Darren Shepherd 263722ccf2 Add install script for get.k3s.io 2019-02-08 16:59:58 -07:00