CKS PDF問題集で2026年01月04日最近更新された問題 [Q70-Q86]

Share

CKS PDF問題集で2026年01月04日最近更新された問題

CKS試験問題有効なCKS問題集PDF


CKS認定試験は、候補者のKubernetesセキュリティの専門知識を実世界のシナリオでテストするために設計されています。試験はオンラインで実施され、多肢選択問題、パフォーマンスベースのタスク、そして実践的なラボで構成されています。試験は、Kubernetesクラスタのセットアップ、ネットワークポリシー、ポッドセキュリティポリシー、ノードセキュリティ、コンテナセキュリティ、そしてRBAC(ロールベースアクセスコントロール)を含む幅広いトピックをカバーしています。CKS試験は、Kubernetesセキュリティの概念とベストプラクティスに対する深い理解が必要な厳しい試験です。ただし、試験に合格することは、ITプロフェッショナルがKubernetesおよびコンテナセキュリティの分野でキャリアを進めるのに役立つ大きな成果です。

 

質問 # 70
SIMULATION
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 the Feedback on it.

正解:A


質問 # 71
Context: Cluster: prod Master node: master1 Worker node: worker1
You can switch the cluster/configuration context using the following command:
[desk@cli] $ kubectl config use-context prod
Task: Analyse and edit the given Dockerfile (based on the ubuntu:18:04 image) /home/cert_masters/Dockerfile fixing two instructions present in the file being prominent security/best-practice issues.
Analyse and edit the given manifest file /home/cert_masters/mydeployment.yaml fixing two fields present in the file being prominent security/best-practice issues.
Note: Don't add or remove configuration settings; only modify the existing configuration settings, so that two configuration settings each are no longer security/best-practice concerns. Should you need an unprivileged user for any of the tasks, use user nobody with user id 65535

正解:

解説:
1. For Dockerfile: Fix the image version & user name in Dockerfile 2. For mydeployment.yaml : Fix security contexts Explanation
[desk@cli] $ vim /home/cert_masters/Dockerfile
FROM ubuntu:latest # Remove this
FROM ubuntu:18.04 # Add this
USER root # Remove this
USER nobody # Add this
RUN apt get install -y lsof=4.72 wget=1.17.1 nginx=4.2
ENV ENVIRONMENT=testing
USER root # Remove this
USER nobody # Add this
CMD ["nginx -d"]

[desk@cli] $ vim /home/cert_masters/mydeployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: kafka
name: kafka
spec:
replicas: 1
selector:
matchLabels:
app: kafka
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: kafka
spec:
containers:
- image: bitnami/kafka
name: kafka
volumeMounts:
- name: kafka-vol
mountPath: /var/lib/kafka
securityContext:
{"capabilities":{"add":["NET_ADMIN"],"drop":["all"]},"privileged": True,"readOnlyRootFilesystem": False, "runAsUser": 65535} # Delete This
{"capabilities":{"add":["NET_ADMIN"],"drop":["all"]},"privileged": False,"readOnlyRootFilesystem": True, "runAsUser": 65535} # Add This resources: {} volumes:
- name: kafka-vol
emptyDir: {}
status: {}
Pictorial View: [desk@cli] $ vim /home/cert_masters/mydeployment.yaml


質問 # 72
You are managing a Kubernetes cluster running on AWS and need to assess the security configuration of the kubelet service against the CIS Kubernetes Benchmark v1 -7.1. You suspect that the '--cgroup-driver' flag is not properly configured, which could potentially expose the cluster to security vulnerabilities. Describe how you would use 'kubectl' to audit the current kubelet configuration and then determine the appropriate configuration tor the '-cgroup-driver' flag based on the CIS benchmark guidance. Assume that the kubelet service is running in a containerized environment.

正解:

