[2026] Easy To Download CKS Actual Exam Dumps Resources [Q73-Q96]

Share

[2026] Easy To Download CKS Actual Exam Dumps Resources

Uplift Your CKS Exam Marks With The Help of CKS Dumps

NEW QUESTION # 73
SIMULATION
Create a PSP that will prevent the creation of privileged pods in the namespace.
Create a new PodSecurityPolicy named prevent-privileged-policy which prevents the creation of privileged pods.
Create a new ServiceAccount named psp-sa in the namespace default.
Create a new ClusterRole named prevent-role, which uses the newly created Pod Security Policy prevent-privileged-policy.
Create a new ClusterRoleBinding named prevent-role-binding, which binds the created ClusterRole prevent-role to the created SA psp-sa.
Also, Check the Configuration is working or not by trying to Create a Privileged pod, it should get failed.

Answer:

Explanation:
Create a PSP that will prevent the creation of privileged pods in the namespace.
$ cat clusterrole-use-privileged.yaml
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: use-privileged-psp
rules:
- apiGroups: ['policy']
resources: ['podsecuritypolicies']
verbs: ['use']
resourceNames:
- default-psp
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: privileged-role-bind
namespace: psp-test
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: use-privileged-psp
subjects:
- kind: ServiceAccount
name: privileged-sa
$ kubectl -n psp-test apply -f clusterrole-use-privileged.yaml
After a few moments, the privileged Pod should be created.
Create a new PodSecurityPolicy named prevent-privileged-policy which prevents the creation of privileged pods.
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: example
spec:
privileged: false # Don't allow privileged pods!
# The rest fills in some required fields.
seLinux:
rule: RunAsAny
supplementalGroups:
rule: RunAsAny
runAsUser:
rule: RunAsAny
fsGroup:
rule: RunAsAny
volumes:
- '*'
And create it with kubectl:
kubectl-admin create -f example-psp.yaml
Now, as the unprivileged user, try to create a simple pod:
kubectl-user create -f- <<EOF
apiVersion: v1
kind: Pod
metadata:
name: pause
spec:
containers:
- name: pause
image: k8s.gcr.io/pause
EOF
The output is similar to this:
Error from server (Forbidden): error when creating "STDIN": pods "pause" is forbidden: unable to validate against any pod security policy: [] Create a new ServiceAccount named psp-sa in the namespace default.
$ cat clusterrole-use-privileged.yaml
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: use-privileged-psp
rules:
- apiGroups: ['policy']
resources: ['podsecuritypolicies']
verbs: ['use']
resourceNames:
- default-psp
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: privileged-role-bind
namespace: psp-test
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: use-privileged-psp
subjects:
- kind: ServiceAccount
name: privileged-sa
$ kubectl -n psp-test apply -f clusterrole-use-privileged.yaml
After a few moments, the privileged Pod should be created.
Create a new ClusterRole named prevent-role, which uses the newly created Pod Security Policy prevent-privileged-policy.
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: example
spec:
privileged: false # Don't allow privileged pods!
# The rest fills in some required fields.
seLinux:
rule: RunAsAny
supplementalGroups:
rule: RunAsAny
runAsUser:
rule: RunAsAny
fsGroup:
rule: RunAsAny
volumes:
- '*'
And create it with kubectl:
kubectl-admin create -f example-psp.yaml
Now, as the unprivileged user, try to create a simple pod:
kubectl-user create -f- <<EOF
apiVersion: v1
kind: Pod
metadata:
name: pause
spec:
containers:
- name: pause
image: k8s.gcr.io/pause
EOF
The output is similar to this:
Error from server (Forbidden): error when creating "STDIN": pods "pause" is forbidden: unable to validate against any pod security policy: [] Create a new ClusterRoleBinding named prevent-role-binding, which binds the created ClusterRole prevent-role to the created SA psp-sa.
apiVersion: rbac.authorization.k8s.io/v1
# This role binding allows "jane" to read pods in the "default" namespace.
# You need to already have a Role named "pod-reader" in that namespace.
kind: RoleBinding
metadata:
name: read-pods
namespace: default
subjects:
# You can specify more than one "subject"
- kind: User
name: jane # "name" is case sensitive
apiGroup: rbac.authorization.k8s.io
roleRef:
# "roleRef" specifies the binding to a Role / ClusterRole
kind: Role #this must be Role or ClusterRole
name: pod-reader # this must match the name of the Role or ClusterRole you wish to bind to apiGroup: rbac.authorization.k8s.io apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata:
namespace: default
name: pod-reader
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["pods"]
verbs: ["get", "watch", "list"]


NEW QUESTION # 74
SIMULATION
Using the runtime detection tool Falco, Analyse the container behavior for at least 20 seconds, using filters that detect newly spawning and executing processes in a single container of Nginx.
store the incident file art /opt/falco-incident.txt, containing the detected incidents. one per line, in the format
[timestamp],[uid],[processName]

  • A. Send us the Feedback on it.

Answer: A


NEW QUESTION # 75
Analyze and edit the given Dockerfile
FROM ubuntu:latest
RUN apt-get update -y
RUN apt-install nginx -y
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
USER ROOT
Fixing two instructions present in the file being prominent security best practice issues Analyze and edit the deployment manifest file apiVersion: v1 kind: Pod metadata:
name: security-context-demo-2
spec:
securityContext:
runAsUser: 1000
containers:
- name: sec-ctx-demo-2
image: gcr.io/google-samples/node-hello:1.0
securityContext:
runAsUser: 0
privileged: True
allowPrivilegeEscalation: false
Fixing two fields present in the file being prominent security best practice issues Don't add or remove configuration settings; only modify the existing configuration settings Whenever you need an unprivileged user for any of the tasks, use user test-user with the user id 5487

  • A. Send us your Feedback on this.

Answer: A


NEW QUESTION # 76
SIMULATION
Use the kubesec docker images to scan the given YAML manifest, edit and apply the advised changes, and passed with a score of 4 points.
kubesec-test.yaml
apiVersion: v1
kind: Pod
metadata:
name: kubesec-demo
spec:
containers:
- name: kubesec-demo
image: gcr.io/google-samples/node-hello:1.0
securityContext:
readOnlyRootFilesystem: true
Hint: docker run -i kubesec/kubesec:512c5e0 scan /dev/stdin < kubesec-test.yaml

  • A. Send us the Feedback on it.

Answer: A


NEW QUESTION # 77
You have a Kubernetes cluster with a custom admission controller that enforces certain security policies. You need to write a script that can be used to test the functionality of the admission controller by creating a Pod With specific properties that should be rejected by the controller.

Answer:

Explanation:
Solution (Step by Step) :
1. Define tne admission controller policy:
- Assume the admission controller is configured to reject Pods that are not running in a specific namespace, like 'secure-namespace
2. Create a test Pod YAML file:

3. Write a Python script to create the Pod and check the result

4. Run the script: - Save the script as . - Execute the script using 'python test _ admission_controller.py' 5. Verify the results: - You should see the output indicating that the pod creation was rejected by the admission controller.


NEW QUESTION # 78
You can switch the cluster/configuration context using the following command:
[desk@cli] $ kubectl config use-context dev
A default-deny NetworkPolicy avoid to accidentally expose a Pod in a namespace that doesn't have any other NetworkPolicy defined.
Task: Create a new default-deny NetworkPolicy named deny-network in the namespace test for all traffic of type Ingress + Egress The new NetworkPolicy must deny all Ingress + Egress traffic in the namespace test.
Apply the newly created default-deny NetworkPolicy to all Pods running in namespace test.
You can find a skeleton manifests file at /home/cert_masters/network-policy.yaml

Answer:

Explanation:
master1 $ k get pods -n test --show-labels
NAME READY STATUS RESTARTS AGE LABELS
test-pod 1/1 Running 0 34s role=test,run=test-pod
testing 1/1 Running 0 17d run=testing
$ vim netpol.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-network
namespace: test
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
master1 $ k apply -f netpol.yaml
Explanation
controlplane $ k get pods -n test --show-labels
NAME READY STATUS RESTARTS AGE LABELS
test-pod 1/1 Running 0 34s role=test,run=test-pod
testing 1/1 Running 0 17d run=testing
master1 $ vim netpol1.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-network
namespace: test
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
master1 $ k apply -f netpol1.yaml Reference: https://kubernetes.io/docs/concepts/services-networking/network-policies/ Reference:
master1 $ k apply -f netpol1.yaml Reference: https://kubernetes.io/docs/concepts/services-networking/network-policies/ Explanation controlplane $ k get pods -n test --show-labels NAME READY STATUS RESTARTS AGE LABELS test-pod 1/1 Running 0 34s role=test,run=test-pod testing 1/1 Running 0 17d run=testing master1 $ vim netpol1.yaml apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata:
name: deny-network
namespace: test
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
master1 $ k apply -f netpol1.yaml Reference: https://kubernetes.io/docs/concepts/services-networking/network-policies/ master1 $ k apply -f netpol1.yaml Reference: https://kubernetes.io/docs/concepts/services-networking/network-policies/


NEW QUESTION # 79
Context
A default-deny NetworkPolicy avoids to accidentally expose a Pod in a namespace that doesn't have any other NetworkPolicy defined.
Task
Create a new default-deny NetworkPolicy named defaultdeny in the namespace testing for all traffic of type Egress.
The new NetworkPolicy must deny all Egress traffic in the namespace testing.
Apply the newly created default-deny NetworkPolicy to all Pods running in namespace testing.

Answer:

Explanation:



NEW QUESTION # 80
Your organization is running a critical application in a Kubernetes cluster, and you need to implement a system to monitor and detect any malicious activity within the containers. Describe how you can leverage audit logs and container runtime security tools like Sysdig to achieve this goal.

Answer:

Explanation:
Solution (Step by Step) :
1. Enable Kubernetes Audit Logging:
- Configure your Kubernetes cluster to generate audit logs. This involves enabling the 'audit' feature in the 'kube-apiserver' configuration and specifying the desired level of audit logging (e.g., 'Metadata', 'Request' , 'RequestResponse').
2. Define Audit Policies:
- Create audit policies to filter and prioritize the audit events you want to capture. For example, define a policy to audit all container image pulls and API requests related to specific resources.

3. Deploy Sysdig: - Install and configure Sysdig on your Kubernetes cluster Sysdig is a powerful container runtime security tool that provides real-time monitoring and threat detection capabilities. 4. Configure Sysdig Rules: - Create custom rules in Sysdig to detect suspicious activity within containers. These rules can be based on specific events, file access patterns, network connections, and other indicators of compromise.

5. Integrate with Logging and Monitoring Systems: - Integrate Sysdig with your existing logging and monitoring tools (e.g., ELK stack, Prometheus) to centralize and analyze security events. 6. Review and Analyze Logs: - Regularly review the audit logs and Sysdig alerts to identify any potential security threats. - Investigate suspicious events to understand the root cause and take appropriate actions.


NEW QUESTION # 81
You must complete this task on the following cluster/nodes:
Cluster: apparmor
Master node: master
Worker node: worker1
You can switch the cluster/configuration context using the following command:
[desk@cli] $ kubectl config use-context apparmor
Given: AppArmor is enabled on the worker1 node.
Task:
On the worker1 node,
1. Enforce the prepared AppArmor profile located at: /etc/apparmor.d/nginx
2. Edit the prepared manifest file located at /home/cert_masters/nginx.yaml to apply the apparmor profile
3. Create the Pod using this manifest

Answer:

Explanation:
[desk@cli] $ ssh worker1
[worker1@cli] $apparmor_parser -q /etc/apparmor.d/nginx
[worker1@cli] $aa-status | grep nginx
nginx-profile-1
[worker1@cli] $ logout
[desk@cli] $vim nginx-deploy.yaml
Add these lines under metadata:
annotations: # Add this line
container.apparmor.security.beta.kubernetes.io/<container-name>: localhost/nginx-profile-1
[desk@cli] $kubectl apply -f nginx-deploy.yaml
Explanation
[desk@cli] $ ssh worker1
[worker1@cli] $apparmor_parser -q /etc/apparmor.d/nginx
[worker1@cli] $aa-status | grep nginx
nginx-profile-1
[worker1@cli] $ logout
[desk@cli] $vim nginx-deploy.yaml

[desk@cli] $kubectl apply -f nginx-deploy.yaml pod/nginx-deploy created Reference: https://kubernetes.io/docs/tutorials/clusters/apparmor/ pod/nginx-deploy created
[desk@cli] $kubectl apply -f nginx-deploy.yaml pod/nginx-deploy created Reference: https://kubernetes.io/docs/tutorials/clusters/apparmor/


