Skip to content

Commit

Permalink
Add --ipsec option to the installer
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Melgarejo Bresanovich <cmelgarejo.dev@gmail.com>
  • Loading branch information
cmelgarejo authored and alexellis committed Dec 6, 2019
1 parent 2b2a5c9 commit b83ecfb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ Other options for `install`:
* `--merge` - Merge config into existing file instead of overwriting (e.g. to add config to the default kubectl config, use `--local-path ~/.kube/config --merge`).
* `--context` - default is `default` - set the name of the kubeconfig context.
* `--ssh-port` - default is `22`, but you can specify an alternative port i.e. `2222`
* `--k3s-extra-args` - Optional extra arguments to pass to k3s installer, wrapped in quotes, i.e. `--k3s-extra-args '--no-deploy traefik'` or `--k3s-extra-args '--docker'`. For multiple args combine then within single quotes `--k3s-extra-args '--no-deploy traefik --docker'`.
* `--k3s-extra-args` - Optional extra arguments to pass to k3s installer, wrapped in quotes, i.e. `--k3s-extra-args '--no-deploy traefik'` or `--k3s-extra-args '--docker'`. For multiple args combine then within single quotes `--k3s-extra-args '--no-deploy traefik --docker'`.
* `--k3s-version` - set the specific version of k3s, i.e. `v0.9.1`
- `--ipsec` - Enforces the optional extra argument for k3s: `--flannel-backend` option: `ipsec`
* See even more install options by running `k3sup install --help`.

* Now try the access:
Expand Down
6 changes: 6 additions & 0 deletions pkg/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func MakeInstall() *cobra.Command {
command.Flags().String("local-path", "kubeconfig", "Local path to save the kubeconfig file")
command.Flags().String("context", "default", "Set the name of the kubeconfig context.")
command.Flags().String("k3s-extra-args", "", "Optional extra arguments to pass to k3s installer, wrapped in quotes (e.g. --k3s-extra-args '--no-deploy servicelb')")
command.Flags().Bool("ipsec", false, "Enforces and/or activates optional extra argument for k3s: flannel-backend option: ipsec")
command.Flags().Bool("merge", false, "Merge the config with existing kubeconfig if it already exists.\nProvide the --local-path flag with --merge if a kubeconfig already exists in some other directory")
command.Flags().String("k3s-version", config.K3sVersion, "Optional version to install, pinned at a default")

Expand All @@ -64,6 +65,7 @@ func MakeInstall() *cobra.Command {

k3sVersion, _ := command.Flags().GetString("k3s-version")
k3sExtraArgs, _ := command.Flags().GetString("k3s-extra-args")
flannelIPSec, _ := command.Flags().GetBool("ipsec")

local, _ := command.Flags().GetBool("local")

Expand All @@ -76,6 +78,10 @@ func MakeInstall() *cobra.Command {
clusterStr = "--cluster-init"
}

if flannelIPSec {
k3sExtraArgs += ` '--flannel-backend ipsec'`
}

installk3sExec := fmt.Sprintf("INSTALL_K3S_EXEC='server %s --tls-san %s %s'", clusterStr, ip, strings.TrimSpace(k3sExtraArgs))

installK3scommand := fmt.Sprintf("curl -sLS https://get.k3s.io | %s INSTALL_K3S_VERSION='%s' sh -\n", installk3sExec, k3sVersion)
Expand Down

0 comments on commit b83ecfb

Please sign in to comment.