Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit897a673

Browse files
committed
update secure way for 1.24
1 parent9ecd479 commit897a673

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

‎_docs/deploy-to-kubernetes/add-kubernetes-cluster.md‎

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,113 @@ echo $(kubectl get secret -n kube-system -o go-template='{{index .data "token" }
351351
{% endraw %}
352352
{% endhighlight %}
353353

354+
####The proper/secure way for Kubernetes Cluster 1.24+
355+
356+
For production environments you should create a service account and/or role for Codefresh access.
357+
The minimum permissions Codefresh needs to work with the cluster are the following:
358+
359+
`codefresh-role.yml`
360+
{% highlight yaml %}
361+
{% raw %}
362+
kind: ClusterRole
363+
apiVersion: rbac.authorization.k8s.io/v1
364+
metadata:
365+
name: codefresh-role
366+
rules:
367+
- apiGroups:[“”]
368+
resources:[*]
369+
verbs:[“list”, “watch”, “get”]
370+
{% endraw %}
371+
{% endhighlight %}
372+
373+
Note that these permissions will only allow Codefresh to read the cluster resources and populate the respective dashboards. You need to give more privileges for actual deployments. For more information see the[Kubernetes RBAC documentation page](https://kubernetes.io/docs/reference/access-authn-authz/rbac/).
374+
375+
Here is an example with role + service account + binding.
376+
377+
`codefresh-role-sa-bind.yml`
378+
{% highlight yaml %}
379+
{% raw %}
380+
kind: ClusterRole
381+
apiVersion: rbac.authorization.k8s.io/v1
382+
metadata:
383+
name: codefresh-role
384+
rules:
385+
- apiGroups:[*]
386+
resources:[*]
387+
verbs:[“get”, “list”, “watch”, “create”, “update”, “patch”, “delete”]
388+
389+
apiVersion: v1
390+
kind: ServiceAccount
391+
metadata:
392+
name: codefresh-user
393+
namespace: kube-system
394+
395+
apiVersion: rbac.authorization.k8s.io/v1
396+
kind: ClusterRoleBinding
397+
metadata:
398+
name: codefresh-user
399+
roleRef:
400+
apiGroup: rbac.authorization.k8s.io
401+
kind: ClusterRole
402+
name: codefresh-role
403+
subjects:
404+
- kind: ServiceAccount
405+
name: codefresh-user
406+
namespace: kube-system
407+
408+
apiVersion: v1
409+
kind: Secret
410+
type: kubernetes.io/service-account-token
411+
metadata:
412+
name: codefresh-user-token
413+
namespace: kube-system
414+
annotations:
415+
kubernetes.io/service-account.name: “codefresh-user”
416+
417+
{% endraw %}
418+
{% endhighlight %}
419+
420+
Select the appropriate cluster if you have more than one:
421+
422+
`Choose cluster`
423+
{% highlight shell %}
424+
{% raw %}
425+
kubectl config use-context <my-cluster-name>
426+
{% endraw %}
427+
{% endhighlight %}
428+
429+
Create the Codefresh user/role:
430+
431+
`Apply Codefresh access rules`
432+
{% highlight shell %}
433+
{% raw %}
434+
kubectl apply -f codefresh-role-sa-bind.yml
435+
{% endraw %}
436+
{% endhighlight %}
437+
438+
Finally run the following commands and copy-paste the result to each Codefresh field in the UI:
439+
440+
`Host IP`
441+
{% highlight shell %}
442+
{% raw %}
443+
export CURRENT_CONTEXT=$(kubectl config current-context) && export CURRENT_CLUSTER=$(kubectl config view -o go-template=“{{\$curr_context := \”$CURRENT_CONTEXT\” }}{{range .contexts}}{{if eq .name\$curr_context}}{{.context.cluster}}{{end}}{{end}}”) && echo $(kubectl config view -o go-template=“{{\$cluster_context := \”$CURRENT_CLUSTER\”}}{{range .clusters}}{{if eq .name\$cluster_context}}{{.cluster.server}}{{end}}{{end}}”)
444+
{% endraw %}
445+
{% endhighlight %}
446+
447+
`Certificate`
448+
{% highlight shell %}
449+
{% raw %}
450+
echo $(kubectl get secret -n kube-system -o go-template=‘{{index .data “ca.crt” }}’ codefresh-user-token)
451+
{% endraw %}
452+
{% endhighlight %}
453+
454+
`Token`
455+
{% highlight shell %}
456+
{% raw %}
457+
echo $(kubectl get secret -n kube-system -o go-template=‘{{index .data “token” }}’ codefresh-user-token)
458+
{% endraw %}
459+
{% endhighlight %}
460+
354461
###Restrict Codefresh access to a specific namespace
355462

356463
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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp