共计 15267 个字符,预计需要花费 39 分钟才能阅读完成。
公司内部存在十多个k8s集群,版本低至1.12,高至1.20。目前还没有统一登录认证,以后也许会有。。。目前每个集群都是存在kubeadashboard,各项目组人员都只能通过这个操作集群资源(国企考虑东西过多,不考虑其他类似kubesphere/kuboard和其他国外面板等)。所以每次有项目增删改查或人员变动,对kubeconfig和权限操控都很繁琐,所以记录下改造脚本释放自己
使用CertificateSigningRequest资源创建
脚本一
[root@k8s-master kubeconfig]# cat create-user-kubeconfig.sh
#/bin/bash
namespace=$1
username=$2
dir=`mktemp -d ${username}.XXXXXXXX`
cd $dir
openssl genrsa -out ${username}.key 2048
openssl req -new -key ${username}.key -out ${username}.csr -subj "/CN=${username}"
cat >${username}-csr.yaml<<-EOF
apiVersion: certificates.k8s.io/v1beta1
kind: CertificateSigningRequest
metadata:
name: ${username}
spec:
request: `cat ${username}.csr | base64 | tr -d "\n"`
signerName: kubernetes.io/kube-apiserver-client
usages:
- client auth
EOF
kubectl delete csr ${username} 2> /dev/null
kubectl apply -f ${username}-csr.yaml
kubectl certificate approve ${username}
kubectl get csr ${username} -o jsonpath='{.status.certificate}'| base64 -d > ${username}.crt
cat >${username}-rbac.yaml<<-EOF
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: ${username}
namespace: ${namespace}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: role-${username}
namespace: ${namespace}
rules:
- apiGroups:
- '*'
resources:
- '*'
verbs:
- '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: ${username}-role-binding
namespace: ${namespace}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: role-${username}
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: ${username}
- kind: ServiceAccount
namespace: ${userspace}
name: ${username}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: node-read-clusterrole
rules:
- apiGroups:
- ""
resources:
- nodes
- namespaces
verbs:
- get
- watch
- list
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: node-read-clusterrolebinding-${username}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: node-read-clusterrole
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: ${username}
- kind: ServiceAccount
name: ${username}
namespace: ${namespace}
EOF
kubectl apply -f ${username}-rbac.yaml
kubectl config view --raw | head -6 > config.${username}
kubectl config set-context ${username}@kubernetes --cluster=kubernetes --user=${username} --kubeconfig=config.${username}
kubectl config set-credentials ${username} --client-certificate=${username}.crt --client-key=${username}.key --embed-certs=true --kubeconfig=config.${username}
kubectl config use-context ${username}@kubernetes --kubeconfig=config.${username}
user_secret_name=`kubectl get secret -n ${namespace} | grep ${username}-token | awk '{print $1}'`
user_token=$(kubectl -n ${namespace} get secrets ${user_secret_name} -o jsonpath={.data.token} |base64 -d)
kubectl config set-credentials ${username} --token=${user_token} --kubeconfig=config.${username}
脚本二
[root@k8s-master kubeconfig]# cat create-user-kubeconfig.sh
#/bin/bash
namespace=$1
username=$2
dir=`mktemp -d ${username}.XXXXXXXX`
cd $dir
openssl genrsa -out ${username}.key 2048
openssl req -new -key ${username}.key -out ${username}.csr -subj "/CN=${username}"
# 此处高版本k8s集群可以识别expirationSeconds字段来控制证书过期
cat >${username}-csr.yaml<<-EOF
apiVersion: certificates.k8s.io/v1
kind: CertificateSigningRequest
metadata:
name: ${username}
spec:
request: `cat ${username}.csr | base64 | tr -d "\n"`
expirationSeconds: 86400 # one day
signerName: kubernetes.io/kube-apiserver-client
usages:
- client auth
EOF
kubectl delete csr ${username} 2> /dev/null
kubectl apply -f ${username}-csr.yaml
kubectl certificate approve ${username}
kubectl get csr ${username} -o jsonpath='{.status.certificate}'| base64 -d > ${username}.crt
cat >${username}-rbac.yaml<<-EOF
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: ${username}
namespace: ${namespace}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: role-${username}
namespace: ${namespace}
rules:
- apiGroups:
- '*'
resources:
- '*'
verbs:
- '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: ${username}-role-binding
namespace: ${namespace}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: role-${username}
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: ${username}
- kind: ServiceAccount
namespace: ${userspace}
name: ${username}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: node-read-clusterrole
rules:
- apiGroups:
- ""
resources:
- nodes
- namespaces
verbs:
- get
- watch
- list
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: node-read-clusterrolebinding-${username}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: node-read-clusterrole
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: ${username}
- kind: ServiceAccount
name: ${username}
namespace: ${namespace}
EOF
kubectl apply -f ${username}-rbac.yaml
kubectl config view --raw | head -6 > config.${username}
kubectl config set-context ${username}@kubernetes --cluster=kubernetes --user=${username} --kubeconfig=config.${username}
kubectl config set-credentials ${username} --client-certificate=${username}.crt --client-key=${username}.key --embed-certs=true --kubeconfig=config.${username}
kubectl config use-context ${username}@kubernetes --kubeconfig=config.${username}
user_secret_name=`kubectl get secret -n ${namespace} | grep ${username}-token | awk '{print $1}'`
user_token=$(kubectl -n ${namespace} get secrets ${user_secret_name} -o jsonpath={.data.token} |base64 -d)
kubectl config set-credentials ${username} --token=${user_token} --kubeconfig=config.${username}
使用openssl方式创建
[root@k8s-master kubeconfig]# cat create-user-kubeconfig-v2.sh
#/bin/bash
namespace=$1
username=$2
ca_file="/etc/kubernetes/pki/ca.crt"
ca_key="/etc/kubernetes/pki/ca.key"
expire_day=3650
dir=`mktemp -d ${username}.XXXXXXXX`
cd $dir
openssl genrsa -out ${username}.key 2048
openssl req -new -key ${username}.key -out ${username}.csr -subj "/CN=${username}"
openssl x509 -req -in ${username}.csr -CA $ca_file -CAkey $ca_key -CAcreateserial -out ${username}.crt -days ${expire_day}
cat >${username}-rbac.yaml<<-EOF
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: ${username}
namespace: ${namespace}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: role-${username}
namespace: ${namespace}
rules:
- apiGroups:
- '*'
resources:
- '*'
verbs:
- '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: ${username}-role-binding
namespace: ${namespace}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: role-${username}
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: ${username}
- kind: ServiceAccount
namespace: ${userspace}
name: ${username}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: node-read-clusterrole
rules:
- apiGroups:
- ""
resources:
- nodes
- namespaces
verbs:
- get
- watch
- list
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: node-read-clusterrolebinding-${username}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: node-read-clusterrole
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: ${username}
- kind: ServiceAccount
name: ${username}
namespace: ${namespace}
EOF
kubectl apply -f ${username}-rbac.yaml
kubectl config view --raw | head -6 > config.${username}
kubectl config set-context ${username}@kubernetes --cluster=kubernetes --user=${username} --kubeconfig=config.${username}
kubectl config set-credentials ${username} --client-certificate=${username}.crt --client-key=${username}.key --embed-certs=true --kubeconfig=config.${username}
kubectl config use-context ${username}@kubernetes --kubeconfig=config.${username}
user_secret_name=`kubectl get secret -n ${namespace} | grep ${username}-token | awk '{print $1}'`
user_token=$(kubectl -n ${namespace} get secrets ${user_secret_name} -o jsonpath={.data.token} |base64 -d)
kubectl config set-credentials ${username} --token=${user_token} --kubeconfig=config.${username}
测试验证权限
测试创建kubeconfig
[root@k8s-master kubeconfig]# bash create-user-kubeconfig.sh default xadocker4
Generating RSA private key, 2048 bit long modulus
....+++
....+++
e is 65537 (0x10001)
certificatesigningrequest.certificates.k8s.io/xadocker4 created
certificatesigningrequest.certificates.k8s.io/xadocker4 approved
serviceaccount/xadocker4 created
role.rbac.authorization.k8s.io/role-xadocker4 created
rolebinding.rbac.authorization.k8s.io/xadocker4-role-binding created
clusterrole.rbac.authorization.k8s.io/node-read-clusterrole unchanged
clusterrolebinding.rbac.authorization.k8s.io/node-read-clusterrolebinding-xadocker4 created
Context "xadocker4@kubernetes" created.
User "xadocker4" set.
Switched to context "xadocker4@kubernetes".
User "xadocker4" set.
# 查看生成的kubeconfig文件
[root@k8s-master xadocker4.cPJiUwYK]# cat config.xadocker4
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeU1EZ3hOREE0TlRFME9Wb1hEVE15TURneE1UQTROVEUwT1Zvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTjArCnRMOWhZWjFRSVZoYnlPQ0xsN0hOd21OT3FxeW9BUHAxdjRUaDJrZnhZVHptUnppc3VSdm1BOS9DL2JJdEE4cDEKR3JWcEhXWitvL1VUYU9zUjlOcmc5S2NBREdQcVAzbkFFeDNRSVRpaTZ1TWYvUFVvU09kUHRJbjRUOUVTVGM2MApsYWV1dE9RN1hBV1JmQ2N3cHA4cUFHWWM5QXkveGc4SDlxaVA5eHJtekRWeFl6UUdOUk5jQkNTR2huQkJ1WnhoCjVqLzFHUHZ5a2x4VWhLTGZEdTBTNVRCT0ZjcjNxU0FzNnl4alFmeCtLU0lVNmVqNkdEL1JYSm12UVNPMlI4b1oKVk1pcnRqK2NVR3EvUVErWXVMS1lXSWc5M255YWl3QXpCbzVkd2UyZ2NtemRBT2ZWRGJFVWw4anJQM2dTQ1EvVwpNTzdROVpZejRIUytkbXY1YXA4Q0F3RUFBYU1qTUNFd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFBNngwUlNvaUdoTFU5TTVWNUV5Ymw4eDdCbksKb3ZqcHcwRndpM0dyZHkyczRYdzBMZEtXZDdlcmZKR2JyMk1WZm1FQ1lERTVLblJuVkF3WE9yQ1pueWNSTmhrSwpmNGc5SDZuMHQxam95T2piT1NKZkdHVWVnb01OaW1HREFYT3RrcDFyS1FNOU5CRkdBcW9YeUFDTXdWN0N5Q1BjClp0alh2MWlLcVJkSEEyam83ZU11VTRLMkMvRFlKTFNSVkcwSStjamRuYzN2a0hoMjBvaDVPdTR3NUhHRWhrci8KTjdCdVhwN2pRM1BKUjhUQmluWmxMS0JJZEdsOVNYay9ad29Fd1V3YzNMdFlrRGNjeVhuZmdkMmJORjVOYkVFbwo4Qm5WdnR6K1JSd0hFUUdFTTRDT0t1OWFHUHlUNFdmYU83bSsxaDhBYXBENVRYOVY0TTI3SHFpVnVWUT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
server: https://apiserver.demo:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: xadocker4
name: xadocker4@kubernetes
current-context: xadocker4@kubernetes
kind: Config
preferences: {}
users:
- name: xadocker4
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMyRENDQWNDZ0F3SUJBZ0lRTUpZVU1SS3dQcTVaYjhuWXpxdUNuREFOQmdrcWhraUc5dzBCQVFzRkFEQVYKTVJNd0VRWURWUVFERXdwcmRXSmxjbTVsZEdWek1CNFhEVEl5TURneU1qRXpOVFl5TVZvWERUSXpNRGd5T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DI_AovVfCiLsB09HkoTDLiAPRLlmuAiyxw1KydB9h-TAwsfEiI9RXOsGJtOgtX_DE6fZwBwjoeqoEZ-VsQoghQZpuOmIakB1ReLxd7xRjqgg
测试验证权限
[root@k8s-master xadocker4.cPJiUwYK]# ll
total 28
-rw-r--r-- 1 root root 6294 Aug 22 22:01 config.xadocker4
-rw-r--r-- 1 root root 1046 Aug 22 22:01 xadocker4.crt
-rw-r--r-- 1 root root 891 Aug 22 22:01 xadocker4.csr
-rw-r--r-- 1 root root 1382 Aug 22 22:01 xadocker4-csr.yaml
-rw-r--r-- 1 root root 1675 Aug 22 22:01 xadocker4.key
-rw-r--r-- 1 root root 1176 Aug 22 22:01 xadocker4-rbac.yaml
[root@k8s-master xadocker4.cPJiUwYK]# kubectl get all -n default --kubeconfig=config.xadocker4
NAME READY STATUS RESTARTS AGE
pod/grafana-5c858fffcb-drkh8 1/1 Running 2 3d22h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/grafana NodePort 10.96.172.204 <none> 80:31230/TCP 3d22h
service/jenkins NodePort 10.96.115.162 <none> 8080:32593/TCP,50000:31243/TCP 6d23h
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 8d
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/grafana 1/1 1 1 3d22h
NAME DESIRED CURRENT READY AGE
replicaset.apps/grafana-5c858fffcb 1 1 1 3d22h
正文完