Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Script for Downloading and Installing the Latest KSOPS Exec Plugin #84

Merged
merged 3 commits into from
Dec 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ At [Viaduct](https://www.viaduct.ai/), we manage our Kubernetes resources via th

KSOPS was originally developed as a [kustomize Go plugin](https://kubernetes-sigs.github.io/kustomize/guides/plugins/#go-plugins). Up until *v2.2.0* this was the only installation option. To install, follow steps 0-3 of the [Getting Started section](#getting-started) and then run `make install`.

### [Experimental] Exec Plugin
### Exec Plugin

[kustomize exec plugins](https://kubernetes-sigs.github.io/kustomize/guides/plugins/#exec-plugins) offers a simpler installation and dependency management alternative to [kustomize Go plugin](https://kubernetes-sigs.github.io/kustomize/guides/plugins/#go-plugins) at the cost of debugability (error messages are swallowed). By popular demand, we now offer support for KSOPS as a kustomize exec plugin.

Expand All @@ -47,21 +47,30 @@ apiVersion: viaduct.ai/v1
kind: ksops-exec
```

Alternatively, you can choose to switch over entirely to the exec plugin by running
Alternatively, you can choose to switch over entirely to the exec plugin by running one of the following commands:


#### Remotely Download the Latest Release
```bash
# Verify the $XDG_CONFIG_HOME environment variable exists then run
source <(curl -s https://raw.githubusercontent.com/viaduct-ai/kustomize-sops/master/scripts/install-ksops-archive.sh)
```

#### Run `make install-exec-only` with the Cloned Repo Locally

```bash
# install exec plugin under ksops
make install-exec-only
```

This will install the exec plugin under both `ksops` and `ksops-exec`, so your existing generator manifests will use the exec plugin.
These will install the exec plugin under both `ksops` and `ksops-exec`, so your existing generator manifests will use the exec plugin.

Please provide feedback, ideas, and make an issue if you have questions or run into issues!


## Getting Started

### 0. Verify Requirements
### 0. Verify Requirements
Before continuing, verify your installation of [Go](https://github.com/golang/go), [SOPS](https://github.com/mozilla/sops), and `gpg`. Below are a few non-comprehensive commands to quickly check your installations:

```bash
Expand Down Expand Up @@ -234,7 +243,7 @@ kind: Secret
metadata:
name: argocd-secret
annotations:
# replace the base secret data/stringData values with these encrypted data/stringData values
# replace the base secret data/stringData values with these encrypted data/stringData values
kustomize.config.k8s.io/behavior: replace
type: Opaque
data:
Expand All @@ -251,7 +260,7 @@ kind: Secret
metadata:
name: argocd-secret
annotations:
# merge the base secret data/stringData values with these encrypted data/stringData values
# merge the base secret data/stringData values with these encrypted data/stringData values
kustomize.config.k8s.io/behavior: merge
type: Opaque
data:
Expand Down
48 changes: 48 additions & 0 deletions scripts/install-ksops-archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
set -e

# Require $XDG_CONFIG_HOME to be set
if [[ -z "$XDG_CONFIG_HOME" ]]; then
echo "You must define XDG_CONFIG_HOME to use a kustomize plugin"
echo "Add 'export XDG_CONFIG_HOME=\$HOME/.config' to your .bashrc or .zshrc"
exit 1
fi


PLUGIN_PATH="$XDG_CONFIG_HOME/kustomize/plugin/viaduct.ai/v1/ksops/"
EXEC_PLUGIN_PATH="$XDG_CONFIG_HOME/kustomize/plugin/viaduct.ai/v1/ksops-exec/"


echo "Verify ksops plugin directory exists and is empty"
rm -rf $PLUGIN_PATH || true
rm -rf $EXEC_PLUGIN_PATH || true
mkdir -p $PLUGIN_PATH
mkdir -p $EXEC_PLUGIN_PATH

ARCH=$(uname -m)
OS=""
case $(uname | tr '[:upper:]' '[:lower:]') in
linux*)
OS="Linux"
;;
darwin*)
OS="Darwin"
;;
msys*)
OS="Windows"
;;
windowsnt*)
OS="Windows"
;;
*)
echo "Unknown OS type: $(uname)"
echo "Please consider contributing to this script to support your OS."
exit 1
;;
esac


echo "Downloading latest release to ksops plugin path"
wget -c https://github.com/viaduct-ai/kustomize-sops/releases/latest/download/ksops_latest_${OS}_${ARCH}.tar.gz -O - | tar -xz -C $PLUGIN_PATH
cp $PLUGIN_PATH* $EXEC_PLUGIN_PATH
echo "Successfully installed ksops"
2 changes: 1 addition & 1 deletion scripts/install-ksops.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
# Require $XDG_CONFIG_HOME to be set
if [[ -z "$XDG_CONFIG_HOME" ]]; then
echo "You must define XDG_CONFIG_HOME to use a kustomize plugin"
echo "Add 'export XDG_CONFIG_HOME=\$HOME/.config' to your .bashrc"
echo "Add 'export XDG_CONFIG_HOME=\$HOME/.config' to your .bashrc or .zshrc"
exit 1
fi

Expand Down