-
Create a File for the Script:
- Name the file
kubectl-guard
.
- Name the file
-
Change File Permissions:
- Run the command:
chmod +x kubectl-guard
.
- Run the command:
-
Update Your Shell Configuration File (e.g., ~/.zshrc):
- Open
~/.zshrc
in a text editor:vi ~/.zshrc
.
- Open
-
Add an Alias:
- Update
~/.zshrc
with the following line:alias kubectl='full-path-to/kubectl-guard'
- Replace
full-path-to
with the actual path where thekubectl-guard
script is located.
- Update
-
Save the File.
-
Close the Terminal Session:
- Close your current terminal session.
-
Start a New Terminal Session:
- Open a new terminal window to apply the changes.
- This is a small demo. Exercise caution when using it.
- Always ensure that the name of the production cluster contains the word 'prod' or you can change the variable
PROD_IDENTIFIER
.