IEIT by Elias
Connexion

Droits RBAC et packaging avec Helm

RBAC

Les droits dans Kubernetes reposent sur quatre objets :

ObjetPortée
RoleDes permissions dans un namespace
ClusterRoleDes permissions sur tout le cluster ou réutilisables
RoleBindingAttribue un Role ou ClusterRole dans un namespace
ClusterRoleBindingAttribue un ClusterRole sur tout le cluster

Exemple : l'équipe applicative peut tout lire et redémarrer les déploiements dans son namespace, rien d'autre.

rbac.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: app-operator
  namespace: app
rules:
  - apiGroups: ["", "apps"]
    resources: ["pods", "pods/log", "services", "deployments"]
    verbs: ["get", "list", "watch"]
  - apiGroups: ["apps"]
    resources: ["deployments"]
    verbs: ["patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: app-operator
  namespace: app
subjects:
  - kind: Group
    name: equipe-app
    apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: app-operator
  apiGroup: rbac.authorization.k8s.io
bash
kubectl auth can-i patch deployments -n app --as-group=equipe-app --as=test

Les applications qui appellent l'API utilisent un ServiceAccount lié à un Role, jamais le compte par défaut avec des droits étendus.

Helm

Helm empaquette une application (manifestes, valeurs par défaut, dépendances) en chart versionné.

bash
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
helm search repo grafana/grafana
helm show values grafana/grafana > grafana-values.yaml   # valeurs modifiables

helm install grafana grafana/grafana -n monitoring --create-namespace -f grafana-values.yaml
helm list -A
helm upgrade grafana grafana/grafana -n monitoring -f grafana-values.yaml
helm history grafana -n monitoring
helm rollback grafana 1 -n monitoring
helm uninstall grafana -n monitoring

Créer son propre chart

bash
helm create monapp
helm template monapp ./monapp -f valeurs-prod.yaml     # voir les manifestes générés
helm lint ./monapp