YOKOHEI.COM

YOKOHEI.COM

›Kubernetes Basics

Kubernetes Basics

  • Kubernetes Basics
  • Commands
  • Static Pod
  • Drain & Uncordon
  • Cluster Upgrade
  • Backup & Restore
  • Certification
  • RBAC
  • CNI
  • CoreDNS
  • Ingress

Kubernetes the Hard Way

  • the Hard Way?
  • AWS Prerequisites
  • CA and TLS
  • Configuration Files
  • Data Encryption
  • Bootstrapping etcd
  • Bootstrapping Control Plane
  • Bootstrapping Worker Node
  • kubectl configuraton
  • Pod Network
  • RBAC for Kubelet
  • Coredns Add-On
  • Test
  • TLS Bootstrapping

Amazon EKS

  • EKS Introduction
  • Ingress with ALB
  • PersistentVolume with EBS
  • NetworkPolicy with Calico
  • Secret with KMS
  • EKS Hands-On

RBAC

Role の作成

https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#role-v1-rbac-authorization-k8s-io

マニフェストのサンプルは以下。

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  creationTimestamp: null
  name: developer
rules:
- apiGroups: [""]
  resources: ["pods"]
  verbs: ["list","get"]

create role コマンドからも作成可能。

$ kubectl create role developer --verb=list --verb=create --resource=pods

Role Binding の作成

https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#rolebinding-v1-rbac-authorization-k8s-io

こちらも create から作成可能。

$ kubectl create rolebinding dev-user-binding --role=devloper --user=dev-user

権限の確認

操作可能か簡単に調べる

自分がどの操作を許可されているか、というのを auth コマンドから確認できる。

$ kubectl auth can-i create deployment
yes
$ kubectl auth can-i delete node
yes

また、特定のユーザを指定することも可能。

$ kubectl auth can-i delete pod --as dev-user
no

ユーザーに紐づく role の確認

以下の方法が良いと思っているが、もっと詳細を一気に見るような方法はあるのだろうか…。

$ kubectl get rolebinding -o wide
NAME               AGE       ROLE            USERS      GROUPS    SERVICEACCOUNTS
dev-user-binding   7m        Role/devloper   dev-user

$ kubectl describe role developer
Name:         developer
Labels:       
Annotations:  
PolicyRule:
  Resources  Non-Resource URLs  Resource Names  Verbs
  ---------  -----------------  --------------  -----
  pods       []                 []              [list create]
← CertificationCNI →
▼ Codes ▼
LeetCodeGitHub
▼ Profile ▼
LinkedInFlickr
▼ Logo made with DesignEvo ▼
DesignEvo
Copyright © 2020 Kohei Yoshida