@@ -6,28 +6,23 @@ if client want then it need private key and client certificate
6
6
7
7
## How to access the kubeconfig file on our machine
8
8
9
- ``` bash
10
- rahulxf@Rahuls-MacBook-Air-3 ~ % cd $HOME /.kube/
9
+ ``` go
10
+ rahulxf@Rahuls-MacBook-Air-3 ~ % cd $HOME/.kube / <- --
11
11
12
12
rahulxf@Rahuls-MacBook-Air-3 .kube % ls -l
13
13
total 160
14
14
drwxr-x---@ 4 rahulxf staff 128 Jan 17 22 :46 cache
15
- -rw-------@ 1 rahulxf staff 31948 Feb 17 10:48 config
15
+ -rw-------@ 1 rahulxf staff 31948 Feb 17 10 :48 config <- -- kubeconfig file
16
16
-rw-r--r-- 1 rahulxf staff 7973 Feb 4 16 :01 karmada-apiserver.config
17
17
-rw------- 1 rahulxf staff 13415 Feb 11 19 :28 karmada.config
18
18
-rw-r--r-- 1 rahulxf staff 4 Feb 17 10 :43 kubectx
19
19
drwxr-xr-x 4 rahulxf staff 128 Feb 17 10 :48 kubens
20
20
-rw-r--r-- 1 rahulxf staff 16652 Feb 2 22 :01 members.config
21
-
22
- rahulxf@Rahuls-MacBook-Air-3 .kube %
23
-
24
- rahulxf@Rahuls-MacBook-Air-3 .kube % vim config
25
- rahulxf@Rahuls-MacBook-Air-3 .kube % vim config
26
21
```
27
22
28
23
* config is the kubeconfig file
29
24
30
- ```
25
+ ``` rs
31
26
apiVersion: v1
32
27
clusters :
33
28
- cluster :
@@ -78,7 +73,14 @@ client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURLVENDQWhHZ0F
78
73
client - key - data : LS0tLS
79
74
```
80
75
76
+ Flow diagram
77
+ ----
78
+
79
+ <img width =" 929 " alt =" shapes at 25-02-20 12 40 47 " src =" https://github.com/user-attachments/assets/fee09087-1fce-4324-bf42-44f01e0464ad " />
80
+
81
+
81
82
How to add users
83
+ ----
82
84
83
85
```
84
86
$ kubectl config set-credentials devuser --client-certificate du.crt --client-key du.key
@@ -87,6 +89,7 @@ User "devuser" set.
87
89
```
88
90
89
91
You also need to map it , i mean you need to add context for this user for the cluster
92
+ ---
90
93
91
94
```
92
95
$ kubectl config set-context --cluster kind-kind --user devuser
@@ -102,6 +105,7 @@ Context "devuser-kind" created
102
105
```
103
106
104
107
If you want to check which context we are using
108
+ ---
105
109
106
110
` $ kubectl config current-context `
107
111
@@ -121,7 +125,8 @@ $ export KUBECONFIG=~/.kube/config:~/.kube/karmada.config:~/.kube/karmada-apiser
121
125
122
126
<img width =" 1120 " alt =" Screenshot 2025-02-18 at 11 21 48 PM " src =" https://github.com/user-attachments/assets/d1d742bf-d308-42a8-bcf6-41b4d5c881da " />
123
127
124
- To authenticate the user to kubernetes cluster we will do client certificate management
128
+ To authenticate the user to Kubernetes cluster we will do client certificate management
129
+ ---
125
130
126
131
docker ps (get the id )
127
132
docker exec -it <id > bash
@@ -131,7 +136,7 @@ ls -l (you will see the key, csr and other files )
131
136
132
137
* So for creating private key and csr key you can run this command to generate
133
138
134
- <img width =" 1179 " alt =" shapes at 25-02-20 00 13 41 " src =" https://github.com/user-attachments/assets/2aedf2d0-8b1b-4a23-9ce0-c815020ec5fa " />
139
+ <img width =" 1199 " alt =" shapes at 25-02-20 12 39 00 " src =" https://github.com/user-attachments/assets/99159373-2e30-4568-85a3-d36f1536d9a9 " />
135
140
136
141
Generate new ssl key:
137
142
-----
@@ -182,9 +187,57 @@ $ kubectx
182
187
```
183
188
<img width =" 1094 " alt =" Screenshot 2025-02-19 at 1 10 23 AM " src =" https://github.com/user-attachments/assets/093537f4-76b7-4f11-890e-77781eefa5cd " />
184
189
190
+
185
191
* allow namespaces
186
192
<img width =" 1310 " alt =" Screenshot 2025-02-19 at 1 17 41 AM " src =" https://github.com/user-attachments/assets/b9e2ca7c-ac1c-4b7c-9384-4ec96a951f15 " />
187
193
188
194
189
195
* allow pods
190
196
<img width =" 1310 " alt =" Screenshot 2025-02-19 at 1 23 04 AM " src =" https://github.com/user-attachments/assets/9967a9df-bac0-42d9-9b3a-d177e764b2b5 " />
197
+
198
+ Certificate Singning Request
199
+ ----
200
+ * Creating the certificate singning request with the k8s ca.crt key
201
+ <img width =" 1337 " alt =" Screenshot 2025-02-19 at 1 31 19 AM " src =" https://github.com/user-attachments/assets/2b8a8983-e7b8-4731-861c-4664d129f649 " />
202
+
203
+ * To put into our csr yaml file we need to encode the key
204
+ <img width =" 1337 " alt =" Screenshot 2025-02-19 at 1 34 14 AM " src =" https://github.com/user-attachments/assets/d602c7c0-b2d1-421e-b8ee-962f2742e046 " />
205
+
206
+ ``` yaml
207
+ // csr.yaml
208
+ apiVersion : certificates.k8s.io/v1
209
+ kind : CertificateSigningRequest
210
+ metadata :
211
+ name : rahulxf
212
+ spec :
213
+ groups :
214
+ - developers
215
+ request : |
216
+ LS0tLS1CRUdJTiBDRVJUSUZJQ0FURSBSRVFVRVNULS....
217
+ signerName : kubernetes.io/kube-apiserver-client
218
+ usages :
219
+ - client auth
220
+ ` ` `
221
+
222
+ And then create it using kubectl command
223
+
224
+ ` ` ` bash
225
+ $ kubectl create -f csr. yaml
226
+ certificatesigningrequest.certificates.k8s.io/rahulxf_created
227
+
228
+ # Get your certificate
229
+ $ kubectl get csr
230
+
231
+ # Approve your certificate
232
+ # rahulxf == name
233
+ $ kubectl certificate approve rahulxf
234
+
235
+ # Look for the certificate details
236
+ $ kubectl describe csr rahulxf
237
+ ```
238
+
239
+ <img width =" 1337 " alt =" Screenshot 2025-02-19 at 1 44 04 AM " src =" https://github.com/user-attachments/assets/477297d6-ac7a-4db7-8b0e-f26b586b9620 " />
240
+
241
+ <img width =" 1231 " alt =" Screenshot 2025-02-20 at 12 35 04 PM " src =" https://github.com/user-attachments/assets/87e933b6-de22-44ef-9d32-3b1ad54b9f7b " />
242
+
243
+
0 commit comments