ΠΡΠ΅Π΄ΡΡΠ°Π²Π»ΡΡ Π²Π°ΡΠ΅ΠΌΡ Π²Π½ΠΈΠΌΠ°Π½ΠΈΡ ΡΡΡΠΎΡΠΈΠ°Π» Π΄Π»Ρ Π³Π΅Π½Π΅ΡΠ°ΡΠΈΠΈ Π΄ΠΎΡΡΡΠΏΠΎΠ² ΠΊ Kubernetes-ΠΊΠ»Π°ΡΡΠ΅ΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Dex, dex-k8s-authenticator ΠΈ GitHub.
ΠΠΎΠΊΠ°Π»ΡΠ½ΡΠΉ ΠΌΠ΅ΠΌ ΠΈΠ· ΡΡΡΡΠΊΠΎΡΠ·ΡΡΠ½ΠΎΠ³ΠΎ ΡΠ°ΡΠ° Kubernetes Π²
ΠΠ²Π΅Π΄Π΅Π½ΠΈΠ΅
ΠΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ Kubernetes Π΄Π»Ρ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ Π΄ΠΈΠ½Π°ΠΌΠΈΡΠ΅ΡΠΊΠΈΡ ΠΎΠΊΡΡΠΆΠ΅Π½ΠΈΠΉ Π΄Π»Ρ ΠΊΠΎΠΌΠ°Π½Π΄Ρ ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠΎΠ² ΠΈ QA. Π’Π°ΠΊΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ, ΠΌΡ Ρ ΠΎΡΠΈΠΌ ΠΏΡΠ΅Π΄ΠΎΡΡΠ°Π²ΠΈΡΡ ΠΈΠΌ Π΄ΠΎΡΡΡΠΏ ΠΊ ΠΊΠ»Π°ΡΡΠ΅ΡΡ ΠΊΠ°ΠΊ Π΄Π»Ρ Π΄Π°ΡΠ±ΠΎΡΠ΄Π°, ΡΠ°ΠΊ ΠΈ Π΄Π»Ρ kubectl. Π ΠΎΡΠ»ΠΈΡΠΈΠ΅ ΠΎΡ ΡΠΎΠ³ΠΎ ΠΆΠ΅ OpenShift, Π²Π°Π½ΠΈΠ»ΡΠ½ΡΠΉ Kubernetes Π½Π΅ ΠΈΠΌΠ΅Π΅Ρ Π½Π°ΡΠΈΠ²Π½ΠΎΠΉ Π°ΡΡΠ΅Π½ΡΠΈΡΠΈΠΊΠ°ΡΠΈΠΈ, ΠΏΠΎΡΡΠΎΠΌΡ ΠΌΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ Π΄Π»Ρ ΡΡΠΎΠ³ΠΎ ΡΡΠΎΡΠΎΠ½Π½ΠΈΠ΅ ΡΡΠ΅Π΄ΡΡΠ²Π°.
Π Π΄Π°Π½Π½ΠΎΠΉ ΠΊΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΠΈ ΠΌΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ:
dex-k8s-authenticatorβ β Π²Π΅Π±-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π΄Π»Ρ Π³Π΅Π½Π΅ΡΠ°ΡΠΈΠΈ ΠΊΠΎΠ½ΡΠΈΠ³Π° kubectlDex β ΠΏΡΠΎΠ²Π°ΠΉΠ΄Π΅Ρ OpenID Connect- GitHub β ΠΏΡΠΎΡΡΠΎ ΠΏΠΎΡΠΎΠΌΡ-ΡΡΠΎ ΠΌΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ GitHub Π² Π½Π°ΡΠ΅ΠΉ ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΈ
ΠΡ ΠΏΡΡΠ°Π»ΠΈΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Google OIDC, Π½ΠΎ ΠΊ ΡΠΎΠΆΠ°Π»Π΅Π½ΠΈΡ Π½Π°ΠΌ
ΠΡΠ°ΠΊ, ΠΊΠ°ΠΊ ΠΆΠ΅ ΡΠ°Π±ΠΎΡΠ°Π΅Ρ Π½Π°Ρ ΠΏΡΠΎΡΠ΅ΡΡ Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΠΈΠΈ Π² Kubernetes Π² Π²ΠΈΠ·ΡΠ°Π»ΡΠ½ΠΎΠΌ ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»Π΅Π½ΠΈΠΈ:
ΠΡΠΎΡΠ΅ΡΡ Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΠΈΠΈ
ΠΠ΅ΠΌΠ½ΠΎΠ³ΠΎ ΠΏΠΎΠ΄ΡΠΎΠ±Π½Π΅Π΅ ΠΈ ΠΏΠΎ ΠΏΡΠ½ΠΊΡΠ°ΠΌ:
- ΠΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ Π²Ρ
ΠΎΠ΄ΠΈΡ Π² dex-k8s-authenticator (
login.k8s.example.com
) - dex-k8s-authenticator ΠΏΠ΅ΡΠ΅Π½Π°ΠΏΡΠ°Π²Π»ΡΠ΅Ρ Π·Π°ΠΏΡΠΎΡ Π² Dex (
dex.k8s.example.com
) - Dex ΠΏΠ΅ΡΠ΅Π½Π°ΠΏΡΠ°Π²Π»ΡΠ΅Ρ Π½Π° ΡΡΡΠ°Π½ΠΈΡΡ Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΠΈΠΈ Π² GitHub
- GitHub Π³Π΅Π½Π΅ΡΠΈΡΡΠ΅Ρ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΡΡ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΎΠ± Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΠΈΠΈ ΠΈ Π²ΠΎΠ·Π²ΡΠ°ΡΠ°Π΅Ρ Π΅Π΅ Π² Dex
- Dex ΠΏΠ΅ΡΠ΅Π΄Π°Π΅Ρ ΠΏΠΎΠ»ΡΡΠ΅Π½Π½ΡΡ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ Π² dex-k8s-authenticator
- ΠΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ ΠΏΠΎΠ»ΡΡΠ°Π΅Ρ OIDC token ΠΎΡ GitHub
- dex-k8s-authenticator Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅Ρ ΡΠΎΠΊΠ΅Π½ Π² kubeconfig
- kubectl ΠΏΠ΅ΡΠ΅Π΄Π°Π΅Ρ ΡΠΎΠΊΠ΅Π½ Π² KubeAPIServer
- KubeAPIServer Π½Π° ΠΎΡΠ½ΠΎΠ²Π΅ ΠΏΠ΅ΡΠ΅Π΄Π°Π½Π½ΠΎΠ³ΠΎ ΡΠΎΠΊΠ΅Π½Π° Π²ΠΎΠ·Π²ΡΠ°ΡΠ°Π΅Ρ Π΄ΠΎΡΡΡΠΏΡ Π² kubectl
- ΠΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ ΠΏΠΎΠ»ΡΡΠ°Π΅Ρ Π΄ΠΎΡΡΡΠΏΡ ΠΎΡ kubectl
ΠΠΎΠ΄Π³ΠΎΡΠΎΠ²ΠΈΡΠ΅Π»ΡΠ½ΡΠ΅ Π΄Π΅ΠΉΡΡΠ²ΠΈΡ
Π‘Π°ΠΌΠΎ ΡΠΎΠ±ΠΎΠΉ Ρ Π½Π°Ρ ΡΠΆΠ΅ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½ Kubernetes-ΠΊΠ»Π°ΡΡΠ΅Ρ (k8s.example.com
), Π° ΡΠ°ΠΊΠΆΠ΅ ΠΏΡΠ΅Π΄ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½ HELM. Π’Π°ΠΊΠΆΠ΅ Ρ Π½Π°Ρ Π΅ΡΡΡ ΠΎΡΠ³Π°Π½ΠΈΠ·Π°ΡΠΈΡ Π² GitHub (super-org).
ΠΡΠ»ΠΈ Ρ Π²Π°Ρ Π½Π΅Ρ HELM, ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΡΡΡ ΠΎΠ½
Π‘Π½Π°ΡΠ°Π»Π° Π½Π°ΠΌ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ Π½Π°ΡΡΡΠΎΠΈΡΡ GitHub.
ΠΠ΅ΡΠ΅Ρ
ΠΎΠ΄ΠΈΠΌ Π½Π° ΡΡΡΠ°Π½ΠΈΡΡ Π½Π°ΡΡΡΠΎΠ΅ΠΊ ΠΎΡΠ³Π°Π½ΠΈΠ·Π°ΡΠΈΠΈ, (https://github.com/organizations/super-org/settings/applications
) ΠΈ ΡΠΎΠ·Π΄Π°Π΅ΠΌ Π½ΠΎΠ²ΠΎΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ (Authorized OAuth App):
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ Π½ΠΎΠ²ΠΎΠ³ΠΎ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π² GitHub
ΠΠ°ΠΏΠΎΠ»Π½ΡΠ΅ΠΌ ΠΏΠΎΠ»Ρ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΡΠΌΠΈ URL, Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ:
- Homepage URL:
https://dex.k8s.example.com
- Authorization callback URL:
https://dex.k8s.example.com/callback
ΠΡΠ΄ΡΡΠ΅ Π²Π½ΠΈΠΌΠ°ΡΠ΅Π»ΡΠ½Ρ Ρ ΡΡΡΠ»ΠΊΠ°ΠΌΠΈ, Π²Π°ΠΆΠ½ΠΎ Π½Π΅ ΠΏΠΎΡΠ΅ΡΡΡΡ ΡΠ»Π΅ΡΠΈ.
Π ΠΎΡΠ²Π΅Ρ Π½Π° Π·Π°ΠΏΠΎΠ»Π½Π΅Π½Π½ΡΡ ΡΠΎΡΠΌΡ, GitHub ΡΠ³Π΅Π½Π΅ΡΠΈΡΡΠ΅Ρ Client ID
ΠΈ Client secret
, ΡΠΎΡ
ΡΠ°Π½ΠΈΡΠ΅ ΠΈΡ
Π² Π½Π°Π΄Π΅ΠΆΠ½ΠΎΠΌ ΠΌΠ΅ΡΡΠ΅, ΠΎΠ½ΠΈ Π½Π°ΠΌ ΠΏΡΠΈΠ³ΠΎΠ΄ΡΡΡΡ (ΠΌΡ Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ
Client ID: 1ab2c3d4e5f6g7h8
Client secret: 98z76y54x32w1
ΠΠΎΠ΄Π³ΠΎΡΠΎΠ²ΡΡΠ΅ DNS-Π·Π°ΠΏΠΈΡΠΈ Π΄Π»Ρ ΡΡΠ±Π΄ΠΎΠΌΠ΅Π½ΠΎΠ² login.k8s.example.com
ΠΈ dex.k8s.example.com
, Π° ΡΠ°ΠΊΠΆΠ΅ SSL-ΡΠ΅ΡΡΠΈΡΠΈΠΊΠ°ΡΡ Π΄Π»Ρ ΠΈΠ½Π³ΡΠ΅ΡΡΠΎΠ².
Π‘ΠΎΠ·Π΄Π°Π΄ΠΈΠΌ SSL-ΡΠ΅ΡΡΠΈΡΠΈΠΊΠ°ΡΡ:
cat <<EOF | kubectl create -f -
apiVersion: certmanager.k8s.io/v1alpha1
kind: Certificate
metadata:
name: cert-auth-dex
namespace: kube-system
spec:
secretName: cert-auth-dex
dnsNames:
- dex.k8s.example.com
acme:
config:
- http01:
ingressClass: nginx
domains:
- dex.k8s.example.com
issuerRef:
name: le-clusterissuer
kind: ClusterIssuer
---
apiVersion: certmanager.k8s.io/v1alpha1
kind: Certificate
metadata:
name: cert-auth-login
namespace: kube-system
spec:
secretName: cert-auth-login
dnsNames:
- login.k8s.example.com
acme:
config:
- http01:
ingressClass: nginx
domains:
- login.k8s.example.com
issuerRef:
name: le-clusterissuer
kind: ClusterIssuer
EOF
kubectl describe certificates cert-auth-dex -n kube-system
kubectl describe certificates cert-auth-login -n kube-system
ClusterIssuer Ρ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ΠΌ le-clusterissuer
ΡΠΆΠ΅ Π΄ΠΎΠ»ΠΆΠ΅Π½ ΡΡΡΠ΅ΡΡΠ²ΠΎΠ²Π°ΡΡ, Π΅ΡΠ»ΠΈ ΠΆΠ΅ Π½Π΅Ρ β ΡΠΎΠ·Π΄Π°Π΄ΠΈΠΌ Π΅Π³ΠΎ Ρ ΠΏΠΎΠΌΠΎΡΡΡ HELM:
helm install --namespace kube-system -n cert-manager stable/cert-manager
cat << EOF | kubectl create -f -
apiVersion: certmanager.k8s.io/v1alpha1
kind: ClusterIssuer
metadata:
name: le-clusterissuer
namespace: kube-system
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: [email protected]
privateKeySecretRef:
name: le-clusterissuer
http01: {}
EOF
ΠΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΡ KubeAPIServer
ΠΠ»Ρ ΡΠ°Π±ΠΎΡΡ kubeAPIServer Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ ΡΠΊΠΎΠ½ΡΠΈΠ³ΡΡΠΈΡΠΎΠ²Π°ΡΡ OIDC ΠΈ ΠΎΠ±Π½ΠΎΠ²ΠΈΡΡ ΠΊΠ»Π°ΡΡΠ΅Ρ:
kops edit cluster
...
kubeAPIServer:
anonymousAuth: false
authorizationMode: RBAC
oidcClientID: dex-k8s-authenticator
oidcGroupsClaim: groups
oidcIssuerURL: https://dex.k8s.example.com/
oidcUsernameClaim: email
kops update cluster --yes
kops rolling-update cluster --yes
ΠΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ
ΠΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΡ Dex ΠΈ dex-k8s-authenticator
ΠΠ»Ρ ΡΠ°Π±ΠΎΡΡ Dex Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ ΠΈΠΌΠ΅ΡΡ ΡΠ΅ΡΡΠΈΡΠΈΠΊΠ°Ρ ΠΈ ΠΊΠ»ΡΡ Ρ Kubernetes-ΠΌΠ°ΡΡΠ΅ΡΠ°, Π²ΡΡΠ°ΡΠΈΠΌ Π΅Π³ΠΎ ΠΎΡΡΡΠ΄Π°:
sudo cat /srv/kubernetes/ca.{crt,key}
-----BEGIN CERTIFICATE-----
AAAAAAAAAAABBBBBBBBBBCCCCCC
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
DDDDDDDDDDDEEEEEEEEEEFFFFFF
-----END RSA PRIVATE KEY-----
Π‘ΠΊΠ»ΠΎΠ½ΠΈΡΡΠ΅ΠΌ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΉ dex-k8s-authenticator:
git clone [email protected]:mintel/dex-k8s-authenticator.git
cd dex-k8s-authenticator/
Π‘ ΠΏΠΎΠΌΠΎΡΡΡ values-ΡΠ°ΠΉΠ»ΠΎΠ² ΠΌΡ ΠΌΠΎΠΆΠ΅ΠΌ Π³ΠΈΠ±ΠΊΠΎ Π½Π°ΡΡΡΠ°ΠΈΠ²Π°ΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅ Π΄Π»Ρ Π½Π°ΡΠΈΡ
ΠΠΏΠΈΡΠ΅ΠΌ ΠΊΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΡ Π΄Π»Ρ Dex:
cat << EOF > values-dex.yml
global:
deployEnv: prod
tls:
certificate: |-
-----BEGIN CERTIFICATE-----
AAAAAAAAAAABBBBBBBBBBCCCCCC
-----END CERTIFICATE-----
key: |-
-----BEGIN RSA PRIVATE KEY-----
DDDDDDDDDDDEEEEEEEEEEFFFFFF
-----END RSA PRIVATE KEY-----
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: "true"
path: /
hosts:
- dex.k8s.example.com
tls:
- secretName: cert-auth-dex
hosts:
- dex.k8s.example.com
serviceAccount:
create: true
name: dex-auth-sa
config: |
issuer: https://dex.k8s.example.com/
storage: # https://github.com/dexidp/dex/issues/798
type: sqlite3
config:
file: /var/dex.db
web:
http: 0.0.0.0:5556
frontend:
theme: "coreos"
issuer: "Example Co"
issuerUrl: "https://example.com"
logoUrl: https://example.com/images/logo-250x25.png
expiry:
signingKeys: "6h"
idTokens: "24h"
logger:
level: debug
format: json
oauth2:
responseTypes: ["code", "token", "id_token"]
skipApprovalScreen: true
connectors:
- type: github
id: github
name: GitHub
config:
clientID: $GITHUB_CLIENT_ID
clientSecret: $GITHUB_CLIENT_SECRET
redirectURI: https://dex.k8s.example.com/callback
orgs:
- name: super-org
teams:
- team-red
staticClients:
- id: dex-k8s-authenticator
name: dex-k8s-authenticator
secret: generatedLongRandomPhrase
redirectURIs:
- https://login.k8s.example.com/callback/
envSecrets:
GITHUB_CLIENT_ID: "1ab2c3d4e5f6g7h8"
GITHUB_CLIENT_SECRET: "98z76y54x32w1"
EOF
Π Π΄Π»Ρ dex-k8s-authenticator:
cat << EOF > values-auth.yml
global:
deployEnv: prod
dexK8sAuthenticator:
clusters:
- name: k8s.example.com
short_description: "k8s cluster"
description: "Kubernetes cluster"
issuer: https://dex.k8s.example.com/
k8s_master_uri: https://api.k8s.example.com
client_id: dex-k8s-authenticator
client_secret: generatedLongRandomPhrase
redirect_uri: https://login.k8s.example.com/callback/
k8s_ca_pem: |
-----BEGIN CERTIFICATE-----
AAAAAAAAAAABBBBBBBBBBCCCCCC
-----END CERTIFICATE-----
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: "true"
path: /
hosts:
- login.k8s.example.com
tls:
- secretName: cert-auth-login
hosts:
- login.k8s.example.com
EOF
Π£ΡΡΠ°Π½ΠΎΠ²ΠΈΠΌ Dex ΠΈ dex-k8s-authenticator:
helm install -n dex --namespace kube-system --values values-dex.yml charts/dex
helm install -n dex-auth --namespace kube-system --values values-auth.yml charts/dex-k8s-authenticator
ΠΡΠΎΠ²Π΅ΡΠΈΠΌ ΡΠ°Π±ΠΎΡΠΎΡΠΏΠΎΡΠΎΠ±Π½ΠΎΡΡΡ ΡΠ΅ΡΠ²ΠΈΡΠΎΠ² (Dex Π΄ΠΎΠ»ΠΆΠ΅Π½ Π²Π΅ΡΠ½ΡΡΡ ΠΊΠΎΠ΄ 400, Π° dex-k8s-authenticator β ΠΊΠΎΠ΄ 200):
curl -sI https://dex.k8s.example.com/callback | head -1
HTTP/2 400
curl -sI https://login.k8s.example.com/ | head -1
HTTP/2 200
RBAC-ΠΊΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΡ
Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ ClusterRole Π΄Π»Ρ Π³ΡΡΠΏΠΏΡ, Π² Π½Π°ΡΠ΅ΠΌ ΡΠ»ΡΡΠ°Π΅ Ρ read-only Π΄ΠΎΡΡΡΠΏΠ°ΠΌΠΈ:
cat << EOF | kubectl create -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: cluster-read-all
rules:
-
apiGroups:
- ""
- apps
- autoscaling
- batch
- extensions
- policy
- rbac.authorization.k8s.io
- storage.k8s.io
resources:
- componentstatuses
- configmaps
- cronjobs
- daemonsets
- deployments
- events
- endpoints
- horizontalpodautoscalers
- ingress
- ingresses
- jobs
- limitranges
- namespaces
- nodes
- pods
- pods/log
- pods/exec
- persistentvolumes
- persistentvolumeclaims
- resourcequotas
- replicasets
- replicationcontrollers
- serviceaccounts
- services
- statefulsets
- storageclasses
- clusterroles
- roles
verbs:
- get
- watch
- list
- nonResourceURLs: ["*"]
verbs:
- get
- watch
- list
- apiGroups: [""]
resources: ["pods/exec"]
verbs: ["create"]
EOF
Π‘ΠΎΠ·Π΄Π°Π΄ΠΈΠΌ ΠΊΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΡ Π΄Π»Ρ ClusterRoleBinding:
cat <<EOF | kubectl create -f -
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: dex-cluster-auth
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-read-all
subjects:
kind: Group
name: "super-org:team-red"
EOF
Π’Π΅ΠΏΠ΅ΡΡ ΠΌΡ Π³ΠΎΡΠΎΠ²Ρ ΠΊ ΡΠ΅ΡΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ.
Π’Π΅ΡΡΡ
ΠΠ΅ΡΠ΅Ρ
ΠΎΠ΄ΠΈΠΌ Π½Π° ΡΡΡΠ°Π½ΠΈΡΡ Π»ΠΎΠ³ΠΈΠ½Π° (https://login.k8s.example.com
) ΠΈ Π°Π²ΡΠΎΡΠΈΠ·ΡΠ΅ΠΌΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ GitHub-Π°ΠΊΠΊΠ°ΡΠ½ΡΠ°:
Π‘ΡΡΠ°Π½ΠΈΡΠ° Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΠΈΠΈ
Π‘ΡΡΠ°Π½ΠΈΡΠ° Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΠΈΠΈ ΠΏΠ΅ΡΠ΅Π½Π°ΠΏΡΠ°Π²Π»Π΅Π½Π½Π°Ρ Π½Π° GitHub
Β Π‘Π»Π΅Π΄ΡΠ΅ΠΌ ΡΠ³Π΅Π½Π΅ΡΠΈΡΠΎΠ²Π°Π½Π½ΠΎΠΉ ΠΈΠ½ΡΡΡΡΠΊΡΠΈΠΈ Π΄Π»Ρ ΠΏΠΎΠ»ΡΡΠ΅Π½ΠΈΡ Π΄ΠΎΡΡΡΠΏΠΎΠ²
ΠΠΎΡΠ»Π΅ ΠΊΠΎΠΏΠΈΠΏΠ°ΡΡΡ Ρ Π²Π΅Π±-ΡΡΡΠ°Π½ΠΈΡΡ ΠΌΡ ΠΌΠΎΠΆΠ΅ΠΌ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ kubectl Π΄Π»Ρ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ ΡΠ΅ΡΡΡΡΠ°ΠΌΠΈ Π½Π°ΡΠ΅Π³ΠΎ ΠΊΠ»Π°ΡΡΠ΅ΡΠ°:
kubectl get po
NAME READY STATUS RESTARTS AGE
mypod 1/1 Running 0 3d
kubectl delete po mypod
Error from server (Forbidden): pods "mypod" is forbidden: User "[email protected]" cannot delete pods in the namespace "default"
Π ΡΡΠΎ ΡΠ°Π±ΠΎΡΠ°Π΅Ρ, Π²ΡΠ΅ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΠΈ GitHub Π² Π½Π°ΡΠ΅ΠΉ ΠΎΡΠ³Π°Π½ΠΈΠ·Π°ΡΠΈΠΈ ΠΌΠΎΠ³ΡΡ Π²ΠΈΠ΄Π΅ΡΡ ΡΠ΅ΡΡΡΡΡ ΠΈ Π²Ρ
ΠΎΠ΄ΠΈΡΡ Π² ΠΏΠΎΠ΄Ρ, ΠΎΠ΄Π½Π°ΠΊΠΎ ΠΎΠ½ΠΈ Π½Π΅ ΠΈΠΌΠ΅ΡΡ ΠΏΡΠ°Π² Π½Π° ΠΈΡ
ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠ΅.
ΠΡΡΠΎΡΠ½ΠΈΠΊ: habr.com