Skip to content

extremenetworks/teleport-alias

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

teleport-alias

The alias are for easy use kubectl -n namespace xxx to access kubernetes clusters

First you need add alias into Git repo for each of kubernetes cluster. The alias *.sh name convention as: load_alias_{cluster_name}-{gdc/rdc}.sh

Usage

Linux & macOS Setup

  1. Set Up the `tkl`` function Alias: Add the following line to your ~/.zshrc (for zsh) or ~/.bashrc (for bash). If using ~/.bash_profile, add it there instead.

    tkl() {
      # Unset any existing Teleport session context so you can switch clusters
      eval $(tsh env --unset)
      
      # Update your alias repository, cloning if necessary
      git -C ~/.my_private_alias_repo pull >/dev/null 2>&1 || \
        git clone git@github.com:extremenetworks/teleport-alias.git ~/.my_private_alias_repo
      
      # Load the appropriate alias loader with any passed arguments
      source ~/.my_private_alias_repo/alias_loader.sh "$@"
    }
    
  2. Apply the Changes: Run:

    source ~/.zshrc  # For zsh
    source ~/.bashrc  # For bash
  3. **Use the tkl`` Alias**: Use the tkl` alias to load aliases and login to the cluster:

    tkl eu0-gdc
    tkl stage-rdc
  4. Validate Aliases: Once the script completes, aliases will be available in your shell. For example:

    alias
    tsh status
    tsh kube ls
    k get pod

Windows Setup Windows users can use Git Bash, PowerShell, or Windows Subsystem for Linux (WSL). Using Git Bash

  1. Open Git Bash. Edit ~/.bashrc (or ~/.bash_profile) using:
    nano ~/.bashrc
  2. Add the function of alias
    tkl() {
      # Unset any existing Teleport session context so you can switch clusters
      eval $(tsh env --unset)
      
      # Update your alias repository, cloning if necessary
      git -C ~/.my_private_alias_repo pull >/dev/null 2>&1 || \
        git clone git@github.com:extremenetworks/teleport-alias.git ~/.my_private_alias_repo
      
      # Load the appropriate alias loader with any passed arguments
      source ~/.my_private_alias_repo/alias_loader.sh "$@"
    }
  3. Apply changes
    source ~/.bashrc
  4. User tkl
    tkl eu0-gdc
    tkl stage-rdc
  5. Validate Aliases: Once the script completes, aliases will be available in your shell. For example:
    alias
    tsh status
    tsh kube ls
    k get pod

About

We'll add alias access each of kubernetes clusters

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages