-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path25-KUBECONFIG
74 lines (62 loc) · 2.23 KB
/
25-KUBECONFIG
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
--------------------------------------------------------------------------
KUBECONFIG
if we specify details in file $HOME/.kube/config, then we dont need to specify kubeconfig in command
example kubeconfig file -
apiVersion: v1
kind: config
clusters:
- name: kube-api-server<this is name of the config>
cluster:
certificate-authority: ca.crt
server: https://kube-api-server:6443
contexts:
- name: my-kube-admin@kube-api-server
context:
cluster: kube-api-server
user: my-kube-admin
users:
- name: my-kube-admin
user:
client-certificate: admin.crt
client-key: admin.key
example config file with multiple clusters,users,contexts -
apiVersion: v1
kind: config
current-context: dev-user@google < this mean kubectl will always user dev-user to access google cluster >
clusters:
- name: kube-api-server<this is name of the config>
cluster:
certificate-authority: ca.crt
server: https://kube-api-server:6443
- name: development
cluster:
certificate-authority: dev-ca.crt
server: https://development:6443
contexts:
- name: my-kube-admin@kube-api-server
context:
cluster: kube-api-server
user: my-kube-admin
- name: dev-user@google
context:
cluster: development
user: dev-user
namespace: finance
users:
- name: my-kube-admin
user:
client-certificate: admin.crt
client-key: admin.key
- name: dev-user
user:
client-certificate: dev.crt
client-key: dev.key
command to view the current config file thats being used - kubectl config view
command to view custom config - kubectl config view --kubeconfig=my-custom-config
command to change the context while access different cluster - kubectl config use-context my-kube-admin@kube-api-server - this will change the cureent-context in the kubeconfig file
use this command to know more option - kubectl config -h
NOTE- instead of certificate file, we can also specify the certificate data
convert the certificate data in base64 encoaed using command - cat ca.crt | base64 | tr -d \\n
use certificate-authority-data instead of certificate-authority
ex - certificate-authority-data: <base64 encoaded certificate>
--------------------------------------------------------------------------