mirror of
https://github.com/rancher/rancher-docs.git
synced 2026-05-15 09:33:30 +00:00
Edit K3s installation options
This commit is contained in:
@@ -5,18 +5,16 @@ weight: 20
|
||||
|
||||
This page focuses on the options that can be used when you set up K3s for the first time:
|
||||
|
||||
- [Installation script options](#installation-script-options)
|
||||
- [Installing K3s from the binary](#installing-k3s-from-the-binary)
|
||||
- [Options for installation with script](#options-for-installation-with-script)
|
||||
- [Options for installation from binary](#options-for-installation-from-binary)
|
||||
- [Registration options for the K3s server](#registration-options-for-the-k3s-server)
|
||||
- [Registration options for the K3s agent](#registration-options-for-the-k3s-agent)
|
||||
- [How to Use Flags and Environment Variables](#how-to-use-flags-and-environment-variables)
|
||||
|
||||
For more advanced options, refer to [this page.]({{<baseurl>}}/k3s/latest/en/advanced)
|
||||
|
||||
> Throughout the K3s documentation, you will see some options that can be passed in as both command flags and environment variables. For help with passing in options, refer to [How to Use Flags and Environment Variables.](#how-to-use-flags-and-environment-variables)
|
||||
> Throughout the K3s documentation, you will see some options that can be passed in as both command flags and environment variables. For help with passing in options, refer to [How to Use Flags and Environment Variables.]({{<baseurl>}}/k3s/latest/en/installation/install-options/how-to-flags)
|
||||
|
||||
|
||||
# Installation Script Options
|
||||
### Options for Installation with Script
|
||||
|
||||
As mentioned in the [Quick-Start Guide]({{<baseurl>}}/k3s/latest/en/quick-start/), you can use the installation script available at https://get.k3s.io to install K3s as a service on systemd and openrc based systems.
|
||||
|
||||
@@ -36,7 +34,7 @@ When using this method to install K3s, the following environment variables can b
|
||||
| `INSTALL_K3S_BIN_DIR` | Directory to install K3s binary, links, and uninstall script to, or use `/usr/local/bin` as the default. |
|
||||
| `INSTALL_K3S_BIN_DIR_READ_ONLY` | If set to true will not write files to `INSTALL_K3S_BIN_DIR`, forces setting `INSTALL_K3S_SKIP_DOWNLOAD=true`. |
|
||||
| `INSTALL_K3S_SYSTEMD_DIR` | Directory to install systemd service and environment files to, or use `/etc/systemd/system` as the default. |
|
||||
| `INSTALL_K3S_EXEC` | Command with flags to use for launching K3s in the service. If the command is not specified, it will default to "agent" if `K3S_URL` is set, or "server" if it is not set. For help, refer to [this example.](#example-b-install-k3s-exec) |
|
||||
| `INSTALL_K3S_EXEC` | Command with flags to use for launching K3s in the service. If the command is not specified, and the `K3S_URL` is set, it will default to "agent." If `K3S_URL` not set, it will default to "server." For help, refer to [this example.]({{<baseurl>}}/k3s/latest/en/installation/install-options/how-to-flags/#example-b-install-k3s-exec) |
|
||||
| `INSTALL_K3S_NAME` | Name of systemd service to create, will default from the K3s exec command if not specified. If specified the name will be prefixed with 'k3s-'. |
|
||||
| `INSTALL_K3S_TYPE` | Type of systemd service to create, will default from the K3s exec command if not specified.
|
||||
|
||||
@@ -46,7 +44,7 @@ Setting `K3S_URL` without explicitly setting an exec command will default the co
|
||||
|
||||
When running the agent `K3S_TOKEN` must also be set.
|
||||
|
||||
# Installing K3s from the Binary
|
||||
### Options for Installation from Binary
|
||||
|
||||
As stated, the installation script is primarily concerned with configuring K3s to run as a service. If you choose to not use the script, you can run K3s simply by downloading the binary from our [release page](https://github.com/rancher/k3s/releases/latest), placing it on your path, and executing it. The K3s binary supports the following commands:
|
||||
|
||||
@@ -61,43 +59,11 @@ Command | Description
|
||||
|
||||
The `k3s server` and `k3s agent` commands have additional configuration options that can be viewed with <span class='nowrap'>`k3s server --help`</span> or <span class='nowrap'>`k3s agent --help`</span>. For convenience, that help text is presented here:
|
||||
|
||||
# Registration Options for the K3s Server
|
||||
### Registration Options for the K3s Server
|
||||
|
||||
For details on configuring the K3s server, refer to the [server configuration reference.]({{<baseurl>}}/k3s/latest/en/installation/install-options/server-config)
|
||||
|
||||
|
||||
# Registration Options for the K3s Agent
|
||||
### Registration Options for the K3s Agent
|
||||
|
||||
For details on configuring the K3s agent, refer to the [agent configuration reference.]({{<baseurl>}}/k3s/latest/en/installation/install-options/agent-config)
|
||||
|
||||
|
||||
# How to Use Flags and Environment Variables
|
||||
|
||||
Throughout the K3s documentation, you will see some options that can be passed in as both command flags and environment variables. The below examples show how these options can be passed in both ways.
|
||||
|
||||
### Example A: K3S_KUBECONFIG_MODE
|
||||
|
||||
The option to allow writing to the kubeconfig file is useful for allowing a K3s cluster to be imported into Rancher. Below are two ways to pass in the option.
|
||||
|
||||
Using the flag `--write-kubeconfig-mode 644`:
|
||||
```bash
|
||||
$ curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644
|
||||
```
|
||||
Using the environment variable `K3S_KUBECONFIG_MODE`:
|
||||
```bash
|
||||
$ curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" sh -s -
|
||||
```
|
||||
|
||||
### Example B: INSTALL_K3S_EXEC
|
||||
|
||||
If this command is not specified as a server or agent command, it will default to "agent" if `K3S_URL` is set, or "server" if it is not set.
|
||||
|
||||
The final systemd command resolves to a combination of this environment variable and script args. To illustrate this, the following commands result in the same behavior of registering a server without flannel:
|
||||
|
||||
```bash
|
||||
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--no-flannel" sh -s -
|
||||
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server --no-flannel" sh -s -
|
||||
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server" sh -s - --no-flannel
|
||||
curl -sfL https://get.k3s.io | sh -s - server --no-flannel
|
||||
curl -sfL https://get.k3s.io | sh -s - --no-flannel
|
||||
```
|
||||
For details on configuring the K3s agent, refer to the [agent configuration reference.]({{<baseurl>}}/k3s/latest/en/installation/install-options/agent-config)
|
||||
@@ -4,7 +4,7 @@ weight: 2
|
||||
---
|
||||
In this section, you'll learn how to configure the K3s agent.
|
||||
|
||||
> Throughout the K3s documentation, you will see some options that can be passed in as both command flags and environment variables. For help with passing in options, refer to [How to Use Flags and Environment Variables.]({{<baseurl>}}/k3s/latest/en/installation/install-options/#how-to-use-flags-and-environment-variables)
|
||||
> Throughout the K3s documentation, you will see some options that can be passed in as both command flags and environment variables. For help with passing in options, refer to [How to Use Flags and Environment Variables.]({{<baseurl>}}/k3s/latest/en/installation/install-options/how-to-flags)
|
||||
|
||||
- [Logging](#logging)
|
||||
- [Cluster Options](#cluster-options)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: How to Use Flags and Environment Variables
|
||||
weight: 3
|
||||
---
|
||||
|
||||
Throughout the K3s documentation, you will see some options that can be passed in as both command flags and environment variables. The below examples show how these options can be passed in both ways.
|
||||
|
||||
### Example A: K3S_KUBECONFIG_MODE
|
||||
|
||||
The option to allow writing to the kubeconfig file is useful for allowing a K3s cluster to be imported into Rancher. Below are two ways to pass in the option.
|
||||
|
||||
Using the flag `--write-kubeconfig-mode 644`:
|
||||
```bash
|
||||
$ curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644
|
||||
```
|
||||
Using the environment variable `K3S_KUBECONFIG_MODE`:
|
||||
```bash
|
||||
$ curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" sh -s -
|
||||
```
|
||||
|
||||
### Example B: INSTALL_K3S_EXEC
|
||||
|
||||
If this command is not specified as a server or agent command, it will default to "agent" if `K3S_URL` is set, or "server" if it is not set.
|
||||
|
||||
The final systemd command resolves to a combination of this environment variable and script args. To illustrate this, the following commands result in the same behavior of registering a server without flannel:
|
||||
|
||||
```bash
|
||||
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--no-flannel" sh -s -
|
||||
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server --no-flannel" sh -s -
|
||||
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server" sh -s - --no-flannel
|
||||
curl -sfL https://get.k3s.io | sh -s - server --no-flannel
|
||||
curl -sfL https://get.k3s.io | sh -s - --no-flannel
|
||||
```
|
||||
@@ -5,7 +5,7 @@ weight: 1
|
||||
|
||||
In this section, you'll learn how to configure the K3s server.
|
||||
|
||||
> Throughout the K3s documentation, you will see some options that can be passed in as both command flags and environment variables. For help with passing in options, refer to [How to Use Flags and Environment Variables.]({{<baseurl>}}/k3s/latest/en/installation/install-options/#how-to-use-flags-and-environment-variables)
|
||||
> Throughout the K3s documentation, you will see some options that can be passed in as both command flags and environment variables. For help with passing in options, refer to [How to Use Flags and Environment Variables.]({{<baseurl>}}/k3s/latest/en/installation/install-options/how-to-flags)
|
||||
|
||||
- [Commonly Used Options](#commonly-used-options)
|
||||
- [Database](#database)
|
||||
|
||||
Reference in New Issue
Block a user