cube

command module
v0.0.0-...-77b1a84 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2023 License: MIT Imports: 1 Imported by: 0

README

* cube

=kubectl= configuration manipulation tool.

Features
- Merge ~kubeconfig~ from local file
- Merge remote ~kubeconfig~ and access remote cluster via jumper ssh server

** Prerequisite

=cube= depends on =ssh tunnel= for communication with remote cluster. Make sure
following files are correctly set.
- =~/.ssh/config=
- and =/etc/hosts=

*** =~/.ssh/config=

#+begin_src shell
  # add SSH dynamic port forwarding, where `SSH_VIA` is in the format of "<user>@<public-ip>"
  # alias aws_proxy='ssh -qTfnN -D 127.0.0.1:62222 ${SSH_VIA}'

  # Rules for Remote
  Host [remote/private/ip/range(e.g. 172.31.*)]
   ProxyCommand /usr/bin/nc -X 4 -x 127.0.0.1:62222 %h %p
   StrictHostKeyChecking no
   UserKnownHostsFile=/dev/null
   user core
   IdentityFile [/path/to/pem/file]
   LogLevel ERROR

#+end_src

*** =/etc/hosts=

#+begin_src shell
  # add following line to /etc/hosts
  # to access AWS k8s cluster by SSH tunnel
  sudo echo "127.0.0.1	kubernetes" >> /etc/hosts
#+end_src


** Install

For Go =1.17+=
#+begin_src shell
  go install git.sr.ht/~shohi/cube@latest
#+end_src

For Go =1.17-=
#+begin_src shell
  go get -u git.sr.ht/~shohi/cube
#+end_src

** Usage

*** Help

#+begin_src shell
  $> cube --help
  kubectl config manipulation tool

  Usage:
    cube [command]

  Available Commands:
    add         add remote cluster to kube config
    delete      delete kubectl config for specified cluster
    forward     run local ssh port forwarding for remote cluster
    help        Help about any command
    history     show cube commands history
    list        list all clusters
    merge       Merge kube config
    show        show local kubectl config
    version     print version info

  Flags:
    -h, --help   help for cube

  Use "cube [command] --help" for more information about a command.
#+end_src

*** Merge Local Config File

Please make sure cluster name is unique in merged =~/.cube/config=.

#+begin_src shell
  cube merge --path /path/to/local/kubeconfig
#+end_src

*** Merge Remote Config File

Remote ~kubeconfig~ is fetched via jumper ssh server, please do check ~ssh
tunnel~ is correctly established.

#+begin_src shell
  cube add \
       --remote-ip <ip> \
       --remote-user <user> \
       --local-port <local-port> \
       --name-suffix <local-name-suffix> \
       --ssh-via <jumper-ssh-server>
#+end_src


*** Cluster Switch

use [[https://github.com/ahmetb/kubectx][kubectx]] to switch cluster

#+begin_src shell
  $> kubectx
#+end_src

*** Docker

#+begin_src shell
  # build docker image
  docker build -t cube:0.1.0 .

  # run container
  docker run --rm -it \
      -v $PWD/.ssh:/root/.ssh \
      -v $PWD/.kube:/root/.kube \
      cube:0.1.0
#+end_src


** Note
1. =cube= leverages =SSH= and =SCP= to transfer files from remote cluster. Make
   sure SSH correctly configured.

2. Only AWS cluster is supported now.

** FAQ

1. channel 2: open failed: connect failed: Connection refused
   #+begin_src shell
     > make sure the target service is up and running
   #+end_src

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
add
del
pkg
log
scp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL