diff --git a/pod-sec/101-pod.yaml b/pod-sec/101-pod.yaml index 9bd1463..c8c27dc 100644 --- a/pod-sec/101-pod.yaml +++ b/pod-sec/101-pod.yaml @@ -10,4 +10,10 @@ spec: resources: {} ports: - containerPort: 3000 - + securityContext: + allowPrivilegeEscalation: false + runAsNonRoot: true + seccompProfile: + type: RuntimeDefault + capabilities: + drop: ["ALL"] \ No newline at end of file diff --git a/training/np/0-namespace.yaml b/training/np/0-namespace.yaml new file mode 100644 index 0000000..f07853b --- /dev/null +++ b/training/np/0-namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: isolated \ No newline at end of file diff --git a/training/np/1-np.yaml b/training/np/1-np.yaml new file mode 100644 index 0000000..11d4c31 --- /dev/null +++ b/training/np/1-np.yaml @@ -0,0 +1,11 @@ +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: all-deny + namespace: isolated +spec: + podSelector: + matchLabels: + app: http + policyTypes: + - Egress diff --git a/training/np/2-pod.yaml b/training/np/2-pod.yaml new file mode 100644 index 0000000..1e08b31 --- /dev/null +++ b/training/np/2-pod.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Pod +metadata: + name: web + namespace: isolated + labels: + app: http +spec: + containers: + - name: myapp + image: nginx + resources: {} + ports: + - containerPort: 80 diff --git a/training/np/3-service.yaml b/training/np/3-service.yaml new file mode 100644 index 0000000..92cffd1 --- /dev/null +++ b/training/np/3-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: web + namespace: isolated +spec: + selector: + app: http + ports: + - port: 80 + targetPort: 80 diff --git a/training/rbac/pod.yaml b/training/rbac/pod.yaml new file mode 100644 index 0000000..062dddc --- /dev/null +++ b/training/rbac/pod.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Pod +metadata: + labels: + run: shell + name: shell +spec: + serviceAccount: demo + containers: + - image: ghcr.io/trion-development/kubectl:1 + name: shell + tty: true + resources: {} + \ No newline at end of file diff --git a/training/rbac/rb.yaml b/training/rbac/rb.yaml new file mode 100644 index 0000000..2015821 --- /dev/null +++ b/training/rbac/rb.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: pod-reader +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: pod-reader +subjects: +- kind: ServiceAccount + name: demo + namespace: default diff --git a/training/rbac/role.yaml b/training/rbac/role.yaml new file mode 100644 index 0000000..628afa7 --- /dev/null +++ b/training/rbac/role.yaml @@ -0,0 +1,13 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: pod-reader +rules: +- apiGroups: + - "" + resources: + - pods + verbs: + - get + - list + - watch diff --git a/training/rbac/sa.yaml b/training/rbac/sa.yaml new file mode 100644 index 0000000..4d95351 --- /dev/null +++ b/training/rbac/sa.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: demo