rbac-Serviceaccount实操
  1D6o7E39IQo1 2023年11月02日 27 0
创建SA
apiVersion: v1
kind: ServiceAccount
metadata:
  name: sa-test
创建Role
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: default
  name: sa-test
rules:
- apiGroups: [""]
  resources: ["pods","pods/log"]
  verbs: ["get","watch","list"]
创建RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: sa-test-rolebinding
  namespace: default
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: sa-test
subjects:
- namespace: default
  kind: ServiceAccount
  name: sa-test
创建Pod
apiVersion: v1
kind: Pod
metadata:
  name: sa-test
  labels:
    app: sa
spec:
  serviceAccountName: sa-test
  containers:
  - name: sa-nginx
    image: nginx
    imagePullPolicy: IfNotPresent
    ports:
    - containerPort: 80
Pod内执行
root@sa-test:/run/secrets/kubernetes.io/serviceaccount# curl --cacert ./ca.crt -H "Authorization: Bearer $(cat ./token)" https://kubernetes/api/v1/namespaces/default/pods/sa-test/log 
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2023/09/07 08:27:14 [notice] 1#1: using the "epoll" event method
2023/09/07 08:27:14 [notice] 1#1: nginx/1.25.2
2023/09/07 08:27:14 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14) 
2023/09/07 08:27:14 [notice] 1#1: OS: Linux 6.2.0-32-generic
2023/09/07 08:27:14 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2023/09/07 08:27:14 [notice] 1#1: start worker processes
2023/09/07 08:27:14 [notice] 1#1: start worker process 30
2023/09/07 08:27:14 [notice] 1#1: start worker process 31
2023/09/07 08:27:14 [notice] 1#1: start worker process 32
2023/09/07 08:27:14 [notice] 1#1: start worker process 33


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  1D6o7E39IQo1   2023年11月02日   23   0   0 UserAccountserviceaccountrbac
  1D6o7E39IQo1   2023年11月02日   28   0   0 sarbac
  1D6o7E39IQo1   2023年11月02日   51   0   0 rolerbac
1D6o7E39IQo1
作者其他文章 更多

2023-11-13

2023-11-13

2023-11-13

2023-11-13

2023-11-13

2023-11-13

2023-11-13

2023-11-13