<p>Configured my kubernetes cluster to use OpenID Connect Authentication . i'm getting the error as &quot;error: You must be logged in to the server (Unauthorized)&quot; . I have</p>
<pre><code>kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: admin-role
rules:
- apiGroups: [&quot;*&quot;]
  resources: [&quot;*&quot;]
  verbs: [&quot;*&quot;]

kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: admin-binding
subjects:
- kind: User
  name: krishnavamsi@gmail.com
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: admin-role
</code></pre>
<p>Below is the part of the configuration that i have added.</p>
<pre><code>users:
- name: krishnavamsi@gmail.com
  user:
    auth-provider:
      config:
        client-id: XXXXXX
        client-secret: YYYYYYYYYY
        id-token: ZZZZZZZZZZZZZZ
        idp-issuer-url: https://accounts.google.com
        refresh-token: PPPPPPPPPPPPP
      name:oidc
</code></pre>

Vamsi Jakkula
<p>I now got the issue resolved . This step was missing.</p>
<p>sed -i &quot;/- kube-apiserver/a\    - --oidc-issuer-url=https://accounts.google.com\n    - --oidc-username-claim=email\n    - --oidc-client-id=[YOUR_GOOGLE_CLIENT_ID]&quot; /etc/kubernetes/manifests/kube-apiserver.yaml on master before.</p>
