Skip to content

Instantly share code, notes, and snippets.

@azlkiniue
Last active April 9, 2024 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azlkiniue/22f1e4a9d579ed1c68e7f6b566f99a1b to your computer and use it in GitHub Desktop.
Save azlkiniue/22f1e4a9d579ed1c68e7f6b566f99a1b to your computer and use it in GitHub Desktop.
Create Read-only Kubernetes Config
apiVersion: v1
kind: ServiceAccount
metadata:
name: read-only-user
secrets:
- name: read-only-secret
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: read-only-role
rules:
- apiGroups: [""]
resources: ["*"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: read-only-role-binding
subjects:
- kind: ServiceAccount
name: read-only-user
namespace: default # Replace with the namespace where you want to grant read-only access.
roleRef:
kind: ClusterRole
name: read-only-role
apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
kind: Secret
metadata:
name: read-only-secret
annotations:
kubernetes.io/service-account.name: read-only-user
type: kubernetes.io/service-account-token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment