Skip to content

Instantly share code, notes, and snippets.

@tamas-molnar
Last active October 9, 2025 01:43
Show Gist options
  • Save tamas-molnar/32a07c0eb83e95484e3cdb4b7fada32b to your computer and use it in GitHub Desktop.
Save tamas-molnar/32a07c0eb83e95484e3cdb4b7fada32b to your computer and use it in GitHub Desktop.

Revisions

  1. tamas-molnar revised this gist May 14, 2018. 1 changed file with 0 additions and 6 deletions.
    6 changes: 0 additions & 6 deletions kubectl-shortcuts.sh
    Original file line number Diff line number Diff line change
    @@ -138,12 +138,6 @@ function kcstat() {
    echo -e "$(kubectl describe node $node | grep -A 4 "Allocated resources")\n";
    done
    }
    function kcreach(){
    for public_ip in $(kubectl get nodes -o wide | tail -n +2 | awk '{print $4}'); do
    echo $public_ip
    echo -e "$(ssh core@$public_ip date)\n"
    done
    }
    function kcready() {
    for node in $(kubectl get nodes | tail -n +2 | awk '{print $1}'); do
    echo $node
  2. tamas-molnar revised this gist May 14, 2018. 1 changed file with 48 additions and 1 deletion.
    49 changes: 48 additions & 1 deletion kubectl-shortcuts.sh
    Original file line number Diff line number Diff line change
    @@ -15,8 +15,10 @@ alias kcre='kubectl get pod | sort -nk 4 | grep -v "Running 0"'
    alias kcrey='kubectl get pod | sort -nk 4 | grep -v "Running 0\|NAME" | cut -d" " -f1 | xargs -i kubectl describe pod {} | grep "Reason\|^Name:\|Finished"'
    alias kcall='kubectl get nodes --no-headers | awk '\''{print $1}'\'' | xargs -I {} sh -c '\''echo {} ; kubectl describe node {} | grep Allocated -A 5 | grep -ve Event -ve Allocated -ve percent -ve -- ; echo '\'''
    alias hd='helm list --deployed | grep -v "NAME" | awk '\''{print $1}'\'' | sort | uniq -c | awk '\''{print $1,$2}'\'' | grep -v "^1 "'

    function hl() { helm list $@; }
    function hh() { helm history $(helm list -q $@); }
    function gcm() { kubectl get configmap $@ -o yaml; }
    function kclfl() { kubectl logs --tail=$@ -f; }
    function kcpf() {
    result=$(kubectl get pod | grep -m1 $@)
    @@ -39,6 +41,16 @@ function kclfa() {
    read -n 1 -p "Press any key for logs of ${result[0]} and ${result[5]}"
    (kubectl logs --tail=10 -f ${result[0]} & kubectl logs --tail=10 -f ${result[5]} &) | tee
    }
    function kclff(){
    result=($(kubectl get pod | grep $1))
    exitCode=$?
    if [ ! "$exitCode" -eq 0 ]; then
    echo "Could not find pod matching [$@]."
    return 1;
    fi
    echo "Showing logs for ${result[0]}"
    kubectl logs --tail=200 -f ${result[0]}
    }
    function kcops(){
    kubectl proxy &
    docker run -it --net=host hjacobs/kube-ops-view &
    @@ -50,6 +62,41 @@ function kcfd() { kubectl get deployment -o wide | grep $@; }
    function kcxsh() { kubectl exec -ti $@ sh; }
    function kcxbash() { kubectl exec -ti $@ bash; }
    function kcph() { kubectl exec -ti $@ -- sh -c 'apk -q update; apk add -q curl jq; curl localhost:8080/__health | jq'; }
    function kcstop() {
    echo "Stopping $1"
    desired_replicas=$(kubectl get deployments --selector=app=$1 -o jsonpath='{$.items[0].spec.replicas}');
    kubectl scale --replicas=0 deployments/$1;
    current_replicas=$(kubectl get deployments --selector=app=$1 -o jsonpath='{$.items[0].status.availableReplicas}')
    while [ ! -z "$current_replicas" ]; do
    sleep 1;
    current_replicas=$(kubectl get deployments --selector=app=$1 -o jsonpath='{$.items[0].status.availableReplicas}')
    done;
    echo "Stopped [$desired_replicas] instances of $1."
    return $desiredReplicas
    }
    function kcstart() {
    echo "Scaling deployment $1 up to $2 replicas...";
    kubectl scale --replicas=$2 deployments/$1;
    if [ "$3" == "skipCheck" ]; then
    echo "Skipping healthchecks"
    return
    fi
    default_sleep=10
    initial_sleep=$(kubectl get deployments --selector=app=$1 -o jsonpath='{$.items[0].spec.template.spec.containers[0].readinessProbe.initialDelaySeconds}')
    initial_sleep=${initial_sleep:-10}
    echo "Waiting $initial_sleep seconds for the first readiness probe check..."
    sleep $initial_sleep
    period_sleep=$(kubectl get deployments --selector=app=$1 -o jsonpath='{$.items[0].spec.template.spec.containers[0].readinessProbe.periodSeconds}')
    period_sleep=${period_sleep:-10}
    while [ "$current_replicas" != "$2" ]; do
    echo "Waiting $period_sleep seconds until checking the node count"
    sleep $period_sleep
    current_replicas=$(kubectl get deployments --selector=app=$1 -o jsonpath='{$.items[0].status.availableReplicas}')
    current_replicas=${current_replicas:-0}
    echo "Current nr of replicas: $current_replicas"
    done;
    echo "$1 restarted"
    }
    function kcres() {
    echo "Scaling $1"
    desired_replicas=$(kubectl get deployments --selector=app=$1 -o jsonpath='{$.items[0].spec.replicas}');
    @@ -102,4 +149,4 @@ function kcready() {
    echo $node
    echo -e "$(kubectl describe node $node | grep "Ready")\n";
    done
    }
    }
  3. tamas-molnar revised this gist Mar 20, 2018. 1 changed file with 0 additions and 6 deletions.
    6 changes: 0 additions & 6 deletions kubectl-shortcuts.sh
    Original file line number Diff line number Diff line change
    @@ -17,13 +17,7 @@ alias kcall='kubectl get nodes --no-headers | awk '\''{print $1}'\'' | xargs -I
    alias hd='helm list --deployed | grep -v "NAME" | awk '\''{print $1}'\'' | sort | uniq -c | awk '\''{print $1,$2}'\'' | grep -v "^1 "'
    function hl() { helm list $@; }
    function hh() { helm history $(helm list -q $@); }
    function gc() { kubectl get configmap global-config -o yaml; }
    function gcf() { kubectl get configmap global-config -o yaml | grep $@; }
    function gs() { kubectl get secret global-secrets -o yaml; }
    function gsf() { kubectl get secret global-secrets -o yaml | grep $@; }
    function gcm() { kubectl get configmap $@ -o yaml; }
    function kclfl() { kubectl logs --tail=$@ -f; }
    function kcgcf() { kubectl get configmap global-config -o yaml | grep $@; }
    function kcpf() {
    result=$(kubectl get pod | grep -m1 $@)
    exitCode=$?
  4. tamas-molnar revised this gist Mar 20, 2018. 1 changed file with 41 additions and 19 deletions.
    60 changes: 41 additions & 19 deletions kubectl-shortcuts.sh
    Original file line number Diff line number Diff line change
    @@ -10,19 +10,52 @@ alias kcdd='kubectl describe deployment'
    alias kcdf='kubectl delete -f'
    alias kcaf='kubectl apply -f'
    alias kcci='kubectl cluster-info'

    function kcpp() {
    kcgp | grep $@ | head -1 | awk '{ print $1}' | xargs -i kubectl port-forward {} 8080:8080 > /dev/null 2>&1 &
    sleep 2;
    xdg-open http://localhost:8080/__health > /dev/null 2>&1;
    alias kcbad='kubectl get pod | grep "0\/"'
    alias kcre='kubectl get pod | sort -nk 4 | grep -v "Running 0"'
    alias kcrey='kubectl get pod | sort -nk 4 | grep -v "Running 0\|NAME" | cut -d" " -f1 | xargs -i kubectl describe pod {} | grep "Reason\|^Name:\|Finished"'
    alias kcall='kubectl get nodes --no-headers | awk '\''{print $1}'\'' | xargs -I {} sh -c '\''echo {} ; kubectl describe node {} | grep Allocated -A 5 | grep -ve Event -ve Allocated -ve percent -ve -- ; echo '\'''
    alias hd='helm list --deployed | grep -v "NAME" | awk '\''{print $1}'\'' | sort | uniq -c | awk '\''{print $1,$2}'\'' | grep -v "^1 "'
    function hl() { helm list $@; }
    function hh() { helm history $(helm list -q $@); }
    function gc() { kubectl get configmap global-config -o yaml; }
    function gcf() { kubectl get configmap global-config -o yaml | grep $@; }
    function gs() { kubectl get secret global-secrets -o yaml; }
    function gsf() { kubectl get secret global-secrets -o yaml | grep $@; }
    function gcm() { kubectl get configmap $@ -o yaml; }
    function kclfl() { kubectl logs --tail=$@ -f; }
    function kcgcf() { kubectl get configmap global-config -o yaml | grep $@; }
    function kcpf() {
    result=$(kubectl get pod | grep -m1 $@)
    exitCode=$?
    if [ ! "$exitCode" -eq 0 ]; then
    echo "Could not find pod matching [$@]."
    return 1;
    fi
    podName=$(echo $result | awk '{print $1}')
    echo "Forwarding port 8080 of $podName to local port 8080"
    kubectl port-forward $podName 8080:8080
    }

    function kclfa() {
    result=($(kubectl get pod | grep $@))
    exitCode=$?
    if [ ! "$exitCode" -eq 0 ]; then
    echo "Could not find pod matching [$@]."
    return 1;
    fi
    read -n 1 -p "Press any key for logs of ${result[0]} and ${result[5]}"
    (kubectl logs --tail=10 -f ${result[0]} & kubectl logs --tail=10 -f ${result[5]} &) | tee
    }
    function kcops(){
    kubectl proxy &
    docker run -it --net=host hjacobs/kube-ops-view &
    xdg-open http://localhost:8080 &
    }
    function kcfp() { kubectl get pod -o wide| grep $@; }
    function kcfs() { kubectl get service -o wide| grep $@; }
    function kcfd() { kubectl get deployment -o wide | grep $@; }
    function kcssh() { ssh -A core@$(kubectl get node -o wide | grep $@ | awk '{ print $4}'); }
    function kcxsh() { kubectl exec -ti $@ sh; }
    function kcxbash() { kubectl exec -ti $@ bash; }
    function kcph() { kubectl exec -ti $@ -- sh -c 'apk -q update; apk add -q curl jq; curl localhost:8080/__health | jq'; }
    function kcres() {
    echo "Scaling $1"
    desired_replicas=$(kubectl get deployments --selector=app=$1 -o jsonpath='{$.items[0].spec.replicas}');
    @@ -57,7 +90,7 @@ function kcres() {
    done;
    echo "$1 restarted"
    }
    function kcgnt() { for machine in $(kcgn | tail -n +2 | awk '{ print $1 }' ); do echo -n "${machine}: "; echo $(kc describe node $machine | grep -i taints); done | sort -k 2; }
    function kcgnt() { for machine in $(kcgn | tail -n +2 | awk '{ print $1 }' ); do echo -n "${machine}: "; echo $(kc describe node $machine | grep -i "node-role\|role="); done | sort -k 2; }
    function kcstat() {
    for node in $(kubectl get nodes | tail -n +2 | awk '{print $1}'); do
    echo $node
    @@ -76,14 +109,3 @@ function kcready() {
    echo -e "$(kubectl describe node $node | grep "Ready")\n";
    done
    }


    export PS1="[\W]\[\033[0;33m\][\t]\[\033[0;31m\][\${FLEETCTL_TUNNEL%-tunnel-up.ft.com}][\${KUBE_ENV}]\[\033[0m\]\$ "

    . ~/services_autocomplete.sh

    source <(kubectl completion bash)

    export FT_K8S_CONFIG_FOLDER=your-folder-here
    alias k8s-del='export KUBECONFIG=$FT_K8S_CONFIG_FOLDER/kubeconfig; export KUBE_ENV=k8s-delivery'
    alias k8s-pub='export KUBECONFIG=$FT_K8S_CONFIG_FOLDER/kubeconfig-pub; export KUBE_ENV=k8s-pub'
  5. tamas-molnar revised this gist Sep 13, 2017. 1 changed file with 53 additions and 32 deletions.
    85 changes: 53 additions & 32 deletions kubectl-shortcuts.sh
    Original file line number Diff line number Diff line change
    @@ -11,12 +11,11 @@ alias kcdf='kubectl delete -f'
    alias kcaf='kubectl apply -f'
    alias kcci='kubectl cluster-info'

    # forwards port 8080 of the first pod to match the query to local port 8080, then opens a browser to the health endpoint
    function kcpp() {
    kcgp | grep $@ | head -1 | awk '{ print $1}' | xargs -i kubectl port-forward {} 8080:8080 > /dev/null 2>&1 &
    sleep 2;
    xdg-open http://localhost:8080/__health > /dev/null 2>&1;
    }
    kcgp | grep $@ | head -1 | awk '{ print $1}' | xargs -i kubectl port-forward {} 8080:8080 > /dev/null 2>&1 &
    sleep 2;
    xdg-open http://localhost:8080/__health > /dev/null 2>&1;
    }

    function kcfp() { kubectl get pod -o wide| grep $@; }
    function kcfs() { kubectl get service -o wide| grep $@; }
    @@ -25,44 +24,66 @@ function kcssh() { ssh -A core@$(kubectl get node -o wide | grep $@ | awk '{ pri
    function kcxsh() { kubectl exec -ti $@ sh; }
    function kcxbash() { kubectl exec -ti $@ bash; }
    function kcres() {
    desired_replicas=$(kubectl get deployments --selector=app=$@ -o jsonpath='{$.items[0].spec.replicas}');
    echo "Desired nf or replicas: $desired_replicas";
    echo "Scaling deployment $@ down to 0 replicas...";
    kubectl scale --replicas=0 deployments/$@;
    current_replicas=$(kubectl get deployments --selector=app=$@ -o jsonpath='{$.items[0].status.availableReplicas}')
    while [ ! -z "$current_replicas" ]; do
    sleep 1;
    current_replicas=$(kubectl get deployments --selector=app=$@ -o jsonpath='{$.items[0].status.availableReplicas}')
    done;
    echo "Scaling deployment $@ up to $desired_replicas replicas...";
    kubectl scale --replicas=$desired_replicas deployments/$@;
    default_sleep=10
    initial_sleep=$(kubectl get deployments --selector=app=$@ -o jsonpath='{$.items[0].spec.template.spec.containers[0].readinessProbe.initialDelaySeconds}')
    initial_sleep=${initial_sleep:-10}
    echo "Waiting $initial_sleep seconds for the first readiness probe check..."
    echo "Scaling $1"
    desired_replicas=$(kubectl get deployments --selector=app=$1 -o jsonpath='{$.items[0].spec.replicas}');
    echo "Desired nf or replicas: $desired_replicas";
    echo "Scaling deployment $1 down to 0 replicas...";
    kubectl scale --replicas=0 deployments/$1;
    current_replicas=$(kubectl get deployments --selector=app=$1 -o jsonpath='{$.items[0].status.availableReplicas}')
    while [ ! -z "$current_replicas" ]; do
    sleep 1;
    current_replicas=$(kubectl get deployments --selector=app=$1 -o jsonpath='{$.items[0].status.availableReplicas}')
    done;
    echo "Scaling deployment $1 up to $desired_replicas replicas...";
    kubectl scale --replicas=$desired_replicas deployments/$1;
    if [ "$2" == "skipCheck" ]; then
    echo "Skipping healthchecks"
    return
    fi

    default_sleep=10
    initial_sleep=$(kubectl get deployments --selector=app=$1 -o jsonpath='{$.items[0].spec.template.spec.containers[0].readinessProbe.initialDelaySeconds}')
    initial_sleep=${initial_sleep:-10}
    echo "Waiting $initial_sleep seconds for the first readiness probe check..."
    sleep $initial_sleep
    while [ "$current_replicas" != "$desired_replicas" ]; do
    current_replicas=$(kubectl get deployments --selector=app=$@ -o jsonpath='{$.items[0].status.availableReplicas}')
    period_sleep=$(kubectl get deployments --selector=app=$1 -o jsonpath='{$.items[0].spec.template.spec.containers[0].readinessProbe.periodSeconds}')
    period_sleep=${period_sleep:-10}
    while [ "$current_replicas" != "$desired_replicas" ]; do
    echo "Waiting $period_sleep seconds until checking the node count"
    sleep $period_sleep
    current_replicas=$(kubectl get deployments --selector=app=$1 -o jsonpath='{$.items[0].status.availableReplicas}')
    current_replicas=${current_replicas:-0}
    echo "Current nr of replicas: $current_replicas"
    sleep 1
    done;
    echo "$@ restarted"
    echo "$1 restarted"
    }

    function kcgnt() { for machine in $(kcgn | tail -n +2 | awk '{ print $1 }' ); do echo -n "${machine}: "; echo $(kc describe node $machine | grep -i taints); done | sort -k 2; }

    function kcstat() {
    for node in $(kubectl get nodes | tail -n +2 | awk '{print $1}'); do
    echo $node
    echo -e "$(kubectl describe node $node | grep -A 4 "Allocated resources")\n";
    done
    for node in $(kubectl get nodes | tail -n +2 | awk '{print $1}'); do
    echo $node
    echo -e "$(kubectl describe node $node | grep -A 4 "Allocated resources")\n";
    done
    }

    function kcreach(){
    for public_ip in $(kubectl get nodes -o wide | tail -n +2 | awk '{print $4}'); do
    for public_ip in $(kubectl get nodes -o wide | tail -n +2 | awk '{print $4}'); do
    echo $public_ip
    echo -e "$(ssh core@$public_ip date)\n"
    done
    }
    function kcready() {
    for node in $(kubectl get nodes | tail -n +2 | awk '{print $1}'); do
    echo $node
    echo -e "$(kubectl describe node $node | grep "Ready")\n";
    done
    }


    export PS1="[\W]\[\033[0;33m\][\t]\[\033[0;31m\][\${FLEETCTL_TUNNEL%-tunnel-up.ft.com}][\${KUBE_ENV}]\[\033[0m\]\$ "

    . ~/services_autocomplete.sh

    source <(kubectl completion bash)

    export FT_K8S_CONFIG_FOLDER=your-folder-here
    alias k8s-del='export KUBECONFIG=$FT_K8S_CONFIG_FOLDER/kubeconfig; export KUBE_ENV=k8s-delivery'
    alias k8s-pub='export KUBECONFIG=$FT_K8S_CONFIG_FOLDER/kubeconfig-pub; export KUBE_ENV=k8s-pub'
  6. tamas-molnar revised this gist May 23, 2017. 1 changed file with 0 additions and 6 deletions.
    6 changes: 0 additions & 6 deletions kubectl-shortcuts.sh
    Original file line number Diff line number Diff line change
    @@ -18,12 +18,6 @@ function kcpp() {
    xdg-open http://localhost:8080/__health > /dev/null 2>&1;
    }

    function kcneo() {
    kcgp | grep ^neo4j | head -1 | awk '{ print $1}' | xargs -i kubectl port-forward {} 7474:7474 > /dev/null 2>&1 &
    sleep 2;
    xdg-open http://localhost:7474/browser > /dev/null 2>&1;
    }

    function kcfp() { kubectl get pod -o wide| grep $@; }
    function kcfs() { kubectl get service -o wide| grep $@; }
    function kcfd() { kubectl get deployment -o wide | grep $@; }
  7. tamas-molnar revised this gist May 11, 2017. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions kubectl-shortcuts.sh
    Original file line number Diff line number Diff line change
    @@ -58,4 +58,17 @@ function kcres() {

    function kcgnt() { for machine in $(kcgn | tail -n +2 | awk '{ print $1 }' ); do echo -n "${machine}: "; echo $(kc describe node $machine | grep -i taints); done | sort -k 2; }

    function kcstat() {
    for node in $(kubectl get nodes | tail -n +2 | awk '{print $1}'); do
    echo $node
    echo -e "$(kubectl describe node $node | grep -A 4 "Allocated resources")\n";
    done
    }

    function kcreach(){
    for public_ip in $(kubectl get nodes -o wide | tail -n +2 | awk '{print $4}'); do
    echo $public_ip
    echo -e "$(ssh core@$public_ip date)\n"
    done
    }

  8. tamas-molnar revised this gist Apr 28, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions kubectl-shortcuts.sh
    Original file line number Diff line number Diff line change
    @@ -56,4 +56,6 @@ function kcres() {
    echo "$@ restarted"
    }

    function kcgnt() { for machine in $(kcgn | tail -n +2 | awk '{ print $1 }' ); do echo -n "${machine}: "; echo $(kc describe node $machine | grep -i taints); done | sort -k 2; }


  9. tamas-molnar revised this gist Apr 26, 2017. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion kubectl-shortcuts.sh
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,6 @@ function kcfd() { kubectl get deployment -o wide | grep $@; }
    function kcssh() { ssh -A core@$(kubectl get node -o wide | grep $@ | awk '{ print $4}'); }
    function kcxsh() { kubectl exec -ti $@ sh; }
    function kcxbash() { kubectl exec -ti $@ bash; }

    function kcres() {
    desired_replicas=$(kubectl get deployments --selector=app=$@ -o jsonpath='{$.items[0].spec.replicas}');
    echo "Desired nf or replicas: $desired_replicas";
    @@ -43,14 +42,18 @@ function kcres() {
    done;
    echo "Scaling deployment $@ up to $desired_replicas replicas...";
    kubectl scale --replicas=$desired_replicas deployments/$@;
    default_sleep=10
    initial_sleep=$(kubectl get deployments --selector=app=$@ -o jsonpath='{$.items[0].spec.template.spec.containers[0].readinessProbe.initialDelaySeconds}')
    initial_sleep=${initial_sleep:-10}
    echo "Waiting $initial_sleep seconds for the first readiness probe check..."
    sleep $initial_sleep
    while [ "$current_replicas" != "$desired_replicas" ]; do
    current_replicas=$(kubectl get deployments --selector=app=$@ -o jsonpath='{$.items[0].status.availableReplicas}')
    current_replicas=${current_replicas:-0}
    echo "Current nr of replicas: $current_replicas"
    sleep 1
    done;
    echo "$@ restarted"
    }


  10. tamas-molnar renamed this gist Apr 12, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  11. tamas-molnar revised this gist Apr 12, 2017. 1 changed file with 23 additions and 0 deletions.
    23 changes: 23 additions & 0 deletions kubectl-shortcuts
    Original file line number Diff line number Diff line change
    @@ -31,3 +31,26 @@ function kcssh() { ssh -A core@$(kubectl get node -o wide | grep $@ | awk '{ pri
    function kcxsh() { kubectl exec -ti $@ sh; }
    function kcxbash() { kubectl exec -ti $@ bash; }

    function kcres() {
    desired_replicas=$(kubectl get deployments --selector=app=$@ -o jsonpath='{$.items[0].spec.replicas}');
    echo "Desired nf or replicas: $desired_replicas";
    echo "Scaling deployment $@ down to 0 replicas...";
    kubectl scale --replicas=0 deployments/$@;
    current_replicas=$(kubectl get deployments --selector=app=$@ -o jsonpath='{$.items[0].status.availableReplicas}')
    while [ ! -z "$current_replicas" ]; do
    sleep 1;
    current_replicas=$(kubectl get deployments --selector=app=$@ -o jsonpath='{$.items[0].status.availableReplicas}')
    done;
    echo "Scaling deployment $@ up to $desired_replicas replicas...";
    kubectl scale --replicas=$desired_replicas deployments/$@;
    initial_sleep=$(kubectl get deployments --selector=app=$@ -o jsonpath='{$.items[0].spec.template.spec.containers[0].readinessProbe.initialDelaySeconds}')
    echo "Waiting $initial_sleep seconds for the first readiness probe check..."
    sleep $initial_sleep
    while [ "$current_replicas" != "$desired_replicas" ]; do
    current_replicas=$(kubectl get deployments --selector=app=$@ -o jsonpath='{$.items[0].status.availableReplicas}')
    echo "Current nr of replicas: $current_replicas"
    sleep 1
    done;
    echo "$@ restarted"
    }

  12. tamas-molnar revised this gist Mar 31, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions kubectl-shortcuts
    Original file line number Diff line number Diff line change
    @@ -28,4 +28,6 @@ function kcfp() { kubectl get pod -o wide| grep $@; }
    function kcfs() { kubectl get service -o wide| grep $@; }
    function kcfd() { kubectl get deployment -o wide | grep $@; }
    function kcssh() { ssh -A core@$(kubectl get node -o wide | grep $@ | awk '{ print $4}'); }
    function kcxsh() { kubectl exec -ti $@ sh; }
    function kcxbash() { kubectl exec -ti $@ bash; }

  13. tamas-molnar revised this gist Mar 29, 2017. 1 changed file with 9 additions and 8 deletions.
    17 changes: 9 additions & 8 deletions kubectl-shortcuts
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    alias kc='kubectl'
    alias kclf='kubectl logs -f'
    alias kcgs='kubectl get service'
    alias kcgd='kubectl get deployment'
    alias kcgp='kubectl get pod'
    alias kcgn='kubectl get node'
    alias kclf='kubectl logs --tail=200 -f'
    alias kcgs='kubectl get service -o wide'
    alias kcgd='kubectl get deployment -o wide'
    alias kcgp='kubectl get pod -o wide'
    alias kcgn='kubectl get node -o wide'
    alias kcdp='kubectl describe pod'
    alias kcds='kubectl describe service'
    alias kcdd='kubectl describe deployment'
    @@ -24,7 +24,8 @@ function kcneo() {
    xdg-open http://localhost:7474/browser > /dev/null 2>&1;
    }

    function kcfp() { kubectl get pod | grep $@; }
    function kcfs() { kubectl get service | grep $@; }
    function kcfd() { kubectl get deployment | grep $@; }
    function kcfp() { kubectl get pod -o wide| grep $@; }
    function kcfs() { kubectl get service -o wide| grep $@; }
    function kcfd() { kubectl get deployment -o wide | grep $@; }
    function kcssh() { ssh -A core@$(kubectl get node -o wide | grep $@ | awk '{ print $4}'); }

  14. tamas-molnar revised this gist Feb 13, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions kubectl-shortcuts
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,12 @@ function kcpp() {
    xdg-open http://localhost:8080/__health > /dev/null 2>&1;
    }

    function kcneo() {
    kcgp | grep ^neo4j | head -1 | awk '{ print $1}' | xargs -i kubectl port-forward {} 7474:7474 > /dev/null 2>&1 &
    sleep 2;
    xdg-open http://localhost:7474/browser > /dev/null 2>&1;
    }

    function kcfp() { kubectl get pod | grep $@; }
    function kcfs() { kubectl get service | grep $@; }
    function kcfd() { kubectl get deployment | grep $@; }
  15. tamas-molnar revised this gist Feb 9, 2017. No changes.
  16. tamas-molnar revised this gist Feb 9, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions kubectl-shortcuts
    Original file line number Diff line number Diff line change
    @@ -11,8 +11,14 @@ alias kcdf='kubectl delete -f'
    alias kcaf='kubectl apply -f'
    alias kcci='kubectl cluster-info'

    # forwards port 8080 of the first pod to match the query to local port 8080, then opens a browser to the health endpoint
    function kcpp() {
    kcgp | grep $@ | head -1 | awk '{ print $1}' | xargs -i kubectl port-forward {} 8080:8080 > /dev/null 2>&1 &
    sleep 2;
    xdg-open http://localhost:8080/__health > /dev/null 2>&1;
    }

    function kcfp() { kubectl get pod | grep $@; }
    function kcfs() { kubectl get service | grep $@; }
    function kcfd() { kubectl get deployment | grep $@; }

  17. tamas-molnar created this gist Feb 9, 2017.
    18 changes: 18 additions & 0 deletions kubectl-shortcuts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    alias kc='kubectl'
    alias kclf='kubectl logs -f'
    alias kcgs='kubectl get service'
    alias kcgd='kubectl get deployment'
    alias kcgp='kubectl get pod'
    alias kcgn='kubectl get node'
    alias kcdp='kubectl describe pod'
    alias kcds='kubectl describe service'
    alias kcdd='kubectl describe deployment'
    alias kcdf='kubectl delete -f'
    alias kcaf='kubectl apply -f'
    alias kcci='kubectl cluster-info'

    function kcpp() {
    kcgp | grep $@ | head -1 | awk '{ print $1}' | xargs -i kubectl port-forward {} 8080:8080 > /dev/null 2>&1 &
    sleep 2;
    xdg-open http://localhost:8080/__health > /dev/null 2>&1;
    }