728x90
Jenkins등 외부에서 Kubernetes 자원에 접근이 필요한 경우가 있다.
이럴때는 SA를 생성하고 해당 credential로 API서버에 인증을 받아서 수행해야 한다.
아래는 SA를 만들고 해당 SA의 Credential까지 얻는 방법이다. (이 Credential을 Jenkins에 등록하면 됩니다.)
# Create a ServiceAccount named `jenkins-robot` in a given namespace.
$ kubectl -n <namespace> create serviceaccount jenkins-robot
# The next line gives `jenkins-robot` administator permissions for this namespace.
# * You can make it an admin over all namespaces by creating a `ClusterRoleBinding` instead of a `RoleBinding`.
# * You can also give it different permissions by binding it to a different `(Cluster)Role`.
$ kubectl -n <namespace> create rolebinding jenkins-robot-binding --clusterrole=cluster-admin --serviceaccount=<namespace>:jenkins-robot
# Get the name of the token that was automatically generated for the ServiceAccount `jenkins-robot`.
$ kubectl -n <namespace> get serviceaccount jenkins-robot -o go-template --template='{{range .secrets}}{{.name}}{{"\n"}}{{end}}'
jenkins-robot-token-d6d8z
# Retrieve the token and decode it using base64.
$ kubectl -n <namespace> get secrets jenkins-robot-token-d6d8z -o go-template --template '{{index .data "token"}}' | base64 -d
'PaaS > Kubernetes' 카테고리의 다른 글
(완독정리) 쿠버네티스 마스터 / 에이콘/ 1장 쿠버네티스 아키텍처 이해 (0) | 2021.10.12 |
---|---|
(Notice) Kubernetes Cluster API 프로젝트 진척상황 (0) | 2021.10.09 |
(세미나) 2021 Kubernetes Community 발표회 정리 (0) | 2021.09.09 |
(Kubernetes) 쿠버네티스/OpenShift HA클러스터 아키텍처 가이드 (0) | 2021.08.31 |
(Kubernetes) Rancher로 Kubernetes 노드 올리기 (0) | 2021.08.30 |