解説:
Solution (Step by Step) :
1. Audit the kubelet configuration:
- Execute the following command to retrieve the kubelet configuration:
bash
kubectl get nodes -o jsonpath='{.items0.status.nodelnfo.kubeletVersion}'
- This command will output the kubelet version, which can be used to identifry the specific version of the CIS Kubernetes Benchmark that applies.
- Use 'kubectl describe node to retrieve the kubelet configuration for the specific node.
2. Review the CIS Benchmark guidance:
- Refer to the CIS Kubernetes Benchmark v1 -7.1 document for the specific guidance on the '--cgroup-driver' flag. The benchmark typically recommends using a specific 'cgroup-driver' value depending on the Kubernetes version and the underlying operating systenm
- For example, on a Kubernetes cluster running on AWS, the CIS bencnmark may recommend using the 'systemd' cgroup driver.
3. Determine the current kubelet configuration:
- Check the output of 'kubectl describe node for the value of the flag.
- This will show you the current configuration of the '-cgroup-driver' flag for the kubelet
5. Update the kubelet configuratiom
- Update the kubelet configuration for each node in your cluster to reflect the CIS benchmark recommendation. This may involve editing the kubelet configuration file or using a tool such as kubeadm or kubectl to modify the kubelet configuration.
6. Verify the changes:
- Run the audit commands again to verify that the kubelet configuration has been updated as expected.


質問 # 73
You are managing a Kubernetes cluster With several applications running within pods. Your security policy mandates that all pods should run with the 'privileged' flag set to 'false' , while allowing a few pods to run with privileged access for specific tasks. How would you implement this policy by leveraging the Kubernetes security best practices?

正解:

解説:
Solution (Step by Step) :
1. Create a Security Context Constraint (SCC): Create a new SCC named 'non-privileged-sce with the following configuration:
- 'allowPrivilegeEscalation': 'false' (Prevents pods from elevating privileges even if they run with privileged containers)
- 'privileged': 'false' (Disallows containers from running with privileged access)
- 'runAsLJser': ' 1000' (Assigns a specific non-root user ID for containers)
- 'readOnlyRootFilesystem': 'true' (Prevents containers from modifying the host's root filesystem)
- 'seccompProfile': 'localhost/unconfined' (Specifies a seccomp profile for restricting system calls)

2. Apply the SCC: Apply the SCC using 'kuoectl apply -f non-privileged-scc.yaml 3. Create a Second SCC for Privileged Pods: Create a new SCC named 'privileged-sce with the following configuratiom - 'allowPrivilegeEscalation': 'trues - 'privileged': 'true' - 'runAsuser': - 'readOnlyRootFilesystem': 'false' - 'seccompprofile': 'localhost/unconfined'

4. Apply the Privileged SCC: Apply the SCC using 'kubectl apply -f privileged-scc.yaml 5. Update Your Deployment Configurations: - For deployments requiring privileged access, include 'securityContext.securityContextConstraints: privileged-sce within the pod specification. - For all other deployments, include 'securityContext.securityContextConstraints: non-prjvileged-scc' within the pod specification.

6. Restrict Access to SCCs: You can funer enhance security by configuring which users or service accounts can use each SCC. This can be done by using Role-Based Access Control (RBAC) to grant permissions to specific user accounts or service accounts for the SCCs.

This approach ensures that the majority of pods operate with minimal privileges, enhancing security, while allowing a few essential deployments to run with elevated access. Remember to constantly review and update your security policies as your cluster and applications evolve.


質問 # 74
You have a Kubernetes cluster with a Deployment named 'secure-app-deployment running a sensitive application. You want to ensure that only authorized users can access the application's pods and its sensitive data.
How would you use Role-Based Access Control (RBAC) to restrict access to the 'secure-app-deployment' and its resources?

正解:

解説:
Solution (Step by Step) :
1. Create a Service Account for the Application:

2. Create a Role for the Service Account


質問 # 75
Cluster: scanner
Master node: controlplane
Worker node: worker1
You can switch the cluster/configuration context using the following command:
[desk@cli] $ kubectl config use-context scanner
Given:
You may use Trivy's documentation.
Task:
Use the Trivy open-source container scanner to detect images with severe vulnerabilities used by Pods in the namespace nato.
Look for images with High or Critical severity vulnerabilities and delete the Pods that use those images.
Trivy is pre-installed on the cluster's master node. Use cluster's master node to use Trivy.

正解:

解説:
[controlplane@cli] $ k get pods -n nato -o yaml | grep "image: "
[controlplane@cli] $ trivy image <image-name>
[controlplane@cli] $ k delete pod <vulnerable-pod> -n nato
[desk@cli] $ ssh controlnode
[controlplane@cli] $ k get pods -n nato
NAME READY STATUS RESTARTS AGE
alohmora 1/1 Running 0 3m7s
c3d3 1/1 Running 0 2m54s
neon-pod 1/1 Running 0 2m11s
thor 1/1 Running 0 58s
[controlplane@cli] $ k get pods -n nato -o yaml | grep "image: "

[controlplane@cli] $ k delete pod thor -n nato
[controlplane@cli] $ k delete pod neon-pod -n nato Reference: https://github.com/aquasecurity/trivy
[controlplane@cli] $ k delete pod neon-pod -n nato Reference: https://github.com/aquasecurity/trivy


質問 # 76
You are tasked with securing a Kubemetes cluster that is running on AWS- One of the security best practices you want to implement is to limit tne number of IP addresses that can access the Kubernetes API server. You need to configure the 'kube-apiserver' to only allow access from specific IP addresses, using the '--insecure-bind-address' flag to restrict access.
How would you configure 'kube-apiserver' to achieve this using an '--insecure-bind-address' flag, but allow access from only specific IP addresses?

正解:

解説:
Solution (Step by Step) :
1 . Identify Allowed IP Addresses: Determine the specific IP addresses that should be allowed to access the Kubernetes API server. For example, you might allow access from your local machine's IP address (e.g., 192.168.1.100), and the IP addresses of any bastion hosts that are used for remote management.
2. Modify the 'kube-apiserver' Configuration:
- Locate the 'kube-apjserver' configuration file (typically found at "etc/kubernetestmanifests/kube-apiserver.yaml or similar).
- In tne 'kube-apiserver' configuration file, find tne '--insecure-bind-address' flag.
- Set the '--insecure-bind-address' flag to '0.0.0.0' to allow access from all IP addresses.

3. Restart 'kube-apiserver': Apply the updated configuration file. Depending on how the Kubernetes cluster is deployed, you may need to restart the 'kube-apisepver' pod or container. 4. Verify the Configuration: - After restarting 'kube-apiservers , test that you can access the API server from the allowed IP addresses. - Test from any disallowed IP addresses to confirm access is blocked.


質問 # 77
You are running a critical application within a Kubernetes cluster, and you need to implement a robust security posture to prevent unauthorized access and protect sensitive dat
a. The application uses a PostgreSQL database, and you want to enforce strong access control for the database while ensuring the database pods are not directly accessible from the internet Describe how you would implement the following security measures using Kubernetes resources and tools:
1. Network Policy: Create a network policy that restricts access to the PostgreSQL database pods to only the application pods.
2. Pod Security Policies: Enforce strong security policies for the database pods, including restrictions on capabilities, resource usage, and privileged
access.
3. Secret Management Securely store the database credentials using a Kubernetes secret, ensuring that only authorized application pods can access
them.
4. Logging and Monitoring: Implement logging and monitoring for the PostgreSQL database pods to detect any potential security threats or anomalies.

正解:

解説:
Solution (Step by Step) :
1. Network Policy:
1. Create a network policy:

2. Apply the network policy: basn kubectl apply -f postgres-access-policy.yaml 2. Pod Security Policies: 1. Create a Pod Security Policy:

2. Apply the Pod Security Policy: bash kubectl apply -f postgres-psp.yaml 3. Apply the PSP to the PostgreSQL deployment:

3. Secret Management: 1. Create a secret for the database credentials: bash kubectl create secret generic postgres-credentials --from-literal--username=postgres --from-literal-password-your-password 2. Mount the secret in the PostgreSQL pod:

4. Logging and Monitoring: 1. Configure logging for the PostgreSQL pods: - Use a logging solution like Fluentd or EFK (Elasticsearch, Fluentd, Kibana) to collect logs from the PostgreSQL pods. - Configure the logging solution to capture both application logs and database logs. 2. Implement monitoring: - Use Prometheus and Grafana to monitor the PostgreSQL pods for metrics like CPIJ usage, memory consumption, and database queries. - Set up alerts for any unusual activity or performance degradation- Important Notes: - Replace 'your-namespace' with your actual namespace. - Replace 'your-application' with the name of your application- - Ensure that the service account 'postgres-sa' has access to the secret. - You may need to adjust the PSP based on your specific security requirements. This approach provides a comprehensive security posture for your PostgreSQL database within a Kubernetes cluster, ensuring data integrity and access control while providing the necessary monitoring and logging for early threat detection.


質問 # 78
You are working on a Kubernetes cluster that hosts an application that interacts With sensitive data. You need to perform a static analysis of the application's container image to identify potential security vulnerabilities before deploying it to the cluster.

正解:

解説:
Solution (Step by Step) :
1. cnoose a Static Analysis Tool:
- Select a suitable static analysis tool for container images. Some popular options include:
- Trivy: [https://aquasecurity.github.io/trivy/](https://aquasecurity.github.io/trivy/)
- Snyk: [https://snyk.io/](https://snyk.io/)
- Anchore Engine: [https://anchore.com/l(https://anchore.com/)
2 Install and Configure the Tool:
- Install the chosen tool on your machine or integrate it into your CI/CD pipeline.
- Configure the tool to scan the container image for vulnerabilities.
3. Scan the Container Image:
- Use the tool's command-line interface or API to scan the container image.
- Provide the image name or tag as input to the tool.
4. Analyze the Results:
- The tool will generate a report detailing the identified vulnerabilities.
- Review the report and prioritize remediation actions based on the severity and impact of the vulnerabilities.
- Use the tool's features to track the status of vulnerabilities and their remediation.


質問 # 79
You have a microservice application running in a Kubernetes cluster with a sidecar container responsible for logging. The sidecar container has access to the main application containers sensitive data, including credentials. You need to implement a security policy to prevent the sidecar container from accessing the main application container's data.

正解:

解説:
Solution (Step by Step) :
1. Create a Securitycontext for the main application container:

2. Apply the updated Deployment: bash kubectl apply -f my-app-deployment.yaml - The readOnlyRootFilesystem: true' setting in the main application container's security context prevents the sidecar container from writing to the main container's filesystem. - This ensures that the sidecar container cannot modify or access the main application's sensitive data. Important Notes: - This policy restricts the sidecar container from accessing the main containers data through the filesystem. - If the sidecar needs access to specific data, you can mount a shared volume that is read-only for the sidecar container and read-write for the main container. - It's crucial to review the security context of both main and sidecar containers to ensure that all necessary access restrictions are implemented.


質問 # 80
You're tasked With securing a Kubernetes cluster for a sensitive application. The application utilizes a service account for accessing a database. However, due to legacy reasons, this service account has broad permissions, including 'read', 'write', and 'delete' access to all resources in the cluster. How would you mitigate this security risk while maintaining application functionality? Implement a solution that minimizes the permissions granted to the service account and adheres to the principle of least privilege.

正解:

解説:
Solution (Step by Step) :
1. Create a new Role With restricted permissions:
- Define a Role that grants only the necessary permissions for the service account to interact with the database.
- The Role should have specific permissions for 'read' , 'write' , and 'delete' operations, but limited to the database resources used by the application.

2. Create a RoleBinding: - Bind the newly created Role to the service account. - This will grant the service account the specific permissions defined in the Role.

3. Update the Deployment - Update the Deployment configuration to use the new service account with restricted permissions.

4. Validate the Permissions: - Verity that the application still functions correctly with the restricted permissions. - Use 'kubectl auth can-i --list --as=your-service-account' to confirm the available permissions for the service account. 5. Revoke the Legacy Service Account: - Once the application is running with the new service account, revoke the old service account with broad permissions.


質問 # 81
Fix all issues via configuration and restart the affected components to ensure the new setting takes effect.
Fix all of the following violations that were found against the API server:- a. Ensure that the RotateKubeletServerCertificate argument is set to true.
b. Ensure that the admission control plugin PodSecurityPolicy is set.
c. Ensure that the --kubelet-certificate-authority argument is set as appropriate.
Fix all of the following violations that were found against the Kubelet:- a. Ensure the --anonymous-auth argument is set to false.
b. Ensure that the --authorization-mode argument is set to Webhook.
Fix all of the following violations that were found against the ETCD:-
a. Ensure that the --auto-tls argument is not set to true
b. Ensure that the --peer-auto-tls argument is not set to true
Hint: Take the use of Tool Kube-Bench

正解:

解説:
Fix all of the following violations that were found against the API server:- a. Ensure that the RotateKubeletServerCertificate argument is set to true.
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
component: kubelet
tier: control-plane
name: kubelet
namespace: kube-system
spec:
containers:
- command:
- kube-controller-manager
+ - --feature-gates=RotateKubeletServerCertificate=true
image: gcr.io/google_containers/kubelet-amd64:v1.6.0
livenessProbe:
failureThreshold: 8
httpGet:
host: 127.0.0.1
path: /healthz
port: 6443
scheme: HTTPS
initialDelaySeconds: 15
timeoutSeconds: 15
name: kubelet
resources:
requests:
cpu: 250m
volumeMounts:
- mountPath: /etc/kubernetes/
name: k8s
readOnly: true
- mountPath: /etc/ssl/certs
name: certs
- mountPath: /etc/pki
name: pki
hostNetwork: true
volumes:
- hostPath:
path: /etc/kubernetes
name: k8s
- hostPath:
path: /etc/ssl/certs
name: certs
- hostPath:
path: /etc/pki
name: pki
b. Ensure that the admission control plugin PodSecurityPolicy is set.
audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
tests:
test_items:
- flag: "--enable-admission-plugins"
compare:
op: has
value: "PodSecurityPolicy"
set: true
remediation: |
Follow the documentation and create Pod Security Policy objects as per your environment.
Then, edit the API server pod specification file $apiserverconf
on the master node and set the --enable-admission-plugins parameter to a value that includes PodSecurityPolicy :
--enable-admission-plugins=...,PodSecurityPolicy,...
Then restart the API Server.
scored: true
c. Ensure that the --kubelet-certificate-authority argument is set as appropriate.
audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
tests:
test_items:
- flag: "--kubelet-certificate-authority"
set: true
remediation: |
Follow the Kubernetes documentation and setup the TLS connection between the apiserver and kubelets. Then, edit the API server pod specification file
$apiserverconf on the master node and set the --kubelet-certificate-authority parameter to the path to the cert file for the certificate authority.
--kubelet-certificate-authority=<ca-string>
scored: true
Fix all of the following violations that were found against the ETCD:-
a. Ensure that the --auto-tls argument is not set to true
Edit the etcd pod specification file $etcdconf on the master
node and either remove the --auto-tls parameter or set it to false.
--auto-tls=false
b. Ensure that the --peer-auto-tls argument is not set to true
Edit the etcd pod specification file $etcdconf on the master
node and either remove the --peer-auto-tls parameter or set it to false.
--peer-auto-tls=false


質問 # 82
You can switch the cluster/configuration context using the following command: [desk@cli] $ kubectl config use-context test-account Task: Enable audit logs in the cluster.
To do so, enable the log backend, and ensure that:
1. logs are stored at /var/log/Kubernetes/logs.txt
2. log files are retained for 5 days
3. at maximum, a number of 10 old audit log files are retained
A basic policy is provided at /etc/Kubernetes/logpolicy/audit-policy.yaml. It only specifies what not to log. Note: The base policy is located on the cluster's master node.
Edit and extend the basic policy to log: 1. Nodes changes at RequestResponse level 2. The request body of persistentvolumes changes in the namespace frontend 3. ConfigMap and Secret changes in all namespaces at the Metadata level Also, add a catch-all rule to log all other requests at the Metadata level Note: Don't forget to apply the modified policy.

正解:

解説:
$ vim /etc/kubernetes/log-policy/audit-policy.yaml
- level: RequestResponse
userGroups: ["system:nodes"]
- level: Request
resources:
- group: "" # core API group
resources: ["persistentvolumes"]
namespaces: ["frontend"]
- level: Metadata
resources:
- group: ""
resources: ["configmaps", "secrets"]
- level: Metadata
$ vim /etc/kubernetes/manifests/kube-apiserver.yaml Add these
- --audit-policy-file=/etc/kubernetes/log-policy/audit-policy.yaml
- --audit-log-path=/var/log/kubernetes/logs.txt
- --audit-log-maxage=5
- --audit-log-maxbackup=10
Explanation
[desk@cli] $ ssh master1 [master1@cli] $ vim /etc/kubernetes/log-policy/audit-policy.yaml apiVersion: audit.k8s.io/v1 # This is required.
kind: Policy
# Don't generate audit events for all requests in RequestReceived stage.
omitStages:
- "RequestReceived"
rules:
# Don't log watch requests by the "system:kube-proxy" on endpoints or services
- level: None
users: ["system:kube-proxy"]
verbs: ["watch"]
resources:
- group: "" # core API group
resources: ["endpoints", "services"]
# Don't log authenticated requests to certain non-resource URL paths.
- level: None
userGroups: ["system:authenticated"]
nonResourceURLs:
- "/api*" # Wildcard matching.
- "/version"
# Add your changes below
- level: RequestResponse
userGroups: ["system:nodes"] # Block for nodes
- level: Request
resources:
- group: "" # core API group
resources: ["persistentvolumes"] # Block for persistentvolumes
namespaces: ["frontend"] # Block for persistentvolumes of frontend ns
- level: Metadata
resources:
- group: "" # core API group
resources: ["configmaps", "secrets"] # Block for configmaps & secrets
- level: Metadata # Block for everything else
[master1@cli] $ vim /etc/kubernetes/manifests/kube-apiserver.yaml
apiVersion: v1
kind: Pod
metadata:
annotations:
kubeadm.kubernetes.io/kube-apiserver.advertise-address.endpoint: 10.0.0.5:6443 labels:
component: kube-apiserver
tier: control-plane
name: kube-apiserver
namespace: kube-system
spec:
containers:
- command:
- kube-apiserver
- --advertise-address=10.0.0.5
- --allow-privileged=true
- --authorization-mode=Node,RBAC
- --audit-policy-file=/etc/kubernetes/log-policy/audit-policy.yaml #Add this
- --audit-log-path=/var/log/kubernetes/logs.txt #Add this
- --audit-log-maxage=5 #Add this
- --audit-log-maxbackup=10 #Add this
...
output truncated
Note: log volume & policy volume is already mounted in vim /etc/kubernetes/manifests/kube-apiserver.yaml so no need to mount it. Reference: https://kubernetes.io/docs/tasks/debug-application-cluster/audit/


質問 # 83
Create a Pod name Nginx-pod inside the namespace testing, Create a service for the Nginx-pod named nginx-svc, using the ingress of your choice, run the ingress on tls, secure port.

正解:

解説:
$ kubectl get ing -n <namespace-of-ingress-resource>
NAME HOSTS ADDRESS PORTS AGE
cafe-ingress cafe.com 10.0.2.15 80 25s
$ kubectl describe ing <ingress-resource-name> -n <namespace-of-ingress-resource> Name: cafe-ingress Namespace: default Address: 10.0.2.15 Default backend: default-http-backend:80 (172.17.0.5:8080) Rules:
Host Path Backends
---- ---- --------
cafe.com
/tea tea-svc:80 (<none>)
/coffee coffee-svc:80 (<none>)
Annotations:
kubectl.kubernetes.io/last-applied-configuration: {"apiVersion":"networking.k8s.io/v1","kind":"Ingress","metadata":{"annotations":{},"name":"cafe-ingress","namespace":"default","selfLink":"/apis/networking/v1/namespaces/default/ingresses/cafe-ingress"},"spec":{"rules":[{"host":"cafe.com","http":{"paths":[{"backend":{"serviceName":"tea-svc","servicePort":80},"path":"/tea"},{"backend":{"serviceName":"coffee-svc","servicePort":80},"path":"/coffee"}]}}]},"status":{"loadBalancer":{"ingress":[{"ip":"169.48.142.110"}]}}} Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal CREATE 1m ingress-nginx-controller Ingress default/cafe-ingress
Normal UPDATE 58s ingress-nginx-controller Ingress default/cafe-ingress
$ kubectl get pods -n <namespace-of-ingress-controller>
NAME READY STATUS RESTARTS AGE
ingress-nginx-controller-67956bf89d-fv58j 1/1 Running 0 1m
$ kubectl logs -n <namespace> ingress-nginx-controller-67956bf89d-fv58j
------------------------------------------------------------------------------- NGINX Ingress controller Release: 0.14.0 Build: git-734361d Repository: https://github.com/kubernetes/ingress-nginx
-------------------------------------------------------------------------------
....


質問 # 84
You are managing a Kubernetes cluster that uses a private Docker registry for storing container images. You need to secure the registry by restricting access to authorized users and teams. Design a solution using role-based access control (RBAC) to enforce the following policies:
- Developers in the "dev" team should be allowed to push and pull images to the registry.
- Operations team members should only be allowed to pull images.
- Security team members should have read-only access to the registry's metadata

正解:

解説:
Solution (Step by Step) :
1. Create a Service Account for each team:
- Dev Team:

- Operations Team:

- Security Team:

- Apply these ServiceAccount YAML files to the cluster using 'kubectl apply -f sa.yaml'. 2. Create a Role for each team: - Dev Team Role:

- Operations Team Role:

- Security Team Role:

- Apply these Role YAML files to the cluster using 'kubectl apply -f roles-yaml'. 3. Bind the Roles to Service Accounts: - Dev Team:

- Operations Team:

- security Team:

- Apply these RoleBinding YAML files to the cluster using 'kubectl apply -f rolebindings.yamr 4. Configure the Registry: - Ensure that your private Docker registry is configured to authenticate users and teams based on the specified RBAC rules. This may involve using a registry-specific Plugin or configuration file. 5. Test the Setup: - Use the created Service Accounts to access the registry. - Verify that each team nas the expected permissions and limitations. - For example, try pushing an image using the 'dev-sa' account and verify it is successful. Then, attempt to push an image using the Sops-sa- account and verify it is unsuccessful due to the missing permission.


質問 # 85
You have a Kubernetes cluster with a sensitive workload running in a specific namespace. You need to restrict access to this namespace to only authorized users- How would you achieve this using Role-Based Access Control (RBAC)?

正解:

解説:
Solution (Step by Step):
1. Create a Role: Define a Role that grants only the required permissions to access the sensitive namespace.
- Name: 'namespace-access-role' (you can choose any name)
- Namespace: The namespace you want to restrict access to.
- Rules:
- Resources: Specify the resources that the role allows access to. For example, 'pods", 'deployments', 'services', etc.
- Verbs: Define the allowed actions on tne resources. For example, 'get', 'list, 'watch', 'create', 'update' , 'delete', etc.
- ApiGroups: Specify the API group that the resources belong to. For example, 'apps', 'extensions' , etc.
- You can use wildcards to grant access to all resources or all verbs.
2. Create a ROIeBinding: Associate the Role with specific users or groups.
- Name: 'namespace-access-binding' (you can choose any name)
- Namespace: The namespace you want to restrict access to.
_ RoleRef-.
- Kind: 'Role' (since you are using a Role)
- Name: The name of the Role you created.
- ApiGroup: 'rbac.authorization.k8s.i0'
- Subjects: Define the users or groups that should have access to this Role.
- Kind: Specify whether it's a user or group.
- Name: The username or group name.
- ApiGroup: 'rbac.authorization.k8s.io'
3. Apply the Role and Role3inding:
- Use 'kubectl apply -f role.yaml' and 'kubectl apply -f rolebinding.yamr to create the Role and RoleBinding respectively
Example YAML for Role and Role8inding:
Role (role-yaml)

Role8inding (rolebinding.yaml)

- The Role 'namespace-access-role' grants permissions to access 'deployments' , 'pods' , 'services', and 'secrets' in the - The RoleBinding 'namespace-access-binding' associates this Role with the user - This setup Will restrict access to the namespace to only tne user Important Notes: - R8AC is a powerful mechanism to control access to resources in Kubernetes- - It's important to understand the different RBAC components (Role, RoleBinding, ClusterRole, ClusterRole8inding) and their usage. - Define granular permissions to ensure least privilege access and enhance security.


質問 # 86
......

CKS問題集合格確定させる練習には179問があります:https://www.passtest.jp/Linux-Foundation/CKS-shiken.html

CKS練習テスト問題解答更新された179問があります:https://drive.google.com/open?id=1HytVbqgOLtTt6unTgqqzDwrHy4m98RoJ