From 03320dfbbcc0b3348d741c579b38e434b2d61c56 Mon Sep 17 00:00:00 2001 From: Maxim Likhachev Date: Mon, 26 Oct 2020 15:51:42 +0300 Subject: [PATCH] Add man pages and adjust Makefile --- Makefile | 124 +++++++++++++++++++++------ README.md | 10 ++- kubectl-compare | 128 ---------------------------- kubectl-http | 196 ------------------------------------------- kubectl-ingress | 27 ------ kubectl-secret | 85 ------------------- kubectl-secrets | 1 - man/kubectl-compare.1 | 185 +++++++++++++++++++++++++++++++++++++++++ man/kubectl-http.1 | 165 ++++++++++++++++++++++++++++++++++++ man/kubectl-ingress.1 | 151 +++++++++++++++++++++++++++++++++ man/kubectl-secret.1 | 158 +++++++++++++++++++++++++++++++++++ man/kubectl-secrets.1 | 158 +++++++++++++++++++++++++++++++++++ scripts/kubectl-compare | 140 +++++++++++++++++++++++++++++++ scripts/kubectl-http | 216 ++++++++++++++++++++++++++++++++++++++++++++++++ scripts/kubectl-ingress | 43 ++++++++++ scripts/kubectl-secret | 104 +++++++++++++++++++++++ scripts/kubectl-secrets | 1 + 17 files changed, 1426 insertions(+), 466 deletions(-) delete mode 100755 kubectl-compare delete mode 100755 kubectl-http delete mode 100755 kubectl-ingress delete mode 100755 kubectl-secret delete mode 120000 kubectl-secrets create mode 100644 man/kubectl-compare.1 create mode 100644 man/kubectl-http.1 create mode 100644 man/kubectl-ingress.1 create mode 100644 man/kubectl-secret.1 create mode 100644 man/kubectl-secrets.1 create mode 100755 scripts/kubectl-compare create mode 100755 scripts/kubectl-http create mode 100755 scripts/kubectl-ingress create mode 100755 scripts/kubectl-secret create mode 120000 scripts/kubectl-secrets diff --git a/Makefile b/Makefile index 3d1bde3..94174b6 100644 --- a/Makefile +++ b/Makefile @@ -1,36 +1,108 @@ -path = ~/.shellrc/bin/scripts +install_path = /usr/local/bin +links_path = ~/.shellrc/bin/scripts +local_man_path = ~/.shellrc/var/man/man1 +system_man_path = /usr/local/share/man/man1 + +SRC := scripts +MAN := man + find := $(shell { command -v gfind || command -v find; } 2>&-) -all: install +SCRIPTS := $(wildcard $(SRC)/kubectl-*) +MAN_PAGES := $(subst $(SRC),$(MAN),$(basename $(wildcard $(SRC)/kubectl-*))) +MAN_FILES := $(addsuffix ".1", $(MAN_PAGES)) + +# -------------------------------------------------------------------------------------------------- + +# copy_files [FILES] TO/ +define copy_files + @for file in $(1); do \ + cp -v $$(realpath -- $$file) $(2)/$$(basename $$file); \ + done +endef + +# link_files [FILES] TO/ +define link_files + @for file in $(1); do \ + ln -f -s -v $$(realpath -- $$file) $(2)/$$(basename $$file); \ + done +endef + +# delete_files [FILES] FROM/ +define delete_files + @for file in $(1); do \ + rm -v $(2)/$$(basename $$file) || :; \ + done +endef + +# -------------------------------------------------------------------------------------------------- + +help: ## Display this help. + @awk 'BEGIN { \ + FS = ":.*##"; \ + printf "\nUsage:\n make \033[36m\033[0m\n\nTargets:\n" \ + } \ + /^[a-zA-Z_-]+:.*?##/ { \ + printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 \ + } \ + END { \ + print \ + }' \ + $(MAKEFILE_LIST) + +# -------------------------------------------------------------------------------------------------- + +man: $(MAN_PAGES) ## Generate man pages. +links: man make_local_dirs make_links link_man_pages ## Install kubectl scripts by creating links. +install: man copy_bin copy_man_pages ## Install kubectl scripts to /usr/local/bin. +uninstall: rm_bin rm_links rm_man_pages rm_man_links rm_local_dirs ## Uninstall kubectl scripts. + +# -------------------------------------------------------------------------------------------------- + +%: $(BIN)/% +$(MAN)/%: $(SRC)/% + pod2man --section 1 --release "1.0.0" --center "KUBECTL EXTENSIONS" $< > $@.1 + +# -------------------------------------------------------------------------------------------------- + +make_man_directory: + @mkdir -p $(system_man_path) + +copy_bin: + $(call copy_files, $(SCRIPTS), $(install_path)) + +rm_bin: + $(call delete_files, $(SCRIPTS), $(install_path)) + +copy_man_pages: make_man_directory + $(call copy_files, $(MAN_FILES), $(system_man_path)) + +rm_man_pages: make_man_directory + $(call delete_files, $(MAN_FILES), $(system_man_path)) + +# -------------------------------------------------------------------------------------------------- + +make_local_dirs: + mkdir -p -v $(links_path) + mkdir -p -v $(local_man_path) -mkdir: - @mkdir -p $(path) +rm_local_dirs: + rmdir $(links_path) 2>&-; : + rmdir $(local_man_path) 2>&-; : -rmdir: - @rmdir $(path) 2>&-; : +make_links: + $(call link_files, $(SCRIPTS), $(links_path)) -install: mkdir - @$(find) . \ - -maxdepth 1 \ - \( -type f -o -type l \) \ - -executable \ - -exec basename {} \; \ - | while read -r line; do \ - ln -v -s $$(realpath -- $$line) $(path)/$$line 2>&-; \ - done; \ - true +rm_links: + $(call delete_files, $(SCRIPTS), $(links_path)) -rmlinks: - @$(find) . \ - -maxdepth 1 \ - \( -type f -o -type l \) \ - -executable \ - -exec basename {} \; \ - | xargs -IF rm -fv $(path)/F +link_man_pages: + $(call link_files, $(MAN_FILES), $(local_man_path)) -uninstall: rmlinks rmdir +rm_man_links: + $(call delete_files, $(MAN_FILES), $(local_man_path)) -clean: uninstall +# -------------------------------------------------------------------------------------------------- -.PHONY: all mkdir rmdir install uninstall clean +.PHONY: all make_local_dirs rm_local_dirs links install uninstall diff --git a/README.md b/README.md index d38174b..abaf246 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,15 @@ otherwise is specified. ## Installing -A command +To install scripts in the `/usr/local/bin` directory run the following command: - $ make install + $ make install -will create the symbolic link for each script in the \ directory. +The command + + $ make links + +will create the symbolic link for each script in the `links_path` directory. # Index diff --git a/kubectl-compare b/kubectl-compare deleted file mode 100755 index 9e8d97d..0000000 --- a/kubectl-compare +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright (C) 2020, Maxim Lihachev, -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation, version 3. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -set -o pipefail - -if [ -z "$DIFF_CMD" ]; then - DIFF_CMD="diff -u --color=always" -fi - -if [ -z "$VISUAL_DIFF_CMD" ]; then - VISUAL_DIFF_CMD="vim -d --cmd 'autocmd BufRead * set filetype=yaml'" -fi - -# Default Kubernetes namespace -NAMESPACE=default - -# Default Kubernetes resource -TYPE=pod - -usage() { -cat <&2 echo "ERROR: $*" - exit 1 -} - -kubecmd() { - IFS='/' read -r -a item <<< "$(sed -E 's:^/|/$::g' <<<"$1")" - - case ${#item[@]} in - 1) kubectl_cmd="kubectl --namespace $NAMESPACE get $TYPE ${item[0]} -o yaml";; - 2) kubectl_cmd="kubectl --namespace $NAMESPACE get ${item[0]} ${item[1]} -o yaml";; - 3) kubectl_cmd="kubectl --namespace ${item[0]} get ${item[1]} ${item[2]} -o yaml";; - *) exit 1;; - esac - - echo "<(${kubectl_cmd[*]})" -} - -#-------------------------------------------------------------------------- - -POSITIONAL=() - -while [[ $# -gt 0 ]]; do - key="$1" - - case $key in - -h|--help) usage;; - -e|--edit|-v|--visual) DIFF_CMD=$VISUAL_DIFF_CMD; shift;; - -n|--namespace) NAMESPACE="$2"; shift; shift;; - -t|--type) TYPE="$2"; shift; shift;; - - *) POSITIONAL+=("$1"); shift;; - esac -done - -set -- "${POSITIONAL[@]}" - -diff_cmd=("$DIFF_CMD") - -if [ $# -lt 2 ]; then - usage 1 -fi - -for cmd in "$@"; do - diff_cmd+=($(kubecmd "$cmd")) || die "Excessive nestedness of Kubernetes resource: $cmd" -done - -eval "${diff_cmd[*]}" - diff --git a/kubectl-http b/kubectl-http deleted file mode 100755 index 8495307..0000000 --- a/kubectl-http +++ /dev/null @@ -1,196 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright (C) 2020, Maxim Lihachev, -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation, version 3. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -rstc="\033[00m" -blue="\033[1;36m" -green="\033[1;32m" -magenta="\033[1;35m" -red="\033[1;31m" -yellow="\033[1;33m" - -USE_HYPERLINKS=false - -# Default resource's type to query -TYPE=svc - -# Default kubectl's proxy endpoint -PROXY_URL="http://127.0.0.1:8001" - -shortname() { - local name_length=${2:-30} - - host=${1/:*} - port=${1/*:} - - if [ "${#1}" -gt "$name_length" ]; then - echo "$(head -c "$name_length" <<<"$host")~:$port" - else - echo "$1" - fi -} - -# Print horizontal rule -hr() { - echo -e -n "$magenta" - printf "%${COLS}s" | sed 's/ /─/g' - echo -e "$rstc" -} - -usage() { - echo -e "$(basename "$0") is a wrapper for \`kubectl proxy' command which shows links to resources.\n" - echo -e "USAGE: $(basename "$0" | tr '-' ' ') [all|pods|services] [standard kubectl selectors]\n" - - echo -e "Command line arguments:" - echo -e " -h --help show this help" - echo -e " -hl --hyperlinks use terminal emulator's hyperlinks feature" - - echo - echo -e "Basic selectors:" - echo -e " all pods and services" - echo -e " po pod pods pods" - echo -e " svc service services services" - - echo - exit "${1:-0}" -} - -footer() { - >&2 echo - >&2 hr - >&2 echo -e " ${magenta}The index page with the links to resources: ${blue}${PROXY_URL}/index" - >&2 hr - >&2 echo -} - -# Remove temporary directory -cleanup() { - rm -rf "$WWW_DIRECTORY" -} - -kubectl_get() { - local resource=${1:-svc} - - shift - - [ $# -eq 0 ] && local filter="-A" - - case "$resource" in - all) { kubectl_get pods "$@"; kubectl_get svc "$@"; };; - svc) eval kubectl get svc "$@" "$filter" --no-headers=true \ - -o=custom-columns=NAME:.metadata.selfLink,PORTS:.spec.ports[*].port;; - pods) eval kubectl get pod "$@" "$filter" --no-headers=true \ - -o=custom-columns=NAME:.metadata.selfLink,PORTS:.spec.containers[*].ports[*].containerPort;; - esac | grep -v '' | sed -E 's/[[:space:]]+/,/g' -} - -die() { - >&2 echo -e "${red}ERROR: ${*}${rstc}" - - exit 1 -} - -# Clean up temporary files on exit -trap cleanup EXIT SIGINT SIGHUP SIGQUIT - -KUBECTL_ARGS=() - -while [[ $# -gt 0 ]]; do - key="$1" - - case $key in - -h|--help) usage 0;; - -hl|--hyperlinks) USE_HYPERLINKS=true; shift;; - all) TYPE=all; shift;; - po|pod|pods) TYPE=pods; shift;; - svc|service|services) TYPE=svc; shift;; - *) KUBECTL_ARGS+=("$1"); shift;; - esac -done - -set -- "${KUBECTL_ARGS[@]}" - -# Temporary directory for index.html file -WWW_DIRECTORY=$(mktemp -d --tmpdir=/tmp KUBE_PROXY.XXXXXXXX) - -COLS=$(tput cols) - -declare -a SERVICES -declare -A URLS - -mapfile -t SERVICES <<<"$(kubectl_get "$TYPE" "$@")" - -[ "${#SERVICES}" -eq 0 ] && die "No resource found" - -for service in "${SERVICES[@]}"; do - svc_url=${service//,*/} - ports=${service#*,} - - IFS=',' - for port in $ports; do - id="$(cut -d '/' -f 5,6,7 <<<"$svc_url"):${port}" - URLS["$id"]="${PROXY_URL}${svc_url}:${port}/proxy" - done -done - -mapfile -d '' SORTED_URLS < <(printf '%s\0' "${!URLS[@]}" | sort -z) - -echo - -MAX_VAL_LENGTH=$(printf '%s\n' "${URLS[@]}" \ - | awk '{ print length }' \ - | sort -n -r \ - | head -n 1) - -MAX_KEY_LENGTH=$(printf '%s\n' "${!URLS[@]}" \ - | sed -E 's/\/[^\/]+$//' \ - | awk '{ print length }' \ - | sort -n -r \ - | head -n 1) - -# ~ ' - ' + ':' + 5-digit of port + spaces -MAX_NAME_LENGTH=$(( COLS - MAX_KEY_LENGTH - MAX_VAL_LENGTH - 15 )) - -for key in "${SORTED_URLS[@]}"; do - printf '
  • %s
  • \n' "${URLS[$key]}" "$key" >> "${WWW_DIRECTORY}/index.html" - IFS='/' read -r ns rs name <<<"$key" - - if [ "$USE_HYPERLINKS" == "true" ]; then - # Address under hyperlink - echo -e -n "- \e]8;;${URLS[$key]}\e\\\\" - echo -e -n "${magenta}${ns}${rstc}/" # namespace - echo -e -n "${yellow}${rs}${rstc}/" # resource's type - echo -e "${green}${name}${rstc}\e]8;;\e\\" # resource's name - else - # - namespace/service http://127.0.0.1:8001/api/.../service:port/proxy - echo -e -n " - ${magenta}${ns}${rstc}/" # namespace - echo -e -n "${yellow}${rs}${rstc}/" # resource's type - - if [ "$MAX_NAME_LENGTH" -gt 10 ]; then - echo -e -n "${green}$(shortname "$name" "$MAX_NAME_LENGTH") " # short resource's name - else - echo -e -n "${green}${name}\n - " # resource's name on the its own line - fi - - echo -e "${blue}${URLS[$key]}${rstc}" # API URL - fi -done | column -t - -footer - ->&2 kubectl proxy --www="$WWW_DIRECTORY" --www-prefix=/index - diff --git a/kubectl-ingress b/kubectl-ingress deleted file mode 100755 index 54d71d0..0000000 --- a/kubectl-ingress +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright (C) 2020, Maxim Lihachev, -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation, version 3. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -## -## kubectl-ingress is a wrapper for 'kubectl get ingress` command which -## makes links clickable. -## - -echo -e "$(sed 's!(([[:alpha:]](-?[[:alnum:]])*)\.)+[[:alpha:]]{2,}!\\e]8;;http://\0\\e\\\\\0\\e]8;;\\e\\!g; - s!((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])!\\e]8;;http://\0\\e\\\\\0\\e]8;;\\e\\!g -' -r <<<"$(kubectl get ingress "$@")")" - diff --git a/kubectl-secret b/kubectl-secret deleted file mode 100755 index da8ce07..0000000 --- a/kubectl-secret +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright (C) 2020, Maxim Lihachev, -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation, version 3. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -usage() { - echo -e "$(basename "$0") is a wrapper for \`kubectl get secret' to decoding secrets automatically.\n" - echo -e "USAGE: $(basename "$0" | tr '-' ' ') [-h|-d|-s] [standard kubectl selectors]\n" - - echo -e "Command line arguments:" - echo -e " -h --help show this help" - echo -e " -s --simple show only secrets" - echo -e " -d --decode show decoded data as plain text" - echo -e " (by default it shows under the link)\n" - - exit "${1:-0}" -} - -KUBECTL_ARGS=() - -while [[ $# -gt 0 ]]; do - key="$1" - - case $key in - -h|--help) usage 0;; - -d|--decode) DECODE=true; shift;; - -s|--simple) SIMPLE=true; shift;; - *) KUBECTL_ARGS+=("$1"); shift;; - esac -done - -set -- "${KUBECTL_ARGS[@]}" - -#------------------------------------------------------------------------------- - -MANIFEST=$(kubectl get secret "${KUBECTL_ARGS[@]}" -o yaml) - -#------------------------------------------------------------------------------- - -if grep -E -q '^kind: List' <<<"$MANIFEST"; then - DELIMITER=" " -else - DELIMITER=" " -fi - -IFS=$'\n' - -REGEX_DATA="^${DELIMITER/ /}data:" -REGEX_SECRET="^${DELIMITER}[[:print:]]+:[[:space:]]+.*$" - -while read -r line; do - if [[ "$line" =~ $REGEX_DATA ]]; then - DATA=1 - elif [[ "$DATA" -eq 1 ]] && [[ "$line" =~ $REGEX_SECRET ]]; then - secret=${line//[[:space:]]/} - key=${secret/:*} - value=${secret/*:} - - if [ "$DECODE" == "true" ]; then - echo -e "${DELIMITER}${key}: $(base64 -d <<<"$value")" - else - echo -e "${DELIMITER}${key}: \e]8;;$(base64 -d <<<"$value")\e\\\\${value}\e]8;;\e\\" - fi - - continue - else - DATA=0 - fi - - [ "$SIMPLE" != "true" ] && echo "$line" -done <<<"$MANIFEST" - diff --git a/kubectl-secrets b/kubectl-secrets deleted file mode 120000 index a5be89c..0000000 --- a/kubectl-secrets +++ /dev/null @@ -1 +0,0 @@ -kubectl-secret \ No newline at end of file diff --git a/man/kubectl-compare.1 b/man/kubectl-compare.1 new file mode 100644 index 0000000..9a8e306 --- /dev/null +++ b/man/kubectl-compare.1 @@ -0,0 +1,185 @@ +.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.nr rF 0 +.if \n(.g .if rF .nr rF 1 +.if (\n(rF:(\n(.g==0)) \{\ +. if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +. \} +.\} +.rr rF +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "KUBECTL-COMPARE 1" +.TH KUBECTL-COMPARE 1 "2020-10-26" "1.0.0" "KUBECTL EXTENSIONS" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +kubectl\-compare allows to juxtapose kubernetes resources with any diff\-like utilities. +.SH "USAGE" +.IX Header "USAGE" +.Vb 5 +\& kubectl compare [\-n|\-\-namespace NAMESPACE] [\-t|\-\-type] [\-e|\-\-edit|\-v|\-\-visual] name1 name2 +\&or +\& kubectl compare [\-e|\-\-edit|\-v|\-\-visual] namespace/type/name1 namespace/type/name2 +\&or +\& kubectl compare [\-e|\-\-edit|\-v|\-\-visual] namespace/type/name1 namespace/type/name2 namespace/type/name3 ... +.Ve +.SH "OPTIONS" +.IX Header "OPTIONS" +.Vb 3 +\& \-n \-\-namespace Kubernetes namespace for search (\*(Aqdefault\*(Aq by default). +\& \-t \-\-type Kubernetes resource\*(Aqs type, e.g. pod, svc, configmap, etc (\*(Aqpod\*(Aq by default). +\& \-e \-\-edit, \-v \-\-visual Open diff in visual editor (e.g. vimdiff). +.Ve +.PP +Set \fB\s-1VISUAL_DIFF_CMD\s0\fR environment variable or provide its value in script's +file (kubectl-compare) to specify utility which will be used. +.PP +To specify main diff program set \fB\s-1DIFF_CMD\s0\fR variable (its default value is \fI'diff +\&\-u \-\-color=always'\fR). +.PP +Use something like \fIdiff3\fR to compare 3 manifests. +.SH "EXAMPLE" +.IX Header "EXAMPLE" +.Vb 7 +\& $ kubectl compare \-n zookeeper \-t pod zookeeper\-0 zookeeper\-1 +\& $ kubectl compare \-n zookeeper pod/zookeeper\-0 pod/zookeeper\-1 +\& $ kubectl compare zookeeper/pod/zookeeper\-0 zookeeper/pod/zookeeper\-1 +\& ^ ^ ^ +\& [namespace]\-\-\-+ | | +\& [type]\-\-\-\-+ | +\& [name]\-\-+ +\& +\& $ kubectl compare zookeeper/pod/zookeeper\-{0,1,2} +.Ve +.SH "BUGS" +.IX Header "BUGS" +If you find a bug, please report it at \fB\fR. +.SH "AUTHORS" +.IX Header "AUTHORS" +envrm \fB\fR. diff --git a/man/kubectl-http.1 b/man/kubectl-http.1 new file mode 100644 index 0000000..1b8977b --- /dev/null +++ b/man/kubectl-http.1 @@ -0,0 +1,165 @@ +.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.nr rF 0 +.if \n(.g .if rF .nr rF 1 +.if (\n(rF:(\n(.g==0)) \{\ +. if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +. \} +.\} +.rr rF +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "KUBECTL-HTTP 1" +.TH KUBECTL-HTTP 1 "2020-10-26" "1.0.0" "KUBECTL EXTENSIONS" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +kubectl\-http is a wrapper for `kubectl proxy' command which shows links to resources. +.SH "USAGE" +.IX Header "USAGE" +kubectl http [all|pods|services] [standard kubectl selectors] +.SH "OPTIONS" +.IX Header "OPTIONS" +.Vb 2 +\& \-h \-\-help = show this help +\& \-hl \-\-hyperlinks = use terminal emulator\*(Aqs hyperlinks feature +.Ve +.PP +Basic selectors: +.PP +.Vb 3 +\& all pods and services +\& po pod pods pods +\& svc service services services +.Ve +.SH "BUGS" +.IX Header "BUGS" +If you find a bug, please report it at \fB\fR. +.SH "AUTHORS" +.IX Header "AUTHORS" +envrm \fB\fR. diff --git a/man/kubectl-ingress.1 b/man/kubectl-ingress.1 new file mode 100644 index 0000000..015045a --- /dev/null +++ b/man/kubectl-ingress.1 @@ -0,0 +1,151 @@ +.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.nr rF 0 +.if \n(.g .if rF .nr rF 1 +.if (\n(rF:(\n(.g==0)) \{\ +. if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +. \} +.\} +.rr rF +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "KUBECTL-INGRESS 1" +.TH KUBECTL-INGRESS 1 "2020-10-26" "1.0.0" "KUBECTL EXTENSIONS" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +kubectl\-ingress is a wrapper for `kubectl get ingress' command which makes links clickable. +.SH "USAGE" +.IX Header "USAGE" +kubectl ingress [standard kubectl selectors] +.SH "BUGS" +.IX Header "BUGS" +If you find a bug, please report it at \fB\fR. +.SH "AUTHORS" +.IX Header "AUTHORS" +envrm \fB\fR. diff --git a/man/kubectl-secret.1 b/man/kubectl-secret.1 new file mode 100644 index 0000000..637f23b --- /dev/null +++ b/man/kubectl-secret.1 @@ -0,0 +1,158 @@ +.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.nr rF 0 +.if \n(.g .if rF .nr rF 1 +.if (\n(rF:(\n(.g==0)) \{\ +. if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +. \} +.\} +.rr rF +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "KUBECTL-SECRET 1" +.TH KUBECTL-SECRET 1 "2020-10-26" "1.0.0" "KUBECTL EXTENSIONS" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +kubectl\-secret is a wrapper for `kubectl get secret' to decoding secrets automatically. +.SH "USAGE" +.IX Header "USAGE" +kubectl secret [\-h|\-d|\-s] [standard kubectl selectors] +.SH "OPTIONS" +.IX Header "OPTIONS" +.Vb 3 +\& \-h \-\-help = show this help +\& \-s \-\-simple = show only secrets +\& \-d \-\-decode = show decoded data as plain text (by default it shows under the link) +.Ve +.SH "BUGS" +.IX Header "BUGS" +If you find a bug, please report it at \fB\fR. +.SH "AUTHORS" +.IX Header "AUTHORS" +envrm \fB\fR. diff --git a/man/kubectl-secrets.1 b/man/kubectl-secrets.1 new file mode 100644 index 0000000..f8d038e --- /dev/null +++ b/man/kubectl-secrets.1 @@ -0,0 +1,158 @@ +.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.nr rF 0 +.if \n(.g .if rF .nr rF 1 +.if (\n(rF:(\n(.g==0)) \{\ +. if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +. \} +.\} +.rr rF +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "KUBECTL-SECRETS 1" +.TH KUBECTL-SECRETS 1 "2020-10-26" "1.0.0" "KUBECTL EXTENSIONS" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +kubectl\-secret is a wrapper for `kubectl get secret' to decoding secrets automatically. +.SH "USAGE" +.IX Header "USAGE" +kubectl secret [\-h|\-d|\-s] [standard kubectl selectors] +.SH "OPTIONS" +.IX Header "OPTIONS" +.Vb 3 +\& \-h \-\-help = show this help +\& \-s \-\-simple = show only secrets +\& \-d \-\-decode = show decoded data as plain text (by default it shows under the link) +.Ve +.SH "BUGS" +.IX Header "BUGS" +If you find a bug, please report it at \fB\fR. +.SH "AUTHORS" +.IX Header "AUTHORS" +envrm \fB\fR. diff --git a/scripts/kubectl-compare b/scripts/kubectl-compare new file mode 100755 index 0000000..ebca8a4 --- /dev/null +++ b/scripts/kubectl-compare @@ -0,0 +1,140 @@ +#!/usr/bin/env bash + +# +# Copyright (C) 2020, Maxim Lihachev, +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation, version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +: <<'MAN' + +=head1 NAME + +kubectl-compare allows to juxtapose kubernetes resources with any diff-like utilities. + +=head1 USAGE + + kubectl compare [-n|--namespace NAMESPACE] [-t|--type] [-e|--edit|-v|--visual] name1 name2 +or + kubectl compare [-e|--edit|-v|--visual] namespace/type/name1 namespace/type/name2 +or + kubectl compare [-e|--edit|-v|--visual] namespace/type/name1 namespace/type/name2 namespace/type/name3 ... + +=head1 OPTIONS + + -n --namespace Kubernetes namespace for search ('default' by default). + -t --type Kubernetes resource's type, e.g. pod, svc, configmap, etc ('pod' by default). + -e --edit, -v --visual Open diff in visual editor (e.g. vimdiff). + +Set B environment variable or provide its value in script's +file (kubectl-compare) to specify utility which will be used. + +To specify main diff program set B variable (its default value is I<'diff +-u --color=always'>). + +Use something like I to compare 3 manifests. + +=head1 EXAMPLE + + $ kubectl compare -n zookeeper -t pod zookeeper-0 zookeeper-1 + $ kubectl compare -n zookeeper pod/zookeeper-0 pod/zookeeper-1 + $ kubectl compare zookeeper/pod/zookeeper-0 zookeeper/pod/zookeeper-1 + ^ ^ ^ + [namespace]---+ | | + [type]----+ | + [name]--+ + + $ kubectl compare zookeeper/pod/zookeeper-{0,1,2} + +=head1 BUGS + +If you find a bug, please report it at B>. + +=head1 AUTHORS + +envrm B>. + +=cut +MAN + + +set -o pipefail + +if [ -z "$DIFF_CMD" ]; then + DIFF_CMD="diff -u --color=always" +fi + +if [ -z "$VISUAL_DIFF_CMD" ]; then + VISUAL_DIFF_CMD="vim -d --cmd 'autocmd BufRead * set filetype=yaml'" +fi + +# Default Kubernetes namespace +NAMESPACE=default + +# Default Kubernetes resource +TYPE=pod + +usage() { + sed -E -n '/^.*MAN/,/^MAN$/{//!p;}; /^MAN$/q' "$0" | sed -E 's/=head. |[LIBC]<|\b>*//g; /=cut/d' + exit "${1:0}" +} + +die() { + >&2 echo "ERROR: $*" + exit 1 +} + +kubecmd() { + IFS='/' read -r -a item <<< "$(sed -E 's:^/|/$::g' <<<"$1")" + + case ${#item[@]} in + 1) kubectl_cmd="kubectl --namespace $NAMESPACE get $TYPE ${item[0]} -o yaml";; + 2) kubectl_cmd="kubectl --namespace $NAMESPACE get ${item[0]} ${item[1]} -o yaml";; + 3) kubectl_cmd="kubectl --namespace ${item[0]} get ${item[1]} ${item[2]} -o yaml";; + *) exit 1;; + esac + + echo "<(${kubectl_cmd[*]})" +} + +#-------------------------------------------------------------------------- + +POSITIONAL=() + +while [[ $# -gt 0 ]]; do + key="$1" + + case $key in + -h|--help) usage;; + -e|--edit|-v|--visual) DIFF_CMD=$VISUAL_DIFF_CMD; shift;; + -n|--namespace) NAMESPACE="$2"; shift; shift;; + -t|--type) TYPE="$2"; shift; shift;; + + *) POSITIONAL+=("$1"); shift;; + esac +done + +set -- "${POSITIONAL[@]}" + +diff_cmd=("$DIFF_CMD") + +if [ $# -lt 2 ]; then + usage 1 +fi + +for cmd in "$@"; do + diff_cmd+=($(kubecmd "$cmd")) || die "Excessive nestedness of Kubernetes resource: $cmd" +done + +eval "${diff_cmd[*]}" + diff --git a/scripts/kubectl-http b/scripts/kubectl-http new file mode 100755 index 0000000..f8e87e3 --- /dev/null +++ b/scripts/kubectl-http @@ -0,0 +1,216 @@ +#!/usr/bin/env bash + +# +# Copyright (C) 2020, Maxim Lihachev, +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation, version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +: <<'MAN' + +=head1 NAME + +kubectl-http is a wrapper for I<`kubectl proxy'> command which shows links to resources. + +=head1 USAGE + +kubectl http [all|pods|services] [standard kubectl selectors] + +=head1 OPTIONS + + -h --help = show this help + -hl --hyperlinks = use terminal emulator's hyperlinks feature + +Basic selectors: + + all pods and services + po pod pods pods + svc service services services + +=head1 BUGS + +If you find a bug, please report it at B>. + +=head1 AUTHORS + +envrm B>. + +=cut +MAN + +rstc="\033[00m" +blue="\033[1;36m" +green="\033[1;32m" +magenta="\033[1;35m" +red="\033[1;31m" +yellow="\033[1;33m" + +USE_HYPERLINKS=false + +# Default resource's type to query +TYPE=svc + +# Default kubectl's proxy endpoint +PROXY_URL="http://127.0.0.1:8001" + +shortname() { + local name_length=${2:-30} + + host=${1/:*} + port=${1/*:} + + if [ "${#1}" -gt "$name_length" ]; then + echo "$(head -c "$name_length" <<<"$host")~:$port" + else + echo "$1" + fi +} + +# Print horizontal rule +hr() { + echo -e -n "$magenta" + printf "%${COLS}s" | sed 's/ /─/g' + echo -e "$rstc" +} + +usage() { + sed -E -n '/^.*MAN/,/^MAN$/{//!p;}; /^MAN$/q' "$0" | sed -E 's/=head. |[LIBC]<|\b>*//g; /=cut/d' + + exit "${1:-0}" +} + +footer() { + >&2 echo + >&2 hr + >&2 echo -e " ${magenta}The index page with the links to resources: ${blue}${PROXY_URL}/index" + >&2 hr + >&2 echo +} + +# Remove temporary directory +cleanup() { + rm -rf "$WWW_DIRECTORY" +} + +kubectl_get() { + local resource=${1:-svc} + + shift + + [ $# -eq 0 ] && local filter="-A" + + case "$resource" in + all) { kubectl_get pods "$@"; kubectl_get svc "$@"; };; + svc) eval kubectl get svc "$@" "$filter" --no-headers=true \ + -o=custom-columns=NAME:.metadata.selfLink,PORTS:.spec.ports[*].port;; + pods) eval kubectl get pod "$@" "$filter" --no-headers=true \ + -o=custom-columns=NAME:.metadata.selfLink,PORTS:.spec.containers[*].ports[*].containerPort;; + esac | grep -v '' | sed -E 's/[[:space:]]+/,/g' +} + +die() { + >&2 echo -e "${red}ERROR: ${*}${rstc}" + + exit 1 +} + +# Clean up temporary files on exit +trap cleanup EXIT SIGINT SIGHUP SIGQUIT + +KUBECTL_ARGS=() + +while [[ $# -gt 0 ]]; do + key="$1" + + case $key in + -h|--help) usage 0;; + -hl|--hyperlinks) USE_HYPERLINKS=true; shift;; + all) TYPE=all; shift;; + po|pod|pods) TYPE=pods; shift;; + svc|service|services) TYPE=svc; shift;; + *) KUBECTL_ARGS+=("$1"); shift;; + esac +done + +set -- "${KUBECTL_ARGS[@]}" + +# Temporary directory for index.html file +WWW_DIRECTORY=$(mktemp -d --tmpdir=/tmp KUBE_PROXY.XXXXXXXX) + +COLS=$(tput cols) + +declare -a SERVICES +declare -A URLS + +mapfile -t SERVICES <<<"$(kubectl_get "$TYPE" "$@")" + +[ "${#SERVICES}" -eq 0 ] && die "No resource found" + +for service in "${SERVICES[@]}"; do + svc_url=${service//,*/} + ports=${service#*,} + + IFS=',' + for port in $ports; do + id="$(cut -d '/' -f 5,6,7 <<<"$svc_url"):${port}" + URLS["$id"]="${PROXY_URL}${svc_url}:${port}/proxy" + done +done + +mapfile -d '' SORTED_URLS < <(printf '%s\0' "${!URLS[@]}" | sort -z) + +echo + +MAX_VAL_LENGTH=$(printf '%s\n' "${URLS[@]}" \ + | awk '{ print length }' \ + | sort -n -r \ + | head -n 1) + +MAX_KEY_LENGTH=$(printf '%s\n' "${!URLS[@]}" \ + | sed -E 's/\/[^\/]+$//' \ + | awk '{ print length }' \ + | sort -n -r \ + | head -n 1) + +# ~ ' - ' + ':' + 5-digit of port + spaces +MAX_NAME_LENGTH=$(( COLS - MAX_KEY_LENGTH - MAX_VAL_LENGTH - 15 )) + +for key in "${SORTED_URLS[@]}"; do + printf '
  • %s
  • \n' "${URLS[$key]}" "$key" >> "${WWW_DIRECTORY}/index.html" + IFS='/' read -r ns rs name <<<"$key" + + if [ "$USE_HYPERLINKS" == "true" ]; then + # Address under hyperlink + echo -e -n "- \e]8;;${URLS[$key]}\e\\\\" + echo -e -n "${magenta}${ns}${rstc}/" # namespace + echo -e -n "${yellow}${rs}${rstc}/" # resource's type + echo -e "${green}${name}${rstc}\e]8;;\e\\" # resource's name + else + # - namespace/service http://127.0.0.1:8001/api/.../service:port/proxy + echo -e -n " - ${magenta}${ns}${rstc}/" # namespace + echo -e -n "${yellow}${rs}${rstc}/" # resource's type + + if [ "$MAX_NAME_LENGTH" -gt 10 ]; then + echo -e -n "${green}$(shortname "$name" "$MAX_NAME_LENGTH") " # short resource's name + else + echo -e -n "${green}${name}\n - " # resource's name on the its own line + fi + + echo -e "${blue}${URLS[$key]}${rstc}" # API URL + fi +done | column -t + +footer + +>&2 kubectl proxy --www="$WWW_DIRECTORY" --www-prefix=/index + diff --git a/scripts/kubectl-ingress b/scripts/kubectl-ingress new file mode 100755 index 0000000..3753e6e --- /dev/null +++ b/scripts/kubectl-ingress @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +# +# Copyright (C) 2020, Maxim Lihachev, +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation, version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +: <<'MAN' + +=head1 NAME + +kubectl-ingress is a wrapper for I<`kubectl get ingress'> command which makes links clickable. + +=head1 USAGE + +kubectl ingress [standard kubectl selectors] + +=head1 BUGS + +If you find a bug, please report it at B>. + +=head1 AUTHORS + +envrm B>. + +=cut +MAN + +echo -e "$(sed 's!(([[:alpha:]](-?[[:alnum:]])*)\.)+[[:alpha:]]{2,}!\\e]8;;http://\0\\e\\\\\0\\e]8;;\\e\\!g; + s!((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])!\\e]8;;http://\0\\e\\\\\0\\e]8;;\\e\\!g +' -r <<<"$(kubectl get ingress "$@")")" + diff --git a/scripts/kubectl-secret b/scripts/kubectl-secret new file mode 100755 index 0000000..12037b3 --- /dev/null +++ b/scripts/kubectl-secret @@ -0,0 +1,104 @@ +#!/usr/bin/env bash + +# +# Copyright (C) 2020, Maxim Lihachev, +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation, version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +: <<'MAN' +=head1 NAME + +kubectl-secret is a wrapper for I<`kubectl get secret'> to decoding secrets automatically. + +=head1 USAGE + +kubectl secret [-h|-d|-s] [standard kubectl selectors] + +=head1 OPTIONS + + -h --help = show this help + -s --simple = show only secrets + -d --decode = show decoded data as plain text (by default it shows under the link) + +=head1 BUGS + +If you find a bug, please report it at B>. + +=head1 AUTHORS + +envrm B>. + +=cut +MAN + +usage() { + sed -E -n '/^.*MAN/,/^MAN$/{//!p;}; /^MAN$/q' "$0" | sed -E 's/=head. |[LIBC]<|\b>*//g; /=cut/d' + + exit "${1:-0}" +} + +KUBECTL_ARGS=() + +while [[ $# -gt 0 ]]; do + key="$1" + + case $key in + -h|--help) usage 0;; + -d|--decode) DECODE=true; shift;; + -s|--simple) SIMPLE=true; shift;; + *) KUBECTL_ARGS+=("$1"); shift;; + esac +done + +set -- "${KUBECTL_ARGS[@]}" + +#------------------------------------------------------------------------------- + +MANIFEST=$(kubectl get secret "${KUBECTL_ARGS[@]}" -o yaml) + +#------------------------------------------------------------------------------- + +if grep -E -q '^kind: List' <<<"$MANIFEST"; then + DELIMITER=" " +else + DELIMITER=" " +fi + +IFS=$'\n' + +REGEX_DATA="^${DELIMITER/ /}data:" +REGEX_SECRET="^${DELIMITER}[[:print:]]+:[[:space:]]+.*$" + +while read -r line; do + if [[ "$line" =~ $REGEX_DATA ]]; then + DATA=1 + elif [[ "$DATA" -eq 1 ]] && [[ "$line" =~ $REGEX_SECRET ]]; then + secret=${line//[[:space:]]/} + key=${secret/:*} + value=${secret/*:} + + if [ "$DECODE" == "true" ]; then + echo -e "${DELIMITER}${key}: $(base64 -d <<<"$value")" + else + echo -e "${DELIMITER}${key}: \e]8;;$(base64 -d <<<"$value")\e\\\\${value}\e]8;;\e\\" + fi + + continue + else + DATA=0 + fi + + [ "$SIMPLE" != "true" ] && echo "$line" +done <<<"$MANIFEST" + diff --git a/scripts/kubectl-secrets b/scripts/kubectl-secrets new file mode 120000 index 0000000..a5be89c --- /dev/null +++ b/scripts/kubectl-secrets @@ -0,0 +1 @@ +kubectl-secret \ No newline at end of file