NEW QUESTION # 82
You are running a multi-tenant Kubernetes cluster where different teams deploy their applications. You are tasked with ensuring isolation between teams and preventing unauthorized access to sensitive dat
a. Describe how you can leverage pod security policies (PSP) and network policies to achieve this goal.

Answer:

Explanation:
Solution (Step by Step):
1. Define Pod Security Policies:
- Create separate PSPs for each team with different security constraints:
- Resource Limits: Limit the resources each team's pods can request (CPU, memory).
- Capabilities: Restrict specific capabilities like ' SYS_ADMIN' or 'NET_ADMIN'
- Security Context: Control the user and group IDs, privileged escalation, and SELinux labels for pods.
- Volume Types: Allow only specific types of volumes (e.g., emptyDir, hostPath, persistentV01umeClaim).
- Example PSP for Team A:

2. Apply PSPs to Teams: - Use 'kubectl apply -f team-a-psp.yaml' to apply the PSP for Team A. - Create and apply similar PSPs for other teams. - Apply these PSPs as admission controllers in your cluster to enforce them on all pods. 3. Configure Network Policies: - Define network policies to control communication between pods within different teams: - Ingress Policy: Control whicn pods can initiate connections to pods in otner teams. - Egress Policy: Control which pods can receive connections from pods in other teams. - Example Network Policy for Team A:

4. Apply Network Policies: - Use ' kubectl apply -f team-a-policy-yamp to apply the policy for Team A. - Create and apply similar policies for other teams. Result: - These PSPs and network policies enforce isolation between teams, limiting their access to resources and preventing unauthorized communication. - Teams can deploy their applications within their defined policies, minimizing the risk of cross-team vulnerabilities. - This approach ensures a secure and isolated environment for multi-tenant deployments.


NEW QUESTION # 83
Your Kubernetes cluster is configured with a default service account with broad permissions. You need to disable this default service account to enhance security and limit access to cluster resources.

Answer:

Explanation:
Solution (Step by Step):
1. Identify Default Service Account:
- Use the command 'kubectl get serviceaccount -n default default to identify the default service account in the default namespace.
2. Remove Default Service Account:
- You need to remove the default service account using the command 'kubectl delete serviceaccount default -n default
3. Review Permissions Check your RBAC configuration and ensure that no other roles or bindings grant unnecessary permissions to any other service accounts.
4. Create Custom Service Accounts: Create new, dedicated service accounts for each application or component that requires access to the cluster.
Assign specific roles or permissions to each service account based on its requirements.
Note: This process may require changes to your applications or configurations to use the new, dedicated service accounts instead of the default service account.


NEW QUESTION # 84
Using the runtime detection tool Falco, Analyse the container behavior for at least 20 seconds, using filters that detect newly spawning and executing processes in a single container of Nginx.

  • A. store the incident file art /opt/falco-incident.txt, containing the detected incidents. one per line, in the format

Answer: A

Explanation:
[timestamp],[uid],[processName]


