Created
October 22, 2018 18:17
-
-
Save surajssd/49366480c7c82eafef810ed598542a7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo " | |
apiVersion: policy/v1beta1 | |
kind: PodSecurityPolicy | |
metadata: | |
name: privileged | |
annotations: | |
seccomp.security.alpha.kubernetes.io/allowedProfileNames: '*' | |
spec: | |
privileged: true | |
allowPrivilegeEscalation: true | |
allowedCapabilities: | |
- '*' | |
volumes: | |
- '*' | |
hostNetwork: true | |
hostPorts: | |
- min: 0 | |
max: 65535 | |
hostIPC: true | |
hostPID: true | |
runAsUser: | |
rule: 'RunAsAny' | |
seLinux: | |
rule: 'RunAsAny' | |
supplementalGroups: | |
rule: 'RunAsAny' | |
fsGroup: | |
rule: 'RunAsAny' | |
--- | |
kind: ClusterRole | |
apiVersion: rbac.authorization.k8s.io/v1 | |
metadata: | |
name: privileged-psp | |
rules: | |
- apiGroups: ['policy'] | |
resources: ['podsecuritypolicies'] | |
verbs: ['use'] | |
resourceNames: | |
- privileged | |
--- | |
kind: ClusterRoleBinding | |
apiVersion: rbac.authorization.k8s.io/v1 | |
metadata: | |
name: privileged-psp-cluster-admins | |
roleRef: | |
kind: ClusterRole | |
name: privileged-psp | |
apiGroup: rbac.authorization.k8s.io | |
subjects: | |
- kind: Group | |
name: system:serviceaccount:kube-system | |
apiGroup: rbac.authorization.k8s.io | |
" | kubectl apply -f - | |
kubectl --kubeconfig kubeconfig create ns psp-testing | |
kubectl --kubeconfig kubeconfig -n psp-testing run web --image httpd | |
kubectl --kubeconfig kubeconfig -n psp-testing get deployment web -o jsonpath='{.status.conditions[-1:].message}' | |
echo " | |
kind: ClusterRoleBinding | |
apiVersion: rbac.authorization.k8s.io/v1 | |
metadata: | |
name: privileged-psp-cluster-admins | |
roleRef: | |
kind: ClusterRole | |
name: privileged-psp | |
apiGroup: rbac.authorization.k8s.io | |
subjects: | |
- kind: Group | |
name: system:serviceaccounts:kube-system | |
apiGroup: rbac.authorization.k8s.io | |
" | kubectl apply -f - | |
kubectl --kubeconfig kubeconfig create ns psp-testing2 | |
kubectl --kubeconfig kubeconfig -n psp-testing2 run web --image httpd | |
kubectl --kubeconfig kubeconfig -n psp-testing2 get pods |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment