From f929a46d2b750d4be4aeb230573052c063bceecd Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 3 Sep 2026 13:41:35 +0000 Subject: [PATCH] training --- pod-sec/101-pod.yaml | 8 +++++++- training/np/0-namespace.yaml | 4 ++++ training/np/1-np.yaml | 11 +++++++++++ training/np/2-pod.yaml | 14 ++++++++++++++ training/np/3-service.yaml | 11 +++++++++++ training/rbac/pod.yaml | 14 ++++++++++++++ training/rbac/rb.yaml | 12 ++++++++++++ training/rbac/role.yaml | 13 +++++++++++++ training/rbac/sa.yaml | 4 ++++ 9 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 training/np/0-namespace.yaml create mode 100644 training/np/1-np.yaml create mode 100644 training/np/2-pod.yaml create mode 100644 training/np/3-service.yaml create mode 100644 training/rbac/pod.yaml create mode 100644 training/rbac/rb.yaml create mode 100644 training/rbac/role.yaml create mode 100644 training/rbac/sa.yaml 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