IAM認証ユーザーの管理
    • PDF

    IAM認証ユーザーの管理

    • PDF

    Article Summary

    最新のコンテンツが反映されていません。早急にアップデート内容をご提供できるよう努めております。最新のコンテンツ内容は韓国語ページをご参照ください。

    VPC環境で利用できます。

    Ncloud Kubernetes Serviceクラスタを作成する場合、クラスタを作成した SubAccountアカウントと メインアカウント はクラスタの RBAC構成に 'system:masters' グループとして自動設定され、この設定はクラスタ情報や ConfigMapに表示されません。IAMユーザーにクラスタの使用権限を追加するには、'kube-system' の名前空間に 'ncp-auth' ConfigMapを登録する必要があります。

    参考

    'ncp-iam-authenticator'がインストールされて kubeconfigが作成された状態で設定できます。ncp-iam-authenticatorインストール, IAM認証 kubeconfigの作成をご参照ください。

    IAMユーザーをクラスタに追加

    1. クラスタを作成した SubAccountアカウント または メインアカウント で 'kubectl' 認証情報が構成される必要があります。
    2. 'ncp-auth' ConfigMapを作成します。
    $ cat <<EOF | kubectl --kubeconfig $KUBE_CONFIG apply -f -
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: ncp-auth
      namespace: kube-system
    data:
      mapSubAccounts: |
        - subAccountIdNo: <iam-user-idno>
          username: <username>
          groups:
            - <groups>
    EOF
    
    1. ConfigMapの IAMユーザーパラメータは、次の通りです。
      • subaccountIdNo: SubAccountコンソールで確認できる追加する SubAccountユーザーの ID
      • username: Kubernetes内で IAMユーザーにマッピングするユーザー名。
      • groups: Kubernetes内でユーザーにマッピングするグループリスト。詳細は Default roles and role bindingsをご参照ください。
    2. 'ncp-auth' ConfigMapに 'ncloud.com/applied-ncp-auth' annotationを通じて適用したユーザーリストを確認します。
    $ kubectl --kubeconfig $KUBE_CONFIG -n kube-system get configmap ncp-auth -o yaml
    ...
    metadata:
      annotations:
         ncloud.com/applied-ncp-auth: '[{"SubAccountIdNo":"<iam-user-idno>","Username":"<username>","Groups":["<groups>"]}]'
    ...     
    
    1. IAMユーザーまたはロールをマッピングした Kubernetesユーザーまたはグループが、'RoleBinding' または'ClusterRoleBinding'を使用して Kubernetesロールにバインドされているか確認します。詳細内容は、 Kubernetes文書の Using RBAC Authorizationをご参照ください。
    • すべての名前空間のリソース閲覧権限 - グループ名は 'full-access-group'であり、これを 'ncp-auth'ConfigMapで IAMユーザーの groupsとマッピングします。
    
    |$ cat <<EOF | kubectl --kubeconfig $KUBE_CONFIG apply -f -|
    
    apiVersion: rbac.authorization.k8s.io/v1  
    kind: ClusterRole  
    metadata:  
     name: full-access-clusterrole  
    rules:  
    - apiGroups:  
      - ""  
      resources:  
      - nodes  
      - namespaces  
      - pods  
      verbs:  
      - get  
      - list  
    - apiGroups:  
      - apps  
      resources:  
      - deployments  
      - daemonsets  
      - statefulsets  
      - replicasets  
      verbs:  
      - get  
      - list  
    - apiGroups:  
      - batch  
      resources:  
      - jobs  
      verbs:  
      - get  
      - list  
    ---  
    apiVersion: rbac.authorization.k8s.io/v1  
    kind: ClusterRoleBinding  
    metadata:  
     name: full-access-binding  
    subjects:  
    - kind: Group  
      name: full-access-group  
      apiGroup: rbac.authorization.k8s.io  
    roleRef:  
     kind: ClusterRole  
     name: full-access-clusterrole  
     apiGroup: rbac.authorization.k8s.io  
    EOF  
    
    • 特定の名前空間のリソース閲覧権限 - ファイルに設定された名前空間は 'default'なので、希望する名前空間を指定して修正します。グループ名は 'restricted-access-group'であり、これを'ncp-auth' ConfigMapで IAMユーザーの groupsとマッピングします。
    
    |$ cat <<EOF | kubectl --kubeconfig $KUBE_CONFIG apply -f -|
    
    apiVersion: rbac.authorization.k8s.io/v1  
    kind: ClusterRole  
    metadata:  
      name: restricted-access-clusterrole  
    rules:  
    - apiGroups:  
      - ""  
      resources:  
      - nodes  
      - namespaces  
      verbs:  
      - get  
      - list  
    ---  
    apiVersion: rbac.authorization.k8s.io/v1  
    kind: ClusterRoleBinding  
    metadata:  
      name: restricted-access-clusterrole-binding  
    subjects:  
    - kind: Group  
      name: restricted-access-group  
      apiGroup: rbac.authorization.k8s.io  
    roleRef:  
      kind: ClusterRole  
      name: restricted-access-clusterrole  
      apiGroup: rbac.authorization.k8s.io  
    ---  
    apiVersion: rbac.authorization.k8s.io/v1  
    kind: Role  
    metadata:  
      namespace: default  
      name: restricted-access-role  
    rules:  
    - apiGroups:  
      - ""  
      resources:  
      - pods  
      verbs:  
      - get  
      - list  
    - apiGroups:  
      - apps  
      resources:  
      - deployments  
      - daemonsets  
      - statefulsets  
      - replicasets  
      verbs:  
      - get  
      - list  
    - apiGroups:  
      - batch  
      resources:  
      - jobs  
      verbs:  
      - get  
      - list  
    ---  
    apiVersion: rbac.authorization.k8s.io/v1  
    kind: RoleBinding  
    metadata:  
      name: restricted-access-role-binding  
      namespace: default  
    subjects:  
    - kind: Group  
      name: restricted-access-group  
      apiGroup: rbac.authorization.k8s.io  
    roleRef:  
      kind: Role  
      name: restricted-access-role  
      apiGroup: rbac.authorization.k8s.io  
    EOF  
    

    mapSubAccountsにユーザー登録せずに全体認証

    1. 'ncp-auth' ConfigMapに 'authenticateAll' 値を「true」で追加するとすべての SubAccountアカウントが mapSubAccountsに追加されなくても認証できます。
    
    |$ cat <<EOF | kubectl --kubeconfig $KUBE_CONFIG apply -f -|
    
    apiVersion: v1  
    kind: ConfigMap  
    metadata:  
      name: ncp-auth  
      namespace: kube-system  
    data:  
      authenticateAll: "true"  
    EOF  
    
    1. 認証されたユーザーは SubAccountユーザーをクラスタに追加と同様に Kubernetesユーザーまたはグループが 'RoleBinding' または 'ClusterRoleBinding'を使用して Kubernetesロールにバインドされている必要があります。

    SubAccountグループを Kubernetesグループとして使用

    1. SubAccountグループに属している SubAccountユーザーは 'ncp-sub-account-group:'が prefixで追加された Kubernetesグループに含まれるようになります。
    2. full-accessという SubAccountグループに属しているユーザー全体に full-access-clusterroleを付与する例は以下のようです。
    
    |$ cat <<EOF | kubectl --kubeconfig $KUBE_CONFIG apply -f -|
    
    apiVersion: rbac.authorization.k8s.io/v1  
    kind: ClusterRole  
    metadata:  
     name: full-access-clusterrole  
    rules:  
    - apiGroups:  
      - ""  
      resources:  
      - nodes  
      - namespaces  
      - pods  
      verbs:  
      - get  
      - list  
    - apiGroups:  
      - apps  
      resources:  
      - deployments  
      - daemonsets  
      - statefulsets  
      - replicasets  
      verbs:  
      - get  
      - list  
    - apiGroups:  
      - batch  
      resources:  
      - jobs  
      verbs:  
      - get  
      - list  
    ---  
    apiVersion: rbac.authorization.k8s.io/v1  
    kind: ClusterRoleBinding  
    metadata:  
     name: full-access-binding  
    subjects:  
    - kind: Group  
      name: ncp-sub-account-group:full-access  
      apiGroup: rbac.authorization.k8s.io  
    roleRef:  
     kind: ClusterRole  
     name: full-access-clusterrole  
     apiGroup: rbac.authorization.k8s.io  
    EOF  
    

    この記事は役に立ちましたか?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.