-
Notifications
You must be signed in to change notification settings - Fork 1
/
TIPS FOR EXAM
115 lines (77 loc) · 2.72 KB
/
TIPS FOR EXAM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
kubectl run pod1 --image nginx --labels='app=mohan,env=prod'
kubectl expose pod pod1 --port=80 --name=svc1 --type=NodePort --dry-run=client -o yaml > expose.yaml
clean every thing on the server
kubectl delete all --all
kubectl get all
kubectl get all -A
get pod in all namespaces
kubectl get pod --all-namespaces
get pod with labels
kubectl get pod --show-labels
aliases
Kubectl Autocomplete (from K8S cheatsheet)
BASH
source <(kubectl completion bash) # setup autocomplete in bash into the current shell, bash-completion package should be installed first.
echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.
alias k=kubectl
complete -F __start_kubectl k
alias k=kubectl
alias kgp='kubectl get pods -o wide'
alias kgs='kubectl get svc -o wide'
alias kgd='kubectl get deploy -o wide'
alias kdp='kubectl describe pod'
alias kdd='kubectl describe deploy'
alias kds='kubectl describe svc'
export gen="--dry-run=client -o yaml"
alias kdn='kubectl describe node'
alias kgn='kubectl get nodes -o wide'
I find useful the below lines:
alias k=kubectl
source <(k completion bash)
source <(k completion bash | sed s/kubectl/k/g)
vi ~/.vimrc
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab ruler incsearch
set number
set ignorecase
set backspace=indent,eol,start
set cursorline
set list
here is my .vimrc file, hope it will be helpful.
syntax enable
set tabstop=2 " number of visual spaces per TAB
set softtabstop=2 " number of spaces in tab when editing
set expandtab " tabs = spaces
set number " show line numbers
set cursorline " highlight the current line
set showcmd " show command in bottom bar
filetype indent on " load filetype specific indent files in ~/.vim/indent/*.vim
set wildmenu
set lazyredraw
set showmatch " show matches of {} [] ()
set incsearch " search as characters are entered
set hlsearch " highlight matches
set ignorecase " ignore upper/lower case when searching
let mapleader = "," " leader is comma
" turn off search highlight, mapping to ,<space>
nnoremap <leader><space> :nohlsearch<CR>
set backspace=indent,eol,start " allows backspace to delete words
Enable the kubelet autocomplete
source <(kubectl completion bash) # setup autocomplete in bash into the current shell, bash-completion package should be installed first.
echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.
alias k=kubectl
complete -F __start_kubectl k
kubectl label nodes node1 room=103
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
containers:
- name: nginx
image: nginx
imagePullPolicy: IfNotPresent
nodeSelector:
room: "103"
kubectl apply -f pod.yaml