Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
so0k committed Dec 12, 2017
0 parents commit 856f6d7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Helmns

helmns is a [Helm](http://helm.sh) cli wrapper forcing `--tiller-namespace` to match kubectl context.

This is meant to simplify management for Kubernetes clusters with RBAC enabled and where tiller is heavily locked down per namespace.

-----

## Installation

Since `helmns` is written in Bash, it can run in shells that support POSIX standards.

- Download the `helmns` script
- Either:
- save to somewhere in your `PATH`,
- or save to a directory, then create symlinks to `helmns` from somewhere in your `PATH`, like `/usr/local/bin`
- Make `helmns` executable (`chmod +x ...`)

-----

Heavily based on [ahmetb/kubens](https://github.com/ahmetb/kubectx)
24 changes: 24 additions & 0 deletions helmns
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
#
# helmns(1) is a utility to force tiller-namespace to current namespace

[[ -n $DEBUG ]] && set -x

set -eou pipefail
IFS=$'\n\t'

current_context() {
kubectl config view -o=jsonpath='{.current-context}'
}

current_namespace() {
local cur_ctx=$(current_context)
ns="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${cur_ctx}\")].context.namespace}")"
if [[ -z "${ns}" ]]; then
echo "default"
else
echo "${ns}"
fi
}

exec helm --tiller-namespace "$(current_namespace)" "$@"

0 comments on commit 856f6d7

Please sign in to comment.