Skip to content
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
6 changes: 4 additions & 2 deletions .krew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ metadata:
spec:
version: "v0.0.12"
homepage: https://github.com/kedify/kubectl-kedify
shortDescription: "Simple TUI based shell script for installing and interfacing with Kedify."
shortDescription: "Inspect, troubleshoot, and configure autoscaling with Kedify."
description: |
It asks couple of questions and fill the answers to the proper places for K8s manifests.
Provides commands for inspecting Kedify status and logs, configuring HTTP
autoscaling, managing multicluster configuration, analyzing scaling
configurations, and collecting diagnostic data.
platforms:
- selector:
matchExpressions:
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# kubectl-kedify plugin

Simple TUI based shell script for installing and interfacing with Kedify.
Simple TUI based shell script for working with Kedify.


[![Watch the full asciicast](./demo.gif)](https://asciinema.org/a/668253)
Expand All @@ -10,8 +10,6 @@ Simple TUI based shell script for installing and interfacing with Kedify.

### Core Commands

- **install, i** - Installs the Kedify agent
- **delete, d** - Uninstalls the Kedify agent
- **status, s** - Prints the status of Kedify agent
- **logs, l** - Prints the logs of Kedify agent
- **autoscale, a** - Runs the interactive mode for creating HTTPScaledObject
Expand Down
83 changes: 1 addition & 82 deletions kubectl-kedify
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ kedify::__resolve_script_path() {

SCRIPT_PATH="$(kedify::__resolve_script_path "$0")"
DIR="${DIR:-$( cd "$( dirname "${SCRIPT_PATH}" )" && pwd )}"
# API=${TEMPLATE_FILE:-"https://api.kedify.io"}
API=${TEMPLATE_FILE:-"https://api.dev.kedify.io"}
AUTOSCALABLE_RESOURCE_KINDS=(ingress service virtualservice httproute)
AUTOSCALABLE_RESOURCE_KIND=""
TEMPLATE_FILE=${TEMPLATE_FILE:-"hso.yaml"}
Expand All @@ -52,16 +50,6 @@ MC_SCRIPT="${DIR}/multicluster.sh"
VERSION_FILE="${DIR}/VERSION"
README_FILE="${DIR}/README.md"

kedify::__has_yes_flag() {
local arg=""
for arg in "$@"; do
if [[ "$arg" == "-y" || "$arg" == "--yes" ]]; then
return 0
fi
done
return 1
}

kedify::__read_single_char() {
if [[ -n "${ZSH_VERSION:-}" ]]; then
IFS= read -r -k 1 REPLY
Expand Down Expand Up @@ -124,12 +112,6 @@ main() {
export KUBECTL

case "${1}" in
install|i)
install "$@"
;;
delete|d)
delete "$@"
;;
status|s)
status
;;
Expand Down Expand Up @@ -236,45 +218,6 @@ check_result() {
exit 0
}

install() {
if [[ $# -gt 2 ]] && [[ "${2}" == --email ]]; then
export EMAIL="${3}"
else
# ask about email
echo "Please enter your email address:"
if [[ -n "${BASH_VERSION:-}" ]]; then
read -er EMAIL
else
read -r EMAIL
fi
export EMAIL
[[ -z $EMAIL ]] && echo "Email can't be empty" && exit 1
fi
set +e
AGENT_ID=$(curl -s --request POST --data '{"email": "'"${EMAIL}"'","name":"cli"}' "${API}"/onboarding/create | jq -e -r '.agent_id')
retVal=$?
[ $retVal -ne 0 ] && echo "Can't create JWT token: $(curl -s --request POST --data '{"email": "'"${EMAIL}"'","name":"cli"}' "${API}"/onboarding/create|jq -C)" && exit 1
set -e
TOKEN=$(curl -s --request POST --data '{"email": "'"${EMAIL}"'","name":"cli"}' "${API}"/onboarding/create | jq -r '.token')
if [[ $- == *i* ]] || kedify::__has_yes_flag "$@"; then
_resp="y"
else # ask only if shell is interactive or -y was passed
printf "Do you want to install Kedify on cluster %s'%s'%s\nHit 'p' for showing the manifests only." \
"$COL" "$(kubectl config current-context)" "$RES"
echo "[y/N/p]?"
kedify::__read_single_char
_resp="${REPLY}"
fi
[[ $_resp =~ [yY] ]] && {
# here we apply the manifests
kubectl apply -f "${API}/onboarding/agent/${AGENT_ID}?token=${TOKEN}"
}
[[ $_resp =~ [pP] ]] && {
curl -s "${API}/onboarding/agent/${AGENT_ID}?token=${TOKEN}" | ${BAT} --color=always -lyaml
}
exit 0
}

status() {
clear
figlet kedify status
Expand All @@ -300,30 +243,12 @@ insights() {
insights::cmd "$@"
}

delete() {
if [[ $- == *i* ]] || kedify::__has_yes_flag "$@"; then
_resp="y"
else # ask only if shell is interactive or -y was passed
printf "Do you want to uninstall Kedify on cluster %s'%s'%s\n" \
"$COL" "$(kubectl config current-context)" "$RES"
echo "[y/N]?"
kedify::__read_single_char
_resp="${REPLY}"
fi
[[ $_resp =~ [yY] ]] && {
echo -e "\nDeleting Kedify.."
"${KUBECTL}" delete kedifyconfigurations kedify -nkeda
}
}

print_usage() {
cat << EOF

Usage: kubectl kedify (i)nstall | (d)elete | (s)tatus | (a)utoscale | (mc)multicluster | (dbg)debug | (ins)ights | (dmp)dump | (h)elp
Usage: kubectl kedify (s)tatus | (a)utoscale | (mc)multicluster | (dbg)debug | (ins)ights | (dmp)dump | -h|--help
Comment thread
josefkarasek marked this conversation as resolved.

Available commands:
install, i Installs the Kedify agent
delete, d Uninstalls the Kedify agent
logs, l Prints the logs of Kedify agent
status, s Prints the status of Kedify agent
autoscale, a Runs the interactive mode for creating HTTPScaledObject
Expand All @@ -336,9 +261,6 @@ Available commands:
--help, -h Shows this help message

Examples:
kubectl kedify install ... installs the Kedify agent in interactive mode
kubectl kedify i --email john.doe@email.com -y ... installs the Kedify agent w/o asking
kubectl kedify d -y ... deletes the Kedify agent w/o asking
kubectl kedify autoscale ... will ask questions
kubectl kedify autoscale ingress ... will ask questions about what ingress to autoscale
kubectl kedify l -f ... prints the logs of Kedify agent and follows them
Expand All @@ -350,9 +272,6 @@ Examples:
kubectl kedify dmp -A --archive ... collects debug info from all namespaces as tar.gz
kubectl kedify dump -o /tmp/debug -n myapp ... collects debug info from specific namespace

Other env vars that can be passed:
API ... defaults to https://api.kedify.io

EOF
}

Expand Down
Loading