@@ -274,10 +274,11 @@ echo $(kubectl get secret -o go-template='{{index .data "token" }}' $(kubectl ge
274
274
275
275
Once the cluster been added successfully you can go to the ` Kubernetes ` tab to start working with the services of your cluster.
276
276
277
- #### The proper/secure way
277
+ #### The proper/secure way for Kubernetes Cluster 1.24+
278
278
279
- For production environments you should create a service account and/or role for Codefresh access.
280
- The minimum permissions Codefresh needs to work with the cluster are the following:
279
+ For production environments, create a service account and/or role for Codefresh access.
280
+
281
+ Codefresh needs these minimum permissions to work with the cluster:
281
282
282
283
` codefresh-role.yml `
283
284
{% highlight yaml %}
@@ -314,7 +315,7 @@ kind: ServiceAccount
314
315
metadata:
315
316
name: codefresh-user
316
317
namespace: kube-system
317
- ---
318
+ ---
318
319
apiVersion: rbac.authorization.k8s.io/v1
319
320
kind: ClusterRoleBinding
320
321
metadata:
@@ -327,29 +328,39 @@ subjects:
327
328
- kind: ServiceAccount
328
329
name: codefresh-user
329
330
namespace: kube-system
331
+ ---
332
+ apiVersion: v1
333
+ kind: Secret
334
+ type: kubernetes.io/service-account-token
335
+ metadata:
336
+ name: codefresh-user-token
337
+ namespace: kube-system
338
+ annotations:
339
+ kubernetes.io/service-account.name: "codefresh-user"
330
340
{% endraw %}
331
341
{% endhighlight %}
332
342
333
- Select the appropriate cluster if you have more than one:
343
+ < br />
334
344
345
+ 1 . Select the appropriate cluster if you have more than one:
335
346
` Choose cluster `
336
347
{% highlight shell %}
337
348
{% raw %}
338
349
kubectl config use-context <my-cluster-name >
339
350
{% endraw %}
340
351
{% endhighlight %}
341
352
342
- Create the Codefresh user/role:
343
-
353
+ { : start ="2"}
354
+ 1 . Create the Codefresh user/role:
344
355
` Apply Codefresh access rules `
345
356
{% highlight shell %}
346
357
{% raw %}
347
358
kubectl apply -f codefresh-role-sa-bind.yml
348
359
{% endraw %}
349
360
{% endhighlight %}
350
361
351
- Finally run the following commands and copy-paste the result to each Codefresh field in the UI:
352
-
362
+ { : start ="3"}
363
+ 1 . Finally run the following commands, and copy-paste the results to the respective Codefresh field in the UI:
353
364
` Host IP `
354
365
{% highlight shell %}
355
366
{% raw %}
@@ -360,22 +371,21 @@ export CURRENT_CONTEXT=$(kubectl config current-context) && export CURRENT_CLUST
360
371
` Certificate `
361
372
{% highlight shell %}
362
373
{% raw %}
363
- echo $(kubectl get secret -n kube-system -o go-template='{{index .data "ca.crt" }}' $(kubectl get sa codefresh-user -n kube-system -o go-template="{{range .secrets}}{{.name}}{{end}}") )
374
+ echo $(kubectl get secret -n kube-system -o go-template='{{index .data "ca.crt" }}' codefresh-user-token )
364
375
{% endraw %}
365
376
{% endhighlight %}
366
377
367
378
` Token `
368
379
{% highlight shell %}
369
380
{% raw %}
370
- echo $(kubectl get secret -n kube-system -o go-template='{{index .data "token" }}' $(kubectl get sa codefresh-user -n kube-system -o go-template="{{range .secrets}}{{.name}}{{end}}") )
381
+ echo $(kubectl get secret -n kube-system -o go-template='{{index .data "token" }}' codefresh-user-token )
371
382
{% endraw %}
372
383
{% endhighlight %}
373
384
374
- #### The proper/secure way for Kubernetes Cluster 1.24+
385
+ #### The proper/secure way Kubernetes 1.23 and older
375
386
376
- For production environments, create a service account and/or role for Codefresh access.
377
-
378
- Codefresh needs these minimum permissions to work with the cluster:
387
+ For production environments you should create a service account and/or role for Codefresh access.
388
+ The minimum permissions Codefresh needs to work with the cluster are the following:
379
389
380
390
` codefresh-role.yml `
381
391
{% highlight yaml %}
@@ -412,7 +422,7 @@ kind: ServiceAccount
412
422
metadata:
413
423
name: codefresh-user
414
424
namespace: kube-system
415
- ---
425
+ ---
416
426
apiVersion: rbac.authorization.k8s.io/v1
417
427
kind: ClusterRoleBinding
418
428
metadata:
@@ -425,39 +435,29 @@ subjects:
425
435
- kind: ServiceAccount
426
436
name: codefresh-user
427
437
namespace: kube-system
428
- ---
429
- apiVersion: v1
430
- kind: Secret
431
- type: kubernetes.io/service-account-token
432
- metadata:
433
- name: codefresh-user-token
434
- namespace: kube-system
435
- annotations:
436
- kubernetes.io/service-account.name: "codefresh-user"
437
438
{% endraw %}
438
439
{% endhighlight %}
439
440
440
- < br />
441
+ Select the appropriate cluster if you have more than one:
441
442
442
- 1 . Select the appropriate cluster if you have more than one:
443
443
` Choose cluster `
444
444
{% highlight shell %}
445
445
{% raw %}
446
446
kubectl config use-context <my-cluster-name >
447
447
{% endraw %}
448
448
{% endhighlight %}
449
449
450
- { : start ="2"}
451
- 1 . Create the Codefresh user/role:
450
+ Create the Codefresh user/role:
451
+
452
452
` Apply Codefresh access rules `
453
453
{% highlight shell %}
454
454
{% raw %}
455
455
kubectl apply -f codefresh-role-sa-bind.yml
456
456
{% endraw %}
457
457
{% endhighlight %}
458
458
459
- { : start ="3"}
460
- 1 . Finally run the following commands, and copy-paste the results to the respective Codefresh field in the UI:
459
+ Finally run the following commands and copy-paste the result to each Codefresh field in the UI:
460
+
461
461
` Host IP `
462
462
{% highlight shell %}
463
463
{% raw %}
@@ -468,17 +468,18 @@ export CURRENT_CONTEXT=$(kubectl config current-context) && export CURRENT_CLUST
468
468
` Certificate `
469
469
{% highlight shell %}
470
470
{% raw %}
471
- echo $(kubectl get secret -n kube-system -o go-template='{{index .data "ca.crt" }}' codefresh-user-token )
471
+ echo $(kubectl get secret -n kube-system -o go-template='{{index .data "ca.crt" }}' $(kubectl get sa codefresh-user -n kube-system -o go-template="{{range .secrets}}{{.name}}{{end}}") )
472
472
{% endraw %}
473
473
{% endhighlight %}
474
474
475
475
` Token `
476
476
{% highlight shell %}
477
477
{% raw %}
478
- echo $(kubectl get secret -n kube-system -o go-template='{{index .data "token" }}' codefresh-user-token )
478
+ echo $(kubectl get secret -n kube-system -o go-template='{{index .data "token" }}' $(kubectl get sa codefresh-user -n kube-system -o go-template="{{range .secrets}}{{.name}}{{end}}") )
479
479
{% endraw %}
480
480
{% endhighlight %}
481
481
482
+
482
483
#### Restrict Codefresh access to a specific namespace
483
484
484
485
In most cases, you want to allow Codefresh to access all namespaces inside the cluster. This is the most convenient option as it will make
0 commit comments