NEW QUESTION # 85
On the Cluster worker node, enforce the prepared AppArmor profile
#include <tunables/global>
profile docker-nginx flags=(attach_disconnected,mediate_deleted) {
#include <abstractions/base>
network inet tcp,
network inet udp,
network inet icmp,
deny network raw,
deny network packet,
file,
umount,
deny /bin/** wl,
deny /boot/** wl,
deny /dev/** wl,
deny /etc/** wl,
deny /home/** wl,
deny /lib/** wl,
deny /lib64/** wl,
deny /media/** wl,
deny /mnt/** wl,
deny /opt/** wl,
deny /proc/** wl,
deny /root/** wl,
deny /sbin/** wl,
deny /srv/** wl,
deny /tmp/** wl,
deny /sys/** wl,
deny /usr/** wl,
audit /** w,
/var/run/nginx.pid w,
/usr/sbin/nginx ix,
deny /bin/dash mrwklx,
deny /bin/sh mrwklx,
deny /usr/bin/top mrwklx,
capability chown,
capability dac_override,
capability setuid,
capability setgid,
capability net_bind_service,
deny @{PROC}/* w, # deny write for all files directly in /proc (not in a subdir)
# deny write to files not in /proc/<number>/** or /proc/sys/**
deny @{PROC}/{[^1-9],[^1-9][^0-9],[^1-9s][^0-9y][^0-9s],[^1-9][^0-9][^0-9][^0-9]*}/** w, deny @{PROC}/sys/[^k]** w, # deny /proc/sys except /proc/sys/k* (effectively /proc/sys/kernel) deny @{PROC}/sys/kernel/{?,??,[^s][^h][^m]**} w, # deny everything except shm* in /proc/sys/kernel/ deny @{PROC}/sysrq-trigger rwklx, deny @{PROC}/mem rwklx, deny @{PROC}/kmem rwklx, deny @{PROC}/kcore rwklx, deny mount, deny /sys/[^f]*/** wklx, deny /sys/f[^s]*/** wklx, deny /sys/fs/[^c]*/** wklx, deny /sys/fs/c[^g]*/** wklx, deny /sys/fs/cg[^r]*/** wklx, deny /sys/firmware/** rwklx, deny /sys/kernel/security/** rwklx,
}
Edit the prepared manifest file to include the AppArmor profile.
apiVersion: v1
kind: Pod
metadata:
name: apparmor-pod
spec:
containers:
- name: apparmor-pod
image: nginx
Finally, apply the manifests files and create the Pod specified on it.
Verify: Try to use command ping, top, sh

  • A. Send us your Feedback on this.

Answer: A


NEW QUESTION # 86
You have a Kubernetes cluster with a Deployment named 'my-app' that exposes a service on port 80. You want to enforce a policy that allows only traffic from pods With a specific label to access this service.

Answer:

Explanation:
Solution (Step by Step) :
1. Create a NetworkPolicy:
- Define a NetworkPolicy resource with a 'podSelector' that matches the 'my-app' Deployment.
- Create an 'ingress' rule that allows traffic only from pods with the specific label.
- Use the 'from' field to specify the label selector.
- Ensure that the port 80 is included in the 'ports' field.

2. Apply the NetworkPolicy: - Apply the YAML file using 'kubectl apply -f my-app-label-policy-yamr 3. Verify the NetworkPolicy: - Use 'kubectl get networkpolicies' to list the available network policies. - Use 'kubectl describe networkpolicy my-app-label-policy' to view the details ot the applied policy. 4. Test the NetworkPolicy: - Deploy a pod with the label 'allowed: true' and attempt to access the service on port 80. Verify that the connection is successful. - Deploy a pod without the label 'allowed: true' and attempt to access the service on port 80. Verify that the connection is denied.


NEW QUESTION # 87
You have an Nginx pod deployed in your Kubernetes cluster. You need to set up a PodSecurityPolicy (PSP) that allows the Nginx pod to access only specific network ports and disallows it from accessing other ports. Describe the steps you would take to implement this PSP.

Answer:

Explanation:
Solution (Step by Step) :
1. Create PodSecurityPolicy (PSP):
- Define a PodSecurityPolicy (PSP) YAML file. This file will restrict the Nginx pod's network access.
- For example, you could define a PSP that allows the Nginx pod to access ports 80 and 443 (HTTP and HTTPS) but restricts access to all other ports:

2. Apply the PSPI - Apply the PSP YAML file using 'kubectl apply -f nginx-psp.yaml' 3. Bind the PSP to the Nginx Pod: - Update the Nginx deployment or pod definition to include the 'securityContext' field with a reference to the created PSP:

4. Verify the psp: - Check that the Nginx pod is using the PSP by running 'kubectl describe pod ' . You should see the PSP name listed in the "Security Context" section. 5. Test Access: - Verity that the Nginx pod can access ports 80 and 443 but not other ports. You can use tools like 'telnet or 'nc' to test connectivity.


NEW QUESTION # 88
You are tasked with securing a Kubernetes cluster that runs sensitive workloads. To prevent unauthorized access, you need to ensure container immutability at runtime. How would you implement a solution that prevents any modifications to the running containers once they are launched? Provide a detailed breakdown of the steps and configurations you would use.

Answer:

Explanation:
Solution (Step by Step) :
1. Enable Read-Only Root Filesystem:
- Configuration:
- Set the 'securityContext.readOnlyRootFilesystem' flag to 'true' in your Pod specification. This ensures that the containers root filesystem is mounted as read-only.
- Example:

2. Disable Privileged Containers: - Configuration: - Set tne 'securitycontext.privileged' flag to 'false' in your Pod specification. This prevents containers from running with escalated privileges, limiting their ability to modify the host system. - Example:

3. Implement Admission Webhook with Container Image Scanning: - Configuration: - Configure an admission webhook using tools like Open Policy Agent (OPA) or Kyverno to inspect container images before they are launched. - Use a container image scanner (e.g., Clair, Ancnore) to analyze images for vulnerabilities and ensure they adhere to your security policies. - Example COPA):

4. Use Immutable Pod Specs: - Configuration: - Utilize the field to specify the container image. - Avoid using in your pod spec. This ensures that the pod's resources are not modifiable during runtime. - Example:

5. Enforce Network Security Policies (NSPs): - Configuration: - Implement Network Security Policies to control network traffic flow between pods within the cluster. This helps prevent unauthorized communication and limits the attack surface. - Example:

Note: This approach offers a multi-layered defense-in-depth strategy for ensuring container immutability at runtime, but you should also consider implementing additional security measures such as container image signing and secure runtime environments.


NEW QUESTION # 89
Create a new NetworkPolicy named deny-all in the namespace testing which denies all traffic of type ingress and egress traffic

Answer:

Explanation:
You can create a "default" isolation policy for a namespace by creating a NetworkPolicy that selects all pods but does not allow any ingress traffic to those pods.
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-ingress
spec:
podSelector: {}
policyTypes:
- Ingress
You can create a "default" egress isolation policy for a namespace by creating a NetworkPolicy that selects all pods but does not allow any egress traffic from those pods.
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-all-egress
spec:
podSelector: {}
egress:
- {}
policyTypes:
- Egress
Default deny all ingress and all egress traffic
You can create a "default" policy for a namespace which prevents all ingress AND egress traffic by creating the following NetworkPolicy in that namespace.
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-all
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
This ensures that even pods that aren't selected by any other NetworkPolicy will not be allowed ingress or egress traffic.


NEW QUESTION # 90
Enable audit logs in the cluster, To Do so, enable the log backend, and ensure that
1. logs are stored at /var/log/kubernetes/kubernetes-logs.txt.
2. Log files are retained for 5 days.
3. at maximum, a number of 10 old audit logs files are retained.
Edit and extend the basic policy to log:

  • A. 1. Cronjobs changes at RequestResponse

Answer: A

Explanation:
2. Log the request body of deployments changes in the namespace kube-system.
3. Log all other resources in core and extensions at the Request level.
4. Don't log watch requests by the "system:kube-proxy" on endpoints or


NEW QUESTION # 91
You are running a critical web application on Kubernetes. You have implemented Pod Security Policies (PSPs) to enforce security restrictions on your pods. You want to configure PSPs to enforce the following security requirements:
Only allow specific image registries: Ensure pods can only pull images from authorized registries like 'docker.ios and 'gcr.ios. Restrict container privileges: Enforce the principle of least privilege by ensuring that only a minimum number of containers have root privileges. Limit resource usage: Prevent resource starvation by restricting the CPU and memory requests of pods.
Provide the detailed configuration for your PSP to enforce these security requirements.

Answer:

Explanation:
Solution (Step by Step) :
1. create a PSP YAML file:

2. Apply the PSP: bash kubectl apply -f restricted-psp.yaml 3. Create a Deployment with a securityContext

4. Apply the Deployment: bash kubectl apply -f myapp-deploymentyaml Note: This configuration assumes that the 'restricted-psps is applied to your entire namespace. You can use a more granular approach by applying the PSP to specific pods or deployments.


NEW QUESTION # 92
You are configuring a Kubernetes cluster with a deployment named 'secure-app' that uses a secret named 'my-secret to access sensitive information You need to implement an Admission Controller webhook to enforce a policy that prevents the deployment from starting if the 'my-secret secret is not present in the cluster.

Answer:

Explanation:
Solution (Step by Step) :
1. Create a Deployment with a Secret Dependency:
- Create a Deployment YAML file named 'secure-app-deployment.yaml that depends on the 'my-secret secret.

2. Create the Admission Controller Webhook Server: - You will need to create a server that will implement the Admission Controller webhook logic This can be a simple web server written in any language that can receive and process AdmissionReview requests. - Here's an example in Node.js using the 'express' framework:

3. Configure the Admission Controller Webhook in Kubernetes: - Create a ValidatingWebhookConfiguration YAML file named 'secure-app-webhook.yaml that specifies the webhook configuration:

- Create the Webhook Service: - Create a Service YAML file named 'secure-app-webhook-service.yamr to expose the webhook server:k

4. Apply the Webhook Configuration and Service: - Apply the YAML files using kubectl apply -f secure-app-webhook.yaml secure-app-webhook-service.yaml 5. Test the Admission Controller: - Try creating the 'secure-app' deployment without the 'my-secret' secret. The deployment creation should fail, and you should see the message from the webhook server - Create the 'my-secret' secret and then try creating the 'secure-app' deployment again. The deployment should now be created successfully.


NEW QUESTION # 93
Your Kubernetes cluster utilizes a container registry hosted on-premise. You want to implement a mechanism to automatically scan images stored in this registry for known vulnerabilities before they are deployed to the cluster. Describe the steps involved in setting up this vulnerability scanning process.

Answer:

Explanation:
Solution (Step by Step) :
1. Choose a Vulnerability Scanner: Select a suitable vulnerability scanner that integrates with your on-premise container registry_ Some popular options include Anchoret Clair, and Trivy.
2. Integrate the Scanner: Configure the chosen scanner to access your on-premise container registry. This might involve providing credentials or setting up network access.
3. Configure Scanning Triggers: Set up triggers within your container registry or CI/CD pipeline that initiate a vulnerability scan whenever a new image is pushed to the registry.
4. Define Scan Policies: Establish scan policies that define the severity levels of vulnerabilities to be flagged and the actions to be taken (e.g., block deployment, send notifications).
5. Integrate with Kubernetes: Integrate the vulnerability scanner with your Kubernetes cluster. This might involve using a Kubemetes admission controller or writing custom scripts to prevent deployments with vulnerable images.
6. Test and Validate: Test the vulnerability scanning process by pushing a known vulnerable image to your registry and verifying that it is flagged and blocked from deployment.


NEW QUESTION # 94
Create a PSP that will prevent the creation of privileged pods in the namespace.
Create a new PodSecurityPolicy named prevent-privileged-policy which prevents the creation of privileged pods.
Create a new ServiceAccount named psp-sa in the namespace default.
Create a new ClusterRole named prevent-role, which uses the newly created Pod Security Policy prevent-privileged-policy.
Create a new ClusterRoleBinding named prevent-role-binding, which binds the created ClusterRole prevent-role to the created SA psp-sa.
Also, Check the Configuration is working or not by trying to Create a Privileged pod, it should get failed.

Answer:

Explanation:
Create a PSP that will prevent the creation of privileged pods in the namespace.
$ cat clusterrole-use-privileged.yaml
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: use-privileged-psp
rules:
- apiGroups: ['policy']
resources: ['podsecuritypolicies']
verbs: ['use']
resourceNames:
- default-psp
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: privileged-role-bind
namespace: psp-test
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: use-privileged-psp
subjects:
- kind: ServiceAccount
name: privileged-sa
$ kubectl -n psp-test apply -f clusterrole-use-privileged.yaml
After a few moments, the privileged Pod should be created.
Create a new PodSecurityPolicy named prevent-privileged-policy which prevents the creation of privileged pods.
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: example
spec:
privileged: false # Don't allow privileged pods!
# The rest fills in some required fields.
seLinux:
rule: RunAsAny
supplementalGroups:
rule: RunAsAny
runAsUser:
rule: RunAsAny
fsGroup:
rule: RunAsAny
volumes:
- '*'
And create it with kubectl:
kubectl-admin create -f example-psp.yaml
Now, as the unprivileged user, try to create a simple pod:
kubectl-user create -f- <<EOF
apiVersion: v1
kind: Pod
metadata:
name: pause
spec:
containers:
- name: pause
image: k8s.gcr.io/pause
EOF
The output is similar to this:
Error from server (Forbidden): error when creating "STDIN": pods "pause" is forbidden: unable to validate against any pod security policy: [] Create a new ServiceAccount named psp-sa in the namespace default.
$ cat clusterrole-use-privileged.yaml
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: use-privileged-psp
rules:
- apiGroups: ['policy']
resources: ['podsecuritypolicies']
verbs: ['use']
resourceNames:
- default-psp
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: privileged-role-bind
namespace: psp-test
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: use-privileged-psp
subjects:
- kind: ServiceAccount
name: privileged-sa
$ kubectl -n psp-test apply -f clusterrole-use-privileged.yaml
After a few moments, the privileged Pod should be created.
Create a new ClusterRole named prevent-role, which uses the newly created Pod Security Policy prevent-privileged-policy.
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: example
spec:
privileged: false # Don't allow privileged pods!
# The rest fills in some required fields.
seLinux:
rule: RunAsAny
supplementalGroups:
rule: RunAsAny
runAsUser:
rule: RunAsAny
fsGroup:
rule: RunAsAny
volumes:
- '*'
And create it with kubectl:
kubectl-admin create -f example-psp.yaml
Now, as the unprivileged user, try to create a simple pod:
kubectl-user create -f- <<EOF
apiVersion: v1
kind: Pod
metadata:
name: pause
spec:
containers:
- name: pause
image: k8s.gcr.io/pause
EOF
The output is similar to this:
Error from server (Forbidden): error when creating "STDIN": pods "pause" is forbidden: unable to validate against any pod security policy: [] Create a new ClusterRoleBinding named prevent-role-binding, which binds the created ClusterRole prevent-role to the created SA psp-sa.
apiVersion: rbac.authorization.k8s.io/v1
# This role binding allows "jane" to read pods in the "default" namespace.
# You need to already have a Role named "pod-reader" in that namespace.
kind: RoleBinding
metadata:
name: read-pods
namespace: default
subjects:
# You can specify more than one "subject"
- kind: User
name: jane # "name" is case sensitive
apiGroup: rbac.authorization.k8s.io
roleRef:
# "roleRef" specifies the binding to a Role / ClusterRole
kind: Role #this must be Role or ClusterRole
name: pod-reader # this must match the name of the Role or ClusterRole you wish to bind to apiGroup: rbac.authorization.k8s.io apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata:
namespace: default
name: pod-reader
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["pods"]
verbs: ["get", "watch", "list"]


NEW QUESTION # 95
You have a Kubernetes cluster with a deployment named 'web-app' running a web applicatiom You suspect that a specific user with the username 'malicious-user' might be attempting unauthorized access to the cluster To investigate this, you want to use Kubernetes audit logs to identify any attempts made by this user to access resources within your namespace 'my-namespace'.
How would you configure Kubernetes audit logging and filter the logs to isolate potential malicious activity by 'malicious-user within the 'my- namespace' namespace?

Answer:

Explanation:
Solution (Step by Step):
1. Enable Kubernetes Audit Logging:
- Create a ConfigMap named 'audit-policy' with the following content:

- Apply the ConfigMap to the cluster: bash kubectl apply -f audit-policy-yaml 2 Configure the Audit Backend: - Create a ConfigMap named 'audit-sink' with the following content

- Apply the ConfigMap: bash kubectl apply -f audit-sink-yaml 3. Filter Audit Logs: - Use ' kubectl logs -f -n kube-system' to view the audit logs. - Filter tne logs for requests made by 'malicious-user' Within 'my-namespace'- bash kubectl logs -f -n kube-system I grep "user.name=malicious-user" I grep "namespace-my-namespace" - This command will display any audit log entries related to requests made by 'malicious-user' within the my-namespace' namespace. 4. Analyze the Logs: - Examine the logs for suspicious activity, such as attempts to access sensitive resources, perform unauthorized actions, or exploit vulnerabilities. - Use the information gathered from the audit logs to take appropriate security measures. Note: - The 'lever field in the audit policy can be customized to control the level ot detail in the audit logs. For example, 'Metadata' logs only the request metadata, while 'Request' logs all details of the request - The audit logs will be stored according to the configuration of the 'audit-sink' ConfigMap. - This is a basic example. You may need to adjust the filters and analysis techniques based on your specific security requirements.


NEW QUESTION # 96
......

Use Linux Foundation CKS Dumps To Succeed Instantly in CKS Exam: https://www.examcollectionpass.com/Linux-Foundation/CKS-practice-exam-dumps.html

Ultimate Guide to CKS Dumps - Enhance Your Future Career Now: https://drive.google.com/open?id=1C_JMtMIG7iA28Vavyh2cS7sIGmwVmJtZ